From e907cc21fb9632fdf02b6751d741322b8b369fd3 Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 31 May 2018 16:59:39 +0300 Subject: [PATCH 01/13] Content: method processContent() will run processMarkdown() method first then only processShortcodes --- flextype/Content.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flextype/Content.php b/flextype/Content.php index 35d0d01d..6ff9e9d6 100755 --- a/flextype/Content.php +++ b/flextype/Content.php @@ -462,9 +462,8 @@ class Content */ public static function processContent(string $content) : string { - $content = Content::processShortcodes($content); $content = Content::processMarkdown($content); - + $content = Content::processShortcodes($content); return $content; } From cb139ad5b6330a9972a3a6350811e59a5cb1ba2b Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 31 May 2018 20:02:12 +0300 Subject: [PATCH 02/13] Delete folders: site/data and site/accounts --- site/accounts/.gitkeep | 0 site/data/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 site/accounts/.gitkeep delete mode 100755 site/data/.gitkeep diff --git a/site/accounts/.gitkeep b/site/accounts/.gitkeep deleted file mode 100755 index e69de29b..00000000 diff --git a/site/data/.gitkeep b/site/data/.gitkeep deleted file mode 100755 index e69de29b..00000000 From fd445d7386997e0c597576a6530645980371110d Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 31 May 2018 20:29:41 +0300 Subject: [PATCH 03/13] Delete folders: site/blocks and site/cache and site/logs --- site/blocks/.gitkeep | 0 site/cache/.gitkeep | 0 site/logs/.gitkeep | 0 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 site/blocks/.gitkeep delete mode 100755 site/cache/.gitkeep delete mode 100755 site/logs/.gitkeep diff --git a/site/blocks/.gitkeep b/site/blocks/.gitkeep deleted file mode 100755 index e69de29b..00000000 diff --git a/site/cache/.gitkeep b/site/cache/.gitkeep deleted file mode 100755 index e69de29b..00000000 diff --git a/site/logs/.gitkeep b/site/logs/.gitkeep deleted file mode 100755 index e69de29b..00000000 From 81eb197429b83c1018c53d81192c4db48c9fd1fd Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 31 May 2018 20:35:06 +0300 Subject: [PATCH 04/13] Content: new protected method initParsers() --- flextype/Content.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/flextype/Content.php b/flextype/Content.php index 6ff9e9d6..f5256d2c 100755 --- a/flextype/Content.php +++ b/flextype/Content.php @@ -92,11 +92,8 @@ class Content // Event: The page is not processed and not sent to the display. Event::dispatch('onCurrentPageBeforeProcessed'); - // Init Markdown - Content::initMarkdown(); - - // Init Shortcodes - Content::initShortcodes(); + // Init Parsers + Content::initParsers(); // Set current requested page data to global $page array Content::$page = Content::getPage(Http::getUriString()); @@ -501,6 +498,21 @@ class Content }); } + /** + * Init Parsers + * + * @access protected + * @return void + */ + protected static function initParsers() : void + { + // Init Markdown + Content::initMarkdown(); + + // Init Shortcodes + Content::initShortcodes(); + } + /** * Init Markdown * From fda2a03160c9882d622a41a443d7137821b5f287 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 1 Jun 2018 00:52:00 +0300 Subject: [PATCH 05/13] Content: - Blocks functionality removed - use Block Plugin - Section shortcode removed - use Section plugin - Site Url shortcode removed - use Site Url plugin - Registry shotcode remobed - use Registry plugin - Prevents automatic linking of URLs for Markdown parser - Method registerDefaultShortcodes() removed --- flextype/Content.php | 91 ++------------------------------------------ 1 file changed, 4 insertions(+), 87 deletions(-) diff --git a/flextype/Content.php b/flextype/Content.php index f5256d2c..44ad5b5f 100755 --- a/flextype/Content.php +++ b/flextype/Content.php @@ -52,14 +52,6 @@ class Content */ private static $page = []; - /** - * Sections data array - * - * @var array - * @access protected - */ - private static $sections = []; - /** * Protected constructor since this is a static class. * @@ -296,47 +288,6 @@ class Content } - /** - * Get block - * - * $block = Content::getBlock('block-name'); - * - * @access public - * @param string $block_name Block name - * @param bool $raw Raw or not raw content - * @return string - */ - public static function getBlock($block_name, $raw = false) : string - { - $block_path = PATH['blocks'] . '/' . $block_name . '.md'; - - // Block cache id - $block_cache_id = ''; - - if (Filesystem::fileExists($block_path)) { - $block_cache_id = md5('block' . $block_path . filemtime($block_path) . (($raw === true) ? 'true' : 'false')); - } - - // Try to get block from cache - if (Cache::contains($block_cache_id)) { - return Cache::fetch($block_cache_id); - } else { - if (Filesystem::fileExists($block_path)) { - - $content = Filesystem::getFileContent($block_path); - - if ($raw === false) { - $content = Content::processContent($content); - } - - Cache::save($block_cache_id, $content); - return $content; - } else { - throw new \RuntimeException("Block does not exist."); - } - } - } - /** * Returns $markdown object * @@ -459,45 +410,11 @@ class Content */ public static function processContent(string $content) : string { - $content = Content::processMarkdown($content); $content = Content::processShortcodes($content); + $content = Content::processMarkdown($content); return $content; } - /** - * Register default shortcodes - * - * @access protected - * @return void - */ - protected static function registerDefaultShortcodes() : void - { - // Shortcode: [site_url] - Content::shortcode()->addHandler('site_url', function() { - return Http::getBaseUrl(); - }); - - // Shortcode: [block name=block-name] - Content::shortcode()->addHandler('block', function(ShortcodeInterface $s) { - return Content::getBlock($s->getParameter('name'), (($s->getParameter('raw') === 'true') ? true : false)); - }); - - // Shortcode: [registry item=site.title] - Content::shortcode()->addHandler('registry', function(ShortcodeInterface $s) { - return Registry::get($s->getParameter('item')); - }); - - // Shortcode: [section_create name=test]Section text here[/section_create] - Content::shortcode()->addHandler('section_create', function(ShortcodeInterface $s) { - Content::$sections[$s->getParameter('name')] = $s->getContent(); - }); - - // Shortcode: [section name=test] - Content::shortcode()->addHandler('section', function(ShortcodeInterface $s) { - return Content::$sections[$s->getParameter('name')]; - }); - } - /** * Init Parsers * @@ -524,6 +441,9 @@ class Content // Create Markdown Parser object Content::$markdown = new Markdown(); + // Prevents automatic linking of URLs + Content::$markdown->setUrlsLinked(false); + // Event: Markdown initialized Event::dispatch('onMarkdownInitialized'); } @@ -539,9 +459,6 @@ class Content // Create Shortcode Parser object Content::$shortcode = new ShortcodeFacade(); - // Register default shortcodes - Content::registerDefaultShortcodes(); - // Event: Shortcodes initialized and now we can add our custom shortcodes Event::dispatch('onShortcodesInitialized'); } From d4fcba7e85b59e012af9d840c746ff51c148a614 Mon Sep 17 00:00:00 2001 From: Awilum Date: Fri, 1 Jun 2018 00:53:03 +0300 Subject: [PATCH 06/13] Constants: accounts, blocks, data - removed. --- index.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/index.php b/index.php index 1585223b..9df1843f 100755 --- a/index.php +++ b/index.php @@ -23,11 +23,8 @@ define('PATH', ['site' => ROOT_DIR . '/site', 'plugins' => ROOT_DIR . '/site/plugins', 'themes' => ROOT_DIR . '/site/themes', 'pages' => ROOT_DIR . '/site/pages', - 'blocks' => ROOT_DIR . '/site/blocks', - 'data' => ROOT_DIR . '/site/data', 'config' => ROOT_DIR . '/site/config', - 'cache' => ROOT_DIR . '/site/cache', - 'accounts' => ROOT_DIR . '/site/accounts']); + 'cache' => ROOT_DIR . '/site/cache']); // Define the path to the logs directory (without trailing slash). define('LOGS_PATH', PATH['site'] . '/logs'); From e293c381837ec5fc0e6677541144dd46b21a89bd Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 2 Jun 2018 22:12:24 +0300 Subject: [PATCH 07/13] update home page --- site/pages/home/page.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/pages/home/page.md b/site/pages/home/page.md index 2a772ce1..bafb242c 100755 --- a/site/pages/home/page.md +++ b/site/pages/home/page.md @@ -24,7 +24,7 @@ Creating a new page is very simple in Flextype. This is the body of **My New Page** ``` -2. Save this file in the `/site/pages/my-new-page/` folder as `page.md` and its will be available by this url: [site_url]/my-new-page +2. Save this file in the `/site/pages/my-new-page/` folder as `page.md` and its will be available by this url: http://your_site_url/my-new-page That is it! From 1360793ff7baae742e0f3646a54245eb95465efe Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 2 Jun 2018 22:26:06 +0300 Subject: [PATCH 08/13] Flextype: new method setErrorHandler() added --- flextype/Flextype.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/flextype/Flextype.php b/flextype/Flextype.php index 779073e5..474a5398 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -86,10 +86,8 @@ class Flextype function_exists('mb_regex_encoding') and mb_regex_encoding(Registry::get('site.charset')); function_exists('mb_internal_encoding') and mb_internal_encoding(Registry::get('site.charset')); - // Set Error handler - set_error_handler('Flextype\Component\ErrorHandler\ErrorHandler::error'); - register_shutdown_function('Flextype\Component\ErrorHandler\ErrorHandler::fatal'); - set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); + // Set error handler + Flextype::setErrorHandler(); // Set default timezone date_default_timezone_set(Registry::get('site.timezone')); @@ -113,6 +111,23 @@ class Flextype ob_end_flush(); } + /** + * Set error handler + * + * @access protected + */ + protected static function setErrorHandler() + { + // Create directory for logs + !Filesystem::fileExists(LOGS_PATH) and Filesystem::createDir(LOGS_PATH); + + // Set Error handler + set_error_handler('Flextype\Component\ErrorHandler\ErrorHandler::error'); + register_shutdown_function('Flextype\Component\ErrorHandler\ErrorHandler::fatal'); + set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); + + } + /** * Return the Flextype instance. * Create it if it's not already created. From 09c5f637a9558cc37d477286dfc4e6579ff65663 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 2 Jun 2018 22:27:07 +0300 Subject: [PATCH 09/13] Flextype: new method setErrorHandler() updates --- flextype/Flextype.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/flextype/Flextype.php b/flextype/Flextype.php index 474a5398..87a26958 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -72,15 +72,6 @@ class Flextype throw new \RuntimeException("Flextype site config file does not exist."); } - // Display Errors - if (Registry::get('site.errors.display')) { - define('DEVELOPMENT', true); - error_reporting(-1); - } else { - define('DEVELOPMENT', false); - error_reporting(0); - } - // Set internal encoding function_exists('mb_language') and mb_language('uni'); function_exists('mb_regex_encoding') and mb_regex_encoding(Registry::get('site.charset')); @@ -116,8 +107,17 @@ class Flextype * * @access protected */ - protected static function setErrorHandler() + protected static function setErrorHandler() : void { + // Display Errors + if (Registry::get('site.errors.display')) { + define('DEVELOPMENT', true); + error_reporting(-1); + } else { + define('DEVELOPMENT', false); + error_reporting(0); + } + // Create directory for logs !Filesystem::fileExists(LOGS_PATH) and Filesystem::createDir(LOGS_PATH); @@ -125,7 +125,6 @@ class Flextype set_error_handler('Flextype\Component\ErrorHandler\ErrorHandler::error'); register_shutdown_function('Flextype\Component\ErrorHandler\ErrorHandler::fatal'); set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); - } /** From 3285b7515c2b0544914d438908788021048cadc5 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 2 Jun 2018 22:28:34 +0300 Subject: [PATCH 10/13] Flextype: new method setSiteConfig() added --- flextype/Flextype.php | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/flextype/Flextype.php b/flextype/Flextype.php index 87a26958..208eda5b 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -62,15 +62,7 @@ class Flextype // Turn on output buffering ob_start(); - // Set empty site item - Registry::set('site', []); - - // Set site items if site config exists - if (Filesystem::fileExists($site_config = PATH['config'] . '/' . 'site.yaml')) { - Registry::set('site', Yaml::parseFile($site_config)); - } else { - throw new \RuntimeException("Flextype site config file does not exist."); - } + Flextype::setSiteConfig(); // Set internal encoding function_exists('mb_language') and mb_language('uni'); @@ -127,6 +119,24 @@ class Flextype set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); } + /** + * Set site config + * + * @access protected + */ + protected static function setSiteConfig() : void + { + // Set empty site item + Registry::set('site', []); + + // Set site items if site config exists + if (Filesystem::fileExists($site_config = PATH['config'] . '/' . 'site.yaml')) { + Registry::set('site', Yaml::parseFile($site_config)); + } else { + throw new \RuntimeException("Flextype site config file does not exist."); + } + } + /** * Return the Flextype instance. * Create it if it's not already created. From 7fba0e87f290dfa32c08ae15a4b24612cb0cce35 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 3 Jun 2018 04:45:53 +0300 Subject: [PATCH 11/13] update changelog --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c817267..3ad13968 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# Flextype 0.5.0, 2018-06-03 +* Delete folders: site/data and site/accounts +* Delete folders: site/blocks and site/cache and site/logs +* Constants: accounts, blocks, data - removed. +* Flextype: new method setSiteConfig() added +* Flextype: new method setErrorHandler() updates +* Flextype: new method setErrorHandler() added +* Content: new protected method initParsers() +* Content: Blocks functionality removed - use Block Plugin +* Content: Section shortcode removed - use Section plugin +* Content: Site Url shortcode removed - use Site Url plugin +* Content: Registry shotcode remobed - use Registry plugin +* Content: Prevents automatic linking of URLs for Markdown parser +* Content: Method registerDefaultShortcodes() removed + # Flextype 0.4.4, 2018-05-29 * Content: added ability to work with CONTENT SECTIONS with help of shortcodes [section] and [section_create] * Content: getPage() method will only return data about requested page and will not insert them in global $page array. From 3df9f5df0efd601f78e918d3f0f4ecd5c4b52a34 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 3 Jun 2018 04:49:25 +0300 Subject: [PATCH 12/13] update config --- site/config/site.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/config/site.yaml b/site/config/site.yaml index d85dbdb5..506ecd85 100755 --- a/site/config/site.yaml +++ b/site/config/site.yaml @@ -3,7 +3,7 @@ # title: "Flextype" -description: "Best Open Source Flat-File Content Management System" +description: "The Best Open Source Flat-File Content Management System" keywords: "flextype, php, cms, flat-file cms, flat cms, flatfile cms, markdown" robots: "index, follow" author: @@ -23,7 +23,7 @@ pages: main: home errors: - display: true + display: false cache: enabled: true From 0b4defa948a6bac0ac1d6d2d0ad601fbc974018b Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 3 Jun 2018 04:52:50 +0300 Subject: [PATCH 13/13] Flextype 0.5.0 --- README.md | 3 ++- flextype/Flextype.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1091b7a5..51458a9f 100755 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Flextype -![Version](https://img.shields.io/badge/version-0.4.4-brightgreen.svg?style=flat-square) +![Version](https://img.shields.io/badge/version-0.5.0-brightgreen.svg?style=flat-square) ![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square) Flextype is next generation of Legendary Monstra Engine it is also Open Source, fast and flexible file-based Content Management System. That's Easy to install, upgrade and use. Flextype provides amazing API's for plugins, themes and core developers! Content in Flextype is just a simple files written with markdown syntax in pages folder. You simply create markdown files in the pages folder and that becomes a page. @@ -52,6 +52,7 @@ Also you may need to install node_modules libs for default Simple Theme ``` cd /flextype/site/themes/simple npm install +gulp ``` diff --git a/flextype/Flextype.php b/flextype/Flextype.php index 208eda5b..9b212d2e 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -40,7 +40,7 @@ class Flextype * * @var string */ - const VERSION = '0.4.4'; + const VERSION = '0.5.0'; /** * Constructor.