ocarina/libsaria/server/pages/root.py

43 lines
1.1 KiB
Python
Raw Normal View History

# Bryan Schumaker (5 / 15 / 2011)
from libsaria import sources
SCRIPT = "<script type=\"text/javascript\" src=\"%s\"></script>"
def write_file(write, file):
f = open(file)
write(f.read())
f.close()
def index(write):
write_file(write, "html/index.html")
def library(write):
write("<html><head>")
write(SCRIPT % "controls.js")
write(SCRIPT % "utils.js")
write("</head><body><table>\n")
color = "white"
for id, title, artist, album in sources.library.walk_library("id", "title", "artist", "album"):
write("<tr style=\"background:%s\" ondblclick=play_id(%s)>" % (color, id))
write("<td><a href=\"RPC/play_id/%s\" onclick=\"play_id(%s);return false\">%s</a></td>" % (id, id, title))
write("<td>%s</td><td>%s</td>\n" % (artist, album))
if color == "white":
color = "aliceblue"
else:
color = "white"
write("</table></body></html>")
def controls(write):
write_file(write, "html/controls.js")
def utils(write):
write_file(write, "html/utils.js")
docs = {
"index.html":(index, "html"),
"library.html":(library, "html"),
"controls.js":(controls, "js"),
"utils.js":(utils, "js"),
}