Skip to content

Commit

Permalink
Enable or disable Markdown parser for bludit#980
Browse files Browse the repository at this point in the history
  • Loading branch information
dignajar committed Mar 9, 2019
1 parent 185ae09 commit 3ab8c4c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
11 changes: 11 additions & 0 deletions bl-kernel/admin/views/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@
'placeholder'=>'https://'
));

echo Bootstrap::formTitle(array('title'=>$L->g('Page content')));

echo Bootstrap::formSelect(array(
'name'=>'markdownParser',
'label'=>$L->g('Markdown parser'),
'options'=>array('true'=>$L->g('Enabled'), 'false'=>$L->g('Disabled')),
'selected'=>($site->markdownParser()?'true':'false'),
'class'=>'',
'tip'=>$L->g('Enable the markdown parser for the content of the page.')
));

echo Bootstrap::formTitle(array('title'=>$L->g('URL Filters')));

echo Bootstrap::formInputText(array(
Expand Down
3 changes: 3 additions & 0 deletions bl-kernel/boot/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@
// TRUE to convert relatives images to absoultes, FALSE No changes apply
define('IMAGE_RELATIVE_TO_ABSOLUTE', $site->imageRelativeToAbsolute());

// TRUE if the markdown parser is enabled
define('MARKDOWN_PARSER', $site->markdownParser());

// --- PHP paths with dependency ---
// This paths are absolutes for the OS
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$site->theme().DS);
Expand Down
6 changes: 4 additions & 2 deletions bl-kernel/pagex.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ public function content($sanitize=false)
$content = $this->contentRaw();

// Parse Markdown
$parsedown = new Parsedown();
$content = $parsedown->text($content);
if (MARKDOWN_PARSER) {
$parsedown = new Parsedown();
$content = $parsedown->text($content);
}

// Parse img src relative to absolute (with domain)
if (IMAGE_RELATIVE_TO_ABSOLUTE) {
Expand Down
23 changes: 12 additions & 11 deletions bl-kernel/site.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ class Site extends dbJSON {
'titleFormatTag'=> '{{tag-name}} | {{site-title}}',
'imageRestrict'=> true,
'imageRelativeToAbsolute'=> false,
'thumbnailWidth' => 400, // px
'thumbnailHeight' => 400, // px
'thumbnailQuality' => 100,
'logo'=> ''
'thumbnailWidth'=> 400, // px
'thumbnailHeight'=> 400, // px
'thumbnailQuality'=> 100,
'logo'=> '',
'markdownParser'=> true
);

function __construct()
Expand All @@ -68,8 +69,9 @@ public function set($args)
// Check values on args or set default values
foreach ($this->dbFields as $field=>$value) {
if (isset($args[$field])) {
// Sanitize if will be stored on database
$finalValue = Sanitize::html($args[$field]);
if ($finalValue==='false') { $finalValue = false; }
elseif ($finalValue==='true') { $finalValue = true; }
settype($finalValue, gettype($value));
$this->db[$field] = $finalValue;
}
Expand Down Expand Up @@ -138,6 +140,11 @@ public function extremeFriendly()
return $this->getField('extremeFriendly');
}

public function markdownParser()
{
return $this->getField('markdownParser');
}

public function twitter()
{
return $this->getField('twitter');
Expand Down Expand Up @@ -168,12 +175,6 @@ public function gitlab()
return $this->getField('gitlab');
}

// DEPRECATED since v3.5
public function googlePlus()
{
return $this->getField('googlePlus');
}

public function linkedin()
{
return $this->getField('linkedin');
Expand Down

0 comments on commit 3ab8c4c

Please sign in to comment.