From 92e37b7a8ca013a67b5f01ff1077cd5a41684237 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Tue, 3 Jun 2014 21:13:40 +0200 Subject: [PATCH] Changed from lease file to (SpaceAPI)[http://spaceapi.net/] --- conf/default.php | 2 +- conf/metadata.php | 2 +- syntax.php | 32 ++++++++++++-------------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/conf/default.php b/conf/default.php index 70be168..c0335b4 100644 --- a/conf/default.php +++ b/conf/default.php @@ -5,4 +5,4 @@ * @author Tim Schumacher */ -$conf['leasefile'] = '/tmp/leasefile'; +$conf['api_path'] = ''; diff --git a/conf/metadata.php b/conf/metadata.php index 5ded4ff..0e7e0a0 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -6,5 +6,5 @@ */ -$meta['leasefile'] = array('the place where the leasefile resides'); +$meta['api_path'] = array('the place where your api resides'); diff --git a/syntax.php b/syntax.php index 5f7b65b..e99ddc5 100644 --- a/syntax.php +++ b/syntax.php @@ -60,27 +60,19 @@ class syntax_plugin_whoisinyourhackspace extends DokuWiki_Syntax_Plugin { global $conf; if($mode != 'xhtml') return false; - $leasefile_path = $this->getConf('leasefile'); - if (file_exists($leasefile_path)) { - $leasefile = file_get_contents($leasefile_path); - $count = preg_match_all('/(([0-9a-f]*):([0-9a-f]*):([0-9a-f]*):([0-9a-f]*):([0-9a-f]*):([0-9a-f]*))/i',$leasefile,$matches); - $class = ''; - if ($count > 0) { - $class = ""; - } else { - $class = "not-available"; - } - if ($count > 1) { - $renderer->doc .= sprintf('

Es sind %s Personen im Hackspace :)

', $count); - } else if ($count == 1) { - $renderer->doc .= sprintf('

Es ist %s Person im Hackspace :)

', $count); - } else { - $renderer->doc .= sprintf('

Es sind keine Personen im Hackspace :(

',$class, $count); - } - } else { - $renderer->doc .= '

No leasefile found

'; - } + $api_path = $this->getConf('api_path'); + + $file = file_get_contents($api_path); + + $api = json_decode($file); + + if ($api->state->open) { + $renderer->doc .= '

Der Krautspace ist besetzt :).

'; + } else { + $renderer->doc .= '

Der Krautspace ist nicht besetzt :(.

'; + } + return true; } }