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

Merge remote-tracking branch 'origin/master' into dev

This commit is contained in:
Awilum
2018-06-08 01:47:27 +03:00
8 changed files with 56 additions and 115 deletions

View File

@@ -12,7 +12,7 @@
RewriteEngine On
RewriteBase /flextype/
RewriteBase /
## Begin - Exploits
# If you experience problems on your site block out the operations listed below
@@ -49,9 +49,9 @@ RewriteRule ^(\.git|flextype)/(.*) error [F]
# Block access to specific file types for these system folders
RewriteRule ^(flextype|vendor)/(.*)\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|sh|bat)$ error [F]
# Block access to specific file types for these user folders
RewriteRule ^(site)/(.*)\.(txt|md|yaml|yml|php|pl|py|cgi|sh|bat)$ error [F]
# Block all direct access to .md files:
RewriteRule \.md$ error [F]
RewriteRule ^(site)/(.*)\.(txt|md|html|yaml|yml|php|pl|py|cgi|sh|bat)$ error [F]
# Block all direct access to .html files:
RewriteRule \.html$ error [F]
# Block all direct access to files and folders beginning with a dot
RewriteRule (^|/)\.(?!well-known) - [F]
# Block access to specific files in the root folder

View File

@@ -2,7 +2,7 @@
"name": "flextype/flextype",
"type": "project",
"description": "Flextype is The Best Open Source Flat-File Content Management System",
"keywords": ["flextype", "php", "cms", "flat-file cms", "flat cms", "flatfile cms", "markdown"],
"keywords": ["flextype", "php", "cms", "flat-file cms", "flat cms", "flatfile cms", "html"],
"homepage": "http://flextype.org",
"license": "MIT",
"authors": [
@@ -17,8 +17,6 @@
},
"require": {
"php": ">=7.1.3",
"erusev/parsedown": "1.7.0",
"erusev/parsedown-extra": "0.7.1",
"doctrine/cache": "1.*",
"symfony/yaml": "4.*",
"thunderer/shortcode": "0.*",

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
*

7
site/pages/404/page.html Executable file
View File

@@ -0,0 +1,7 @@
---
title: Error 404
robots: noindex,nofollow
---
<h2>Error 404</h2>
<p>We're sorry but the page you are looking for doesn't appear to exist!</p>

View File

@@ -1,7 +0,0 @@
---
title: Error 404
robots: noindex,nofollow
---
## Error 404
We're sorry but the page you are looking for doesn't appear to exist!

29
site/pages/home/page.html Executable file
View File

@@ -0,0 +1,29 @@
---
title: Welcome
description: Flextype is a simple and light-weighted Content Management System
template: default
---
<h2>Flextype is succesfully installed!</h2>
<p>You can start editing the content and customising your site.</p>
<h3>Edit this Page</h3>
<p>To edit this page, simply go to the folder you installed Flextype, and then browse to the `/site/pages/home/` folder and open the `page.md` file in your editor.</p>
<h3>Create a New page</h3>
<p>Creating a new page is very simple in Flextype.</p>
<p>
1. Launch your text editor and paste this sample text:
<code>
<pre>
---
title: My New Page
---
&lt;h1&gt;My New Page!&lt;/h1&gt;
&lt;p&gt;This is the body of &lt;b&gt;My New Page&lt;/b&gt;&lt;/p&gt;
</pre>
</code>
2. Save this file in the <code>/site/pages/my-new-page/</code> folder as <code>page.md</code> and its will be available by this url: http://your_site_url/my-new-page
</p>
<p>That is it!</p>

View File

@@ -1,30 +0,0 @@
---
title: Welcome
description: Flextype is a simple and light-weighted Content Management System
template: default
---
## Flextype is succesfully installed!
You can start editing the content and customising your site.
### Edit this Page
To edit this page, simply go to the folder you installed Flextype, and then browse to the `/site/pages/home/` folder and open the `page.md` file in your editor.
### Create a New page
Creating a new page is very simple in Flextype.
1. Launch your text editor and paste this sample text:
```
---
title: My New Page
---
# My New Page!
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: http://your_site_url/my-new-page
That is it!

View File

@@ -1,20 +1,20 @@
<?php
namespace Flextype;
use Flextype\Component\{Event\Event, Http\Http, Registry\Registry, Assets\Assets, Text\Text};
use Flextype\Component\{Event\Event, Http\Http, Registry\Registry, Assets\Assets, Text\Text, Html\Html};
?>
<!doctype html>
<html lang="<?php echo Registry::get('site.locale'); ?>">
<head>
<meta charset="<?php echo Text::lowercase(Registry::get('site.charset')); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="<?php echo (isset($page['description']) ? $page['description'] : Registry::get('site.description')); ?>">
<meta name="description" content="<?php echo (isset($page['description']) ? Html::toText($page['description']) : Html::toText(Registry::get('site.description'))); ?>">
<meta name="keywords" content="<?php echo (isset($page['keywords']) ? $page['keywords'] : Registry::get('site.keywords')); ?>">
<meta name="robots" content="<?php echo (isset($page['robots']) ? $page['robots'] : Registry::get('site.robots')); ?>">
<meta name="generator" content="Powered by Flextype <?php echo Flextype::VERSION; ?>" />
<?php Event::dispatch('onThemeMeta'); ?>
<title><?php echo $page['title']; ?> | <?php echo Registry::get('site.title'); ?></title>
<title><?php echo Html::toText($page['title']); ?> | <?php echo Html::toText(Registry::get('site.title')); ?></title>
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>