mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Improve the look of the stats page
This commit is contained in:
parent
5e1a79aa85
commit
143e1f847b
4 changed files with 459 additions and 142 deletions
527
build/index.php
527
build/index.php
File diff suppressed because it is too large
Load diff
|
@ -46,20 +46,20 @@
|
|||
},
|
||||
{
|
||||
"name": "Sidebar",
|
||||
"version": "0.3",
|
||||
"version": "0.3.1",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a sidebar to the left hand side of every page. Add '$settings->sidebar_show = true;' to your configuration, or append '&sidebar=yes' to the url to enable. Adding to the url sets a cookie to remember your setting.",
|
||||
"id": "extra-sidebar",
|
||||
"lastupdate": 1496779827,
|
||||
"lastupdate": 1505512998,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"name": "Page Comments",
|
||||
"version": "0.2.2",
|
||||
"version": "0.2.3",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds threaded comments to the bottom of every page.",
|
||||
"id": "feature-comments",
|
||||
"lastupdate": 1505489462,
|
||||
"lastupdate": 1505513014,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -82,11 +82,11 @@
|
|||
},
|
||||
{
|
||||
"name": "Recent Changes",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.4",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
||||
"id": "feature-recent-changes",
|
||||
"lastupdate": 1495291194,
|
||||
"lastupdate": 1505512941,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -113,16 +113,16 @@
|
|||
"author": "Starbeamrainbowlabs",
|
||||
"description": "An extensible statistics calculation system. Comes with a range of built-in statistics, but can be extended by other modules too.",
|
||||
"id": "feature-stats",
|
||||
"lastupdate": 1504261794,
|
||||
"lastupdate": 1505564746,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"name": "Uploader",
|
||||
"version": "0.5.10",
|
||||
"version": "0.5.11",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
|
||||
"id": "feature-upload",
|
||||
"lastupdate": 1503848840,
|
||||
"lastupdate": 1505512979,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -190,20 +190,20 @@
|
|||
},
|
||||
{
|
||||
"name": "Page list",
|
||||
"version": "0.10.2",
|
||||
"version": "0.10.3",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a page that lists all the pages in the index along with their metadata.",
|
||||
"id": "page-list",
|
||||
"lastupdate": 1499102118,
|
||||
"lastupdate": 1505513005,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"name": "Login",
|
||||
"version": "0.8.4",
|
||||
"version": "0.8.5",
|
||||
"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",
|
||||
"lastupdate": 1482008539,
|
||||
"lastupdate": 1505512966,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -266,7 +266,7 @@
|
|||
"author": "Emanuil Rusev & Starbeamrainbowlabs",
|
||||
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
|
||||
"id": "parser-parsedown",
|
||||
"lastupdate": 1500065639,
|
||||
"lastupdate": 1505563677,
|
||||
"optional": false
|
||||
}
|
||||
]
|
|
@ -28,26 +28,36 @@ register_module([
|
|||
|
||||
$stats = stats_load();
|
||||
|
||||
$content = "<h1>Statistics</h1>";
|
||||
$content .= "<p>This page contains a selection of statistics about $settings->sitename's content. They are updated automatically about every " . trim(str_replace(["ago", "1 "], [""], human_time($settings->stats_update_interval))) . ", although $settings->sitename's local friendly moderators may update it earlier (you can see their names at the bottom of every page).</p>\n";
|
||||
$stat_scalar_values = [];
|
||||
$stat_contents = [];
|
||||
$stat_pages_list = "<a href='?action=stats'>Main</a> | ";
|
||||
foreach($statistic_calculators as $stat_id => $stat_calculator) {
|
||||
if(!empty($stat_calculator["render"]))
|
||||
$stat_contents[$stat_calculator["name"]] = $stat_calculator["render"]($stats->$stat_id);
|
||||
else
|
||||
$stat_scalar_values[$stat_calculator["name"]] = $stats->$stat_id->value;
|
||||
if($stat_calculator["type"] == "scalar")
|
||||
continue;
|
||||
$stat_pages_list .= "<a href='?action=stats&stat=" . rawurlencode($stat_id) . "'>{$stat_calculator["name"]}</a> | ";
|
||||
}
|
||||
$stat_pages_list = trim($stat_pages_list, " |");
|
||||
|
||||
$content .= "<table class='stats-table'>\n";
|
||||
$content .= "\t<tr><th>Statistic</th><th>Value</th></tr>\n\n";
|
||||
foreach($stat_scalar_values as $scalar_name => $scalar_value) {
|
||||
$content .= "\t<tr><td>$scalar_name</td><td>$scalar_value</td></tr>\n";
|
||||
if(!empty($_GET["stat"]) && !empty($statistic_calculators[$_GET["stat"]])) {
|
||||
$stat_calculator = $statistic_calculators[$_GET["stat"]];
|
||||
$content = "<h1>{$stat_calculator["name"]} - Statistics</h1>\n";
|
||||
$content .= "<p>$stat_pages_list</p>\n";
|
||||
$content .= $stat_calculator["render"]($stats->{$_GET["stat"]});
|
||||
}
|
||||
else
|
||||
{
|
||||
$content = "<h1>Statistics</h1>\n";
|
||||
$content .= "<p>This page contains a selection of statistics about $settings->sitename's content. They are updated automatically about every " . trim(str_replace(["ago", "1 "], [""], human_time($settings->stats_update_interval))) . ", although $settings->sitename's local friendly moderators may update it earlier (you can see their names at the bottom of every page).</p>\n";
|
||||
$content .= "<p>$stat_pages_list</p>\n";
|
||||
|
||||
$content .= "<table class='stats-table'>\n";
|
||||
$content .= "\t<tr><th>Statistic</th><th>Value</th></tr>\n\n";
|
||||
foreach($statistic_calculators as $stat_id => $stat_calculator) {
|
||||
if($stat_calculator["type"] !== "scalar")
|
||||
continue;
|
||||
|
||||
$content .= "\t<tr><td>{$stat_calculator["name"]}</td><td>{$stats->$stat_id->value}</td></tr>\n";
|
||||
}
|
||||
$content .= "</table>\n";
|
||||
}
|
||||
$content .= "</table>\n";
|
||||
|
||||
foreach($stat_contents as $stat_content_part)
|
||||
$content .= "$stat_content_part\n";
|
||||
|
||||
exit(page_renderer::render_main("Statistics - $settings->sitename", $content));
|
||||
});
|
||||
|
@ -96,6 +106,7 @@ register_module([
|
|||
statistic_add([
|
||||
"id" => "longest-pages",
|
||||
"name" => "Longest Pages",
|
||||
"type" => "page",
|
||||
"update" => function($old_stats) {
|
||||
global $pageindex;
|
||||
|
||||
|
@ -126,6 +137,7 @@ register_module([
|
|||
statistic_add([
|
||||
"id" => "page_count",
|
||||
"name" => "Page Count",
|
||||
"type" => "scalar",
|
||||
"update" => function($old_stats) {
|
||||
global $pageindex;
|
||||
|
||||
|
@ -139,6 +151,7 @@ register_module([
|
|||
statistic_add([
|
||||
"id" => "file_count",
|
||||
"name" => "File Count",
|
||||
"type" => "scalar",
|
||||
"update" => function($old_stats) {
|
||||
global $pageindex;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ register_module([
|
|||
statistic_add([
|
||||
"id" => "wanted-pages",
|
||||
"name" => "Wanted Pages",
|
||||
"type" => "page",
|
||||
"update" => function($old_stats) {
|
||||
global $pageindex, $env;
|
||||
|
||||
|
|
Loading…
Reference in a new issue