diff --git a/htmlmodules.py b/htmlmodules.py index 2d6753f..7266eea 100644 --- a/htmlmodules.py +++ b/htmlmodules.py @@ -568,19 +568,18 @@ def module_paginate(page,pages,perpage,**keys): # THIS FUNCTION USES THE ORIGINAL URI KEYS!!! def module_filterselection(keys,time=True,delimit=False): - filterkeys, timekeys, delimitkeys, extrakeys = uri_to_internal(keys) - internalkeys = {**filterkeys,**timekeys,**delimitkeys,**extrakeys} + from malojatime import today, thisweek, thismonth, thisyear, alltime + filterkeys, timekeys, delimitkeys, extrakeys = uri_to_internal(keys) # drop keys that are not relevant so they don't clutter the URI if not time: timekeys = {} if not delimit: delimitkeys = {} + internalkeys = {**filterkeys,**timekeys,**delimitkeys,**extrakeys} html = "" if time: - # all other keys that will not be changed by clicking another filter - unchangedkeys = internal_to_uri({**filterkeys,**delimitkeys,**extrakeys}) # wonky selector for precise date range @@ -600,21 +599,27 @@ def module_filterselection(keys,time=True,delimit=False): # html += "to " # html += "" - from malojatime import today, thisweek, thismonth, thisyear, alltime - # relative to current range html += "
" - if timekeys.get("timerange").next(-1) is not None: - prevrange = timekeys.get("timerange").next(-1) - html += "" + prevrange.desc() + "" + thisrange = timekeys.get("timerange") + prevrange = thisrange.next(-1) + nextrange = thisrange.next(1) + + if prevrange is not None: + link = compose_querystring(internal_to_uri({**internalkeys,"timerange":prevrange})) + html += "" + prevrange.desc() + "" html += " « " - if timekeys.get("timerange").next(-1) is not None or timekeys.get("timerange").next(1) is not None: - html += "" + timekeys.get("timerange").desc() + "" - if timekeys.get("timerange").next(1) is not None: + if prevrange is not None or nextrange is not None: + html += "" + thisrange.desc() + "" + if nextrange is not None: html += " » " - nextrange = timekeys.get("timerange").next(1) - html += "" + nextrange.desc() + "" + link = compose_querystring(internal_to_uri({**internalkeys,"timerange":nextrange})) + html += "" + nextrange.desc() + "" + + html += "
" + + categories = [