Make longest pages statistic use page-list too

This commit is contained in:
Starbeamrainbowlabs 2018-04-28 11:13:58 +01:00
parent 1f190da2df
commit d8ee42f5dd
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
4 changed files with 7 additions and 17 deletions

View File

@ -39,6 +39,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- Disallow uploads if editing is disabled. Previously files could still be uploaded even if editing was disabled - unless `upload_enabled` was set to `false`.
- Added `x-login-required: yes` header to responses that redirect to the login page for easy detection by machines
- Added `x-login-success: (yes|no)` header to login responses for easier machine parsing
- Enhance the longest pages statistic rendering
### Removed
- [Module API] Removed `accept_contains_mime`, as it's both unstable and currently unnecessary. Contributions for a better version are welcome!

View File

@ -387,7 +387,7 @@ if($settings->css === "auto")
/////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */
$version = "v0.16-dev";
$commit = "72825f87552618c6a7bd99507d3b588652eea1f6";
$commit = "1f190da2df88cf16caad5fe7f82ea9437c78ff9f";
/// Environment ///
/** Holds information about the current request environment. */
$env = new stdClass();
@ -4781,7 +4781,7 @@ register_module([
statistic_add([
"id" => "longest-pages",
"name" => "Longest Pages",
"type" => "page",
"type" => "page-list",
"update" => function($old_stats) {
global $pageindex;
@ -4792,7 +4792,7 @@ register_module([
}
arsort($pages);
$result->value = $pages;
$result->value = array_keys($pages);
$result->completed = true;
return $result;
},

View File

@ -113,7 +113,7 @@
"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": 1524909895,
"lastupdate": 1524910399,
"optional": false
},
{

View File

@ -157,7 +157,7 @@ register_module([
statistic_add([
"id" => "longest-pages",
"name" => "Longest Pages",
"type" => "page",
"type" => "page-list",
"update" => function($old_stats) {
global $pageindex;
@ -168,20 +168,9 @@ register_module([
}
arsort($pages);
$result->value = $pages;
$result->value = array_keys($pages);
$result->completed = true;
return $result;
},
"render" => function($stats_data) {
$result = "<h2>$stats_data->name</h2>\n";
$result .= "<ol class='stats-list longest-pages-list'>\n";
$i = 0;
foreach($stats_data->value as $pagename => $page_length) {
$result .= "\t<li class='stats-item long-page'>$pagename <em>(" . human_filesize($page_length) . ")</em></li>\n";
$i++;
}
$result .= "</ol>\n";
return $result;
}
]);