diff --git a/composer.lock b/composer.lock
index 0402273..9f0f86b 100644
--- a/composer.lock
+++ b/composer.lock
@@ -422,16 +422,16 @@
},
{
"name": "slim/slim",
- "version": "3.9.0",
+ "version": "3.9.2",
"source": {
"type": "git",
"url": "https://github.com/slimphp/Slim.git",
- "reference": "575a8b53a0a489447915029c69680156cd355304"
+ "reference": "4086d0106cf5a7135c69fce4161fe355a8feb118"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/slimphp/Slim/zipball/575a8b53a0a489447915029c69680156cd355304",
- "reference": "575a8b53a0a489447915029c69680156cd355304",
+ "url": "https://api.github.com/repos/slimphp/Slim/zipball/4086d0106cf5a7135c69fce4161fe355a8feb118",
+ "reference": "4086d0106cf5a7135c69fce4161fe355a8feb118",
"shasum": ""
},
"require": {
@@ -489,7 +489,7 @@
"micro",
"router"
],
- "time": "2017-11-04T08:46:46+00:00"
+ "time": "2017-11-26T19:13:09+00:00"
},
{
"name": "slim/twig-view",
@@ -543,7 +543,7 @@
},
{
"name": "symfony/event-dispatcher",
- "version": "v3.3.12",
+ "version": "v3.3.13",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
@@ -606,7 +606,7 @@
},
{
"name": "symfony/yaml",
- "version": "v2.8.30",
+ "version": "v2.8.31",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
diff --git a/content/3_for-developers/01-quick-start.md b/content/3_for-developers/01-quick-start.md
index 035623f..f4e9dfb 100644
--- a/content/3_for-developers/01-quick-start.md
+++ b/content/3_for-developers/01-quick-start.md
@@ -11,7 +11,7 @@ You will find all themes in the `theme` folder of TYPEMILL. Change the theme in
There is no theme structure. There are only two files that are required:
- `index.twig`: All content files will be rendered with this template.
-- `404.twig`: This is the template for a not found message.
+- `404.twig`: This is the template for a not found message.
There is another optional template:
diff --git a/content/4_info/15_markdown-test.md b/content/4_info/15_markdown-test.md
index 23ef576..6878b7a 100644
--- a/content/4_info/15_markdown-test.md
+++ b/content/4_info/15_markdown-test.md
@@ -2,6 +2,12 @@
This is just a test file to check, if all the html elements created by the markdown syntax are styled correctly. If you create a new template, please use this page to check your css styling.
+## Table of Contents
+
+You can create a table of contents with the [TOC] tag written in a separate line. The TOC-Tag will be replaced with a link-list to all headlines of the page.
+
+[TOC]
+
## Inline Elements
This is an ordinary paragraph containing only simple text.
diff --git a/content/4_info/20_Übermaß.md b/content/4_info/20_Übermaß.md
new file mode 100644
index 0000000..d7e3629
--- /dev/null
+++ b/content/4_info/20_Übermaß.md
@@ -0,0 +1,5 @@
+# Übermaß: A simple encoding test
+
+This is just a test for character encoding. If you see the correct german word "Übermaß" in the left navigation, and if you can click the navigation point to get to this page, then everything works fine.
+
+I still encourage you to use only english characters to name your content files, because many special characters and many languages won't work. I even doubt, that german or european characters will work in special server environments. So you can try it, but if it does not work, you only option is to avoid special characters in your file-names.
\ No newline at end of file
diff --git a/system/Assets.php b/system/Assets.php
new file mode 100644
index 0000000..8c34038
--- /dev/null
+++ b/system/Assets.php
@@ -0,0 +1,59 @@
+baseUrl = $baseUrl;
+ $this->JS = array();
+ $this->CSS = array();
+ $this->inlineJS = array();
+ $this->inlineCSS = array();
+ }
+
+ public function addCSS(string $CSS)
+ {
+ $CSSpath = __DIR__ . '/../plugins' . $CSS;
+
+ if(file_exists($CSSfile))
+ {
+ $CSSfile = $this->baseUrl . '/plugins' . $CSS;
+ $this->CSS[] = '';
+ }
+ }
+
+ public function addInlineCSS($CSS)
+ {
+ $this->inlineCSS[] = '';
+ }
+
+ public function addJS(string $JS)
+ {
+ $JSpath = __DIR__ . '/../plugins' . $JS;
+
+ if(file_exists($JSpath))
+ {
+ $JSfile = $this->baseUrl . '/plugins' . $JS;
+ $this->JS[] = '';
+ }
+ }
+
+ public function addInlineJS($JS)
+ {
+ $this->inlineJS[] = '';
+ }
+
+ public function renderCSS()
+ {
+ return implode(' ', $this->CSS) . implode(' ', $this->inlineCSS);
+ }
+
+ public function renderJS()
+ {
+ return implode(' ', $this->JS) . implode(' ', $this->inlineJS);
+ }
+}
\ No newline at end of file
diff --git a/system/Controllers/Controller.php b/system/Controllers/Controller.php
index 1340b53..9fbf51a 100644
--- a/system/Controllers/Controller.php
+++ b/system/Controllers/Controller.php
@@ -4,7 +4,7 @@ namespace Typemill\Controllers;
/* Use the slim-container */
use Interop\Container\ContainerInterface;
-use Typemill\Events\RenderSiteEvent;
+use Typemill\Events\RenderPageEvent;
abstract class Controller
{
@@ -17,7 +17,7 @@ abstract class Controller
protected function render($response, $route, $data)
{
- $data = $this->c->dispatcher->dispatch('beforeRenderSite', new RenderSiteEvent($data))->getData();
+ $data = $this->c->dispatcher->dispatch('onPageRendered', new RenderPageEvent($data))->getData();
return $this->c->view->render($response, $route, $data);
}
diff --git a/system/Controllers/PageController.php b/system/Controllers/PageController.php
index 0422d14..b02bf4d 100644
--- a/system/Controllers/PageController.php
+++ b/system/Controllers/PageController.php
@@ -9,9 +9,10 @@ use Typemill\Models\WriteYaml;
use \Symfony\Component\Yaml\Yaml;
use Typemill\Models\VersionCheck;
use Typemill\Models\Helpers;
-use Typemill\Events\LoadStructureEvent;
+use Typemill\Events\LoadPagetreeEvent;
use Typemill\Events\LoadMarkdownEvent;
use Typemill\Events\ParseHtmlEvent;
+use Typemill\Extensions\ParsedownExtension;
class PageController extends Controller
{
@@ -63,7 +64,7 @@ class PageController extends Controller
}
/* dispatch event and let others manipulate the structure */
- $structure = $this->c->dispatcher->dispatch('onStructureLoaded', new LoadStructureEvent($structure))->getData();
+ $structure = $this->c->dispatcher->dispatch('onPagetreeLoaded', new LoadPagetreeEvent($structure))->getData();
}
catch (Exception $e)
{
@@ -122,7 +123,8 @@ class PageController extends Controller
$contentMD = $this->c->dispatcher->dispatch('onMarkdownLoaded', new LoadMarkdownEvent($contentMD))->getData();
/* initialize parsedown */
- $Parsedown = new \ParsedownExtra();
+// $Parsedown = new \ParsedownExtra();
+ $Parsedown = new ParsedownExtension();
/* parse markdown-file to html-string */
$contentHTML = $Parsedown->text($contentMD);
@@ -141,7 +143,7 @@ class PageController extends Controller
*/
$route = empty($args) && $settings['startpage'] ? '/cover.twig' : '/index.twig';
-
+
$this->render($response, $route, array('navigation' => $structure, 'content' => $contentHTML, 'item' => $item, 'breadcrumb' => $breadcrumb, 'settings' => $settings, 'title' => $title, 'description' => $description, 'base_url' => $base_url ));
}
diff --git a/system/Events/LoadStructureEvent.php b/system/Events/LoadPagetreeEvent.php
similarity index 90%
rename from system/Events/LoadStructureEvent.php
rename to system/Events/LoadPagetreeEvent.php
index e7c6b88..7db00e8 100644
--- a/system/Events/LoadStructureEvent.php
+++ b/system/Events/LoadPagetreeEvent.php
@@ -8,7 +8,7 @@ use Symfony\Component\EventDispatcher\Event;
* Event for the folder structure.
*/
-class LoadStructureEvent extends Event
+class LoadPagetreeEvent extends Event
{
protected $data;
diff --git a/system/Events/RenderSiteEvent.php b/system/Events/RenderPageEvent.php
similarity index 90%
rename from system/Events/RenderSiteEvent.php
rename to system/Events/RenderPageEvent.php
index 6717701..538e69f 100644
--- a/system/Events/RenderSiteEvent.php
+++ b/system/Events/RenderPageEvent.php
@@ -8,7 +8,7 @@ use Symfony\Component\EventDispatcher\Event;
* Event for the pure content.
*/
-class RenderSiteEvent extends Event
+class RenderPageEvent extends Event
{
protected $data;
diff --git a/system/Extensions/ParsedownExtension.php b/system/Extensions/ParsedownExtension.php
new file mode 100644
index 0000000..ab8f044
--- /dev/null
+++ b/system/Extensions/ParsedownExtension.php
@@ -0,0 +1,149 @@
+BlockTypes['['], 'TableOfContents');
+ }
+
+ function text($text)
+ {
+ # make sure no definitions are set
+ $this->DefinitionData = array();
+
+ # standardize line breaks
+ $text = str_replace(array("\r\n", "\r"), "\n", $text);
+
+ # remove surrounding line breaks
+ $text = trim($text, "\n");
+
+ # split text into lines
+ $lines = explode("\n", $text);
+
+ # iterate through lines to identify blocks
+ $markup = $this->lines($lines);
+
+ # trim line breaks
+ $markup = trim($markup, "\n");
+
+ if (isset($this->DefinitionData['TableOfContents']))
+ {
+ $TOC = $this->buildTOC($this->headlines);
+
+ $markup = preg_replace('%(