Add action-raw module

This commit is contained in:
Starbeamrainbowlabs 2015-09-21 18:04:51 +01:00
parent 81a479fc05
commit cab6f9f414
3 changed files with 51 additions and 1 deletions

View File

@ -639,7 +639,6 @@ class page_renderer
}
$result = self::$html_template;
// $result = str_replace("{body}", $parts["{body}"], $result);
$result = str_replace(array_keys($parts), array_values($parts), $result);
@ -831,6 +830,28 @@ register_module([
register_module([
"name" => "Raw page source",
"version" => "0.2",
"author" => "Starbeamrainbowlabs",
"description" => "Adds a 'raw' action that shows you the raw source of a page.",
"id" => "action-raw",
"code" => function() {
add_action("raw", function() {
global $page;
http_response_code(307);
header("x-filename: " . rawurlencode($page) . ".md");
header("content-type: text/markdown");
exit(file_get_contents("$page.md"));
exit();
});
}
]);
register_module([
"name" => "Sidebar",

View File

@ -7,6 +7,14 @@
"id": "action-hash",
"lastupdate": 1432497591
},
{
"name": "Raw page source",
"version": "0.2",
"author": "Starbeamrainbowlabs",
"description": "Adds a 'raw' action that shows you the raw source of a page.",
"id": "action-raw",
"lastupdate": 1442855075
},
{
"name": "Sidebar",
"version": "0.2",

21
modules/action-raw.php Normal file
View File

@ -0,0 +1,21 @@
<?php
register_module([
"name" => "Raw page source",
"version" => "0.2",
"author" => "Starbeamrainbowlabs",
"description" => "Adds a 'raw' action that shows you the raw source of a page.",
"id" => "action-raw",
"code" => function() {
add_action("raw", function() {
global $page;
http_response_code(307);
header("x-filename: " . rawurlencode($page) . ".md");
header("content-type: text/markdown");
exit(file_get_contents("$page.md"));
exit();
});
}
]);
?>