Began new library browser

The new library browser will eventually morph into a web-based clone of
the desktop Ocarina application.
This commit is contained in:
Bryan Schumaker 2010-12-26 22:51:18 -05:00
parent 805db95d05
commit 961eacf3c4
2 changed files with 46 additions and 0 deletions

View File

@ -20,6 +20,7 @@ function set_version()
<body>
<table>
<tr><td><a href="library.py">Library Browser</a></td></tr>
<tr><td><a href="library2.py">Library Browser 2</a></td></tr>
<tr><td><a href="controls.html">Remote Controls</a></td></tr>
<tr><td id="version"></td></tr>
</table>

45
html/library2.py Normal file
View File

@ -0,0 +1,45 @@
# Bryan Schumaker (12 / 26 / 2010)
import libsaria
library = libsaria.sources.library
walk = library.walk
get_attrs = library.get_attrs
cols = [("Title", 400), ("Length", 60), ("Artist", 200), ("Album", 200), ("Year", 50)]
def header(wfile):
wfile.write("<html><body>")
def footer(wfile):
wfile.write("</body></html>")
def content_header(wfile):
wfile.write("<table><tr>")
for col, width in cols:
wfile.write("<td style=\"width:%spx;\">%s</td>" % (width, col))
wfile.write("</tr></table>")
wfile.write("<hr>")
def body(wfile):
wfile.write("header stuff goes here")
content_header(wfile)
wfile.write("<div style=\"height:80%;width:100%;overflow:auto;\">")
wfile.write("<table>")
colors = ["white", "aliceblue"]
i = 0
for id in walk():
wfile.write("<tr>")
for index, attr in enumerate(get_attrs(id, "title", "lenstr", "artist", "album", "year")):
wfile.write("<td style=\"width:%spx;background:%s;\">%s</td>" % (cols[index][1], colors[i], attr))
wfile.write("</tr>")
if i == 0:
i = 1
else:
i = 0
wfile.write("</table></div>")
wfile.write("footer stuff goes here")
def to_html(wfile, args):
header(wfile)
body(wfile)
footer(wfile)