1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 14:16:46 +02:00

Content: using html instead of markdown

This commit is contained in:
Awilum
2018-06-08 01:43:15 +03:00
parent 751ae05b2d
commit 08329c6bc2

View File

@@ -16,7 +16,6 @@ use Flextype\Component\{Arr\Arr, Http\Http, Filesystem\Filesystem, Event\Event,
use Symfony\Component\Yaml\Yaml;
use Thunder\Shortcode\ShortcodeFacade;
use Thunder\Shortcode\Shortcode\ShortcodeInterface;
use ParsedownExtra as Markdown;
class Content
{
@@ -28,14 +27,6 @@ class Content
*/
protected static $instance = null;
/**
* Markdown Object
*
* @var object
* @access private
*/
private static $markdown = null;
/**
* Shortcode object
*
@@ -142,9 +133,9 @@ class Content
{
// if $url is empty then set path for defined main page
if ($url === '') {
$file_path = PATH['pages'] . '/' . Registry::get('site.pages.main') . '/page.md';
$file_path = PATH['pages'] . '/' . Registry::get('site.pages.main') . '/page.html';
} else {
$file_path = PATH['pages'] . '/' . $url . '/page.md';
$file_path = PATH['pages'] . '/' . $url . '/page.html';
}
$page_cache_id = '';
@@ -163,7 +154,7 @@ class Content
if (Filesystem::fileExists($file_path)) {
$file_path = $file_path;
} else {
if (Filesystem::fileExists($file_path = PATH['pages'] . '/404/page.md')) {
if (Filesystem::fileExists($file_path = PATH['pages'] . '/404/page.html')) {
$file_path = $file_path;
Http::setResponseStatus(404);
} else {
@@ -179,7 +170,7 @@ class Content
// Get 404 page if page is not published
if (isset($page['published']) && $page['published'] === false) {
if (Filesystem::fileExists($file_path = PATH['pages'] . '/404/page.md')) {
if (Filesystem::fileExists($file_path = PATH['pages'] . '/404/page.html')) {
$page = Content::processPage($file_path);
Http::setResponseStatus(404);
} else {
@@ -226,7 +217,7 @@ class Content
if ($url === '') {
// Get pages list
$pages_list = Filesystem::getFilesList($file_path , 'md');
$pages_list = Filesystem::getFilesList($file_path , 'html');
// Create pages cached id
foreach ($pages_list as $key => $page) {
@@ -247,14 +238,14 @@ class Content
} else {
// Get pages list
$pages_list = Filesystem::getFilesList($file_path, 'md');
$pages_list = Filesystem::getFilesList($file_path, 'html');
// Create pages cached id
foreach ($pages_list as $key => $page) {
if (strpos($page, $url . '/page.md') !== false) {
if (strpos($page, $url . '/page.html') !== false) {
// ignore ...
} else {
$pages_cache_id .= md5('pages' . $page . filemtime($page) . (($raw === true) ? 'true' : 'false') . $order_by . $order_type . $offset . $length);
$pages_cache_id .= html5('pages' . $page . filemtime($page) . (($raw === true) ? 'true' : 'false') . $order_by . $order_type . $offset . $length);
}
}
@@ -263,7 +254,7 @@ class Content
} else {
// Create pages array from pages list and ignore current requested page
foreach ($pages_list as $key => $page) {
if (strpos($page, $url . '/page.md') !== false) {
if (strpos($page, $url . '/page.html') !== false) {
// ignore ...
} else {
$pages[$key] = Content::processPage($page, $raw);
@@ -288,17 +279,6 @@ class Content
}
/**
* Returns $markdown object
*
* @access public
* @return object
*/
public static function markdown() : Markdown
{
return Content::$markdown;
}
/**
* Returns $shortcode object
*
@@ -313,7 +293,7 @@ class Content
/**
* Process page
*
* $page = Content::processPage(PATH['pages'] . '/home/page.md');
* $page = Content::processPage(PATH['pages'] . '/home/page.html');
*
* @access public
* @param string $file_path File path
@@ -343,8 +323,8 @@ class Content
// Create page url item
$url = str_replace(PATH['pages'] , Http::getBaseUrl(), $file_path);
$url = str_replace('page.md', '', $url);
$url = str_replace('.md', '', $url);
$url = str_replace('page.html', '', $url);
$url = str_replace('.html', '', $url);
$url = str_replace('\\', '/', $url);
$url = str_replace('///', '/', $url);
$url = str_replace('//', '/', $url);
@@ -385,20 +365,6 @@ class Content
return Content::shortcode()->process($content);
}
/**
* Process markdown
*
* $content = Content::processMarkdown($content);
*
* @access public
* @param string $content Content to parse
* @return string
*/
public static function processMarkdown(string $content) : string
{
return Content::$markdown->text($content);
}
/**
* Process content with markdown and shortcodes processors
*
@@ -411,7 +377,6 @@ class Content
public static function processContent(string $content) : string
{
$content = Content::processShortcodes($content);
$content = Content::processMarkdown($content);
return $content;
}
@@ -423,31 +388,10 @@ class Content
*/
protected static function initParsers() : void
{
// Init Markdown
Content::initMarkdown();
// Init Shortcodes
Content::initShortcodes();
}
/**
* Init Markdown
*
* @access protected
* @return void
*/
protected static function initMarkdown() : void
{
// Create Markdown Parser object
Content::$markdown = new Markdown();
// Prevents automatic linking of URLs
Content::$markdown->setUrlsLinked(false);
// Event: Markdown initialized
Event::dispatch('onMarkdownInitialized');
}
/**
* Init Shortcodes
*