Bug fixes on page break

This commit is contained in:
dignajar 2015-07-25 21:25:13 -03:00
parent 20fca17d91
commit f518909ce0
10 changed files with 35 additions and 37 deletions

View File

@ -69,7 +69,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// Main // Main
// ============================================================================ // ============================================================================
if(!$dbPages->pageExists($layout['parameters'])) { if(!$dbPages->pageExists($layout['parameters']))
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the page: '.$layout['parameters']);
Redirect::page('admin', 'manage-pages'); Redirect::page('admin', 'manage-pages');
} }

View File

@ -63,7 +63,9 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
// Main // Main
// ============================================================================ // ============================================================================
if(!$dbPosts->postExists($layout['parameters'])) { if(!$dbPosts->postExists($layout['parameters']))
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']);
Redirect::page('admin', 'manage-posts'); Redirect::page('admin', 'manage-posts');
} }

View File

@ -38,7 +38,7 @@ if(!defined('JSON_PRETTY_PRINT')) {
define('SALT_LENGTH', 8); define('SALT_LENGTH', 8);
// Page brake string // Page brake string
define('PAGE_BRAKE', '<!-- pagebreak -->'); define('PAGE_BREAK', '<!-- pagebreak -->');
// Bludit version // Bludit version
define('BLUDIT_VERSION', 'githubVersion'); define('BLUDIT_VERSION', 'githubVersion');

View File

@ -64,8 +64,8 @@ function build_page($key)
$Page->setField('contentRaw', $Page->content(), true); $Page->setField('contentRaw', $Page->content(), true);
// Parse markdown content. // Parse markdown content.
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute. $content = $Parsedown->text($contentRaw); // Parse Markdown.
$content = $Parsedown->text($content); // Parse Markdown. $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
$Page->setField('content', $content, true); $Page->setField('content', $content, true);
// Parse username for the page. // Parse username for the page.

View File

@ -53,10 +53,15 @@ function buildPost($key)
$Post->setField('contentRaw', $contentRaw, true); $Post->setField('contentRaw', $contentRaw, true);
// Parse the content // Parse the content
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute. $content = $Parsedown->text($contentRaw); // Parse Markdown.
$content = $Parsedown->text($content); // Parse Markdown. $content = Text::imgRel2Abs($content, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
$Post->setField('content', $content, true); $Post->setField('content', $content, true);
// Pagebrake
$explode = explode(PAGE_BREAK, $content);
$Post->setField('breakContent', $explode[0], true);
$Post->setField('readMore', !empty($explode[1]), true);
// Parse username for the post. // Parse username for the post.
if( $dbUsers->userExists( $Post->username() ) ) if( $dbUsers->userExists( $Post->username() ) )
{ {

View File

@ -155,7 +155,7 @@ class Text {
public static function imgRel2Abs($string, $base) public static function imgRel2Abs($string, $base)
{ {
return preg_replace("/(src)\=\"([^(http)])(\/)?/", "$1=\"$base$2", $string); return preg_replace('/(src)="([^:"]*)(?:")/', "$1=\"$base$2\"", $string);
} }
} }

View File

@ -20,17 +20,11 @@ class Page extends fileContent
// This content is markdown parser. // This content is markdown parser.
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content. // $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
// $html, TRUE returns the content without satinize, FALSE otherwise. // $html, TRUE returns the content without satinize, FALSE otherwise.
public function content($fullContent=true, $html=true) public function content($html=true)
{ {
// This content is not sanitized. // This content is not sanitized.
$content = $this->getField('content'); $content = $this->getField('content');
if(!$fullContent)
{
$explode = explode(PAGE_BRAKE, $content);
$content = $explode[0];
}
if($html) { if($html) {
return $content; return $content;
} }
@ -42,17 +36,11 @@ class Page extends fileContent
// This content is not markdown parser. // This content is not markdown parser.
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content. // $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
// $html, TRUE returns the content without satinize, FALSE otherwise. // $html, TRUE returns the content without satinize, FALSE otherwise.
public function contentRaw($fullContent=true, $html=true) public function contentRaw($html=true)
{ {
// This content is not sanitized. // This content is not sanitized.
$content = $this->getField('contentRaw'); $content = $this->getField('contentRaw');
if(!$fullContent)
{
$explode = explode(PAGE_BRAKE, $content);
$content = $explode[0];
}
if($html) { if($html) {
return $content; return $content;
} }

View File

@ -27,8 +27,7 @@ class Post extends fileContent
if(!$fullContent) if(!$fullContent)
{ {
$explode = explode(PAGE_BRAKE, $content); $content = $this->getField('breakContent');
$content = $explode[0];
} }
if($html) { if($html) {
@ -38,21 +37,19 @@ class Post extends fileContent
return Sanitize::html($content); return Sanitize::html($content);
} }
public function readMore()
{
return $this->getField('readMore');
}
// Returns the content. // Returns the content.
// This content is not markdown parser. // This content is not markdown parser.
// $fullContent, TRUE returns all content, if FALSE returns the first part of the content.
// $html, TRUE returns the content without satinize, FALSE otherwise. // $html, TRUE returns the content without satinize, FALSE otherwise.
public function contentRaw($fullContent=true, $html=true) public function contentRaw($html=true)
{ {
// This content is not sanitized. // This content is not sanitized.
$content = $this->getField('contentRaw'); $content = $this->getField('contentRaw');
if(!$fullContent)
{
$explode = explode(PAGE_BRAKE, $content);
$content = $explode[0];
}
if($html) { if($html) {
return $content; return $content;
} }

View File

@ -15,10 +15,9 @@ class Url
// Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character. // Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
$decode = urldecode($_SERVER['REQUEST_URI']); $decode = urldecode($_SERVER['REQUEST_URI']);
// Parse, http://php.net/parse_url // remove parameters GET, do not use parse_url because has problem with utf-8.
$parse = parse_url($decode); $explode = explode('?', $decode);
$this->uri = $explode[0];
$this->uri = $parse['path'];
$this->parameters = $_GET; $this->parameters = $_GET;

View File

@ -33,10 +33,15 @@
<!-- Post content --> <!-- Post content -->
<div class="post-content"> <div class="post-content">
<?php echo $Post->content(false) // FALSE to get the first part of the post ?> <?php
// FALSE to get the first part of the post
echo $Post->content(false)
?>
</div> </div>
<?php if($Post->readMore()) { ?>
<a class="read-more" href="<?php echo $Post->permalink() ?>"><?php $Language->printMe('Read more') ?></a> <a class="read-more" href="<?php echo $Post->permalink() ?>"><?php $Language->printMe('Read more') ?></a>
<?php } ?>
</section> </section>