Removed non-jinja support
|
@ -52,8 +52,7 @@ HOST = settings.get_settings("HOST")
|
||||||
THREADS = 24
|
THREADS = 24
|
||||||
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
BaseRequest.MEMFILE_MAX = 15 * 1024 * 1024
|
||||||
|
|
||||||
WEBFOLDER = pkg_resources.resource_filename(__name__,"web")
|
STATICFOLDER = pkg_resources.resource_filename(__name__,"web/static")
|
||||||
STATICFOLDER = pkg_resources.resource_filename(__name__,"static")
|
|
||||||
DATAFOLDER = DATA_DIR
|
DATAFOLDER = DATA_DIR
|
||||||
|
|
||||||
webserver = Bottle()
|
webserver = Bottle()
|
||||||
|
@ -229,7 +228,7 @@ JINJA_CONTEXT = {
|
||||||
|
|
||||||
|
|
||||||
jinjaenv = Environment(
|
jinjaenv = Environment(
|
||||||
loader=PackageLoader('maloja', 'web/jinja'),
|
loader=PackageLoader('maloja', "web/jinja"),
|
||||||
autoescape=select_autoescape(['html', 'xml'])
|
autoescape=select_autoescape(['html', 'xml'])
|
||||||
)
|
)
|
||||||
jinjaenv.globals.update(JINJA_CONTEXT)
|
jinjaenv.globals.update(JINJA_CONTEXT)
|
||||||
|
@ -250,78 +249,24 @@ def static_html(name):
|
||||||
linkheaders = ["</style.css>; rel=preload; as=style"]
|
linkheaders = ["</style.css>; rel=preload; as=style"]
|
||||||
keys = remove_identical(FormsDict.decode(request.query))
|
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)
|
adminmode = request.cookies.get("adminmode") == "true" and auth.check(request)
|
||||||
|
|
||||||
clock = Clock()
|
clock = Clock()
|
||||||
clock.start()
|
clock.start()
|
||||||
|
|
||||||
# if a jinja file exists, use this
|
LOCAL_CONTEXT = {
|
||||||
if ("pyhtml" not in keys and jinja_file and jinja_pref) or (jinja_file and not html_file):
|
"adminmode":adminmode,
|
||||||
LOCAL_CONTEXT = {
|
"apikey":request.cookies.get("apikey") if adminmode else None,
|
||||||
"adminmode":adminmode,
|
"_urikeys":keys, #temporary!
|
||||||
"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)
|
||||||
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)
|
res = template.render(**LOCAL_CONTEXT)
|
||||||
log("Generated page {name} in {time:.5f}s (Jinja)".format(name=name,time=clock.stop()),module="debug_performance")
|
log("Generated page {name} in {time:.5f}s (Jinja)".format(name=name,time=clock.stop()),module="debug_performance")
|
||||||
return res
|
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("</body>",footerhtml + "</body>").replace("</head>",headerhtml + "</head>")
|
|
||||||
|
|
||||||
|
|
||||||
# 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")
|
|
||||||
|
|
||||||
|
|
||||||
# Shortlinks
|
# Shortlinks
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<div class="footer">
|
|
||||||
<div>
|
|
||||||
<span>Get your own Maloja scrobble server on <a target="_blank" rel="noopener noreferrer" href="https://github.com/krateng/maloja">GitHub</a></span>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<a href="/"><span style="font-weight:bold;">Maloja</span></a>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<span><input id="searchinput" placeholder="Search for an artist or track..." oninput="search(this)" onblur="clearresults()" /></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<span id="resultwrap" class="hide">
|
|
||||||
<div class="searchresults">
|
|
||||||
<span>Artists</span>
|
|
||||||
<table class="searchresults_artists" id="searchresults_artists">
|
|
||||||
</table>
|
|
||||||
<br/><br/>
|
|
||||||
<span>Tracks</span>
|
|
||||||
<table class="searchresults_tracks" id="searchresults_tracks">
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a href="/admin_overview"><div title="Server Administration" id="settingsicon">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M17 12.645v-2.289c-1.17-.417-1.907-.533-2.28-1.431-.373-.9.07-1.512.6-2.625l-1.618-1.619c-1.105.525-1.723.974-2.626.6-.9-.374-1.017-1.117-1.431-2.281h-2.29c-.412 1.158-.53 1.907-1.431 2.28h-.001c-.9.374-1.51-.07-2.625-.6l-1.617 1.619c.527 1.11.973 1.724.6 2.625-.375.901-1.123 1.019-2.281 1.431v2.289c1.155.412 1.907.531 2.28 1.431.376.908-.081 1.534-.6 2.625l1.618 1.619c1.107-.525 1.724-.974 2.625-.6h.001c.9.373 1.018 1.118 1.431 2.28h2.289c.412-1.158.53-1.905 1.437-2.282h.001c.894-.372 1.501.071 2.619.602l1.618-1.619c-.525-1.107-.974-1.723-.601-2.625.374-.899 1.126-1.019 2.282-1.43zm-8.5 1.689c-1.564 0-2.833-1.269-2.833-2.834s1.269-2.834 2.833-2.834 2.833 1.269 2.833 2.834-1.269 2.834-2.833 2.834zm15.5 4.205v-1.077c-.55-.196-.897-.251-1.073-.673-.176-.424.033-.711.282-1.236l-.762-.762c-.52.248-.811.458-1.235.283-.424-.175-.479-.525-.674-1.073h-1.076c-.194.545-.25.897-.674 1.073-.424.176-.711-.033-1.235-.283l-.762.762c.248.523.458.812.282 1.236-.176.424-.528.479-1.073.673v1.077c.544.193.897.25 1.073.673.177.427-.038.722-.282 1.236l.762.762c.521-.248.812-.458 1.235-.283.424.175.479.526.674 1.073h1.076c.194-.545.25-.897.676-1.074h.001c.421-.175.706.034 1.232.284l.762-.762c-.247-.521-.458-.812-.282-1.235s.529-.481 1.073-.674zm-4 .794c-.736 0-1.333-.597-1.333-1.333s.597-1.333 1.333-1.333 1.333.597 1.333 1.333-.597 1.333-1.333 1.333z"/></svg>
|
|
||||||
</div></a>
|
|
|
@ -1,11 +0,0 @@
|
||||||
<meta name="description" content='Maloja is a self-hosted music scrobble server.' />
|
|
||||||
<!--<link rel="stylesheet/less" href="/less/maloja.less" />
|
|
||||||
<link rel="stylesheet/less" href="/less/grisons.less" />
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="/css/maloja.css" />
|
|
||||||
<link rel="stylesheet" href="/css/grisons.css" />
|
|
||||||
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js" ></script> -->
|
|
||||||
<link rel="stylesheet" href="/style.css" />
|
|
||||||
<script src="/search.js"></script>
|
|
||||||
<script src="/neopolitan.js"></script>
|
|
||||||
<script src="/upload.js"></script>
|
|
|
@ -1,78 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - Compare</title>
|
|
||||||
<style>
|
|
||||||
.comparecircle {
|
|
||||||
height:500px;
|
|
||||||
width:500px;
|
|
||||||
border-radius:250px;
|
|
||||||
border: 1px solid rgba(245,245,220,0.3);
|
|
||||||
margin:auto;
|
|
||||||
margin-top:100px;
|
|
||||||
text-align:center;
|
|
||||||
line-height:500px;
|
|
||||||
font-size:60px;
|
|
||||||
color:black;
|
|
||||||
/* background-image: linear-gradient(to right,KEY_CIRCLE_CSS); */
|
|
||||||
background-image: radial-gradient(#KEY_CICLE_COLOR KEY_FULLMATCHpx, transparent KEY_PARTIALMATCHpx);
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr td:first-child {
|
|
||||||
text-align: left;
|
|
||||||
padding:10px;
|
|
||||||
width:33%;
|
|
||||||
}
|
|
||||||
table tr td {
|
|
||||||
text-align: center;
|
|
||||||
padding:10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table tr td:last-child {
|
|
||||||
text-align: right;
|
|
||||||
padding:10px;
|
|
||||||
width:33%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table style="width:99%;">
|
|
||||||
<tr>
|
|
||||||
<td><h1>KEY_NAME_SELF</h1></td>
|
|
||||||
<td>
|
|
||||||
|
|
||||||
<div class="comparecircle">
|
|
||||||
KEY_MATCH%
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><h1>KEY_NAME_OTHER</h1></td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td style="font-size:70%;color:grey;">
|
|
||||||
The size of the circle shows matching music taste.
|
|
||||||
The fuzziness of its border indicates differences in quantity.
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td>
|
|
||||||
<span>Common Favorite</span>
|
|
||||||
<h2 style="margin:7px;">KEY_BESTARTIST_LINK</h2>
|
|
||||||
<img src="KEY_BESTARTIST_IMAGE" style="width:80px;" />
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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])
|
|
||||||
},[]
|
|
|
@ -28,7 +28,7 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><span class='stats'></span> <span></span></td>
|
<td></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td><span class='stats'></span> <span></span></td>
|
<td></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - KEY_PULSEDETAILS Performance</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>KEY_PULSEDETAILS Performance</h1>KEY_PULSE_LINK<br/>
|
|
||||||
<span>KEY_LIMITS</span>
|
|
||||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
|
||||||
<br/><br/>
|
|
||||||
KEY_FILTERSELECTOR
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
KEY_PERFORMANCE_TABLE
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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 = "<a href=\"" + pulselink + "\"><span>View Pulse</span></a>"
|
|
||||||
|
|
||||||
|
|
||||||
# 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 += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
|
||||||
|
|
||||||
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)
|
|
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - KEY_PULSEDETAILS Pulse</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>KEY_PULSEDETAILS Pulse</h1>KEY_RANKINGS_LINK<br/>
|
|
||||||
<span>KEY_LIMITS</span>
|
|
||||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
|
||||||
<br/><br/>
|
|
||||||
KEY_FILTERSELECTOR
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
KEY_PULSE_TABLE
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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 = "<a href=\"" + performancelink + "\"><span>View Rankings</span></a>"
|
|
||||||
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 += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
|
||||||
|
|
||||||
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)
|
|
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - Scrobbles</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>Scrobbles</h1><br/>
|
|
||||||
<span>KEY_LIMITS</span><br/>
|
|
||||||
<p class="stats">KEY_SCROBBLES Scrobbles</p>
|
|
||||||
<br/>
|
|
||||||
KEY_FILTERSELECTOR
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
KEY_SCROBBLELIST
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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 += " <span class='extra'>including " + artistLinks(moreartists) + "</span>"
|
|
||||||
|
|
||||||
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)
|
|
Before Width: | Height: | Size: 866 B After Width: | Height: | Size: 866 B |
Before Width: | Height: | Size: 244 B After Width: | Height: | Size: 244 B |
Before Width: | Height: | Size: 239 B After Width: | Height: | Size: 239 B |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 240 B |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 81 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - #1 Artists</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('KEY_TOPARTIST_IMAGEURL')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>#1 Artists</h1><br/>
|
|
||||||
<span>KEY_LIMITS</span>
|
|
||||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
|
||||||
<br/><br/>
|
|
||||||
KEY_FILTERSELECTOR
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
KEY_ARTISTLIST
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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)
|
|
|
@ -1,29 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<title>Maloja - #1 Tracks</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<table class="top_info">
|
|
||||||
<tr>
|
|
||||||
<td class="image">
|
|
||||||
<div style="background-image:url('KEY_TOPTRACK_IMAGEURL')"></div>
|
|
||||||
</td>
|
|
||||||
<td class="text">
|
|
||||||
<h1>#1 Tracks</h1><br/>
|
|
||||||
<span>KEY_LIMITS</span>
|
|
||||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
|
||||||
<br/><br/>
|
|
||||||
KEY_FILTERSELECTOR
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
KEY_TRACKLIST
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -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)
|
|