From 4726c3c91f067bfad8f14d722d6de2cb9d34fee9 Mon Sep 17 00:00:00 2001 From: Remy Date: Mon, 8 Aug 2011 00:06:31 -0700 Subject: [PATCH] Finishing touches - adjusted css for config, fixed bug when no track duration, helpers now converts milliseconds to H:M:S if its more than an hour --- data/css/style.css | 2 ++ data/interfaces/default/album.html | 15 ++++++++++++--- data/interfaces/default/config.html | 12 +++++++++++- data/interfaces/default/shutdown.html | 4 +++- headphones/helpers.py | 6 ++++-- headphones/webserve.py | 13 +++++++------ 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/data/css/style.css b/data/css/style.css index b139cddc..04e1d56f 100755 --- a/data/css/style.css +++ b/data/css/style.css @@ -221,6 +221,8 @@ footer { margin: 20px auto 20px auto; } div#version { text-align: center; font-weight: bold; } div#donate { text-align: center; margin: 20px auto 20px auto; } +div#shutdown{ text-align: center; vertical-align: middle; } + .cloudtag { padding-top: 30px; font-size:16px; } #cloud a.tag1 { font-size: 0.7em; font-weight: 100; } #cloud a.tag2 { font-size: 0.8em; font-weight: 200; } diff --git a/data/interfaces/default/album.html b/data/interfaces/default/album.html index 6fda2b27..e8406f63 100644 --- a/data/interfaces/default/album.html +++ b/data/interfaces/default/album.html @@ -30,9 +30,14 @@ <% totalduration = myDB.action("SELECT SUM(TrackDuration) FROM tracks WHERE AlbumID=?", [album['AlbumID']]).fetchone()[0] totaltracks = len(myDB.select("SELECT TrackTitle from tracks WHERE AlbumID=?", [album['AlbumID']])) + try: + albumduration = helpers.convert_milliseconds(totalduration) + except: + albumduration = 'n/a' + %>

Tracks: ${totaltracks}

-

Duration: ${helpers.convert_milliseconds(totalduration)}

+

Duration: ${albumduration}

%if description:

Description:

${description['Summary']} @@ -55,18 +60,22 @@ %for track in tracks: <% i += 1 - have = myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle like ? AND TrackTitle like ?', [album['ArtistName'], album['AlbumTitle'], track['TrackTitle']]) + have = myDB.select('SELECT TrackTitle from have WHERE ArtistName like ? AND AlbumTitle like ? AND TrackTitle like ?', [track['ArtistName'], track['AlbumTitle'], track['TrackTitle']]) if len(have): grade = 'A' check = 'checkmark' else: grade = 'Z' check = '' + try: + trackduration = helpers.convert_milliseconds(track['TrackDuration']) + except: + trackduration = 'n/a' %> ${i} ${track['TrackTitle']} - ${helpers.convert_milliseconds(track['TrackDuration'])} + ${trackduration} ${check} %endfor diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index bea006a8..dd8c0589 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -1,6 +1,16 @@ <%inherit file="base.html"/> - +<%def name="headerIncludes()"> +
+ +
+ <%def name="body()"> +
+

+

Web Interface

diff --git a/data/interfaces/default/shutdown.html b/data/interfaces/default/shutdown.html index 917be6b2..be7ca21d 100644 --- a/data/interfaces/default/shutdown.html +++ b/data/interfaces/default/shutdown.html @@ -1,11 +1,13 @@ <%inherit file="base.html"/> <%def name="headIncludes()"> - + <%def name="body()">
+

Headphones is ${message}

+
\ No newline at end of file diff --git a/headphones/helpers.py b/headphones/helpers.py index b2e6ca1f..9dc3aa10 100644 --- a/headphones/helpers.py +++ b/headphones/helpers.py @@ -79,8 +79,10 @@ def convert_milliseconds(ms): seconds = ms/1000 gmtime = time.gmtime(seconds) - - minutes = time.strftime("%M:%S", gmtime) + if seconds > 3600: + minutes = time.strftime("%H:%M:%S", gmtime) + else: + minutes = time.strftime("%M:%S", gmtime) return minutes diff --git a/headphones/webserve.py b/headphones/webserve.py index d3ffc7f2..fd406306 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -357,8 +357,8 @@ class WebInterface(object): def shutdown(self): logger.info(u"Headphones is shutting down...") threading.Timer(2, headphones.shutdown).start() - message = 'Shutting Down' - return serve_template(templatename="shutdown.html", title="Shutting Down", message=message) + message = 'Shutting Down...' + return serve_template(templatename="shutdown.html", title="Shutting Down", message=message, timer=15) return page shutdown.exposed = True @@ -366,15 +366,15 @@ class WebInterface(object): def restart(self): logger.info(u"Headphones is restarting...") threading.Timer(2, headphones.shutdown, [True]).start() - message = 'Restarting' - return serve_template(templatename="shutdown.html", title="Restarting", message=message) + message = 'Restarting...' + return serve_template(templatename="shutdown.html", title="Restarting", message=message, timer=30) restart.exposed = True def update(self): logger.info('Headphones is updating...') threading.Timer(2, headphones.shutdown, [True, True]).start() - message = 'Updating' - return serve_template(templatename="shutdown.html", title="Updating", message=message) + message = 'Updating...' + return serve_template(templatename="shutdown.html", title="Updating", message=message, timer=120) return page update.exposed = True @@ -388,6 +388,7 @@ class WebInterface(object): def addReleaseById(self, rid): threading.Thread(target=importer.addReleaseById, args=[rid]).start() + time.sleep(5) raise cherrypy.HTTPRedirect("home") addReleaseById.exposed = True