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

Add primitive page that lists *all* tags at ?action=list-tags.

This commit is contained in:
Starbeamrainbowlabs 2015-11-09 07:37:38 +00:00
parent 97391466ed
commit 6217cbb6c0
3 changed files with 43 additions and 9 deletions

View file

@ -2683,12 +2683,29 @@ register_module([
add_action("list-tags", function() { add_action("list-tags", function() {
global $pageindex, $settings; global $pageindex, $settings;
if(empty($_GET["tag"])) if(!isset($_GET["tag"]))
{ {
http_response_code(301); // Render a list of all tags
header("location: ?action=list"); $all_tags = [];
foreach($pageindex as $entry)
{
if(!isset($entry->tags)) continue;
foreach($entry->tags as $tag)
{
if(!in_array($tag, $all_tags)) $all_tags[] = $tag;
}
} }
$content = "<h1>All tags</h1>
<ul>\n";
foreach($all_tags as $tag)
{
$content .= " <li><a href='?action=list_tags&tag=" . rawurlencode($tag) . "'>$tag</a></li>\n";
}
$content .= "</ul>";
exit(page_renderer::render("All tags - $settings->sitename", $content));
}
$tag = $_GET["tag"]; $tag = $_GET["tag"];

View file

@ -113,7 +113,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a page that lists all the pages in the index along with their metadata.", "description": "Adds a page that lists all the pages in the index along with their metadata.",
"id": "page-list", "id": "page-list",
"lastupdate": 1445787342, "lastupdate": 1447054618,
"optional": false "optional": false
}, },
{ {

View file

@ -22,12 +22,29 @@ register_module([
add_action("list-tags", function() { add_action("list-tags", function() {
global $pageindex, $settings; global $pageindex, $settings;
if(empty($_GET["tag"])) if(!isset($_GET["tag"]))
{ {
http_response_code(301); // Render a list of all tags
header("location: ?action=list"); $all_tags = [];
foreach($pageindex as $entry)
{
if(!isset($entry->tags)) continue;
foreach($entry->tags as $tag)
{
if(!in_array($tag, $all_tags)) $all_tags[] = $tag;
}
} }
$content = "<h1>All tags</h1>
<ul>\n";
foreach($all_tags as $tag)
{
$content .= " <li><a href='?action=list_tags&tag=" . rawurlencode($tag) . "'>$tag</a></li>\n";
}
$content .= "</ul>";
exit(page_renderer::render("All tags - $settings->sitename", $content));
}
$tag = $_GET["tag"]; $tag = $_GET["tag"];