1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added basic filter selection for top artists and top tracks web view

This commit is contained in:
Krateng 2019-04-01 18:15:08 +02:00
parent b4f3f17f9d
commit 6c646f5aac
7 changed files with 55 additions and 7 deletions

View File

@ -274,3 +274,43 @@ def module_trackcharts_tiles(**kwargs):
html += """</tr></table>""" html += """</tr></table>"""
return html return html
def module_filterselection(**keys):
# all other keys that will not be changed by clicking another filter
retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]}
keystr = "?" + urllib.parse.urlencode(retainkeys)
html = "<div>"
if keys.get("since") == "today" or keys.get("in") == "today":
html += "<span class='stat_selector' style='opacity:0.5;'>Today</span>"
else:
html += "<a href='" + keystr + "&since=today'><span class='stat_selector'>Today</span></a>"
html += " | "
if keys.get("since") == "sunday":
html += "<span class='stat_selector' style='opacity:0.5;'>This Week</span>"
else:
html += "<a href='" + keystr + "&since=sunday'><span class='stat_selector'>This Week</span></a>"
html += " | "
if keys.get("since") == "month" or keys.get("in") == "month":
html += "<span class='stat_selector' style='opacity:0.5;'>This Month</span>"
else:
html += "<a href='" + keystr + "&since=month'><span class='stat_selector'>This Month</span></a>"
html += " | "
if keys.get("since") == "year" or keys.get("in") == "year":
html += "<span class='stat_selector' style='opacity:0.5;'>This Year</span>"
else:
html += "<a href='" + keystr + "&since=year'><span class='stat_selector'>This Year</span></a>"
html += " | "
if keys.get("since") is None and keys.get("in") is None:
html += "<span class='stat_selector' style='opacity:0.5;'>All Time</span>"
else:
html += "<a href='" + keystr + "'><span class='stat_selector'>All Time</span></a>"
html += "</div>"
return html

1
images/.gitignore vendored
View File

@ -1,4 +1,5 @@
cache cache
cached/
*.jpg *.jpg
*.jpeg *.jpeg
*.png *.png

3
maloja
View File

@ -161,7 +161,8 @@ def install():
if fail: return False if fail: return False
print("All modules successfully installed!") print("All modules successfully installed!")
return True print("Run the script again (without root) to start Maloja.")
return False
else: else:
print("All necessary modules seem to be installed.") print("All necessary modules seem to be installed.")

View File

@ -16,6 +16,8 @@
<h1>Top Artists</h1><br/> <h1>Top Artists</h1><br/>
<span>KEY_RANGE</span> <span>KEY_RANGE</span>
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>--> <!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
<br/><br/>
KEY_FILTERSELECTOR
</td> </td>
</tr> </tr>

View File

@ -4,7 +4,7 @@ import urllib
def instructions(keys): def instructions(keys):
from utilities import getArtistImage from utilities import getArtistImage
from htmlgenerators import KeySplit from htmlgenerators import KeySplit
from htmlmodules import module_artistcharts from htmlmodules import module_artistcharts, module_filterselection
from malojatime import range_desc from malojatime import range_desc
@ -12,7 +12,9 @@ def instructions(keys):
limitstring = range_desc(**timekeys) limitstring = range_desc(**timekeys)
html_filterselector = module_filterselection(**keys)
html_charts, rep = module_artistcharts(**amountkeys,**timekeys) html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
@ -24,6 +26,6 @@ def instructions(keys):
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts,"KEY_RANGE":limitstring} replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_ARTISTLIST":html_charts,"KEY_RANGE":limitstring,"KEY_FILTERSELECTOR":html_filterselector}
return (replace,pushresources) return (replace,pushresources)

View File

@ -16,7 +16,8 @@
<h1>Top Tracks</h1><br/> <h1>Top Tracks</h1><br/>
<span>KEY_LIMITS</span> <span>KEY_LIMITS</span>
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>--> <!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
<br/><br/>
KEY_FILTERSELECTOR
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -4,7 +4,7 @@ import urllib
def instructions(keys): def instructions(keys):
from utilities import getArtistImage, getTrackImage from utilities import getArtistImage, getTrackImage
from htmlgenerators import artistLink, KeySplit from htmlgenerators import artistLink, KeySplit
from htmlmodules import module_trackcharts from htmlmodules import module_trackcharts, module_filterselection
from malojatime import range_desc from malojatime import range_desc
filterkeys, timekeys, _, amountkeys = KeySplit(keys) filterkeys, timekeys, _, amountkeys = KeySplit(keys)
@ -12,6 +12,7 @@ def instructions(keys):
limitstring = "" limitstring = ""
html_filterselector = module_filterselection(**keys)
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys) html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
@ -30,6 +31,6 @@ def instructions(keys):
replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring} replace = {"KEY_TOPARTIST_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring,"KEY_FILTERSELECTOR":html_filterselector}
return (replace,pushresources) return (replace,pushresources)