1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-26 05:32:59 +00:00

Rework templating engine a bit ready for the file previews

This commit is contained in:
Starbeamrainbowlabs 2015-10-24 10:16:26 +01:00
parent 855e1f6d46
commit 4d37db9f3c
3 changed files with 17 additions and 21 deletions

View file

@ -784,7 +784,12 @@ class page_renderer
"{all-pages-datalist}" => self::generate_all_pages_datalist(), "{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 // 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(array_keys($parts), array_values($parts), $result);
$result = str_replace([ $result = str_replace([
"{title}",
"{content}"
], [ ], [
$title,
$content
], $result); ], $result);
$result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result); $result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result);
@ -1431,19 +1433,11 @@ register_module([
http_response_code(501); http_response_code(501);
exit("Unrecognised file type."); 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) { 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:
}); });
} }
]); ]);

View file

@ -490,7 +490,12 @@ class page_renderer
"{all-pages-datalist}" => self::generate_all_pages_datalist(), "{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 // 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(array_keys($parts), array_values($parts), $result);
$result = str_replace([ $result = str_replace([
"{title}",
"{content}"
], [ ], [
$title,
$content
], $result); ], $result);
$result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result); $result = str_replace("{generation-time-taken}", microtime(true) - $start_time, $result);

View file

@ -50,7 +50,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.",
"id": "feature-upload", "id": "feature-upload",
"lastupdate": 1445677429, "lastupdate": 1445677720,
"optional": false "optional": false
}, },
{ {