mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
raw action: send a 404 if a page couldn't be found
This commit is contained in:
parent
3b00f56485
commit
3409fcc4ca
3 changed files with 15 additions and 3 deletions
|
@ -2287,9 +2287,15 @@ register_module([
|
|||
* ██ ██ ██ ██ ███ ███
|
||||
*/
|
||||
add_action("raw", function() {
|
||||
global $env;
|
||||
global $pageindex, $env;
|
||||
|
||||
if(empty($pageindex->{$env->page})) {
|
||||
http_response_code(404);
|
||||
exit("Error: The page with the name $env->page could not be found.\n");
|
||||
}
|
||||
|
||||
header("content-type: text/markdown");
|
||||
header("content-length: " . filesize($env->page_filename));
|
||||
exit(file_get_contents($env->page_filename));
|
||||
});
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a 'raw' action that shows you the raw source of a page.",
|
||||
"id": "action-raw",
|
||||
"lastupdate": 1476906745,
|
||||
"lastupdate": 1507993680,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -24,9 +24,15 @@ register_module([
|
|||
* ██ ██ ██ ██ ███ ███
|
||||
*/
|
||||
add_action("raw", function() {
|
||||
global $env;
|
||||
global $pageindex, $env;
|
||||
|
||||
if(empty($pageindex->{$env->page})) {
|
||||
http_response_code(404);
|
||||
exit("Error: The page with the name $env->page could not be found.\n");
|
||||
}
|
||||
|
||||
header("content-type: text/markdown");
|
||||
header("content-length: " . filesize($env->page_filename));
|
||||
exit(file_get_contents($env->page_filename));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue