1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-09 06:36:52 +02:00

Merge remote-tracking branch 'origin/dev'

This commit is contained in:
Awilum
2018-06-03 14:44:13 +03:00
12 changed files with 79 additions and 114 deletions

View File

@@ -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.

View File

@@ -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
```

View File

@@ -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.
*
@@ -92,11 +84,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());
@@ -299,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
*
@@ -464,42 +412,22 @@ class Content
{
$content = Content::processShortcodes($content);
$content = Content::processMarkdown($content);
return $content;
}
/**
* Register default shortcodes
* Init Parsers
*
* @access protected
* @return void
*/
protected static function registerDefaultShortcodes() : void
protected static function initParsers() : void
{
// Shortcode: [site_url]
Content::shortcode()->addHandler('site_url', function() {
return Http::getBaseUrl();
});
// Init Markdown
Content::initMarkdown();
// 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 Shortcodes
Content::initShortcodes();
}
/**
@@ -513,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');
}
@@ -528,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');
}

View File

@@ -40,7 +40,7 @@ class Flextype
*
* @var string
*/
const VERSION = '0.4.4';
const VERSION = '0.5.0';
/**
* Constructor.
@@ -62,34 +62,15 @@ 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.");
}
// Display Errors
if (Registry::get('site.errors.display')) {
define('DEVELOPMENT', true);
error_reporting(-1);
} else {
define('DEVELOPMENT', false);
error_reporting(0);
}
Flextype::setSiteConfig();
// Set internal encoding
function_exists('mb_language') and mb_language('uni');
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 +94,49 @@ class Flextype
ob_end_flush();
}
/**
* Set error handler
*
* @access protected
*/
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);
// 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 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.

View File

@@ -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');

View File

View File

0
site/cache/.gitkeep vendored
View File

View File

@@ -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

View File

View File

View File

@@ -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!