mirror of
https://github.com/brmlab/brmdoor.git
synced 2025-06-08 03:34:02 +02:00
brmd.pl: Add support for the SpaceAPI json output; code provided by ruza
This commit is contained in:
parent
34b946c7c1
commit
35e23d428c
1 changed files with 42 additions and 1 deletions
43
brmd/brmd.pl
43
brmd/brmd.pl
|
@ -279,6 +279,7 @@ sub new {
|
|||
"/brmstatus.png" => \&web_brmstatus_png,
|
||||
"/brmstatus.txt" => \&web_brmstatus_txt,
|
||||
"/brmstatus-switch" => sub { $self->web_brmstatus_switch(@_) },
|
||||
"/brmstatus.json" => \&web_brmstatus_json,
|
||||
"/alphasign" => \&web_alphasign_text,
|
||||
"/alphasign-set" => \&web_alphasign_set,
|
||||
"/" => \&web_index
|
||||
|
@ -354,7 +355,7 @@ sub web_index {
|
|||
<h1>brmd web interface</h1>
|
||||
<p>Enjoy the view!</p>
|
||||
<ul>
|
||||
<li><strong>brmstatus</strong> ($sts) <a href="brmstatus.html">status page</a> | <a href="brmstatus.js">javascript code</a> | <a href="brmstatus.txt">plaintext file</a> | <a href="brmstatus.png">picture</a></li>
|
||||
<li><strong>brmstatus</strong> ($sts) <a href="brmstatus.html">status page</a> | <a href="brmstatus.js">javascript code</a> | <a href="brmstatus.json">SpaceAPI JSON</a> | <a href="brmstatus.txt">plaintext file</a> | <a href="brmstatus.png">picture</a></li>
|
||||
<li><strong>brmvideo</strong> ($str) $r_link</li>
|
||||
<li><strong>alphasign</strong> ($astext) $a_link</li>
|
||||
</ul>
|
||||
|
@ -415,6 +416,46 @@ EOT
|
|||
return RC_OK;
|
||||
}
|
||||
|
||||
sub web_brmstatus_json {
|
||||
my ($request, $response) = @_;
|
||||
|
||||
$response->protocol("HTTP/1.0");
|
||||
$response->code(RC_OK);
|
||||
$response->push_header("Content-Type", "application/json");
|
||||
$response->push_header("Access-Control-Allow-Origin", "*");
|
||||
disable_caching($response);
|
||||
|
||||
$response->content(<<EOT
|
||||
{
|
||||
"api":"0.12",
|
||||
"space":"brmlab",
|
||||
"url":"http://brmlab.cz",
|
||||
"icon":{
|
||||
"open":"https://brmlab.cz/status-open-icon.png",
|
||||
"closed":"https://brmlab.cz/status-closed-icon.png"
|
||||
},
|
||||
"address":"Bubenska 1477/1, 170 00 Praha 7, Czech republic",
|
||||
"contact":{
|
||||
"phone":"+420608801582",
|
||||
"twitter":"\@brmlab",
|
||||
"ml":"brmlab\@brmlab.cz"
|
||||
},
|
||||
"irc":"irc://freenode/#brmlab",
|
||||
"logo":"https://brmlab.cz/favicon.ico",
|
||||
"open":${\($status ? 'true' : 'false')},
|
||||
"lastchange":$laststchange,
|
||||
"feeds":[
|
||||
{"name":"blog","type":"application/rss+xml","url":"https://soup.brmlab.cz/rss"},
|
||||
],
|
||||
"lat":37.0625,
|
||||
"lon":-95.67706
|
||||
}
|
||||
EOT
|
||||
);
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
sub web_brmstatus_txt {
|
||||
my ($request, $response) = @_;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue