From 3cf37aff90f3854e0e67fac0d6d115372f96c5f2 Mon Sep 17 00:00:00 2001 From: Krateng Date: Mon, 1 Apr 2019 18:43:08 +0200 Subject: [PATCH] Added filter selection to pulse view --- htmlmodules.py | 92 +++++++++++++++++++++++++++++-------------- website/pulse.html | 2 + website/pulse.py | 6 ++- website/topartists.py | 2 +- website/toptracks.py | 2 +- 5 files changed, 71 insertions(+), 33 deletions(-) diff --git a/htmlmodules.py b/htmlmodules.py index 96d85cd..3694a9f 100644 --- a/htmlmodules.py +++ b/htmlmodules.py @@ -277,40 +277,74 @@ def module_trackcharts_tiles(**kwargs): -def module_filterselection(**keys): +def module_filterselection(keys,time=True,delimit=False): # 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 += " | " + html = "" - if keys.get("since") == "year" or keys.get("in") == "year": - html += "This Year" - else: - html += "This Year" - html += " | " + if time: - if keys.get("since") is None and keys.get("in") is None: - html += "All Time" - else: - html += "All Time" + retainkeys = {k:keys[k] for k in keys if k not in ["since","to","in"]} + keystr = "?" + urllib.parse.urlencode(retainkeys) - html += "
" + + 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 += "
" + + if delimit: + + retainkeys = {k:keys[k] for k in keys if k not in ["step","stepn","trail"]} + keystr = "?" + urllib.parse.urlencode(retainkeys) + + html += "
" + if keys.get("step") == "day": + html += "Daily" + else: + html += "Daily" + html += " | " + + if keys.get("step") == "month": + html += "Monthly" + else: + html += "Monthly" + html += " | " + + if keys.get("step") == "year": + html += "Yearly" + else: + html += "Yearly" + html += " | " + + html += "
" return html diff --git a/website/pulse.html b/website/pulse.html index 96bf85f..5d3a89d 100644 --- a/website/pulse.html +++ b/website/pulse.html @@ -16,6 +16,8 @@

KEY_PULSEDETAILS Pulse


KEY_LIMITS +

+ KEY_FILTERSELECTOR diff --git a/website/pulse.py b/website/pulse.py index 5e8fb10..f04e0f3 100644 --- a/website/pulse.py +++ b/website/pulse.py @@ -5,7 +5,7 @@ import database def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink, keysToUrl, KeySplit - from htmlmodules import module_pulse + from htmlmodules import module_pulse, module_filterselection from malojatime import range_desc, delimit_desc filterkeys, timekeys, delimitkeys, _ = KeySplit(keys) @@ -32,6 +32,8 @@ def instructions(keys): delimitstring = delimit_desc(**delimitkeys) + html_filterselector = module_filterselection(keys,delimit=True) + # get image if filterkeys.get("track") is not None: @@ -47,6 +49,6 @@ def instructions(keys): html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys) - replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring,"KEY_PULSEDETAILS":delimitstring} + replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring,"KEY_PULSEDETAILS":delimitstring,"KEY_FILTERSELECTOR":html_filterselector} return (replace,pushresources) diff --git a/website/topartists.py b/website/topartists.py index b0346cf..a090dcc 100644 --- a/website/topartists.py +++ b/website/topartists.py @@ -12,7 +12,7 @@ def instructions(keys): limitstring = range_desc(**timekeys) - html_filterselector = module_filterselection(**keys) + html_filterselector = module_filterselection(keys) diff --git a/website/toptracks.py b/website/toptracks.py index b79f60a..32930bd 100644 --- a/website/toptracks.py +++ b/website/toptracks.py @@ -12,7 +12,7 @@ def instructions(keys): limitstring = "" - html_filterselector = module_filterselection(**keys) + html_filterselector = module_filterselection(keys) html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)