Work on shared spaceapi module.
This commit is contained in:
parent
df1c590afc
commit
b89b4e3147
2 changed files with 5 additions and 34 deletions
|
@ -29,6 +29,7 @@ class action_plugin_hackerbase extends DokuWiki_Action_Plugin
|
||||||
$user = preg_replace("/[^a-zA-Z0-9\-]+/", "", $INPUT->server->str('REMOTE_USER'));
|
$user = preg_replace("/[^a-zA-Z0-9\-]+/", "", $INPUT->server->str('REMOTE_USER'));
|
||||||
echo file_get_contents($this->getConf("htmlexports") . '/' . $user . ".html");
|
echo file_get_contents($this->getConf("htmlexports") . '/' . $user . ".html");
|
||||||
die();
|
die();
|
||||||
|
} else if ($act === 'brmstatus') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Plugin Now: Inserts a timestamp.
|
* Plugin HackerBase: Inserts SpaceAPI-based open/closed info
|
||||||
*
|
*
|
||||||
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
|
||||||
* @author Dominik Pantůček <dominik.pantucek@trustica.cz>
|
* @author Dominik Pantůček <dominik.pantucek@trustica.cz>
|
||||||
|
@ -9,6 +9,8 @@
|
||||||
// must be run within DokuWiki
|
// must be run within DokuWiki
|
||||||
if(!defined('DOKU_INC')) die();
|
if(!defined('DOKU_INC')) die();
|
||||||
|
|
||||||
|
require_once("common.php"):
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All DokuWiki plugins to extend the parser/rendering mechanism
|
* All DokuWiki plugins to extend the parser/rendering mechanism
|
||||||
* need to inherit from this class
|
* need to inherit from this class
|
||||||
|
@ -30,39 +32,7 @@ class syntax_plugin_hackerbase extends DokuWiki_Syntax_Plugin {
|
||||||
// $data is what the function handle return'ed.
|
// $data is what the function handle return'ed.
|
||||||
if($mode == 'xhtml'){
|
if($mode == 'xhtml'){
|
||||||
$spaceapi_status_json = $this->getConf("spaceapijson");
|
$spaceapi_status_json = $this->getConf("spaceapijson");
|
||||||
$str = file_get_contents($spaceapi_status_json);
|
$status = hackerbase_spaceapi_html_snippet($spaceapi_status_json);
|
||||||
/** @var Doku_Renderer_xhtml $renderer */
|
|
||||||
$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'];
|
|
||||||
$myfile = __FILE__;
|
|
||||||
$mydir = dirname($myfile);
|
|
||||||
$mydirname = basename($mydir);
|
|
||||||
$assetsdir = DOKU_BASE . "lib/plugins/" . $mydirname . "/assets";
|
|
||||||
if ($opened == TRUE) {
|
|
||||||
$status =
|
|
||||||
'<p><img src="' . $assetsdir . '/open-sun.png"></p>' .
|
|
||||||
'<h3>OPEN</h3>';
|
|
||||||
} elseif ($opened == FALSE) {
|
|
||||||
$status =
|
|
||||||
'<p><img src="' . $assetsdir . '/closed-moon.png"></p>' .
|
|
||||||
'<h3>CLOSED</h3>';
|
|
||||||
} else {
|
|
||||||
$status = "ERROR:DECODE";
|
|
||||||
}
|
|
||||||
if ($lastchange) {
|
|
||||||
$str_date = strftime('%Y-%m-%d %H:%M', $lastchange);
|
|
||||||
$status .= '<p>Last changed: ' . $str_date . '</p>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$renderer->doc .= $status;
|
$renderer->doc .= $status;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue