1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00
maloja/website/charts_artists.py
Zack Boehm 864e7bc46d Optionally display tiles in artist + track chart pages
This allows for viewing top tiles for any specific timerange
2019-09-04 01:58:28 -04:00

45 lines
1.1 KiB
Python

import urllib
def instructions(keys):
from utilities import getArtistImage
from urihandler import compose_querystring, uri_to_internal
from htmlmodules import module_artistcharts, module_filterselection, module_artistcharts_tiles
from malojatime import range_desc
from doreah.settings import get_settings
_, timekeys, _, amountkeys = uri_to_internal(keys)
limitstring = timekeys["timerange"].desc(prefix=True)
html_filterselector = module_filterselection(keys)
topartists = ""
if get_settings("CHARTS_DISPLAY_TILES"):
topartists = module_artistcharts_tiles(timerange=timekeys["timerange"])
html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
if rep is not None:
imgurl = getArtistImage(rep)
else:
imgurl = ""
imgdiv = '<div style="background-image:url('+imgurl+')"></div>'
if get_settings("CHARTS_DISPLAY_TILES"):
imgdiv = ""
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
replace = {
"KEY_TOPARTIST_IMAGEDIV":imgdiv,
"KEY_ARTISTCHART":topartists,
"KEY_ARTISTLIST":html_charts,
"KEY_RANGE":limitstring,
"KEY_FILTERSELECTOR":html_filterselector}
return (replace,pushresources)