mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 16:33:00 +00:00
Add CSV support to the recent-changes action
This commit is contained in:
parent
6aa55c74bf
commit
e715c2049f
4 changed files with 37 additions and 5 deletions
|
@ -7,7 +7,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
|
||||||
- Added inter-wiki link support via the new `feature-interwiki-links` module
|
- Added inter-wiki link support via the new `feature-interwiki-links` module
|
||||||
- Added `interwiki_index_location` setting to control the location of the interwiki index (which is a CSV file that is documented in the main _Pepperminty Wiki_ documentation), which has to be specified in order for it to activate
|
- Added `interwiki_index_location` setting to control the location of the interwiki index (which is a CSV file that is documented in the main _Pepperminty Wiki_ documentation), which has to be specified in order for it to activate
|
||||||
- Provides new module api functions: `interwiki_pagename_parse`, `interwiki_pagename_resolve`, `interwiki_get_pagename_url`, and `is_interwiki_link`
|
- Provides new module api functions: `interwiki_pagename_parse`, `interwiki_pagename_resolve`, `interwiki_get_pagename_url`, and `is_interwiki_link`
|
||||||
-
|
- Added CSV support to the `recent-changes` action.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Completely reworked the README to refactor out the documentation to its [own static site](https://starbeamrainbowlabs.com/labs/peppermint/_docpress/)
|
- Completely reworked the README to refactor out the documentation to its [own static site](https://starbeamrainbowlabs.com/labs/peppermint/_docpress/)
|
||||||
|
|
|
@ -409,7 +409,7 @@ if($settings->sessionprefix == "auto")
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
/** The version of Pepperminty Wiki currently running. */
|
/** The version of Pepperminty Wiki currently running. */
|
||||||
$version = "v0.18-dev";
|
$version = "v0.18-dev";
|
||||||
$commit = "e350d1cc8efeab734f9347ec9fc6f1d1e20bed45";
|
$commit = "6aa55c74bfe5a6dfffc96d3c7d8c041d4a707abd";
|
||||||
/// Environment ///
|
/// Environment ///
|
||||||
/** Holds information about the current request environment. */
|
/** Holds information about the current request environment. */
|
||||||
$env = new stdClass();
|
$env = new stdClass();
|
||||||
|
@ -3706,7 +3706,7 @@ register_module([
|
||||||
* @apiGroup Stats
|
* @apiGroup Stats
|
||||||
* @apiPermission Anonymous
|
* @apiPermission Anonymous
|
||||||
*
|
*
|
||||||
* @apiParam {string} format The format to return the recent changes in. Values: html, json. Default: html.
|
* @apiParam {string} format The format to return the recent changes in. Valid values: html, json, csv. Default: html.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* ██████ ███████ ██████ ███████ ███ ██ ████████
|
* ██████ ███████ ██████ ███████ ███ ██ ████████
|
||||||
|
@ -3745,6 +3745,22 @@ register_module([
|
||||||
header("content-length: " . strlen($result));
|
header("content-length: " . strlen($result));
|
||||||
exit($result);
|
exit($result);
|
||||||
break;
|
break;
|
||||||
|
case "csv":
|
||||||
|
if(empty($recent_changes)) {
|
||||||
|
http_response_code(404);
|
||||||
|
header("content-type: text/plain");
|
||||||
|
exit("No changes made been recorded yet. Make some changes and then come back later!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');
|
||||||
|
fputcsv($result, array_keys(get_object_vars($recent_changes[0])));
|
||||||
|
foreach($recent_changes as $recent_change)
|
||||||
|
fputcsv($result, array_values(get_object_vars($recent_change)));
|
||||||
|
rewind($result);
|
||||||
|
|
||||||
|
header("content-type: text/csv");
|
||||||
|
header("content-length: " . fstat($result)["size"]);
|
||||||
|
echo(stream_get_contents($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
"description": "Adds recent changes. Access through the 'recent-changes' action.",
|
||||||
"id": "feature-recent-changes",
|
"id": "feature-recent-changes",
|
||||||
"lastupdate": 1530617266,
|
"lastupdate": 1548353858,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ register_module([
|
||||||
* @apiGroup Stats
|
* @apiGroup Stats
|
||||||
* @apiPermission Anonymous
|
* @apiPermission Anonymous
|
||||||
*
|
*
|
||||||
* @apiParam {string} format The format to return the recent changes in. Values: html, json. Default: html.
|
* @apiParam {string} format The format to return the recent changes in. Valid values: html, json, csv. Default: html.
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* ██████ ███████ ██████ ███████ ███ ██ ████████
|
* ██████ ███████ ██████ ███████ ███ ██ ████████
|
||||||
|
@ -59,6 +59,22 @@ register_module([
|
||||||
header("content-length: " . strlen($result));
|
header("content-length: " . strlen($result));
|
||||||
exit($result);
|
exit($result);
|
||||||
break;
|
break;
|
||||||
|
case "csv":
|
||||||
|
if(empty($recent_changes)) {
|
||||||
|
http_response_code(404);
|
||||||
|
header("content-type: text/plain");
|
||||||
|
exit("No changes made been recorded yet. Make some changes and then come back later!");
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+');
|
||||||
|
fputcsv($result, array_keys(get_object_vars($recent_changes[0])));
|
||||||
|
foreach($recent_changes as $recent_change)
|
||||||
|
fputcsv($result, array_values(get_object_vars($recent_change)));
|
||||||
|
rewind($result);
|
||||||
|
|
||||||
|
header("content-type: text/csv");
|
||||||
|
header("content-length: " . fstat($result)["size"]);
|
||||||
|
echo(stream_get_contents($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue