1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 16:33:00 +00:00

Finish revamp of help page.

This commit is contained in:
Starbeamrainbowlabs 2015-12-21 14:39:56 +00:00
parent 9e63f0f64b
commit e1f5283785
4 changed files with 43 additions and 35 deletions

View file

@ -465,6 +465,7 @@ function human_filesize($bytes, $decimals = 2)
$result = round($bytes / pow(1024, $factor), $decimals); $result = round($bytes / pow(1024, $factor), $decimals);
return $result . @$sz[$factor]; return $result . @$sz[$factor];
} }
/* /*
* @summary Calculates the time sincce a particular timestamp and returns a * @summary Calculates the time sincce a particular timestamp and returns a
* human-readable result. * human-readable result.
@ -2817,37 +2818,40 @@ register_module([
add_action("help", function() { add_action("help", function() {
global $settings, $version, $help_sections; global $settings, $version, $help_sections;
// Sort the help sections by key
ksort($help_sections, SORT_NATURAL);
if(isset($_GET["dev"]) and $_GET["dev"] == "yes") if(isset($_GET["dev"]) and $_GET["dev"] == "yes")
{ {
$title = "Developers Help - $settings->sitename"; $title = "Developers Help - $settings->sitename";
$content = "<p>$settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.</p> $content = "<p>$settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.</p>
<p>A full guide to developing a Pepperminty Wiki module can be found <a href='//github.com/sbrl/Pepperminty-Wiki/blob/master/Module_API_Docs.md#module-api-documentation'>on GitHub</a>.</p> <p>A full guide to developing a Pepperminty Wiki module can be found <a href='//github.com/sbrl/Pepperminty-Wiki/blob/master/Module_API_Docs.md#module-api-documentation'>on GitHub</a>.</p>
<p>A full guide to Pepperminty Wiki can be found <a href=''
<p>The following help sections are currently registered:</p> <p>The following help sections are currently registered:</p>
<table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n"; <table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n";
foreach($help_sections as $index => $section) foreach($help_sections as $index => $section)
{ {
$content .= "\t\t\t<tr><td>$index</td><td>" . $section["title"] . "</td><td>" . strlen($section["content"]) . "</td></tr>\n"; $content .= "\t\t\t<tr><td>$index</td><td>" . $section["title"] . "</td><td>" . human_filesize(strlen($section["content"])) . "</td></tr>\n";
} }
$content .= "\t\t</table>"; $content .= "\t\t</table>";
} }
$title = "Help - $settings->sitename"; else
{
// Sort the help sections by key $title = "Help - $settings->sitename";
ksort($help_sections, SORT_NATURAL);
$content = " <h1>$settings->sitename Help</h1>
$content = " <h1>$settings->sitename Help</h1>
<p>Welcome to $settings->sitename!</p> <p>Welcome to $settings->sitename!</p>
<p>$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server.</p>"; <p>$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server.</p>";
// todo Insert a table of contents here?
// todo Insert a table of contents here?
foreach($help_sections as $index => $section)
{ foreach($help_sections as $index => $section)
{
// Todo add a button that you can click to get a permanent link
// to this section. // Todo add a button that you can click to get a permanent link
$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n"; // to this section.
$content .= $section["content"] . "\n"; $content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
$content .= $section["content"] . "\n";
}
} }
exit(page_renderer::render_main($title, $content)); exit(page_renderer::render_main($title, $content));

View file

@ -111,6 +111,7 @@ function human_filesize($bytes, $decimals = 2)
$result = round($bytes / pow(1024, $factor), $decimals); $result = round($bytes / pow(1024, $factor), $decimals);
return $result . @$sz[$factor]; return $result . @$sz[$factor];
} }
/* /*
* @summary Calculates the time sincce a particular timestamp and returns a * @summary Calculates the time sincce a particular timestamp and returns a
* human-readable result. * human-readable result.

View file

@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds the help action. You really want this one.", "description": "Adds the help action. You really want this one.",
"id": "page-help", "id": "page-help",
"lastupdate": 1450708446, "lastupdate": 1450708748,
"optional": false "optional": false
}, },
{ {

View file

@ -11,37 +11,40 @@ register_module([
add_action("help", function() { add_action("help", function() {
global $settings, $version, $help_sections; global $settings, $version, $help_sections;
// Sort the help sections by key
ksort($help_sections, SORT_NATURAL);
if(isset($_GET["dev"]) and $_GET["dev"] == "yes") if(isset($_GET["dev"]) and $_GET["dev"] == "yes")
{ {
$title = "Developers Help - $settings->sitename"; $title = "Developers Help - $settings->sitename";
$content = "<p>$settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.</p> $content = "<p>$settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.</p>
<p>A full guide to developing a Pepperminty Wiki module can be found <a href='//github.com/sbrl/Pepperminty-Wiki/blob/master/Module_API_Docs.md#module-api-documentation'>on GitHub</a>.</p> <p>A full guide to developing a Pepperminty Wiki module can be found <a href='//github.com/sbrl/Pepperminty-Wiki/blob/master/Module_API_Docs.md#module-api-documentation'>on GitHub</a>.</p>
<p>A full guide to Pepperminty Wiki can be found <a href=''
<p>The following help sections are currently registered:</p> <p>The following help sections are currently registered:</p>
<table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n"; <table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n";
foreach($help_sections as $index => $section) foreach($help_sections as $index => $section)
{ {
$content .= "\t\t\t<tr><td>$index</td><td>" . $section["title"] . "</td><td>" . strlen($section["content"]) . "</td></tr>\n"; $content .= "\t\t\t<tr><td>$index</td><td>" . $section["title"] . "</td><td>" . human_filesize(strlen($section["content"])) . "</td></tr>\n";
} }
$content .= "\t\t</table>"; $content .= "\t\t</table>";
} }
$title = "Help - $settings->sitename"; else
{
// Sort the help sections by key $title = "Help - $settings->sitename";
ksort($help_sections, SORT_NATURAL);
$content = " <h1>$settings->sitename Help</h1>
$content = " <h1>$settings->sitename Help</h1>
<p>Welcome to $settings->sitename!</p> <p>Welcome to $settings->sitename!</p>
<p>$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server.</p>"; <p>$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server.</p>";
// todo Insert a table of contents here?
// todo Insert a table of contents here?
foreach($help_sections as $index => $section)
{ foreach($help_sections as $index => $section)
{
// Todo add a button that you can click to get a permanent link
// to this section. // Todo add a button that you can click to get a permanent link
$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n"; // to this section.
$content .= $section["content"] . "\n"; $content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
$content .= $section["content"] . "\n";
}
} }
exit(page_renderer::render_main($title, $content)); exit(page_renderer::render_main($title, $content));