1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-25 17:23:00 +00:00

Enhanced credits page and cleaned up comments

This commit is contained in:
Starbeamrainbowlabs 2015-07-14 16:11:59 +01:00
parent 94358ff72b
commit 3fa1905070
5 changed files with 122 additions and 44 deletions

View file

@ -236,14 +236,14 @@ if(!isset($_GET["action"]) and !isset($_GET["page"]))
exit(); exit();
} }
//make sure that the action is set // Make sure that the action is set
if(!isset($_GET["action"])) if(!isset($_GET["action"]))
$_GET["action"] = $settings->defaultaction; $_GET["action"] = $settings->defaultaction;
//make sure that the page is set // Make sure that the page is set
if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0) if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0)
$_GET["page"] = $settings->defaultpage; $_GET["page"] = $settings->defaultpage;
//redirect the user to the safe version of the path if they entered an unsafe character // Redirect the user to the safe version of the path if they entered an unsafe character
if(makepathsafe($_GET["page"]) !== $_GET["page"]) if(makepathsafe($_GET["page"]) !== $_GET["page"])
{ {
http_response_code(301); http_response_code(301);
@ -376,12 +376,12 @@ class page_renderer
else else
$result .= "\t\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n"; $result .= "\t\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n";
// loop over all the navigation links // Loop over all the navigation links
foreach($settings->navlinks as $item) foreach($settings->navlinks as $item)
{ {
if(is_string($item)) if(is_string($item))
{ {
//the item is a string // The item is a string
switch($item) switch($item)
{ {
//keywords //keywords
@ -389,14 +389,14 @@ class page_renderer
$result .= "\t\t\t<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>\n"; $result .= "\t\t\t<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>\n";
break; break;
//it isn't a keyword, so just output it directly // It isn't a keyword, so just output it directly
default: default:
$result .= "\t\t\t$item\n"; $result .= "\t\t\t$item\n";
} }
} }
else else
{ {
//output the item as a link to a url // Output the item as a link to a url
$result .= "\t\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n"; $result .= "\t\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n";
} }
} }
@ -470,8 +470,8 @@ function human_time_since($time)
// register themselves // // register themselves //
// or new pages. // // or new pages. //
////////////////////////// //////////////////////////
$modules = []; // list that contains all the loaded modules $modules = []; // List that contains all the loaded modules
// function to register a module // Function to register a module
function register_module($moduledata) function register_module($moduledata)
{ {
global $modules; global $modules;
@ -480,7 +480,7 @@ function register_module($moduledata)
$modules[] = $moduledata; $modules[] = $moduledata;
} }
// function to register an action handler // Function to register an action handler
$actions = new stdClass(); $actions = new stdClass();
function add_action($action_name, $func) function add_action($action_name, $func)
{ {
@ -506,12 +506,12 @@ function add_parser($parser_code)
// %next_module% // // %next_module% //
// execute each module's code // Execute each module's code
foreach($modules as $moduledata) foreach($modules as $moduledata)
{ {
$moduledata["code"](); $moduledata["code"]();
} }
// make sure that the credits page exists // Make sure that the credits page exists
if(!isset($actions->credits)) if(!isset($actions->credits))
{ {
exit(page_renderer::render_main("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>")); exit(page_renderer::render_main("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>"));

View file

@ -12,7 +12,8 @@ $start_time = time(true);
* Code by @Starbeamrainbowlabs * Code by @Starbeamrainbowlabs
* Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900
* Bug reports: * Bug reports:
* #1 - Incorrect closing tag - nibreh <https://github.com/nibreh/> * #2 - Incorrect closing tag - nibreh <https://github.com/nibreh/>
* #8 - Rogue <datalist /> tag - nibreh <https://github.com/nibreh/>
*/ */
// Initialises a new object to store your wiki's settings in. Please don't touch this. // Initialises a new object to store your wiki's settings in. Please don't touch this.
$settings = new stdClass(); $settings = new stdClass();
@ -390,14 +391,14 @@ if(!isset($_GET["action"]) and !isset($_GET["page"]))
exit(); exit();
} }
//make sure that the action is set // Make sure that the action is set
if(!isset($_GET["action"])) if(!isset($_GET["action"]))
$_GET["action"] = $settings->defaultaction; $_GET["action"] = $settings->defaultaction;
//make sure that the page is set // Make sure that the page is set
if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0) if(!isset($_GET["page"]) or strlen($_GET["page"]) === 0)
$_GET["page"] = $settings->defaultpage; $_GET["page"] = $settings->defaultpage;
//redirect the user to the safe version of the path if they entered an unsafe character // Redirect the user to the safe version of the path if they entered an unsafe character
if(makepathsafe($_GET["page"]) !== $_GET["page"]) if(makepathsafe($_GET["page"]) !== $_GET["page"])
{ {
http_response_code(301); http_response_code(301);
@ -530,12 +531,12 @@ class page_renderer
else else
$result .= "\t\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n"; $result .= "\t\t\tBrowsing as Anonymous. <a href='index.php?action=login'>Login</a>. | \n";
// loop over all the navigation links // Loop over all the navigation links
foreach($settings->navlinks as $item) foreach($settings->navlinks as $item)
{ {
if(is_string($item)) if(is_string($item))
{ {
//the item is a string // The item is a string
switch($item) switch($item)
{ {
//keywords //keywords
@ -543,14 +544,14 @@ class page_renderer
$result .= "\t\t\t<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>\n"; $result .= "\t\t\t<form method='get' action='index.php' style='display: inline;'><input type='search' name='page' list='allpages' placeholder='Type a page name here and hit enter' /></form>\n";
break; break;
//it isn't a keyword, so just output it directly // It isn't a keyword, so just output it directly
default: default:
$result .= "\t\t\t$item\n"; $result .= "\t\t\t$item\n";
} }
} }
else else
{ {
//output the item as a link to a url // Output the item as a link to a url
$result .= "\t\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n"; $result .= "\t\t\t<a href='" . str_replace("{page}", $page, $item[1]) . "'>$item[0]</a>\n";
} }
} }
@ -624,8 +625,8 @@ function human_time_since($time)
// register themselves // // register themselves //
// or new pages. // // or new pages. //
////////////////////////// //////////////////////////
$modules = []; // list that contains all the loaded modules $modules = []; // List that contains all the loaded modules
// function to register a module // Function to register a module
function register_module($moduledata) function register_module($moduledata)
{ {
global $modules; global $modules;
@ -634,7 +635,7 @@ function register_module($moduledata)
$modules[] = $moduledata; $modules[] = $moduledata;
} }
// function to register an action handler // Function to register an action handler
$actions = new stdClass(); $actions = new stdClass();
function add_action($action_name, $func) function add_action($action_name, $func)
{ {
@ -685,21 +686,59 @@ register_module([
register_module([ register_module([
"name" => "Credits", "name" => "Credits",
"version" => "0.5", "version" => "0.6",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds the credits page. You *must* have this module :D", "description" => "Adds the credits page. You *must* have this module :D",
"id" => "page-credits", "id" => "page-credits",
"code" => function() { "code" => function() {
add_action("credits", function() { add_action("credits", function() {
global $settings, $version; global $settings, $version, $pageindex, $modules;
$credits = [
"Code" => [
"author" => "Starbeamrainbowlabs",
"author_url" => "https://starbeamrmainbowlabs.com/",
"thing_url" => "https://github.com/sbrl/Pepprminty-Wiki"
],
"Slightly modified version of Slimdown" => [
"author" => "Johnny Broadway",
"author_url" => "https://github.com/jbroadway",
"thing_url" => "https://gist.github.com/jbroadway/2836900"
],
"Default Favicon" => [
"author" => "bluefrog23",
"author_url" => "https://openclipart.org/user-detail/bluefrog23/",
"thing_url" => "https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23"
],
"Bug Reports" => [
"author" => "nibreh",
"author_url" => "https://github.com/nibreh/",
"thing_url" => ""
]
];
$credits_html = "<ul>\n";
foreach($credits as $thing => $author_details)
{
$credits_html .= " <li>";
$credits_html .= "<a href='" . $author_details["thing_url"] . "'>$thing</a> by ";
$credits_html .= "<a href='" . $author_details["author_url"] . "'>" . $author_details["author"] . "</a>";
$credits_html .= "</li>\n";
}
$credits_html .= "</ul>";
$title = "Credits - $settings->sitename"; $title = "Credits - $settings->sitename";
$content = "<h1>$settings->sitename credits</h1> $content = "<h1>$settings->sitename credits</h1>
<p>$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by <a href='//starbeamrainboowlabs.com'>Starbeamrainbowlabs</a>, and can be found <a href='//github.com/sbrl/Pepperminty-Wiki/'>on github</a> (contributors will ablso be listed here in the future).</p> <p>$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by <a href='//starbeamrainbowlabs.com'>Starbeamrainbowlabs</a>, and can be found <a href='//github.com/sbrl/Pepperminty-Wiki/'>on github</a> (contributors will ablso be listed here in the future).</p>
<p>A slightly modified version of slimdown is used to parse text source into HTML. Slimdown is by <a href='https://github.com/jbroadway'>Johnny Broadway</a>, which can be found <a href='https://gist.github.com/jbroadway/2836900'>on github</a>.</p> <h2>Main Credits</h2>
<p>The default favicon is from <a href='//openclipart.org'>Open Clipart</a> by bluefrog23, and can be found <a href='https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23'>here</a>.</p> $credits_html
<p>Administrators can update $settings->sitename here: <a href='?action=update'>Update $settings->sitename</a>.</p> <h2>Site status</h2>
<p>$settings->sitename is currently running on Pepperminty Wiki <code>$version</code></p>"; <table>
<tr><th>Site name:</th><td>$settings->sitename (<a href='?action=update'>Update - Administrators only</a>)</td></tr>
<tr><th>Pepperminty Wiki version:</th><td>$version</td></tr>
<tr><th>Number of pages:</th><td>" . count(get_object_vars($pageindex)) . "</td></tr>
<tr><th>Number of modules:</th><td>" . count($modules) . "</td></tr>
</table>";
exit(page_renderer::render_main($title, $content)); exit(page_renderer::render_main($title, $content));
}); });
} }
@ -1406,12 +1445,12 @@ class Slimdown {
// %next_module% // // %next_module% //
// execute each module's code // Execute each module's code
foreach($modules as $moduledata) foreach($modules as $moduledata)
{ {
$moduledata["code"](); $moduledata["code"]();
} }
// make sure that the credits page exists // Make sure that the credits page exists
if(!isset($actions->credits)) if(!isset($actions->credits))
{ {
exit(page_renderer::render_main("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>")); exit(page_renderer::render_main("Error - $settings->$sitename", "<p>No credits page detected. The credits page is a required module!</p>"));

View file

@ -9,11 +9,11 @@
}, },
{ {
"name": "Credits", "name": "Credits",
"version": "0.5", "version": "0.6",
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the credits page. You *must* have this module :D", "description": "Adds the credits page. You *must* have this module :D",
"id": "page-credits", "id": "page-credits",
"lastupdate": 1432497591 "lastupdate": 1436886691
}, },
{ {
"name": "Page deleter", "name": "Page deleter",

View file

@ -1,21 +1,59 @@
<?php <?php
register_module([ register_module([
"name" => "Credits", "name" => "Credits",
"version" => "0.5", "version" => "0.6",
"author" => "Starbeamrainbowlabs", "author" => "Starbeamrainbowlabs",
"description" => "Adds the credits page. You *must* have this module :D", "description" => "Adds the credits page. You *must* have this module :D",
"id" => "page-credits", "id" => "page-credits",
"code" => function() { "code" => function() {
add_action("credits", function() { add_action("credits", function() {
global $settings, $version; global $settings, $version, $pageindex, $modules;
$credits = [
"Code" => [
"author" => "Starbeamrainbowlabs",
"author_url" => "https://starbeamrmainbowlabs.com/",
"thing_url" => "https://github.com/sbrl/Pepprminty-Wiki"
],
"Slightly modified version of Slimdown" => [
"author" => "Johnny Broadway",
"author_url" => "https://github.com/jbroadway",
"thing_url" => "https://gist.github.com/jbroadway/2836900"
],
"Default Favicon" => [
"author" => "bluefrog23",
"author_url" => "https://openclipart.org/user-detail/bluefrog23/",
"thing_url" => "https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23"
],
"Bug Reports" => [
"author" => "nibreh",
"author_url" => "https://github.com/nibreh/",
"thing_url" => ""
]
];
$credits_html = "<ul>\n";
foreach($credits as $thing => $author_details)
{
$credits_html .= " <li>";
$credits_html .= "<a href='" . $author_details["thing_url"] . "'>$thing</a> by ";
$credits_html .= "<a href='" . $author_details["author_url"] . "'>" . $author_details["author"] . "</a>";
$credits_html .= "</li>\n";
}
$credits_html .= "</ul>";
$title = "Credits - $settings->sitename"; $title = "Credits - $settings->sitename";
$content = "<h1>$settings->sitename credits</h1> $content = "<h1>$settings->sitename credits</h1>
<p>$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by <a href='//starbeamrainboowlabs.com'>Starbeamrainbowlabs</a>, and can be found <a href='//github.com/sbrl/Pepperminty-Wiki/'>on github</a> (contributors will ablso be listed here in the future).</p> <p>$settings->sitename is powered by Pepperminty Wiki - an entire wiki packed inside a single file, which was built by <a href='//starbeamrainbowlabs.com'>Starbeamrainbowlabs</a>, and can be found <a href='//github.com/sbrl/Pepperminty-Wiki/'>on github</a> (contributors will ablso be listed here in the future).</p>
<p>A slightly modified version of slimdown is used to parse text source into HTML. Slimdown is by <a href='https://github.com/jbroadway'>Johnny Broadway</a>, which can be found <a href='https://gist.github.com/jbroadway/2836900'>on github</a>.</p> <h2>Main Credits</h2>
<p>The default favicon is from <a href='//openclipart.org'>Open Clipart</a> by bluefrog23, and can be found <a href='https://openclipart.org/detail/19571/peppermint-candy-by-bluefrog23'>here</a>.</p> $credits_html
<p>Administrators can update $settings->sitename here: <a href='?action=update'>Update $settings->sitename</a>.</p> <h2>Site status</h2>
<p>$settings->sitename is currently running on Pepperminty Wiki <code>$version</code></p>"; <table>
<tr><th>Site name:</th><td>$settings->sitename (<a href='?action=update'>Update - Administrators only</a>)</td></tr>
<tr><th>Pepperminty Wiki version:</th><td>$version</td></tr>
<tr><th>Number of pages:</th><td>" . count(get_object_vars($pageindex)) . "</td></tr>
<tr><th>Number of modules:</th><td>" . count($modules) . "</td></tr>
</table>";
exit(page_renderer::render_main($title, $content)); exit(page_renderer::render_main($title, $content));
}); });
} }

View file

@ -9,7 +9,8 @@
* Code by @Starbeamrainbowlabs * Code by @Starbeamrainbowlabs
* Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900 * Slimdown - by Johnny Broadway from https://gist.github.com/jbroadway/2836900
* Bug reports: * Bug reports:
* #1 - Incorrect closing tag - nibreh <https://github.com/nibreh/> * #2 - Incorrect closing tag - nibreh <https://github.com/nibreh/>
* #8 - Rogue <datalist /> tag - nibreh <https://github.com/nibreh/>
*/ */
// Initialises a new object to store your wiki's settings in. Please don't touch this. // Initialises a new object to store your wiki's settings in. Please don't touch this.
$settings = new stdClass(); $settings = new stdClass();