From e1f52837859fd636cbf1d7d203cf7a8b35cb14bd Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Mon, 21 Dec 2015 14:39:56 +0000
Subject: [PATCH] Finish revamp of help page.

---
 build/index.php       | 38 +++++++++++++++++++++-----------------
 core.php              |  1 +
 module_index.json     |  2 +-
 modules/page-help.php | 37 ++++++++++++++++++++-----------------
 4 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/build/index.php b/build/index.php
index 4c59d08..768e9fa 100644
--- a/build/index.php
+++ b/build/index.php
@@ -465,6 +465,7 @@ function human_filesize($bytes, $decimals = 2)
 	$result = round($bytes / pow(1024, $factor), $decimals);
 	return $result . @$sz[$factor];
 }
+
 /*
  * @summary	Calculates the time sincce a particular timestamp and returns a
  * 			human-readable result.
@@ -2817,37 +2818,40 @@ register_module([
 		add_action("help", function() {
 			global $settings, $version, $help_sections;
 			
+			// Sort the help sections by key
+			ksort($help_sections, SORT_NATURAL);
+			
 			if(isset($_GET["dev"]) and $_GET["dev"] == "yes")
 			{
 				$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>
 				<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>
 				<table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n";
 				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>";
 			}
-			$title = "Help - $settings->sitename";
-			
-			// Sort the help sections by key
-			ksort($help_sections, SORT_NATURAL);
-			
-			$content = "	<h1>$settings->sitename Help</h1>
+			else
+			{
+				$title = "Help - $settings->sitename";
+				
+				$content = "	<h1>$settings->sitename Help</h1>
 		<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>";
-		// todo Insert a table of contents here?
-		
-		foreach($help_sections as $index => $section)
-		{
-			
-				// Todo add a button that you can click to get a permanent link
-				// to this section.
-				$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
-				$content .= $section["content"] . "\n";
+				
+				// todo Insert a table of contents here?
+				
+				foreach($help_sections as $index => $section)
+				{
+					
+					// Todo add a button that you can click to get a permanent link
+					// to this section.
+					$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
+					$content .= $section["content"] . "\n";
+				}
 			}
 			
 			exit(page_renderer::render_main($title, $content));
diff --git a/core.php b/core.php
index 8f5ba50..f175de4 100644
--- a/core.php
+++ b/core.php
@@ -111,6 +111,7 @@ function human_filesize($bytes, $decimals = 2)
 	$result = round($bytes / pow(1024, $factor), $decimals);
 	return $result . @$sz[$factor];
 }
+
 /*
  * @summary	Calculates the time sincce a particular timestamp and returns a
  * 			human-readable result.
diff --git a/module_index.json b/module_index.json
index d738c47..54fa982 100644
--- a/module_index.json
+++ b/module_index.json
@@ -104,7 +104,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds the help action. You really want this one.",
         "id": "page-help",
-        "lastupdate": 1450708446,
+        "lastupdate": 1450708748,
         "optional": false
     },
     {
diff --git a/modules/page-help.php b/modules/page-help.php
index fa9aad5..81347c2 100644
--- a/modules/page-help.php
+++ b/modules/page-help.php
@@ -11,37 +11,40 @@ register_module([
 		add_action("help", function() {
 			global $settings, $version, $help_sections;
 			
+			// Sort the help sections by key
+			ksort($help_sections, SORT_NATURAL);
+			
 			if(isset($_GET["dev"]) and $_GET["dev"] == "yes")
 			{
 				$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>
 				<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>
 				<table><tr><th>Index</th><th>Title</th><th>Length</th></tr>\n";
 				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>";
 			}
-			$title = "Help - $settings->sitename";
-			
-			// Sort the help sections by key
-			ksort($help_sections, SORT_NATURAL);
-			
-			$content = "	<h1>$settings->sitename Help</h1>
+			else
+			{
+				$title = "Help - $settings->sitename";
+				
+				$content = "	<h1>$settings->sitename Help</h1>
 		<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>";
-		// todo Insert a table of contents here?
-		
-		foreach($help_sections as $index => $section)
-		{
-			
-				// Todo add a button that you can click to get a permanent link
-				// to this section.
-				$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
-				$content .= $section["content"] . "\n";
+				
+				// todo Insert a table of contents here?
+				
+				foreach($help_sections as $index => $section)
+				{
+					
+					// Todo add a button that you can click to get a permanent link
+					// to this section.
+					$content .= "<h2 id='$index'>" . $section["title"] . "</h2>\n";
+					$content .= $section["content"] . "\n";
+				}
 			}
 			
 			exit(page_renderer::render_main($title, $content));
