Skip to content

Commit

Permalink
Custom templates of open/close pages for local display, write a symli…
Browse files Browse the repository at this point in the history
…nk so meta-refresh works.
  • Loading branch information
rohieb committed Jul 20, 2013
1 parent 1d1598f commit 84a97ff
Show file tree
Hide file tree
Showing 6 changed files with 3,249 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ server/www/status.html
server/www/status.txt
server/www/status.json
server/www/status.xml
server/www/status-local.html
27 changes: 11 additions & 16 deletions server/supybot/plugins/StratumMonitor/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,9 @@ class StratumMonitor(callbacks.Plugin):
API_ARCHIVE_FILE = API_PATH % "archive.txt"
API_ARCHIVE_TEMPLATE = "{{{ACTION}}}: {{{SINCE}}}\r\n"

API_LOCAL_HTML_FILE = API_PATH % "local.html"
API_LOCAL_HTML_TEMPLATE = """<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Stratum 0 Space Status</title>
<meta http-equiv="refresh" content="6" />
</head>
<body style="background-color:black; color:white;">
<div style="text-align:center">
<h3>{{{STATUS}}}</h3>
<img height="75" width="75" src="http://localhost/{{{STATUS}}}.svg" alt="{{{STATUS}}}" />
</div>
</body></html>"""
LOCAL_HTML_FILE = API_PATH % "status-local.html"
LOCAL_HTML_OPEN_FILE = API_PATH % "open-local.html"
LOCAL_HTML_CLOSED_FILE = API_PATH % "closed-local.html"

VERSION = "0.1" ### Bump this for new Open/Close API versions

Expand Down Expand Up @@ -293,8 +281,15 @@ def writeFiles(self):
self.writeFile(self.API_JSON_FILE, self.API_JSON_TEMPLATE)
self.writeFile(self.API_XML_FILE, self.API_XML_TEMPLATE)
self.writeFile(self.API_HTML_FILE, self.API_HTML_TEMPLATE)
self.writeFile(self.API_LOCAL_HTML_FILE, self.API_LOCAL_HTML_TEMPLATE)
self.writeFile(self.API_ARCHIVE_FILE, self.API_ARCHIVE_TEMPLATE, True)

if(self.isOpen):
r = os.system("rm %s; ln -s %s %s" % (self.LOCAL_HTML_FILE,
self.LOCAL_HTML_OPEN_FILE, self.LOCAL_HTML_FILE))
else:
r = os.system("rm %s; ln -s %s %s" % (self.LOCAL_HTML_FILE,
self.LOCAL_HTML_CLOSED_FILE, self.LOCAL_HTML_FILE))

r = os.system("sudo killall -HUP nginx"); # NOTE: must be in sudoers to do that!

def spaceopen(self, irc, msg, args, nick):
Expand Down
17 changes: 17 additions & 0 deletions server/www/closed-local.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Stratum 0 Space Status</title>
<meta http-equiv="refresh" content="1" />
</head>
<body style="font-size:10pt; font-family:sans-serif; background-color:black;
color:white; overflow:hidden">
<div style="text-align:center">
<p>Es ist zu :-(</p>
<img height="50" width="50" src="closed.svg" alt="zu" />
<p>Du willst rein?<br />
<a href="https://stratum0.org/key">https://stratum0.org/key</a></p>
</div>
</body></html>
Loading

0 comments on commit 84a97ff

Please sign in to comment.