From 761500c1b2663916ac3dc5cf3a754914f3240da2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Sat, 24 Jun 2023 22:52:59 +0200 Subject: [PATCH] Simple rendering. --- dokuwiki/syntax.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/dokuwiki/syntax.php b/dokuwiki/syntax.php index 36db935..44c32fc 100644 --- a/dokuwiki/syntax.php +++ b/dokuwiki/syntax.php @@ -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 = + '

' . + '

OPEN

'; + } elseif ($opened == FALSE) { + $status = + '

' . + '

CLOSED

'; + } else { + $status = "ERROR:DECODE"; + } + } + } + $renderer->doc .= $status; return true; } return false;