Images parse
This commit is contained in:
parent
f075b16e86
commit
20fca17d91
|
@ -48,6 +48,9 @@ define('BLUDIT_RELEASE_DATE', '');
|
|||
//
|
||||
define('NO_PARENT_CHAR', '—');
|
||||
|
||||
// Post per page on Manage->Posts
|
||||
define('POSTS_PER_PAGE_ADMIN', 10);
|
||||
|
||||
// Multibyte string / UTF-8
|
||||
define('MB_STRING', extension_loaded('mbstring'));
|
||||
|
||||
|
@ -123,6 +126,7 @@ define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/');
|
|||
define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/');
|
||||
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'admin/themes/'.$Site->adminTheme().'/');
|
||||
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
|
||||
define('HTML_PATH_UPLOADS', HTML_PATH_ROOT.'content/uploads/');
|
||||
|
||||
// Objects with dependency
|
||||
$Language = new dbLanguage( $Site->locale() );
|
||||
|
|
|
@ -60,10 +60,12 @@ function build_page($key)
|
|||
}
|
||||
|
||||
// Content in raw format
|
||||
$contentRaw = $Page->content();
|
||||
$Page->setField('contentRaw', $Page->content(), true);
|
||||
|
||||
// Parse markdown content.
|
||||
$content = $Parsedown->text( $Page->content() );
|
||||
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$content = $Parsedown->text($content); // Parse Markdown.
|
||||
$Page->setField('content', $content, true);
|
||||
|
||||
// Parse username for the page.
|
||||
|
|
|
@ -15,6 +15,7 @@ function buildPost($key)
|
|||
global $dbPosts;
|
||||
global $dbUsers;
|
||||
global $Parsedown;
|
||||
global $Site;
|
||||
|
||||
// Post object.
|
||||
$Post = new Post($key);
|
||||
|
@ -48,10 +49,12 @@ function buildPost($key)
|
|||
}
|
||||
|
||||
// Content in raw format
|
||||
$Post->setField('contentRaw', $Post->content(), true);
|
||||
$contentRaw = $Post->content();
|
||||
$Post->setField('contentRaw', $contentRaw, true);
|
||||
|
||||
// Parse the content
|
||||
$content = $Parsedown->text( $Post->content() );
|
||||
$content = Text::imgRel2Abs($contentRaw, HTML_PATH_UPLOADS); // Parse img src relative to absolute.
|
||||
$content = $Parsedown->text($content); // Parse Markdown.
|
||||
$Post->setField('content', $content, true);
|
||||
|
||||
// Parse username for the post.
|
||||
|
@ -120,7 +123,7 @@ else
|
|||
{
|
||||
if($Url->whereAmI()==='admin') {
|
||||
// Build post for admin area with drafts
|
||||
build_posts_per_page($Url->pageNumber(), $Site->postsPerPage(), true);
|
||||
build_posts_per_page($Url->pageNumber(), POSTS_PER_PAGE_ADMIN, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -4,18 +4,20 @@
|
|||
$currentPage = $Url->pageNumber();
|
||||
Paginator::set('currentPage', $currentPage);
|
||||
|
||||
// Post per page.
|
||||
$postPerPage = $Site->postsPerPage();
|
||||
Paginator::set('postPerPage', $postPerPage);
|
||||
|
||||
// Number of pages.
|
||||
if($Url->whereAmI()=='admin') {
|
||||
if($Url->whereAmI()=='admin') {
|
||||
$postPerPage = POSTS_PER_PAGE_ADMIN;
|
||||
$numberOfPosts = $dbPosts->numberPost(true); // published and drafts
|
||||
}
|
||||
else {
|
||||
$postPerPage = $Site->postsPerPage();
|
||||
$numberOfPosts = $dbPosts->numberPost(false); // published
|
||||
}
|
||||
|
||||
// Post per page.
|
||||
Paginator::set('postPerPage', $postPerPage);
|
||||
|
||||
// Number of posts
|
||||
Paginator::set('numberOfPosts', $numberOfPosts);
|
||||
|
||||
$numberOfPages = (int) ceil($numberOfPosts / $postPerPage) -1;
|
||||
|
|
|
@ -49,6 +49,12 @@ class dbLanguage extends dbJSON
|
|||
return $this->get($string);
|
||||
}
|
||||
|
||||
// Print translation.
|
||||
public function printMe($string)
|
||||
{
|
||||
echo $this->get($string);
|
||||
}
|
||||
|
||||
// Print translation.
|
||||
public function p($string)
|
||||
{
|
||||
|
|
|
@ -153,4 +153,9 @@ class Text {
|
|||
return !self::isEmpty($string);
|
||||
}
|
||||
|
||||
public static function imgRel2Abs($string, $base)
|
||||
{
|
||||
return preg_replace("/(src)\=\"([^(http)])(\/)?/", "$1=\"$base$2", $string);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -125,5 +125,6 @@
|
|||
"write-the-tags-separeted-by-comma": "Write the tags separeted by comma. eg: tag1, tag2, tag3",
|
||||
"delete": "Delete",
|
||||
"delete-the-user-and-all-its-posts":"Delete the user and all its posts",
|
||||
"delete-the-user-and-associate-its-posts-to-admin-user": "Delete the user and associate its posts to admin user"
|
||||
"delete-the-user-and-associate-its-posts-to-admin-user": "Delete the user and associate its posts to admin user",
|
||||
"read-more": "Read more"
|
||||
}
|
|
@ -117,7 +117,7 @@ Pages and Posts
|
|||
------------------------ */
|
||||
.page,
|
||||
.post {
|
||||
margin: 20px 0;
|
||||
margin: 0 0 70px 0;
|
||||
}
|
||||
|
||||
.page-title,
|
||||
|
@ -135,6 +135,14 @@ Pages and Posts
|
|||
display: inline-block;
|
||||
}
|
||||
|
||||
.page a.read-more,
|
||||
.post a.read-more{
|
||||
display: block;
|
||||
text-align: center;
|
||||
padding: 2px 5px;
|
||||
}
|
||||
|
||||
|
||||
.page-content,
|
||||
.post-content {
|
||||
color: #444;
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
<?php echo $Post->content(false) // FALSE to get the first part of the post ?>
|
||||
</div>
|
||||
|
||||
<a class="read-more" href="<?php echo $Post->permalink() ?>"><?php $Language->printMe('Read more') ?></a>
|
||||
|
||||
</section>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
|
Loading…
Reference in New Issue