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