2017-06-26 10:36:04 +00:00
< ? php
2020-09-23 22:22:39 +00:00
/* 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 /. */
2017-06-26 10:36:04 +00:00
register_module ([
" name " => " API status " ,
" version " => " 0.1 " ,
" author " => " Starbeamrainbowlabs " ,
2018-07-02 11:23:11 +00:00
" description " => " Provides a basic JSON status action that provides a few useful bits of information for API consumption. " ,
2017-06-26 10:36:04 +00:00
" id " => " api-status " ,
" code " => function () {
global $settings ;
/**
2018-03-27 16:20:58 +00:00
* @ api { get } ? action = status [ & minified = type ] Get the json - formatted status of this wiki
2018-03-27 15:59:11 +00:00
* @ apiName Status
* @ apiGroup Stats
2017-06-26 10:36:04 +00:00
* @ apiPermission Anonymous
2018-03-27 16:20:58 +00:00
*
2020-01-05 20:59:21 +00:00
* @ apiParam { bool } Whether or not the result should be minified JSON . Default : false
2017-06-26 10:36:04 +00:00
*/
2018-07-02 22:44:10 +00:00
/*
* ███████ ████████ █████ ████████ ██ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██
* ███████ ██ ███████ ██ ██ ██ ███████
* ██ ██ ██ ██ ██ ██ ██ ██
* ███████ ██ ██ ██ ██ ██████ ███████
*/
2017-06-26 10:36:04 +00:00
add_action ( " status " , function () {
global $version , $env , $settings , $actions ;
2018-03-27 16:20:58 +00:00
$minified = ( $_GET [ " minified " ] ? ? " false " ) == " true " ;
2017-06-26 10:36:04 +00:00
$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 ;
header ( " content-type: application/json " );
2018-03-27 16:20:58 +00:00
exit ( $minified ? json_encode ( $result ) : json_encode ( $result , JSON_PRETTY_PRINT ) . " \n " );
2017-06-26 10:36:04 +00:00
});
2018-04-01 15:34:06 +00:00
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> " );
2017-06-26 10:36:04 +00:00
}
]);
?>