mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Implemented pagination for jinja
This commit is contained in:
parent
7693ba3a20
commit
3e6bcc45d5
@ -5,7 +5,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,7,3
|
||||
version = 2,7,4
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
links = {
|
||||
"pypi":"malojaserver",
|
||||
|
@ -24,7 +24,6 @@ from . import globalconf
|
||||
from doreah import settings
|
||||
from doreah.logging import log
|
||||
from doreah.timing import Clock
|
||||
from doreah.pyhp import file as pyhpfile
|
||||
from doreah import auth
|
||||
# technical
|
||||
#from importlib.machinery import SourceFileLoader
|
||||
@ -241,11 +240,8 @@ def static_html(name):
|
||||
linkheaders = ["</style.css>; rel=preload; as=style"]
|
||||
keys = remove_identical(FormsDict.decode(request.query))
|
||||
|
||||
|
||||
pyhp_file = os.path.exists(pthjoin(WEBFOLDER,"pyhp",name + ".pyhp"))
|
||||
html_file = os.path.exists(pthjoin(WEBFOLDER,name + ".html"))
|
||||
jinja_file = os.path.exists(pthjoin(WEBFOLDER,"jinja",name + ".jinja"))
|
||||
pyhp_pref = settings.get_settings("USE_PYHP")
|
||||
jinja_pref = settings.get_settings("USE_JINJA")
|
||||
|
||||
adminmode = request.cookies.get("adminmode") == "true" and auth.check(request)
|
||||
@ -254,7 +250,7 @@ def static_html(name):
|
||||
clock.start()
|
||||
|
||||
# if a jinja file exists, use this
|
||||
if (jinja_file and jinja_pref) or (jinja_file and not html_file and not pyhp_file):
|
||||
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,
|
||||
@ -268,32 +264,6 @@ def static_html(name):
|
||||
log("Generated page {name} in {time:.5f}s (Jinja)".format(name=name,time=clock.stop()),module="debug")
|
||||
return res
|
||||
|
||||
# if a pyhp file exists, use this
|
||||
elif (pyhp_file and pyhp_pref) or (pyhp_file and not html_file):
|
||||
|
||||
#things we expose to the pyhp pages
|
||||
environ = {
|
||||
"adminmode":adminmode,
|
||||
"apikey":request.cookies.get("apikey") if adminmode else None,
|
||||
# maloja
|
||||
"db": database,
|
||||
"htmlmodules": htmlmodules,
|
||||
"htmlgenerators": htmlgenerators,
|
||||
"malojatime": malojatime,
|
||||
"utilities": utilities,
|
||||
"urihandler": urihandler,
|
||||
"settings": settings.get_settings,
|
||||
# external
|
||||
"urllib": urllib
|
||||
}
|
||||
# request
|
||||
environ["filterkeys"], environ["limitkeys"], environ["delimitkeys"], environ["amountkeys"] = uri_to_internal(keys)
|
||||
environ["_urikeys"] = keys #temporary!
|
||||
|
||||
#response.set_header("Content-Type","application/xhtml+xml")
|
||||
res = pyhpfile(pthjoin(WEBFOLDER,"pyhp",name + ".pyhp"),environ)
|
||||
log("Generated page {name} in {time:.5f}s (PYHP)".format(name=name,time=clock.stop()),module="debug")
|
||||
return res
|
||||
|
||||
# if not, use the old way
|
||||
else:
|
||||
|
@ -113,6 +113,12 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False):
|
||||
|
||||
return resultkeys1, resultkeys2, resultkeys3, resultkeys4
|
||||
|
||||
def compose_from_dicts(*dicts):
|
||||
return compose_querystring(internal_to_uri_p(*dicts))
|
||||
|
||||
def internal_to_uri_p(*dicts):
|
||||
return internal_to_uri({k:d[k] for d in dicts for k in d})
|
||||
|
||||
def internal_to_uri(keys):
|
||||
urikeys = FormsDict()
|
||||
|
||||
|
@ -1,74 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - KEY_ARTISTNAME</title>
|
||||
<script src="/cookies.js"></script>
|
||||
<script src="/rangeselect.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>KEY_ARTISTNAME</h1>
|
||||
<span class="rank"><a href="/charts_artists">KEY_POSITION</a></span>
|
||||
<br/>
|
||||
<span>KEY_ASSOCIATED</span>
|
||||
<p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_SCROBBLES Scrobbles</a></p>
|
||||
|
||||
<p class="desc">KEY_DESCRIPTION</p>
|
||||
<span>KEY_MEDALS</span> <span>KEY_TOPWEEKS</span> <span>KEY_CERTS</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><a href='/charts_tracks?artist=KEY_ENC_ARTISTNAME'>Top Tracks</a></h2>
|
||||
KEY_TRACKLIST
|
||||
|
||||
<table class="twopart">
|
||||
<tr>
|
||||
<td>
|
||||
<h2><a class="stat_link_pulse" href='/pulse?artist=KEY_ENC_ARTISTNAME&trail=1&step=month'>Pulse</a></h2>
|
||||
|
||||
|
||||
<span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
|
||||
| <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
|
||||
| <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
|
||||
| <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_pulse pulse_month">KEY_PULSE_MONTHS</span>
|
||||
<span class="stat_module_pulse pulse_day" style="display:none;">KEY_PULSE_DAYS</span>
|
||||
<span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEARS</span>
|
||||
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEKS</span>
|
||||
</td>
|
||||
<td>
|
||||
<!-- We use the same classes / function calls here because we want it to switch together with pulse -->
|
||||
<h2><a class="stat_link_pulse" href='/performance?artist=KEY_ENC_CREDITEDARTISTNAME&trail=1&step=month'>Performance</a></h2>
|
||||
<span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
|
||||
| <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
|
||||
| <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
|
||||
| <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_pulse pulse_month">KEY_PERFORMANCE_MONTHS</span>
|
||||
<span class="stat_module_pulse pulse_day" style="display:none;">KEY_PERFORMANCE_DAYS</span>
|
||||
<span class="stat_module_pulse pulse_year" style="display:none;">KEY_PERFORMANCE_YEARS</span>
|
||||
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PERFORMANCE_WEEKS</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h2><a href='/scrobbles?KEY_SCROBBLELINK'>Last Scrobbles</a></h2>
|
||||
KEY_SCROBBLELIST
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,110 +0,0 @@
|
||||
import urllib
|
||||
from .. import database
|
||||
from ..malojatime import today,thisweek,thismonth,thisyear
|
||||
|
||||
|
||||
def instructions(keys):
|
||||
from ..utilities import getArtistImage
|
||||
from ..htmlgenerators import artistLink, artistLinks, link_address
|
||||
from ..urihandler import compose_querystring, uri_to_internal
|
||||
from ..htmlmodules import module_pulse, module_performance, module_trackcharts, module_scrobblelist
|
||||
|
||||
filterkeys, _, _, _ = uri_to_internal(keys,forceArtist=True)
|
||||
artist = filterkeys.get("artist")
|
||||
imgurl = getArtistImage(filterkeys["artist"],fast=True)
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
data = database.artistInfo(filterkeys["artist"])
|
||||
scrobbles = str(data["scrobbles"])
|
||||
pos = "#" + str(data["position"])
|
||||
|
||||
html_medals = ""
|
||||
if "medals" in data and data["medals"] is not None:
|
||||
if "gold" in data["medals"]:
|
||||
for y in data["medals"]["gold"]:
|
||||
html_medals += "<a title='Best Artist in " + str(y) + "' class='hidelink medal shiny gold' href='/charts_artists?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
if "silver" in data["medals"]:
|
||||
for y in data["medals"]["silver"]:
|
||||
html_medals += "<a title='Second Best Artist in " + str(y) + "' class='hidelink medal shiny silver' href='/charts_artists?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
if "bronze" in data["medals"]:
|
||||
for y in data["medals"]["bronze"]:
|
||||
html_medals += "<a title='Third Best Artist in " + str(y) + "' class='hidelink medal shiny bronze' href='/charts_artists?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
|
||||
html_cert = ""
|
||||
for track in database.get_tracks(artist=artist):
|
||||
info = database.trackInfo(track)
|
||||
if info.get("certification") is not None:
|
||||
img = "/media/record_{cert}.png".format(cert=info["certification"])
|
||||
trackname = track["title"].replace("'","'")
|
||||
tracklink = link_address(track)
|
||||
tooltip = "{title} has reached {cert} status".format(title=trackname,cert=info["certification"].capitalize())
|
||||
html_cert += "<a href='{link}'><img class='certrecord_small' src='{img}' title='{tooltip}' /></a>".format(tooltip=tooltip,img=img,link=tracklink)
|
||||
|
||||
|
||||
html_topweeks = ""
|
||||
if data.get("topweeks") not in [0,None]:
|
||||
link = "/performance?artist=" + urllib.parse.quote(keys["artist"]) + "&trail=1&step=week"
|
||||
title = str(data["topweeks"]) + " weeks on #1"
|
||||
html_topweeks = "<a title='" + title + "' href='" + link + "'><img class='star' src='/media/star.png' />" + str(data["topweeks"]) + "</a>"
|
||||
|
||||
|
||||
credited = data.get("replace")
|
||||
includestr = " "
|
||||
if credited is not None:
|
||||
includestr = "Competing under " + artistLink(credited) + " (" + pos + ")"
|
||||
pos = ""
|
||||
else:
|
||||
credited = artist
|
||||
included = data.get("associated")
|
||||
if included is not None and included != []:
|
||||
includestr = "associated: "
|
||||
includestr += artistLinks(included)
|
||||
|
||||
|
||||
html_tracks, _ = module_trackcharts(**filterkeys,max_=15)
|
||||
|
||||
html_scrobbles, _, _ = module_scrobblelist(artist=artist,max_=10,earlystop=True)
|
||||
|
||||
# pulse and rankings
|
||||
html_pulse_days = module_pulse(**filterkeys,max_=7,since=today().next(-6),step="day",trail=1)
|
||||
html_pulse_weeks = module_pulse(**filterkeys,max_=12,since=thisweek().next(-11),step="week",trail=1)
|
||||
html_pulse_months = module_pulse(**filterkeys,max_=12,since=thismonth().next(-11),step="month",trail=1)
|
||||
html_pulse_years = module_pulse(**filterkeys,max_=10,since=thisyear().next(-9),step="year",trail=1)
|
||||
|
||||
html_performance_days = module_performance(artist=credited,max_=7,since=today().next(-6),step="day",trail=1)
|
||||
html_performance_weeks = module_performance(artist=credited,max_=12,since=thisweek().next(-11),step="week",trail=1)
|
||||
html_performance_months = module_performance(artist=credited,max_=12,since=thismonth().next(-11),step="month",trail=1)
|
||||
html_performance_years = module_performance(artist=credited,max_=10,since=thisyear().next(-9),step="year",trail=1)
|
||||
|
||||
replace = {
|
||||
# info
|
||||
"KEY_ARTISTNAME":keys["artist"],
|
||||
"KEY_ENC_ARTISTNAME":urllib.parse.quote(keys["artist"]),
|
||||
"KEY_ENC_CREDITEDARTISTNAME":urllib.parse.quote(credited),
|
||||
"KEY_IMAGEURL":imgurl,
|
||||
"KEY_DESCRIPTION":"",
|
||||
"KEY_SCROBBLES":scrobbles,
|
||||
"KEY_POSITION":pos,
|
||||
"KEY_ASSOCIATED":includestr,
|
||||
"KEY_MEDALS":html_medals,
|
||||
"KEY_CERTS":html_cert,
|
||||
"KEY_TOPWEEKS":html_topweeks,
|
||||
# tracks
|
||||
"KEY_TRACKLIST":html_tracks,
|
||||
# pulse
|
||||
"KEY_PULSE_MONTHS":html_pulse_months,
|
||||
"KEY_PULSE_YEARS":html_pulse_years,
|
||||
"KEY_PULSE_DAYS":html_pulse_days,
|
||||
"KEY_PULSE_WEEKS":html_pulse_weeks,
|
||||
# performance
|
||||
"KEY_PERFORMANCE_MONTHS":html_performance_months,
|
||||
"KEY_PERFORMANCE_YEARS":html_performance_years,
|
||||
"KEY_PERFORMANCE_DAYS":html_performance_days,
|
||||
"KEY_PERFORMANCE_WEEKS":html_performance_weeks,
|
||||
# scrobbles
|
||||
"KEY_SCROBBLELIST":html_scrobbles,
|
||||
"KEY_SCROBBLELINK":compose_querystring(keys),
|
||||
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
@ -1,34 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Artist Charts</title>
|
||||
<script src="/datechange.js" async></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
KEY_TOPARTIST_IMAGEDIV
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Artist Charts</h1><a href="/top_artists"><span>View #1 Artists</span></a><br/>
|
||||
<span>KEY_RANGE</span>
|
||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||
<br/><br/>
|
||||
KEY_FILTERSELECTOR
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<span class="stat_module_topartists">
|
||||
KEY_ARTISTCHART
|
||||
</span>
|
||||
|
||||
KEY_ARTISTLIST
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,47 +0,0 @@
|
||||
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)
|
||||
|
||||
|
||||
|
||||
|
||||
html_charts, rep = module_artistcharts(**amountkeys,**timekeys)
|
||||
|
||||
if rep is not None:
|
||||
imgurl = getArtistImage(rep)
|
||||
else:
|
||||
imgurl = ""
|
||||
|
||||
html_tiles = ""
|
||||
if get_settings("CHARTS_DISPLAY_TILES"):
|
||||
html_tiles = module_artistcharts_tiles(timerange=timekeys["timerange"])
|
||||
imgurl = "favicon.png"
|
||||
|
||||
imgdiv = '<div style="background-image:url('+imgurl+')"></div>'
|
||||
|
||||
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
|
||||
replace = {
|
||||
"KEY_TOPARTIST_IMAGEDIV":imgdiv,
|
||||
"KEY_ARTISTCHART":html_tiles,
|
||||
"KEY_ARTISTLIST":html_charts,
|
||||
"KEY_RANGE":limitstring,
|
||||
"KEY_FILTERSELECTOR":html_filterselector
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Track Charts</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
KEY_TOPARTIST_IMAGEDIV
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Track Charts</h1>TOP_TRACKS_LINK<br/>
|
||||
<span>KEY_LIMITS</span>
|
||||
<!--<p class="stats">KEY_SCROBBLES Scrobbles</p>-->
|
||||
<br/><br/>
|
||||
KEY_FILTERSELECTOR
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<span class="stat_module_topartists">
|
||||
KEY_TRACKCHART
|
||||
</span>
|
||||
|
||||
KEY_TRACKLIST
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,62 +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_trackcharts, module_filterselection, module_trackcharts_tiles
|
||||
from ..malojatime import range_desc
|
||||
from doreah.settings import get_settings
|
||||
|
||||
filterkeys, timekeys, _, amountkeys = uri_to_internal(keys)
|
||||
|
||||
if len(filterkeys) == 0:
|
||||
toptrackslink = "<a href='/top_tracks'><span>View #1 Tracks</span></a>"
|
||||
else:
|
||||
toptrackslink = ""
|
||||
|
||||
|
||||
limitstring = ""
|
||||
|
||||
html_filterselector = module_filterselection(keys)
|
||||
|
||||
html_charts, rep = module_trackcharts(**amountkeys,**timekeys,**filterkeys)
|
||||
|
||||
|
||||
|
||||
html_tiles = ""
|
||||
|
||||
if filterkeys.get("artist") is not None:
|
||||
imgurl = getArtistImage(filterkeys.get("artist"))
|
||||
limitstring = "by " + artistLink(filterkeys.get("artist"))
|
||||
elif rep is not None:
|
||||
imgurl = getTrackImage(rep["artists"],rep["title"])
|
||||
else:
|
||||
imgurl = ""
|
||||
|
||||
html_tiles = ""
|
||||
if get_settings("CHARTS_DISPLAY_TILES"):
|
||||
html_tiles = module_trackcharts_tiles(timerange=timekeys["timerange"])
|
||||
imgurl = "favicon.png"
|
||||
|
||||
imgdiv = '<div style="background-image:url('+imgurl+')"></div>'
|
||||
|
||||
|
||||
|
||||
limitstring += " " + timekeys["timerange"].desc(prefix=True)
|
||||
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
|
||||
|
||||
replace = {
|
||||
"KEY_TOPARTIST_IMAGEDIV":imgdiv,
|
||||
"KEY_TRACKCHART":html_tiles,
|
||||
"KEY_TRACKLIST":html_charts,
|
||||
"KEY_LIMITS":limitstring,
|
||||
"KEY_FILTERSELECTOR":html_filterselector,
|
||||
"TOP_TRACKS_LINK":toptrackslink,
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
@ -6,6 +6,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% set charts = dbp.get_charts_artists(filterkeys,limitkeys) %}
|
||||
{% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %}
|
||||
{% if charts[0] is defined %}
|
||||
{% set topartist = charts[0].artist %}
|
||||
{% set img = utilities.getArtistImage(artist=topartist,fast=True) %}
|
||||
@ -37,5 +38,8 @@
|
||||
|
||||
{{ charts_artists.charts_artists(limitkeys,amountkeys,compare=False) }}
|
||||
|
||||
{% import 'snippets/pagination.jinja' as pagination %}
|
||||
|
||||
{{ pagination.pagination(filterkeys,limitkeys,delimitkeys,amountkeys,pages) }}
|
||||
|
||||
{% endblock %}
|
||||
|
@ -6,6 +6,7 @@
|
||||
{% endblock %}
|
||||
|
||||
{% set charts = dbp.get_charts_tracks(filterkeys,limitkeys) %}
|
||||
{% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %}
|
||||
{% if charts[0] is defined %}
|
||||
{% set toptrack = charts[0].track %}
|
||||
{% set img = utilities.getTrackImage(artists=toptrack.artists,title=toptrack.title,fast=True) %}
|
||||
@ -37,5 +38,8 @@
|
||||
|
||||
{{ charts_tracks.charts_tracks(filterkeys,limitkeys,amountkeys,charts=charts,compare=false) }}
|
||||
|
||||
{% import 'snippets/pagination.jinja' as pagination %}
|
||||
|
||||
{{ pagination.pagination(filterkeys,limitkeys,delimitkeys,amountkeys,pages) }}
|
||||
|
||||
{% endblock %}
|
||||
|
50
maloja/web/jinja/snippets/pagination.jinja
Normal file
50
maloja/web/jinja/snippets/pagination.jinja
Normal file
@ -0,0 +1,50 @@
|
||||
{% macro pagination(filterkeys,limitkeys,delimitkeys,amountkeys,pages=1) %}
|
||||
|
||||
{% set page = amountkeys.page %}
|
||||
|
||||
|
||||
|
||||
|
||||
<div class='paginate'>
|
||||
|
||||
{% if pages > 1 %}
|
||||
{% if page > 1 %}
|
||||
<a href='?{{ urihandler.compose_from_dicts(filterkeys,limitkeys,delimitkeys,amountkeys,{'page':0}) }}'>
|
||||
<span class='stat_selector'>1</span>
|
||||
</a> |
|
||||
{% endif %}
|
||||
|
||||
{% if page > 2 %}
|
||||
... |
|
||||
{% endif %}
|
||||
|
||||
{% if page > 0 %}
|
||||
<a href='?{{ urihandler.compose_from_dicts(filterkeys,limitkeys,delimitkeys,amountkeys,{'page':page-1}) }}'>
|
||||
<span class='stat_selector'>{{ page }}</span>
|
||||
</a> «
|
||||
{% endif %}
|
||||
|
||||
<span style='opacity:0.5;' class='stat_selector'>
|
||||
{{ page + 1 }}
|
||||
</span>
|
||||
|
||||
{% if page < pages-1 %}
|
||||
» <a href='?{{ urihandler.compose_from_dicts(filterkeys,limitkeys,delimitkeys,amountkeys,{'page':page+1}) }}'>
|
||||
<span class='stat_selector'>{{ page+2 }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{% if page < pages-3 %}
|
||||
| ...
|
||||
{% endif %}
|
||||
|
||||
{% if page < pages-2 %}
|
||||
| <a href='?{{ urihandler.compose_from_dicts(filterkeys,limitkeys,delimitkeys,amountkeys,{'page':pages-1}) }}'>
|
||||
<span class='stat_selector'>{{ pages }}</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% endmacro %}
|
41
maloja/web/jinja/wait.jinja
Normal file
41
maloja/web/jinja/wait.jinja
Normal file
@ -0,0 +1,41 @@
|
||||
{% extends "abstracts/base.jinja" %}
|
||||
{% block title %}Maloja - Please wait...{% endblock %}
|
||||
|
||||
{% block heading %}Redbuilding the database{% endblock %}
|
||||
|
||||
{% block top_info %}
|
||||
Please wait...
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
var pending = false;
|
||||
setInterval(probeServer,1500);
|
||||
|
||||
function probeServer() {
|
||||
if (!pending) {
|
||||
console.log("Probing...");
|
||||
pending = true;
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET","/api/test", true);
|
||||
xhttp.onreadystatechange = goback;
|
||||
xhttp.send();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function goback() {
|
||||
if ((this.readyState == 4) && (this.status == 205)) {
|
||||
console.log("Not ready yet!")
|
||||
pending = false;
|
||||
}
|
||||
if ((this.readyState == 4) && (this.status == 204)) {
|
||||
console.log("K");
|
||||
pending = false;
|
||||
window.location = "/issues";
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Artist Charts</title>
|
||||
<script src="/datechange.js" async></script>
|
||||
|
||||
<pyhp include="common/header.html" />
|
||||
</head>
|
||||
|
||||
<pyhp>
|
||||
try:
|
||||
top = db.get_charts_artists(**filterkeys,**limitkeys)[0]["artist"]
|
||||
img = utilities.getArtistImage(top)
|
||||
except:
|
||||
img = ""
|
||||
</pyhp>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('{img}')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Artist Charts</h1><a href="/top_artists"><span>View #1 Artists</span></a><br/>
|
||||
<span><pyhp echo="limitkeys['timerange'].desc(prefix=True)" /></span>
|
||||
<br/><br/>
|
||||
<pyhp echo="htmlmodules.module_filterselection(_urikeys)" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<span class="stat_module_topartists">
|
||||
<pyhp if="settings('CHARTS_DISPLAY_TILES')">
|
||||
<pyhp include="partial/charts_artists_tiles.pyhp" />
|
||||
</pyhp>
|
||||
|
||||
</span>
|
||||
|
||||
<pyhp include="partial/charts_artists.pyhp" />
|
||||
|
||||
<pyhp include="common/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Track Charts</title>
|
||||
<script src="/datechange.js" async></script>
|
||||
|
||||
<pyhp include="common/header.html" />
|
||||
</head>
|
||||
|
||||
<pyhp>
|
||||
try:
|
||||
try:
|
||||
img = utilities.getArtistImage(filterkeys['artist'])
|
||||
except:
|
||||
top = db.get_charts_tracks(**filterkeys,**limitkeys)[0]["track"]
|
||||
img = utilities.getTrackImage(**top)
|
||||
except:
|
||||
img = ""
|
||||
</pyhp>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('{img}')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Track Charts</h1><a href="/top_tracks"><span>View #1 Tracks</span></a><br/>
|
||||
<span>
|
||||
<pyhp if="filterkeys.get('artist') is not None">by <pyhp echo="htmlgenerators.artistLink(filterkeys.get('artist'))" /></pyhp>
|
||||
<pyhp echo="limitkeys['timerange'].desc(prefix=True)" />
|
||||
</span>
|
||||
<br/><br/>
|
||||
<pyhp echo="htmlmodules.module_filterselection(_urikeys)" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<span class="stat_module_toptracks">
|
||||
<pyhp if="settings('CHARTS_DISPLAY_TILES')">
|
||||
<pyhp include="partial/charts_tracks_tiles.pyhp" />
|
||||
</pyhp>
|
||||
|
||||
</span>
|
||||
|
||||
<pyhp include="partial/charts_tracks.pyhp" />
|
||||
|
||||
<pyhp include="common/footer.html" />
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,70 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - KEY_TRACKTITLE</title>
|
||||
<script src="/cookies.js" ></script>
|
||||
<script src="/rangeselect.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('KEY_IMAGEURL')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<span>KEY_ARTISTS</span><br/>
|
||||
<h1>KEY_TRACKTITLE</h1> KEY_CERTS <span class="rank"><a href="/charts_tracks">KEY_POSITION</a></span>
|
||||
|
||||
<p class="stats"><a href="/scrobbles?KEY_SCROBBLELINK">KEY_SCROBBLES Scrobbles</a></p>
|
||||
|
||||
<p class="desc"></p>
|
||||
<span>KEY_MEDALS</span> <span>KEY_TOPWEEKS</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<table class="twopart">
|
||||
<tr>
|
||||
<td>
|
||||
<h2><a class="stat_link_pulse" href='/pulse?KEY_SCROBBLELINK&trail=1&step=month'>Pulse</a></h2>
|
||||
<span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
|
||||
| <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
|
||||
| <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
|
||||
| <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_pulse pulse_month">KEY_PULSE_MONTHS</span>
|
||||
<span class="stat_module_pulse pulse_day" style="display:none;">KEY_PULSE_DAYS</span>
|
||||
<span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEARS</span>
|
||||
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEKS</span>
|
||||
</td>
|
||||
<td>
|
||||
<h2><a class="stat_link_pulse" href='/performance?KEY_SCROBBLELINK&trail=1&step=month'>Performance</a></h2>
|
||||
<span onclick="showRangeManual('pulse','day')" class="stat_selector_pulse selector_pulse_day">7 days</span>
|
||||
| <span onclick="showRangeManual('pulse','week')" class="stat_selector_pulse selector_pulse_week">12 weeks</span>
|
||||
| <span onclick="showRangeManual('pulse','month')" class="stat_selector_pulse selector_pulse_month" style="opacity:0.5;">12 months</span>
|
||||
| <span onclick="showRangeManual('pulse','year')" class="stat_selector_pulse selector_pulse_year">10 years</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_pulse pulse_month">KEY_PERFORMANCE_MONTHS</span>
|
||||
<span class="stat_module_pulse pulse_day" style="display:none;">KEY_PERFORMANCE_DAYS</span>
|
||||
<span class="stat_module_pulse pulse_year" style="display:none;">KEY_PERFORMANCE_YEARS</span>
|
||||
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PERFORMANCE_WEEKS</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h2><a href='/scrobbles?KEY_SCROBBLELINK'>Last Scrobbles</a></h2>
|
||||
KEY_SCROBBLELIST
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,88 +0,0 @@
|
||||
import urllib
|
||||
from .. import database
|
||||
from ..malojatime import today,thisweek,thismonth,thisyear
|
||||
|
||||
|
||||
def instructions(keys):
|
||||
from ..utilities import getArtistImage, getTrackImage
|
||||
from ..htmlgenerators import artistLinks
|
||||
from ..urihandler import compose_querystring, uri_to_internal
|
||||
from ..htmlmodules import module_scrobblelist, module_pulse, module_performance
|
||||
|
||||
|
||||
filterkeys, _, _, _ = uri_to_internal(keys,forceTrack=True)
|
||||
|
||||
track = filterkeys.get("track")
|
||||
imgurl = getTrackImage(track["artists"],track["title"],fast=True)
|
||||
pushresources = [{"file":imgurl,"type":"image"}] if imgurl.startswith("/") else []
|
||||
|
||||
data = database.trackInfo(track)
|
||||
|
||||
scrobblesnum = str(data["scrobbles"])
|
||||
pos = "#" + str(data["position"])
|
||||
|
||||
html_cert = ""
|
||||
if data["certification"] is not None:
|
||||
html_cert = "<img class='certrecord' src='/media/record_{cert}.png' title='This track has reached {certc} status' />".format(cert=data["certification"],certc=data["certification"].capitalize())
|
||||
|
||||
html_medals = ""
|
||||
if "medals" in data and data["medals"] is not None:
|
||||
if "gold" in data["medals"]:
|
||||
for y in data["medals"]["gold"]:
|
||||
html_medals += "<a title='Best Track in " + str(y) + "' class='hidelink medal shiny gold' href='/charts_tracks?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
if "silver" in data["medals"]:
|
||||
for y in data["medals"]["silver"]:
|
||||
html_medals += "<a title='Second Best Track in " + str(y) + "' class='hidelink medal shiny silver' href='/charts_tracks?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
if "bronze" in data["medals"]:
|
||||
for y in data["medals"]["bronze"]:
|
||||
html_medals += "<a title='Third Best Track in " + str(y) + "' class='hidelink medal shiny bronze' href='/charts_tracks?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
|
||||
|
||||
html_topweeks = ""
|
||||
if data.get("topweeks") not in [0,None]:
|
||||
link = "/performance?" + compose_querystring(keys) + "&trail=1&step=week"
|
||||
title = str(data["topweeks"]) + " weeks on #1"
|
||||
html_topweeks = "<a title='" + title + "' href='" + link + "'><img class='star' src='/media/star.png' />" + str(data["topweeks"]) + "</a>"
|
||||
|
||||
|
||||
|
||||
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=10,earlystop=True) # we have the number already from the trackinfo
|
||||
|
||||
html_pulse = module_pulse(track=track,step="year",stepn=1,trail=1)
|
||||
html_performance = module_performance(track=track,step="year",stepn=1,trail=1)
|
||||
|
||||
# pulse and rankings
|
||||
html_pulse_days = module_pulse(track=track,max_=7,since=today().next(-6),step="day",trail=1)
|
||||
html_pulse_weeks = module_pulse(track=track,max_=12,since=thisweek().next(-11),step="week",trail=1)
|
||||
html_pulse_months = module_pulse(track=track,max_=12,since=thismonth().next(-11),step="month",trail=1)
|
||||
html_pulse_years = module_pulse(track=track,max_=10,since=thisyear().next(-9),step="year",trail=1)
|
||||
|
||||
html_performance_days = module_performance(track=track,max_=7,since=today().next(-6),step="day",trail=1)
|
||||
html_performance_weeks = module_performance(track=track,max_=12,since=thisweek().next(-11),step="week",trail=1)
|
||||
html_performance_months = module_performance(track=track,max_=12,since=thismonth().next(-11),step="month",trail=1)
|
||||
html_performance_years = module_performance(track=track,max_=10,since=thisyear().next(-9),step="year",trail=1)
|
||||
|
||||
|
||||
replace = {
|
||||
"KEY_TRACKTITLE":track.get("title"),
|
||||
"KEY_ARTISTS":artistLinks(track.get("artists")),
|
||||
"KEY_SCROBBLES":scrobblesnum,
|
||||
"KEY_POSITION":pos,
|
||||
"KEY_IMAGEURL":imgurl,
|
||||
"KEY_SCROBBLELINK":compose_querystring(keys),
|
||||
"KEY_MEDALS":html_medals,
|
||||
"KEY_CERTS":html_cert,
|
||||
"KEY_TOPWEEKS":html_topweeks,
|
||||
"KEY_SCROBBLELIST":html_scrobbles,
|
||||
# pulse
|
||||
"KEY_PULSE_MONTHS":html_pulse_months,
|
||||
"KEY_PULSE_YEARS":html_pulse_years,
|
||||
"KEY_PULSE_DAYS":html_pulse_days,
|
||||
"KEY_PULSE_WEEKS":html_pulse_weeks,
|
||||
# performance
|
||||
"KEY_PERFORMANCE_MONTHS":html_performance_months,
|
||||
"KEY_PERFORMANCE_YEARS":html_performance_years,
|
||||
"KEY_PERFORMANCE_DAYS":html_performance_days,
|
||||
"KEY_PERFORMANCE_WEEKS":html_performance_weeks,
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
@ -1,55 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Please wait</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
|
||||
<td class="text">
|
||||
<h1>Maloja</h1><br/>
|
||||
<span>Redbuilding the database</span>
|
||||
|
||||
<p>Please wait...</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var pending = false;
|
||||
setInterval(probeServer,1500);
|
||||
|
||||
function probeServer() {
|
||||
if (!pending) {
|
||||
console.log("Probing...");
|
||||
pending = true;
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET","/api/test", true);
|
||||
xhttp.onreadystatechange = goback;
|
||||
xhttp.send();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function goback() {
|
||||
if ((this.readyState == 4) && (this.status == 205)) {
|
||||
console.log("Not ready yet!")
|
||||
pending = false;
|
||||
}
|
||||
if ((this.readyState == 4) && (this.status == 204)) {
|
||||
console.log("K");
|
||||
pending = false;
|
||||
window.location = "/issues";
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user