"Help page", "version" => "0.10.2", "author" => "Starbeamrainbowlabs", "description" => "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "id" => "page-help", "code" => function() { global $settings; /** * @api {get} ?action=help[&dev=yes] Get a help page * @apiDescription Get a customised help page. This page will be slightly different for every wiki, depending on their name, settings, and installed modules. * @apiName Help * @apiGroup Utility * @apiPermission Anonymous * * @apiParam {string} dev Set to 'yes' to get a developer help page instead. The developer help page gives some general information about which modules and help page sections are registered, and other various (non-sensitive) settings. */ /* * ██ ██ ███████ ██ ██████ * ██ ██ ██ ██ ██ ██ * ███████ █████ ██ ██████ * ██ ██ ██ ██ ██ * ██ ██ ███████ ███████ ██ */ add_action("help", function() { global $env, $paths, $settings, $version, $help_sections, $actions; // 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 = "

$settings->sitename runs on Pepperminty Wiki, an entire wiki packed into a single file. This page contains some information that developers may find useful.

A full guide to developing a Pepperminty Wiki module can be found on GitHub.

Registered Help Sections

The following help sections are currently registered:

\n"; $totalSize = 0; foreach($help_sections as $index => $section) { $sectionLength = strlen($section["content"]); $totalSize += $sectionLength; $content .= "\t\t\t\n"; } $content .= "\t\t\t\n"; $content .= "\t\t
IndexTitleLength
$index" . $section["title"] . "" . human_filesize($sectionLength) . "
Total:" . human_filesize($totalSize) . "
\n"; $content .= "

Registered Actions

"; $registeredActions = array_keys(get_object_vars($actions)); sort($registeredActions); $content .= "

The following actions are currently registered:

\n"; $content .= "

" . implode(", ", $registeredActions) . "

"; $content .= "

Environment

\n"; $content .= "\n"; $content .= "

Data

\n"; $wikiSize = new stdClass(); $wikiSize->all = 0; $wikiSize->images = 0; $wikiSize->audio = 0; $wikiSize->videos = 0; $wikiSize->pages = 0; $wikiSize->history = 0; $wikiSize->indexes = 0; $wikiSize->other = 0; $wikiFiles = glob_recursive($env->storage_prefix . "*"); foreach($wikiFiles as $filename) { $extension = strtolower(substr($filename, strrpos($filename, ".") + 1)); if($extension === "php") continue; // Skip php files $nextFilesize = filesize($filename); $wikiSize->all += $nextFilesize; if($extension[0] === "r") // It's a revision of a page $wikiSize->history += $nextFilesize; else if($extension == "md") // It's a page $wikiSize->pages += $nextFilesize; else if(in_array($extension, ["json", "sqlite"])) // It's an index $wikiSize->indexes += $nextFilesize; else if(in_array($extension, [ // It's an uploaded image "jpg", "jpeg", "png", "gif", "webp", "svg", "jxl", "avif", "hiec", "hief" ])) $wikiSize->images += $nextFilesize; else if(in_array($extension, [ "flac", "mp3", "ogg", "wav", "aac", "m4a" ])) // It's an audio file $wikiSize->audio += $nextFilesize; else if(in_array($extension, [ "avi", "mp4", "m4v", "webm" ])) // It's a video file $wikiSize->videos += $nextFilesize; else $wikiSize->other += $nextFilesize; } $content .= "

$settings->sitename is currently " . human_filesize($wikiSize->all) . " in size.

\n"; $content .= "
Indexes: " . human_filesize($wikiSize->indexes) . "
Pages: " . human_filesize($wikiSize->pages) . "
Page History: " . human_filesize($wikiSize->history) . "
Images: " . human_filesize($wikiSize->images) . "
\n"; if($wikiSize->audio > 0) $content .= "
Audio: " . human_filesize($wikiSize->audio) . "
\n"; if($wikiSize->videos > 0) $content .= "
Videos: " . human_filesize($wikiSize->videos) . "
\n"; if($wikiSize->other > 0) $content .= "
Other: " . human_filesize($wikiSize->other) . "
\n"; $content .= "
"; } else { $title = "Help - $settings->sitename"; $content = "

$settings->sitename Help

Welcome to $settings->sitename!

$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server and expect it to just work.

Contents

    "; foreach($help_sections as $index => $section) $content .= "
  1. {$section["title"]}
  2. \n"; $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 .= "

{$section["title"]}

\n"; $content .= $section["content"] . "\n"; } } exit(page_renderer::render_main($title, $content)); }); // Register a help section on general navigation add_help_section("5-navigation", "Navigating", "

All the navigation links can be found on the top bar, along with a search box (if your site administrator has enabled it). There is also a "More..." menu in the top right that contains some additional links that you may fine useful.

This page, along with the credits page, can be found on the bar at the bottom of every page.

"); add_help_section("1-extra", "Extra Information", "

You can find out which version of Pepperminty Wiki $settings->sitename is using by visiting the credits page.

Information for developers can be found on this page.

"); } ]); ?>