Compare commits

..

No commits in common. "1b47aebf646c17bd3af6cc8bb88e1cf9b196fc1e" and "d3aabedd87ad84e03d7611c5a8ec5828bf1182c1" have entirely different histories.

6 changed files with 157 additions and 8 deletions

View File

@ -12,7 +12,6 @@ $lang['wiyh_closed'] = 'ist geschlossen';
$lang['wiyh_stats'] = 'Raumöffnungsstatistiken'; $lang['wiyh_stats'] = 'Raumöffnungsstatistiken';
$lang['wiyh_no_api_path'] = 'Es wurde kein API-Pfad angegeben.'; $lang['wiyh_no_api_path'] = 'Es wurde kein API-Pfad angegeben.';
$lang['wiyh_fetch_error'] = 'Der API-Pfad konnte nicht abgerufen werden.'; $lang['wiyh_fetch_error'] = 'Der API-Pfad konnte nicht abgerufen werden.';
$lang['wiyh_since'] = 'seit';

View File

@ -7,12 +7,11 @@
// menu entry for admin plugins // menu entry for admin plugins
$lang['wiyh_heading'] = 'State'; $lang['wiyh_heading'] = 'State';
$lang['wiyh_open'] = 'is open'; $lang['wiyh_open'] = 'is open.';
$lang['wiyh_closed'] = 'is closed'; $lang['wiyh_closed'] = 'is closed.';
$lang['wiyh_stats'] = 'Stats'; $lang['wiyh_stats'] = 'Stats';
$lang['wiyh_no_api_path'] = 'No API path was given.'; $lang['wiyh_no_api_path'] = 'No API path was given.';
$lang['wiyh_fetch_error'] = 'Could not fetch API path.'; $lang['wiyh_fetch_error'] = 'Could not fetch API path.';
$lang['wiyh_since'] = 'since';
//Setup VIM: ex: et ts=4 : //Setup VIM: ex: et ts=4 :

View File

