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

Add offset & count to recent-changes action

This commit is contained in:
Starbeamrainbowlabs 2019-01-24 18:25:10 +00:00
parent e715c2049f
commit 242f197ccf
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 21 additions and 4 deletions

View file

@ -8,6 +8,7 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
- 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`
- Added CSV support to the `recent-changes` action.
- Added `count` and `offset` GET parameters to `recent-changes` action.
### Changed
- Completely reworked the README to refactor out the documentation to its [own static site](https://starbeamrainbowlabs.com/labs/peppermint/_docpress/)

View file

@ -409,7 +409,7 @@ if($settings->sessionprefix == "auto")
/////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */
$version = "v0.18-dev";
$commit = "6aa55c74bfe5a6dfffc96d3c7d8c041d4a707abd";
$commit = "e715c2049f0782f46919fd2b220eac9292183075";
/// Environment ///
/** Holds information about the current request environment. */
$env = new stdClass();
@ -3701,11 +3701,13 @@ register_module([
file_put_contents($paths->recentchanges, "[]");
/**
* @api {get} ?action=recent-changes[&format={code}] Get a list of recent changes
* @api {get} ?action=recent-changes[&offset={number}][&count={number}][&format={code}] Get a list of recent changes
* @apiName RecentChanges
* @apiGroup Stats
* @apiPermission Anonymous
*
* @apiParam {number} offset If specified, start returning changes from this many changes in. 0 is the beginning.
* @apiParam {number} count If specified, return at most this many changes. A value of 0 means no limit (the default) - apart from the limit on the number of changes stored by the server (configurable in pepppermint.json).
* @apiParam {string} format The format to return the recent changes in. Valid values: html, json, csv. Default: html.
*/
/*
@ -3725,9 +3727,15 @@ register_module([
global $settings, $paths, $pageindex;
$format = $_GET["format"] ?? "html";
$offset = intval($_GET["offset"] ?? 0);
$count = intval($_GET["count"] ?? 0);
$recent_changes = json_decode(file_get_contents($paths->recentchanges));
// Limit the number of changes displayed if requested
if($count > 0)
$recent_changes = array_slice($recent_changes, $offset, $count);
switch($format) {
case "html":
$content = "\t\t<h1>Recent Changes</h1>\n";

View file

@ -95,7 +95,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds recent changes. Access through the 'recent-changes' action.",
"id": "feature-recent-changes",
"lastupdate": 1548353858,
"lastupdate": 1548354223,
"optional": false
},
{

View file

@ -15,11 +15,13 @@ register_module([
file_put_contents($paths->recentchanges, "[]");
/**
* @api {get} ?action=recent-changes[&format={code}] Get a list of recent changes
* @api {get} ?action=recent-changes[&offset={number}][&count={number}][&format={code}] Get a list of recent changes
* @apiName RecentChanges
* @apiGroup Stats
* @apiPermission Anonymous
*
* @apiParam {number} offset If specified, start returning changes from this many changes in. 0 is the beginning.
* @apiParam {number} count If specified, return at most this many changes. A value of 0 means no limit (the default) - apart from the limit on the number of changes stored by the server (configurable in pepppermint.json).
* @apiParam {string} format The format to return the recent changes in. Valid values: html, json, csv. Default: html.
*/
/*
@ -39,9 +41,15 @@ register_module([
global $settings, $paths, $pageindex;
$format = $_GET["format"] ?? "html";
$offset = intval($_GET["offset"] ?? 0);
$count = intval($_GET["count"] ?? 0);
$recent_changes = json_decode(file_get_contents($paths->recentchanges));
// Limit the number of changes displayed if requested
if($count > 0)
$recent_changes = array_slice($recent_changes, $offset, $count);
switch($format) {
case "html":
$content = "\t\t<h1>Recent Changes</h1>\n";