From 96a1b4db9b2b4706977554a83cce67b3fa4440d1 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sat, 25 Apr 2015 14:33:09 +0100 Subject: [PATCH] added php script to auto-build the module index --- module_index.json | 96 ++++++++++++++++++++++++++++++++++++---- modules/action-hash.php | 2 +- rebuild_module_index.php | 31 +++++++++++++ 3 files changed, 120 insertions(+), 9 deletions(-) create mode 100644 rebuild_module_index.php diff --git a/module_index.json b/module_index.json index f7dcff4..5c0da50 100644 --- a/module_index.json +++ b/module_index.json @@ -1,10 +1,90 @@ [ - { - "name": "Page Viewer", - "version": "0.4", - "author": "Starbeamrainbowlabs", - "description": "Allows you to view pages. You should include this one.", - "id": "page-view", - "lastupdate": 1426362000, - } + { + "name": "Password hashing action", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.", + "id": "action-hash", + "lastmodified": 1429968727 + }, + { + "name": "Credits", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds the credits page. You *must* have this module :D", + "id": "page-credits", + "lastmodified": 1428760042 + }, + { + "name": "Page deleter", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds an action to allow administrators to delete pages.", + "id": "page-delete", + "lastmodified": 1428759115 + }, + { + "name": "Page editor", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.", + "id": "page-edit", + "lastmodified": 1428758936 + }, + { + "name": "Help page", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds the help action. You really want this one.", + "id": "page-help", + "lastmodified": 1428759307 + }, + { + "name": "Page list", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds a page that lists all the pages in the index long with their metadata.", + "id": "page-list", + "lastmodified": 1428758608 + }, + { + "name": "Login", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds a pair of actions (login and checklogin) that allow users to login. You need this one if you want your users to be able to login.", + "id": "page-login", + "lastmodified": 1428759587 + }, + { + "name": "Logout", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds an action to let users user out. For security reasons it is wise to add this module since logging in automatically opens a session that is valid for 30 days.", + "id": "page-logout", + "lastmodified": 1428760035 + }, + { + "name": "Page mover", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds an action to allow administrators to move pages.", + "id": "page-move", + "lastmodified": 1428760214 + }, + { + "name": "Update", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Adds an update page that downloads the latest stable version of Pepperminty Wiki. This module is currently outdated as it doesn't save your module preferences.", + "id": "page-update", + "lastmodified": 1428760319 + }, + { + "name": "Page viewer", + "version": "0.4", + "author": "Starbeamrainbowlabs", + "description": "Allows you to view pages. You should include this one.", + "id": "page-view", + "lastmodified": 1428757674 + } ] \ No newline at end of file diff --git a/modules/action-hash.php b/modules/action-hash.php index eb0527a..ff7cb72 100644 --- a/modules/action-hash.php +++ b/modules/action-hash.php @@ -4,7 +4,7 @@ register_module([ "version" => "0.4", "author" => "Starbeamrainbowlabs", "description" => "Adds a utility action (that anyone can use) called hash that hashes a given string. Useful when changing a user's password.", - "id" => "page-hash", + "id" => "action-hash", "code" => function() { add_action("hash", function() { if(!isset($_GET["string"])) diff --git a/rebuild_module_index.php b/rebuild_module_index.php new file mode 100644 index 0000000..245bf04 --- /dev/null +++ b/rebuild_module_index.php @@ -0,0 +1,31 @@ + $settings["name"], + "version" => $settings["version"], + "author" => $settings["author"], + "description" => $settings["description"], + "id" => $settings["id"], + "lastmodified" => filemtime("modules/" . $settings["id"] . ".php") + ]; + $module_index[] = $newmodule; +} + +foreach($modules as $filename) +{ + echo("Processing $filename\n"); + require($filename); +} + +echo("*** Processing Complete ***\n"); + +echo("Writing new module index to disk..."); +file_put_contents("module_index.json", json_encode($module_index, JSON_PRETTY_PRINT)); +echo("done\n"); + +?>