@ -1,3 +1,22 @@
/*.ample {
display: block;
width: 200px;
height: 100px;
font-size: 24px;
font-weight: bold;
padding: 5px;
}
.available {
background-color: green;
color: white;
}
.not-available {
background-color: red;
color: white;
}*/
div.hackerspace-room-state { div.hackerspace-room-state {
border: 1px solid #cccccc; border: 1px solid #cccccc;
background-color: #ffffff; background-color: #ffffff;
@ -8,6 +27,11 @@ div.hackerspace-room-state h3 {
} }
div.leinelab-state img.icon {
display: inline;
width: 180px;
}
div.hackerspace-room-state .text { div.hackerspace-room-state .text {
display: inline; display: inline;
margin-left: 0.3rem; margin-left: 0.3rem;
@ -16,4 +40,4 @@ div.hackerspace-room-state .text {
div.hackerspace-room-state hr { div.hackerspace-room-state hr {
margin-top: 0.3rem; margin-top: 0.3rem;
margin-bottom: 0.3rem; margin-bottom: 0.3rem;
} }

44
style.css~ Normal file
View File

@ -0,0 +1,44 @@
/*.ample {
display: block;
width: 200px;
height: 100px;
font-size: 24px;
font-weight: bold;
padding: 5px;
}
.available {
background-color: green;
color: white;
}
.not-available {
background-color: red;
color: white;
}*/
div.hackerspace-room-state {
border: 1px solid #cccccc;
background-color: #ffffff;
padding: 0.5rem;
}
div.hackerspace-room-state h3 {
}
div.hackerspace-room-state .icon {
display: inline;
width: 24px;
height: 24px;
}
div.hackerspace-room-state .text {
display: inline;
margin-left: 0.3rem;
}
div.hackerspace-room-state hr {
margin-top: 0.3rem;
margin-bottom: 0.3rem;
}

View File

@ -76,18 +76,18 @@ class syntax_plugin_whoisinyourhackspace extends DokuWiki_Syntax_Plugin {
$content .= "<h3>" . $this->getLang('wiyh_heading') . "</h3>"; $content .= "<h3>" . $this->getLang('wiyh_heading') . "</h3>";
if ($api->state->open) { if ($api->state->open) {
$message = "{$api->space} {$this->getLang('wiyh_open')}"; $message = "{$api->space} {$this->getLang('wiyh_open')}";
$content .= $api->state->icon->open ? "<img class=\"icon\" src=\"{$api->state->icon->open}\" alt=\"{$message}\" title=\"{$message}\" />" : ''; $content .= $api->state->icon->open ? "<img class=\"icon\" src=\"{$api->state->icon->open}\" alt=\"{$message}\" title=\"{$message}\" />" : '';
$content .= "<p class=\"text\">{$message}</p>"; $content .= "<p class=\"text\">{$message}</p>";
} else { } else {
$message = "{$api->space} {$this->getLang('wiyh_closed')}"; $message = "{$api->space} {$this->getLang('wiyh_closed')}";
$content .= $api->state->icon->closed ? "<img class=\"icon\" src=\"{$api->state->icon->closed}\" alt=\"{$message}\" title=\"{$message}\" />" : ''; $content .= $api->state->icon->closed ? "<img class=\"icon\" src=\"{$api->state->icon->closed}\" alt=\"{$message}\" title=\"{$message}\" />" : '';
$content .= "<p class=\"text\">{$message}</p>"; $content .= "<p class=\"text\">{$message}</p>";
} }
$date = new DateTime(); $date = new DateTime();
$date->setTimeStamp($api->state->lastchange); $date->setTimeStamp($api->state->lastchange);
$content .= "<p class=\"text\">{$this->getLang('wiyh_since')} " . $date->format('d.m.Y H:i') . " Uhr</p>"; $content .= "<p class=\"text\">seit " . $date->format('d.m.Y H:i') . " Uhr</p>";
$content .= '<hr />'; $content .= '<hr />';
$content .= '</div>'; $content .= '</div>';

83
syntax.php~ Normal file
View File

@ -0,0 +1,83 @@
<?php
/**
* DokuWiki Plugin whoisinyourhackspace (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Tim Schumacher <tim.daniel.schumacher@gmail.com>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_whoisinyourhackspace extends DokuWiki_Syntax_Plugin {
/**
* Check if a given option has been given, and remove it from the initial string
* @param string $match The string match by the plugin
* @param string $pattern The pattern which activate the option
* @param $varAffected The variable which will memorise the option
* @param $valIfFound the value affected to the previous variable if the option is found
*/
private function _checkOption(&$match, $pattern, &$varAffected, $valIfFound){
if ( preg_match($pattern, $match, $found) ){
$varAffected = $valIfFound;
$match = str_replace($found[0], '', $match);
}
} // _checkOption
public function getType() {
return 'substition';
}
public function getPType() {
return 'block';
}
public function getSort() {
return 0;
}
public function connectTo($mode) {
$this->Lexer->addSpecialPattern('\[wiyh\]',$mode,'plugin_whoisinyourhackspace');
}
public function render($mode, &$renderer, $data) {
global $conf;
if($mode != 'xhtml') return false;
$api_path = $this->getConf('api_path');
$file = file_get_contents($api_path);
$api = json_decode($file);
$content = '';
$content .= '<div class="leinelab-state">';
$content .= "<h3>" . $this->getLang('wiyh_heading') . "</h3>";
if ($api->state->open) {
$content .= "<img class=\"icon\" src=\"{$api->state->icon->open}\" alt=\"{$api->space} ist besetzt.\" title=\"{$api->space} ist besetzt.\" />";
$content .= "<p class=\"text\">{$api->space} " . $this->getLang('wiyh_open') . "</p>";
} else {
$content .= "<img class=\"icon\" src=\"{$api->state->icon->closed}\" alt=\"{$api->space} ist geschlossen.\" title=\"{$api->space} ist geschlossen.\" />";
$content .= "<p class=\"text\">{$api->space} " . $this->getLang('wiyh_closed') . "</p>";
}
$content .= '<hr />';
$content .= sprintf('<p><a href="http://spaceapi-stats.n39.eu/#%s">'.$this->getLang('wiyh_stats').'</a></p>',strtolower($api->space));
$content .= '</div>';
$renderer->doc .= $content;
return true;
}
}
// vim:ts=4:sw=4:et: