mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-27 15:24:56 +00:00
55 lines
2.3 KiB
PHP
55 lines
2.3 KiB
PHP
<?php
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
register_module([
|
|
"name" => "API status",
|
|
"version" => "0.2",
|
|
"author" => "Starbeamrainbowlabs",
|
|
"description" => "Provides a basic JSON status action that provides a few useful bits of information for API consumption.",
|
|
"id" => "api-status",
|
|
"code" => function() {
|
|
global $settings;
|
|
/**
|
|
* @api {get} ?action=status[&minified=type] Get the json-formatted status of this wiki
|
|
* @apiName Status
|
|
* @apiGroup Stats
|
|
* @apiPermission Anonymous
|
|
*
|
|
* @apiParam {bool} Whether or not the result should be minified JSON. Default: false
|
|
*/
|
|
|
|
/*
|
|
* ███████ ████████ █████ ████████ ██ ██ ███████
|
|
* ██ ██ ██ ██ ██ ██ ██ ██
|
|
* ███████ ██ ███████ ██ ██ ██ ███████
|
|
* ██ ██ ██ ██ ██ ██ ██ ██
|
|
* ███████ ██ ██ ██ ██ ██████ ███████
|
|
*/
|
|
add_action("status", function() {
|
|
global $version, $env, $settings, $actions;
|
|
|
|
$minified = ($_GET["minified"] ?? "false") == "true";
|
|
|
|
$action_names = array_keys(get_object_vars($actions));
|
|
sort($action_names);
|
|
|
|
$result = new stdClass();
|
|
$result->status = "ok";
|
|
$result->version = $version;
|
|
$result->available_actions = $action_names;
|
|
$result->wiki_name = $settings->sitename;
|
|
$result->logo_url = $settings->favicon;
|
|
if(module_exists("page-sitemap"))
|
|
$result->sitemap_url = url_stem()."?action=sitemap";
|
|
|
|
header("content-type: application/json");
|
|
exit($minified ? json_encode($result) : json_encode($result, JSON_PRETTY_PRINT) . "\n");
|
|
});
|
|
|
|
add_help_section("960-api-status", "Wiki Status API", "<p>$settings->sitename has a <a href='?action=status'>status page</a> that returns some basic information about the current state of the wiki in <a href='http://www.secretgeek.net/json_3mins'>JSON</a>. It can be used as a connection tester - as the Pepperminty Wiki Android app does.</p>");
|
|
}
|
|
]);
|
|
|
|
?>
|