Initial Commit of the old dw-plugin
This commit is contained in:
commit
01c885d48f
|
@ -0,0 +1,28 @@
|
|||
# whoisinyourhackspace Plugin for DokuWiki
|
||||
|
||||
This plugin uses the [SpaceAPI](http://spaceapi.net/) of your hackerspace to display the current room state.
|
||||
|
||||
## Install
|
||||
|
||||
The best way is to put [wiyh] into the page :sidebar, but any other place is fine too.
|
||||
|
||||
If you install this plugin manually, make sure it is installed in
|
||||
lib/plugins/whoisinyourhackspace/ - if the folder is called different it
|
||||
will not work!
|
||||
|
||||
Please refer to http://www.dokuwiki.org/plugins for additional info
|
||||
on how to install plugins in DokuWiki.
|
||||
|
||||
----
|
||||
Copyright (C) Tim Schumacher <tim@datenknoten.me>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
See the COPYING file in your DokuWiki folder for details
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* Default settings for the whoisinyourhackspace plugin
|
||||
*
|
||||
* @author Tim Schumacher <tim.daniel.schumacher@gmail.com>
|
||||
*/
|
||||
|
||||
$conf['api_path'] = '';
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
/**
|
||||
* Options for the whoisinyourhackspace plugin
|
||||
*
|
||||
* @author Tim Schumacher <tim.daniel.schumacher@gmail.com>
|
||||
*/
|
||||
|
||||
|
||||
$meta['api_path'] = array('the place where your api resides');
|
||||
|
|
@ -0,0 +1 @@
|
|||
de
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* English language file for whoisinyourhackspace plugin
|
||||
*
|
||||
* @author Tim Schumacher <tim@datenknoten.me>
|
||||
*/
|
||||
|
||||
// menu entry for admin plugins
|
||||
$lang['wiyh_heading'] = 'Raumstatus';
|
||||
$lang['wiyh_open'] = 'ist geöffnet.';
|
||||
$lang['wiyh_closed'] = 'ist geschlossen.';
|
||||
$lang['wiyh_stats'] = 'Raumöffnungsstatistiken';
|
||||
|
||||
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=4 :
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* English language file for whoisinyourhackspace plugin
|
||||
*
|
||||
* @author Tim Schumacher <tim@datenknoten.me>
|
||||
*/
|
||||
|
||||
// menu entry for admin plugins
|
||||
$lang['wiyh_heading'] = 'State';
|
||||
$lang['wiyh_open'] = 'is open.';
|
||||
$lang['wiyh_closed'] = 'is closed.';
|
||||
$lang['wiyh_stats'] = 'Stats';
|
||||
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=4 :
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* english language file for whoisinyourhackspace plugin
|
||||
*
|
||||
* @author Tim Schumacher <tim.daniel.schumacher@gmail.com>
|
||||
*/
|
||||
|
||||
// keys need to match the config setting name
|
||||
// $lang['fixme'] = 'FIXME';
|
||||
|
||||
|
||||
|
||||
//Setup VIM: ex: et ts=4 :
|
|
@ -0,0 +1 @@
|
|||
installed=Sat, 28 Mar 2015 11:24:37 +0100
|
|
@ -0,0 +1,7 @@
|
|||
base whoisinyourhackspace
|
||||
author Tim Schumacher
|
||||
email tim.daniel.schumacher@gmail.com
|
||||
date 2011-09-09
|
||||
name whoisinyourhackspace plugin
|
||||
desc Displays if someone is in your hackspace
|
||||
url http://hackspace-jena.de/
|
|
@ -0,0 +1,43 @@
|
|||
/*.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.leinelab-state img.icon {
|
||||
display: inline;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
div.hackerspace-room-state .text {
|
||||
display: inline;
|
||||
margin-left: 0.3rem;
|
||||
}
|
||||
|
||||
div.hackerspace-room-state hr {
|
||||
margin-top: 0.3rem;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?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>";
|
||||
}
|
||||
|
||||
$date = new DateTime();
|
||||
$date->setTimeStamp($api->lastchange);
|
||||
$content .= "<p class=\"text\"> seit " . $date->format('d.m.Y H:i') . " Uhr</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:
|
|
@ -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:
|
Loading…
Reference in New Issue