diff --git a/htmlmodules.py b/htmlmodules.py index c920984..96d85cd 100644 --- a/htmlmodules.py +++ b/htmlmodules.py @@ -274,3 +274,43 @@ def module_trackcharts_tiles(**kwargs): 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 = "
" + if keys.get("since") == "today" or keys.get("in") == "today": + html += "Today" + else: + html += "Today" + html += " | " + + if keys.get("since") == "sunday": + html += "This Week" + else: + html += "This Week" + html += " | " + + if keys.get("since") == "month" or keys.get("in") == "month": + html += "This Month" + else: + html += "This Month" + html += " | " + + if keys.get("since") == "year" or keys.get("in") == "year": + html += "This Year" + else: + html += "This Year" + html += " | " + + if keys.get("since") is None and keys.get("in") is None: + html += "All Time" + else: + html += "All Time" + + html += "
" + + return html diff --git a/images/.gitignore b/images/.gitignore index f538531..fe357fd 100644 --- a/images/.gitignore +++ b/images/.gitignore @@ -1,4 +1,5 @@ cache +cached/ *.jpg *.jpeg *.png diff --git a/maloja b/maloja index 8f39250..1bc7f0a 100755 --- a/maloja +++ b/maloja @@ -161,7 +161,8 @@ def install(): if fail: return False print("All modules successfully installed!") - return True + print("Run the script again (without root) to start Maloja.") + return False else: print("All necessary modules seem to be installed.") diff --git a/website/topartists.html b/website/topartists.html index 4af64d7..c7afeea 100644 --- a/website/topartists.html +++ b/website/topartists.html @@ -16,6 +16,8 @@

Top Artists


KEY_RANGE +

+ KEY_FILTERSELECTOR diff --git a/website/topartists.py b/website/topartists.py index 2af4bfb..b0346cf 100644 --- a/website/topartists.py +++ b/website/topartists.py @@ -4,7 +4,7 @@ import urllib def instructions(keys): from utilities import getArtistImage from htmlgenerators import KeySplit - from htmlmodules import module_artistcharts + from htmlmodules import module_artistcharts, module_filterselection from malojatime import range_desc @@ -12,7 +12,9 @@ def instructions(keys): limitstring = range_desc(**timekeys) - + html_filterselector = module_filterselection(**keys) + + html_charts, rep = module_artistcharts(**amountkeys,**timekeys) @@ -24,6 +26,6 @@ def instructions(keys): 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) diff --git a/website/toptracks.html b/website/toptracks.html index 61fb06c..a5f39a4 100644 --- a/website/toptracks.html +++ b/website/toptracks.html @@ -16,7 +16,8 @@

Top Tracks


KEY_LIMITS - +

+ KEY_FILTERSELECTOR diff --git a/website/toptracks.py b/website/toptracks.py index 8074e1e..b79f60a 100644 --- a/website/toptracks.py +++ b/website/toptracks.py @@ -4,7 +4,7 @@ import urllib def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, KeySplit - from htmlmodules import module_trackcharts + from htmlmodules import module_trackcharts, module_filterselection from malojatime import range_desc filterkeys, timekeys, _, amountkeys = KeySplit(keys) @@ -12,6 +12,7 @@ def instructions(keys): limitstring = "" + html_filterselector = module_filterselection(**keys) 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)