From 4d37db9f3c416a4fbd1e920bb9ddbee6d12baa4c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 24 Oct 2015 10:16:26 +0100 Subject: [PATCH] Rework templating engine a bit ready for the file previews --- build/index.php | 24 +++++++++--------------- core.php | 12 +++++++----- module_index.json | 2 +- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/build/index.php b/build/index.php index 3d1578b..811b86f 100644 --- a/build/index.php +++ b/build/index.php @@ -784,7 +784,12 @@ class page_renderer "{all-pages-datalist}" => self::generate_all_pages_datalist(), - "{footer-message}" => $settings->footer_message + "{footer-message}" => $settings->footer_message, + + /// Secondary Parts /// + + "{content}" => $content, + "{title}" => $title, ]; // Pass the parts through the part processors @@ -798,11 +803,8 @@ class page_renderer $result = str_replace(array_keys($parts), array_values($parts), $result); $result = str_replace([ - "{title}", - "{content}" + ], [ - $title, - $content ], $result); $result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result); @@ -1431,19 +1433,11 @@ register_module([ http_response_code(501); exit("Unrecognised file type."); } - - // todo render a preview here - - /* - * size (image outputs only, possibly width / height) - * 1-2048 (configurable) - * filetype - * either a mime type or 'native' - */ }); page_renderer::register_part_preprocessor(function(&$parts) { - // Todo add the preview to the top o fthe page here, but onyl if the current action is view and we are on a page prefixed with file: + // Todo add the preview to the top of the page here, but onyl if the current action is view and we are on a page prefixed with file: + }); } ]); diff --git a/core.php b/core.php index bc1947a..ab89334 100644 --- a/core.php +++ b/core.php @@ -490,7 +490,12 @@ class page_renderer "{all-pages-datalist}" => self::generate_all_pages_datalist(), - "{footer-message}" => $settings->footer_message + "{footer-message}" => $settings->footer_message, + + /// Secondary Parts /// + + "{content}" => $content, + "{title}" => $title, ]; // Pass the parts through the part processors @@ -504,11 +509,8 @@ class page_renderer $result = str_replace(array_keys($parts), array_values($parts), $result); $result = str_replace([ - "{title}", - "{content}" + ], [ - $title, - $content ], $result); $result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result); diff --git a/module_index.json b/module_index.json index af1a8e8..c4e4fed 100644 --- a/module_index.json +++ b/module_index.json @@ -50,7 +50,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.", "id": "feature-upload", - "lastupdate": 1445677429, + "lastupdate": 1445677720, "optional": false }, {