Simple rendering.

This commit is contained in:
Dominik Pantůček 2023-06-24 22:52:59 +02:00
parent 3173639b6f
commit 761500c1b2

View file

@ -29,8 +29,33 @@ class syntax_plugin_brmburo extends DokuWiki_Syntax_Plugin {
public function render($mode, Doku_Renderer $renderer, $data) {
// $data is what the function handle return'ed.
if($mode == 'xhtml'){
$spaceapi_status_json = '/home/brmdoor-web/spaceapi-status/brmstatus.json';
$str = file_get_contents($spaceapi_status_json);
/** @var Doku_Renderer_xhtml $renderer */
$renderer->doc .= "BrmBuro: " . date('r');
$status = "UNKNOWN";
if ($str == FALSE) {
$status = "ERROR:FILE";
} else {
$json = json_decode($str, true);
if ($json == NULL) {
$status = "ERROR:JSON";
} else {
$opened = $json['state']['open'];
$lastchange = $json['state']['lastchange'];
if ($opened == TRUE) {
$status =
'<p><img src="/status-renderer/open-sun.png"></p>' .
'<h3>OPEN</h3>';
} elseif ($opened == FALSE) {
$status =
'<p><img src="/status-renderer/closed-moon.png"></p>' .
'<h3>CLOSED</h3>';
} else {
$status = "ERROR:DECODE";
}
}
}
$renderer->doc .= $status;
return true;
}
return false;