diff --git a/maloja/server.py b/maloja/server.py index f448eed..e777c3f 100755 --- a/maloja/server.py +++ b/maloja/server.py @@ -52,8 +52,7 @@ HOST = settings.get_settings("HOST") THREADS = 24 BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024 -WEBFOLDER = pkg_resources.resource_filename(__name__,"web") -STATICFOLDER = pkg_resources.resource_filename(__name__,"static") +STATICFOLDER = pkg_resources.resource_filename(__name__,"web/static") DATAFOLDER = DATA_DIR webserver = Bottle() @@ -229,7 +228,7 @@ JINJA_CONTEXT = { jinjaenv = Environment( - loader=PackageLoader('maloja', 'web/jinja'), + loader=PackageLoader('maloja', "web/jinja"), autoescape=select_autoescape(['html', 'xml']) ) jinjaenv.globals.update(JINJA_CONTEXT) @@ -250,78 +249,24 @@ def static_html(name): linkheaders = ["; rel=preload; as=style"] keys = remove_identical(FormsDict.decode(request.query)) - html_file = os.path.exists(pthjoin(WEBFOLDER,name + ".html")) - jinja_file = os.path.exists(pthjoin(WEBFOLDER,"jinja",name + ".jinja")) - jinja_pref = settings.get_settings("USE_JINJA") - adminmode = request.cookies.get("adminmode") == "true" and auth.check(request) clock = Clock() clock.start() - # if a jinja file exists, use this - if ("pyhtml" not in keys and jinja_file and jinja_pref) or (jinja_file and not html_file): - LOCAL_CONTEXT = { - "adminmode":adminmode, - "apikey":request.cookies.get("apikey") if adminmode else None, - "_urikeys":keys, #temporary! - } - lc = LOCAL_CONTEXT - lc["filterkeys"], lc["limitkeys"], lc["delimitkeys"], lc["amountkeys"], lc["specialkeys"] = uri_to_internal(keys) + LOCAL_CONTEXT = { + "adminmode":adminmode, + "apikey":request.cookies.get("apikey") if adminmode else None, + "_urikeys":keys, #temporary! + } + lc = LOCAL_CONTEXT + lc["filterkeys"], lc["limitkeys"], lc["delimitkeys"], lc["amountkeys"], lc["specialkeys"] = uri_to_internal(keys) - template = jinjaenv.get_template(name + '.jinja') + template = jinjaenv.get_template(name + '.jinja') - res = template.render(**LOCAL_CONTEXT) - log("Generated page {name} in {time:.5f}s (Jinja)".format(name=name,time=clock.stop()),module="debug_performance") - return res - - - # if not, use the old way - else: - try: - with open(pthjoin(WEBFOLDER,name + ".html")) as htmlfile: - html = htmlfile.read() - - # apply global substitutions - with open(pthjoin(WEBFOLDER,"common/footer.html")) as footerfile: - footerhtml = footerfile.read() - with open(pthjoin(WEBFOLDER,"common/header.html")) as headerfile: - headerhtml = headerfile.read() - html = html.replace("",footerhtml + "").replace("",headerhtml + "") - - - # If a python file exists, it provides the replacement dict for the html file - if os.path.exists(pthjoin(WEBFOLDER,name + ".py")): - #txt_keys = SourceFileLoader(name,"web/" + name + ".py").load_module().replacedict(keys,DATABASE_PORT) - try: - module = importlib.import_module(".web." + name,package="maloja") - txt_keys,resources = module.instructions(keys) - except Exception as e: - log("Error in website generation: " + str(sys.exc_info()),module="error") - raise - - # add headers for server push - for resource in resources: - if all(ord(c) < 128 for c in resource["file"]): - # we can only put ascii stuff in the http header - linkheaders.append("<" + resource["file"] + ">; rel=preload; as=" + resource["type"]) - - # apply key substitutions - for k in txt_keys: - if isinstance(txt_keys[k],list): - # if list, we replace each occurence with the next item - for element in txt_keys[k]: - html = html.replace(k,element,1) - else: - html = html.replace(k,txt_keys[k]) - - - response.set_header("Link",",".join(linkheaders)) - log("Generated page {name} in {time:.5f}s (Python+HTML)".format(name=name,time=clock.stop()),module="debug_performance") - return html - - except: - abort(404, "Page does not exist") + res = template.render(**LOCAL_CONTEXT) + log("Generated page {name} in {time:.5f}s (Jinja)".format(name=name,time=clock.stop()),module="debug_performance") + return res # Shortlinks diff --git a/maloja/web/common/footer.html b/maloja/web/common/footer.html deleted file mode 100644 index 4f4a96f..0000000 --- a/maloja/web/common/footer.html +++ /dev/null @@ -1,27 +0,0 @@ - - -
- -
diff --git a/maloja/web/common/header.html b/maloja/web/common/header.html deleted file mode 100644 index ba3db6d..0000000 --- a/maloja/web/common/header.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - diff --git a/maloja/web/compare.html b/maloja/web/compare.html deleted file mode 100644 index ff5d3bf..0000000 --- a/maloja/web/compare.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - Maloja - Compare - - - - - - - - - - - - - - - - - - - - - -

KEY_NAME_SELF

- -
- KEY_MATCH% - -
-

KEY_NAME_OTHER

- The size of the circle shows matching music taste. - The fuzziness of its border indicates differences in quantity. -
- Common Favorite -

KEY_BESTARTIST_LINK

- -
- - - - - - diff --git a/maloja/web/compare.py b/maloja/web/compare.py deleted file mode 100644 index 8a08a70..0000000 --- a/maloja/web/compare.py +++ /dev/null @@ -1,90 +0,0 @@ -import urllib -from .. import database -import json -from ..htmlgenerators import artistLink -from ..utilities import getArtistImage - - -def instructions(keys): - - compareto = keys.get("to") - compareurl = compareto + "/api/info" - - response = urllib.request.urlopen(compareurl) - strangerinfo = json.loads(response.read()) - - owninfo = database.info() - - database.add_known_server(compareto) - - artists = {} - - for a in owninfo["artists"]: - artists[a.lower()] = {"name":a,"self":int(owninfo["artists"][a]*1000),"other":0} - - for a in strangerinfo["artists"]: - artists[a.lower()] = artists.setdefault(a.lower(),{"name":a,"self":0}) - artists[a.lower()]["other"] = int(strangerinfo["artists"][a]*1000) - - for a in artists: - common = min(artists[a]["self"],artists[a]["other"]) - artists[a]["self"] -= common - artists[a]["other"] -= common - artists[a]["common"] = common - - best = sorted((artists[a]["name"] for a in artists),key=lambda x: artists[x.lower()]["common"],reverse=True) - - result = { - "unique_self":sum(artists[a]["self"] for a in artists if artists[a]["common"] == 0), - "more_self":sum(artists[a]["self"] for a in artists if artists[a]["common"] != 0), - # "common":{ - # **{ - # artists[a]["name"]:artists[a]["common"] - # for a in best[:3]}, - # None: sum(artists[a]["common"] for a in artists if a not in best[:3]) - # }, - "common":sum(artists[a]["common"] for a in artists), - "more_other":sum(artists[a]["other"] for a in artists if artists[a]["common"] != 0), - "unique_other":sum(artists[a]["other"] for a in artists if artists[a]["common"] == 0) - } - - total = sum(result[c] for c in result) - - percentages = {c:result[c]*100/total for c in result} - css = [] - - cumulative = 0 - for color,category in [ - ("rgba(255,255,255,0.2)","unique_self"), - ("rgba(255,255,255,0.5)","more_self"), - ("white","common"), - ("rgba(255,255,255,0.5)","more_other"), - ("rgba(255,255,255,0.2)","unique_other")]: - cumulative += percentages[category] - css.append(color + " " + str(cumulative) + "%") - - - fullmatch = percentages["common"] - partialmatch = percentages["more_self"] + percentages["more_other"] - - match = fullmatch + (partialmatch)/2 - pixel_fullmatch = fullmatch * 2.5 - pixel_partialmatch = (fullmatch+partialmatch) * 2.5 - - match = min(match,100) - - - matchcolor = format(int(min(1,match/50)*255),"02x") * 2 + format(int(max(0,match/50-1)*255),"02x") - - - return { - "KEY_CIRCLE_CSS":",".join(css), - "KEY_CICLE_COLOR":matchcolor, - "KEY_MATCH":str(round(match,2)), - "KEY_FULLMATCH":str(int(pixel_fullmatch)), - "KEY_PARTIALMATCH":str(int(pixel_partialmatch)), - "KEY_NAME_SELF":owninfo["name"], - "KEY_NAME_OTHER":strangerinfo["name"], - "KEY_BESTARTIST_LINK":artistLink(best[0]), - "KEY_BESTARTIST_IMAGE":getArtistImage(best[0]) - },[] diff --git a/maloja/web/jinja/partials/charts_artists_tiles.jinja b/maloja/web/jinja/partials/charts_artists_tiles.jinja index 6097b16..9408be4 100644 --- a/maloja/web/jinja/partials/charts_artists_tiles.jinja +++ b/maloja/web/jinja/partials/charts_artists_tiles.jinja @@ -28,7 +28,7 @@ {% else %} - + {% endif %} {% endfor %} diff --git a/maloja/web/jinja/partials/charts_tracks_tiles.jinja b/maloja/web/jinja/partials/charts_tracks_tiles.jinja index b3b6ea2..f35324c 100644 --- a/maloja/web/jinja/partials/charts_tracks_tiles.jinja +++ b/maloja/web/jinja/partials/charts_tracks_tiles.jinja @@ -28,7 +28,7 @@ {% else %} - + {% endif %} {% endfor %} diff --git a/maloja/web/performance.html b/maloja/web/performance.html deleted file mode 100644 index 196641e..0000000 --- a/maloja/web/performance.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Maloja - KEY_PULSEDETAILS Performance - - - - - - - - -
-
-
-

KEY_PULSEDETAILS Performance

KEY_PULSE_LINK
- KEY_LIMITS - -

- KEY_FILTERSELECTOR - -
- - KEY_PERFORMANCE_TABLE - - - diff --git a/maloja/web/performance.py b/maloja/web/performance.py deleted file mode 100644 index 3a7612d..0000000 --- a/maloja/web/performance.py +++ /dev/null @@ -1,67 +0,0 @@ -import urllib -from .. import database - - -def instructions(keys): - from ..utilities import getArtistImage, getTrackImage - from ..htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink - from ..urihandler import compose_querystring, uri_to_internal, internal_to_uri - from ..htmlmodules import module_performance, module_filterselection - from ..malojatime import range_desc, delimit_desc - - filterkeys, timekeys, delimitkeys, paginatekeys = uri_to_internal(keys) - - #equivalent pulse chart - pulselink_keys = internal_to_uri({**filterkeys,**timekeys,**delimitkeys,**paginatekeys}) - pulselink = "/pulse?" + compose_querystring(pulselink_keys) - - pulselink = "View Pulse" - - - # describe the scope (and creating a key for the relevant artist or track) - limitstring = "" - #limitkey = {} - if filterkeys.get("track") is not None: - #limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")} - limitstring += "of " + trackLink(filterkeys["track"]) + " " - limitstring += "by " + artistLinks(filterkeys["track"]["artists"]) - - elif filterkeys.get("artist") is not None: - #limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None) - limitstring += "of " + artistLink(filterkeys.get("artist")) - # associated are counted by default - data = database.artistInfo(filterkeys["artist"]) - moreartists = data["associated"] - if moreartists != []: - limitstring += " including " + artistLinks(moreartists) + "" - - limitstring += " " + timekeys["timerange"].desc(prefix=True) - - delimitstring = delimit_desc(**delimitkeys) - - html_filterselector = module_filterselection(keys,delimit=True) - - - # get image - if filterkeys.get("track") is not None: - imgurl = getTrackImage(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]) - elif filterkeys.get("artist") is not None: - imgurl = getArtistImage(keys.get("artist")) - else: - imgurl = "" - - pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] - - - - html_performance = module_performance(**filterkeys,**timekeys,**delimitkeys,**paginatekeys) - - replace = { - "KEY_PULSE_LINK":pulselink, - "KEY_PERFORMANCE_TABLE":html_performance, - "KEY_IMAGEURL":imgurl, - "KEY_LIMITS":limitstring, - "KEY_PULSEDETAILS":delimitstring, - "KEY_FILTERSELECTOR":html_filterselector} - - return (replace,pushresources) diff --git a/maloja/web/pulse.html b/maloja/web/pulse.html deleted file mode 100644 index 385b4dc..0000000 --- a/maloja/web/pulse.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Maloja - KEY_PULSEDETAILS Pulse - - - - - - - - -
-
-
-

KEY_PULSEDETAILS Pulse

KEY_RANKINGS_LINK
- KEY_LIMITS - -

- KEY_FILTERSELECTOR - -
- - KEY_PULSE_TABLE - - - diff --git a/maloja/web/pulse.py b/maloja/web/pulse.py deleted file mode 100644 index 0d6f1b1..0000000 --- a/maloja/web/pulse.py +++ /dev/null @@ -1,71 +0,0 @@ -import urllib -from .. import database - - -def instructions(keys): - from ..utilities import getArtistImage, getTrackImage - from ..htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink - from ..urihandler import compose_querystring, uri_to_internal, internal_to_uri - from ..htmlmodules import module_pulse, module_filterselection - from ..malojatime import range_desc, delimit_desc - - filterkeys, timekeys, delimitkeys, paginatekeys = uri_to_internal(keys) - - #equivalent performance chart if we're not looking at the overall pulse - if len(filterkeys) != 0: - performancelink_keys = internal_to_uri({**filterkeys,**timekeys,**delimitkeys,**paginatekeys}) - performancelink = "/performance?" + compose_querystring(performancelink_keys) - - performancelink = "View Rankings" - else: - performancelink = "" - - - # describe the scope (and creating a key for the relevant artist or track) - limitstring = "" - #limitkey = {} - if filterkeys.get("track") is not None: - #limitkey["track"] = {"artists":keys.getall("artist"),"title":keys.get("title")} - limitstring += "of " + trackLink(filterkeys["track"]) + " " - limitstring += "by " + artistLinks(filterkeys["track"]["artists"]) - - elif filterkeys.get("artist") is not None: - #limitkey["artist"], limitkey["associated"] = keys.get("artist"), (keys.get("associated")!=None) - limitstring += "of " + artistLink(filterkeys.get("artist")) - if filterkeys.get("associated"): - data = database.artistInfo(filterkeys["artist"]) - moreartists = data["associated"] - if moreartists != []: - limitstring += " including " + artistLinks(moreartists) + "" - - limitstring += " " + range_desc(timekeys["timerange"],prefix=True) - - delimitstring = delimit_desc(**delimitkeys) - - html_filterselector = module_filterselection(keys,delimit=True) - - - # get image - if filterkeys.get("track") is not None: - imgurl = getTrackImage(filterkeys.get("track")["artists"],filterkeys.get("track")["title"]) - elif filterkeys.get("artist") is not None: - imgurl = getArtistImage(keys.get("artist")) - else: - imgurl = "" - - pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] - - - - html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys,**paginatekeys) - - replace = { - "KEY_RANKINGS_LINK":performancelink, - "KEY_PULSE_TABLE":html_pulse, - "KEY_IMAGEURL":imgurl, - "KEY_LIMITS":limitstring, - "KEY_PULSEDETAILS":delimitstring, - "KEY_FILTERSELECTOR":html_filterselector - } - - return (replace,pushresources) diff --git a/maloja/web/scrobbles.html b/maloja/web/scrobbles.html deleted file mode 100644 index 879e936..0000000 --- a/maloja/web/scrobbles.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Maloja - Scrobbles - - - - - - - - -
-
-
-

Scrobbles


- KEY_LIMITS
-

KEY_SCROBBLES Scrobbles

-
- KEY_FILTERSELECTOR - -
- - KEY_SCROBBLELIST - - - diff --git a/maloja/web/scrobbles.py b/maloja/web/scrobbles.py deleted file mode 100644 index 955eeb8..0000000 --- a/maloja/web/scrobbles.py +++ /dev/null @@ -1,56 +0,0 @@ -import urllib -from .. import database - - -def instructions(keys): - from ..utilities import getArtistImage, getTrackImage - from ..htmlgenerators import artistLink, artistLinks, trackLink - from ..urihandler import compose_querystring, uri_to_internal - from ..htmlmodules import module_scrobblelist, module_filterselection - from ..malojatime import range_desc - - - filterkeys, timekeys, _, amountkeys = uri_to_internal(keys) - - # describe the scope - limitstring = "" - if filterkeys.get("track") is not None: - limitstring += "of " + trackLink(filterkeys["track"]) + " " - limitstring += "by " + artistLinks(filterkeys["track"]["artists"]) - - elif filterkeys.get("artist") is not None: - limitstring += "by " + artistLink(filterkeys.get("artist")) - if filterkeys.get("associated"): - data = database.artistInfo(filterkeys["artist"]) - moreartists = data.get("associated") - if moreartists != []: - limitstring += " including " + artistLinks(moreartists) + "" - - limitstring += " " + timekeys["timerange"].desc(prefix=True) - - html_filterselector = module_filterselection(keys) - - - html, amount, rep = module_scrobblelist(**filterkeys,**timekeys,**amountkeys) - - # get image - if filterkeys.get("track") is not None: - imgurl = getTrackImage(filterkeys.get("track")["artists"],filterkeys.get("track")["title"],fast=True) - elif filterkeys.get("artist") is not None: - imgurl = getArtistImage(keys.get("artist"),fast=True) - elif rep is not None: - imgurl = getTrackImage(rep["artists"],rep["title"],fast=True) - else: - imgurl = "" - - - pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] - - - replace = {"KEY_SCROBBLELIST":html, - "KEY_SCROBBLES":str(amount), - "KEY_IMAGEURL":imgurl, - "KEY_LIMITS":limitstring, - "KEY_FILTERSELECTOR":html_filterselector} - - return (replace,pushresources) diff --git a/maloja/static/ico/favicon.ico b/maloja/web/static/ico/favicon.ico similarity index 100% rename from maloja/static/ico/favicon.ico rename to maloja/web/static/ico/favicon.ico diff --git a/maloja/static/js/cookies.js b/maloja/web/static/js/cookies.js similarity index 100% rename from maloja/static/js/cookies.js rename to maloja/web/static/js/cookies.js diff --git a/maloja/static/js/datechange.js b/maloja/web/static/js/datechange.js similarity index 100% rename from maloja/static/js/datechange.js rename to maloja/web/static/js/datechange.js diff --git a/maloja/static/js/manualscrobble.js b/maloja/web/static/js/manualscrobble.js similarity index 100% rename from maloja/static/js/manualscrobble.js rename to maloja/web/static/js/manualscrobble.js diff --git a/maloja/static/js/neopolitan.js b/maloja/web/static/js/neopolitan.js similarity index 100% rename from maloja/static/js/neopolitan.js rename to maloja/web/static/js/neopolitan.js diff --git a/maloja/static/js/rangeselect.js b/maloja/web/static/js/rangeselect.js similarity index 100% rename from maloja/static/js/rangeselect.js rename to maloja/web/static/js/rangeselect.js diff --git a/maloja/static/js/search.js b/maloja/web/static/js/search.js similarity index 100% rename from maloja/static/js/search.js rename to maloja/web/static/js/search.js diff --git a/maloja/static/js/upload.js b/maloja/web/static/js/upload.js similarity index 100% rename from maloja/static/js/upload.js rename to maloja/web/static/js/upload.js diff --git a/maloja/static/less/grisons.less b/maloja/web/static/less/grisons.less similarity index 100% rename from maloja/static/less/grisons.less rename to maloja/web/static/less/grisons.less diff --git a/maloja/static/less/grisonsfont.less b/maloja/web/static/less/grisonsfont.less similarity index 100% rename from maloja/static/less/grisonsfont.less rename to maloja/web/static/less/grisonsfont.less diff --git a/maloja/static/less/maloja.less b/maloja/web/static/less/maloja.less similarity index 100% rename from maloja/static/less/maloja.less rename to maloja/web/static/less/maloja.less diff --git a/maloja/static/png/chartpos_bronze.png b/maloja/web/static/png/chartpos_bronze.png similarity index 100% rename from maloja/static/png/chartpos_bronze.png rename to maloja/web/static/png/chartpos_bronze.png diff --git a/maloja/static/png/chartpos_gold.png b/maloja/web/static/png/chartpos_gold.png similarity index 100% rename from maloja/static/png/chartpos_gold.png rename to maloja/web/static/png/chartpos_gold.png diff --git a/maloja/static/png/chartpos_normal.png b/maloja/web/static/png/chartpos_normal.png similarity index 100% rename from maloja/static/png/chartpos_normal.png rename to maloja/web/static/png/chartpos_normal.png diff --git a/maloja/static/png/chartpos_silver.png b/maloja/web/static/png/chartpos_silver.png similarity index 100% rename from maloja/static/png/chartpos_silver.png rename to maloja/web/static/png/chartpos_silver.png diff --git a/maloja/static/png/favicon.png b/maloja/web/static/png/favicon.png similarity index 100% rename from maloja/static/png/favicon.png rename to maloja/web/static/png/favicon.png diff --git a/maloja/static/png/record_diamond.png b/maloja/web/static/png/record_diamond.png similarity index 100% rename from maloja/static/png/record_diamond.png rename to maloja/web/static/png/record_diamond.png diff --git a/maloja/static/png/record_gold.png b/maloja/web/static/png/record_gold.png similarity index 100% rename from maloja/static/png/record_gold.png rename to maloja/web/static/png/record_gold.png diff --git a/maloja/static/png/record_gold_original.png b/maloja/web/static/png/record_gold_original.png similarity index 100% rename from maloja/static/png/record_gold_original.png rename to maloja/web/static/png/record_gold_original.png diff --git a/maloja/static/png/record_platinum.png b/maloja/web/static/png/record_platinum.png similarity index 100% rename from maloja/static/png/record_platinum.png rename to maloja/web/static/png/record_platinum.png diff --git a/maloja/static/png/star.png b/maloja/web/static/png/star.png similarity index 100% rename from maloja/static/png/star.png rename to maloja/web/static/png/star.png diff --git a/maloja/static/png/star_alt.png b/maloja/web/static/png/star_alt.png similarity index 100% rename from maloja/static/png/star_alt.png rename to maloja/web/static/png/star_alt.png diff --git a/maloja/static/txt/robots.txt b/maloja/web/static/txt/robots.txt similarity index 100% rename from maloja/static/txt/robots.txt rename to maloja/web/static/txt/robots.txt diff --git a/maloja/web/top_artists.html b/maloja/web/top_artists.html deleted file mode 100644 index d8153e2..0000000 --- a/maloja/web/top_artists.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Maloja - #1 Artists - - - - - - - - -
-
-
-

#1 Artists


- KEY_LIMITS - -

- KEY_FILTERSELECTOR -
- - - KEY_ARTISTLIST - - - diff --git a/maloja/web/top_artists.py b/maloja/web/top_artists.py deleted file mode 100644 index 82b864d..0000000 --- a/maloja/web/top_artists.py +++ /dev/null @@ -1,40 +0,0 @@ -import urllib - - -def instructions(keys): - from ..utilities import getArtistImage, getTrackImage - from ..htmlgenerators import artistLink - from ..urihandler import compose_querystring, uri_to_internal - from ..htmlmodules import module_topartists, module_filterselection - from ..malojatime import range_desc - - _, timekeys, delimitkeys, _ = uri_to_internal(keys) - - - limitstring = "" - - html_filterselector = module_filterselection(keys,delimit=True) - - html_charts, rep = module_topartists(**timekeys, **delimitkeys) - - - #if filterkeys.get("artist") is not None: - # imgurl = getArtistImage(filterkeys.get("artist")) - # limitstring = "by " + artistLink(filterkeys.get("artist")) - if rep is not None: - imgurl = getArtistImage(rep) - else: - imgurl = "" - - limitstring += " " + timekeys["timerange"].desc(prefix=True) - - pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] - - - - replace = {"KEY_TOPARTIST_IMAGEURL":imgurl, - "KEY_ARTISTLIST":html_charts, - "KEY_LIMITS":limitstring, - "KEY_FILTERSELECTOR":html_filterselector} - - return (replace,pushresources) diff --git a/maloja/web/top_tracks.html b/maloja/web/top_tracks.html deleted file mode 100644 index 0657695..0000000 --- a/maloja/web/top_tracks.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Maloja - #1 Tracks - - - - - - - - -
-
-
-

#1 Tracks


- KEY_LIMITS - -

- KEY_FILTERSELECTOR -
- - - KEY_TRACKLIST - - - diff --git a/maloja/web/top_tracks.py b/maloja/web/top_tracks.py deleted file mode 100644 index 2ffd80a..0000000 --- a/maloja/web/top_tracks.py +++ /dev/null @@ -1,37 +0,0 @@ -import urllib - - -def instructions(keys): - from ..utilities import getArtistImage, getTrackImage - from ..htmlgenerators import artistLink - from ..urihandler import compose_querystring, uri_to_internal - from ..htmlmodules import module_toptracks, module_filterselection - from ..malojatime import range_desc - - filterkeys, timekeys, delimitkeys, _ = uri_to_internal(keys) - - - limitstring = "" - - html_filterselector = module_filterselection(keys,delimit=True) - - html_charts, rep = module_toptracks(**timekeys, **delimitkeys) ### **filterkeys implementing? - - - #if filterkeys.get("artist") is not None: - # imgurl = getArtistImage(filterkeys.get("artist")) - # limitstring = "by " + artistLink(filterkeys.get("artist")) - if rep is not None: - imgurl = getTrackImage(rep["artists"],rep["title"]) - else: - imgurl = "" - - limitstring += " " + timekeys["timerange"].desc(prefix=True) - - pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else [] - - - - replace = {"KEY_TOPTRACK_IMAGEURL":imgurl,"KEY_TRACKLIST":html_charts,"KEY_LIMITS":limitstring,"KEY_FILTERSELECTOR":html_filterselector} - - return (replace,pushresources)