mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Implemented start page in jinja
This commit is contained in:
parent
bc5f11d499
commit
7fc879f778
@ -5,7 +5,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,7,9
|
||||
version = 2,7,10
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
links = {
|
||||
"pypi":"malojaserver",
|
||||
|
@ -212,10 +212,17 @@ JINJA_CONTEXT = {
|
||||
('year','10 years',malojatime.thisyear().next(-9),'year',12)
|
||||
],
|
||||
"xranges": [
|
||||
{"identifier":"day","localisation":"14 days","firstrange":malojatime.today().next(-13),"amount":14},
|
||||
{"identifier":"week","localisation":"14 weeks","firstrange":malojatime.thisweek().next(-13),"amount":14},
|
||||
{"identifier":"month","localisation":"14 months","firstrange":malojatime.thismonth().next(-13),"amount":14},
|
||||
{"identifier":"year","localisation":"14 years","firstrange":malojatime.thisyear().next(-13),"amount":14}
|
||||
{"identifier":"day","localisation":"12 days","firstrange":malojatime.today().next(-11),"amount":12},
|
||||
{"identifier":"week","localisation":"12 weeks","firstrange":malojatime.thisweek().next(-11),"amount":12},
|
||||
{"identifier":"month","localisation":"12 months","firstrange":malojatime.thismonth().next(-11),"amount":12},
|
||||
{"identifier":"year","localisation":"12 years","firstrange":malojatime.thisyear().next(-11),"amount":12}
|
||||
],
|
||||
"xcurrent": [
|
||||
{"identifier":"day","localisation":"Today","range":malojatime.today()},
|
||||
{"identifier":"week","localisation":"This Week","range":malojatime.thisweek()},
|
||||
{"identifier":"month","localisation":"This Month","range":malojatime.thismonth()},
|
||||
{"identifier":"year","localisation":"This Year","range":malojatime.thisyear()},
|
||||
{"identifier":"alltime","localisation":"All Time","range":malojatime.alltime()},
|
||||
]
|
||||
}
|
||||
|
||||
|
105
maloja/web/jinja/start.jinja
Normal file
105
maloja/web/jinja/start.jinja
Normal file
@ -0,0 +1,105 @@
|
||||
{% extends "abstracts/base.jinja" %}
|
||||
{% block title %}Maloja{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
|
||||
<script>document.addEventListener('DOMContentLoaded',function() {
|
||||
showRange('topartists','{{ settings("DEFAULT_RANGE_CHARTS_ARTISTS") }}');
|
||||
showRange('toptracks','{{ settings("DEFAULT_RANGE_CHARTS_TRACKS") }}');
|
||||
showRange('pulse','{{ settings("DEFAULT_STEP_PULSE") }}');
|
||||
})</script>
|
||||
<script src="/rangeselect.js"></script>
|
||||
<script src="/cookies.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<!-- ARTIST CHARTS -->
|
||||
<h1><a class="stat_link_topartists" href="/charts_artists?in=alltime">Top Artists</a></h1>
|
||||
|
||||
{% for range in xcurrent %}
|
||||
<span onclick="showRangeManual('topartists','{{ range.identifier }}')" class="stat_selector_topartists selector_topartists_{{ range.identifier }}">
|
||||
{{ range.localisation }}
|
||||
</span>
|
||||
{{ "|" if not loop.last }}
|
||||
{% endfor %}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
{% import 'partials/charts_artists_tiles.jinja' as cha %}
|
||||
|
||||
{% for range in xcurrent %}
|
||||
<span class="stat_module_topartists topartists_{{ range.identifier }}" style="display:none;">
|
||||
{{ cha.charts_artists_tiles({"timerange":range.range}) }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- TRACK CHARTS -->
|
||||
<h1><a class="stat_link_toptracks" href="/charts_tracks?in=alltime">Top Tracks</a></h1>
|
||||
|
||||
{% for range in xcurrent %}
|
||||
<span onclick="showRangeManual('toptracks','{{ range.identifier }}')" class="stat_selector_toptracks selector_toptracks_{{ range.identifier }}">
|
||||
{{ range.localisation }}
|
||||
</span>
|
||||
{{ "|" if not loop.last }}
|
||||
{% endfor %}
|
||||
|
||||
<br/><br/>
|
||||
|
||||
{% import 'partials/charts_tracks_tiles.jinja' as cht %}
|
||||
|
||||
{% for range in xcurrent %}
|
||||
<span class="stat_module_toptracks toptracks_{{ range.identifier }}" style="display:none;">
|
||||
{{ cht.charts_tracks_tiles({},{"timerange":range.range}) }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="sidelist">
|
||||
<!-- SCROBBLES -->
|
||||
{% import 'partials/scrobbles.jinja' as scr %}
|
||||
|
||||
<h1><a href="/scrobbles">Last Scrobbles</a></h1>
|
||||
|
||||
{% for range in xcurrent %}
|
||||
<span class="stats">{{ range.localisation }}</span>
|
||||
<a href='/scrobbles?in={{ range.identifier }}'>{{ db.get_scrobbles_num(timerange=range.range) }}</a>
|
||||
{% endfor %}
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module">
|
||||
|
||||
|
||||
{{ scr.scrobbles({},{},{"perpage":15,"page":0},shortTimeDesc=True) }}
|
||||
</span>
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- PULSE -->
|
||||
{% import 'partials/pulse.jinja' as pls %}
|
||||
<h1><a class="stat_link_pulse" href="/pulse?trail=1&step=month">Pulse</a></h1>
|
||||
|
||||
{% for range in xranges %}
|
||||
<span onclick="showRangeManual('pulse','{{ range.identifier }}')" class="stat_selector_pulse selector_pulse_{{ range.identifier }}">{{ range.localisation }}</span>
|
||||
{{ "|" if not loop.last }}
|
||||
{% endfor %}
|
||||
<br/><br/>
|
||||
|
||||
{% for range in xranges %}
|
||||
<span class="stat_module_pulse pulse_{{ range.identifier }}" style="display:none;">
|
||||
{{ pls.pulse({},{"since":range.firstrange},{"step":range.identifier},{}) }}
|
||||
</span>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -1,114 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja</title>
|
||||
|
||||
<script>document.addEventListener('DOMContentLoaded',function() {
|
||||
KEY_JS_INIT_RANGES
|
||||
})</script>
|
||||
<script src="/cookies.js"></script>
|
||||
<script src="/rangeselect.js"></script>
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<!--<div class="header"><h1>Maloja</h1>
|
||||
</div>-->
|
||||
|
||||
|
||||
<h1><a class="stat_link_topartists" href="/charts_artists?in=alltime">Top Artists</a></h1>
|
||||
<!--All Time | This Year | This Month | This Week-->
|
||||
|
||||
|
||||
|
||||
<span onclick="showRangeManual('topartists','week')" class="stat_selector_topartists selector_topartists_week">This Week</span>
|
||||
| <span onclick="showRangeManual('topartists','month')" class="stat_selector_topartists selector_topartists_month">This Month</span>
|
||||
| <span onclick="showRangeManual('topartists','year')" class="stat_selector_topartists selector_topartists_year">This Year</span>
|
||||
| <span onclick="showRangeManual('topartists','alltime')" class="stat_selector_topartists selector_topartists_alltime" style="opacity:0.5;">All Time</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_topartists topartists_week" style="display:none;">KEY_TOPARTISTS_WEEK</span>
|
||||
<span class="stat_module_topartists topartists_month" style="display:none;">KEY_TOPARTISTS_MONTH</span>
|
||||
<span class="stat_module_topartists topartists_year" style="display:none;">KEY_TOPARTISTS_YEAR</span>
|
||||
<span class="stat_module_topartists topartists_alltime">KEY_TOPARTISTS_TOTAL</span>
|
||||
|
||||
|
||||
|
||||
|
||||
<h1><a class="stat_link_toptracks" href="/charts_tracks?in=alltime">Top Tracks</a></h1>
|
||||
|
||||
|
||||
<span onclick="showRangeManual('toptracks','week')" class="stat_selector_toptracks selector_toptracks_week">This Week</span>
|
||||
| <span onclick="showRangeManual('toptracks','month')" class="stat_selector_toptracks selector_toptracks_month">This Month</span>
|
||||
| <span onclick="showRangeManual('toptracks','year')" class="stat_selector_toptracks selector_toptracks_year">This Year</span>
|
||||
| <span onclick="showRangeManual('toptracks','alltime')" class="stat_selector_toptracks selector_toptracks_alltime" style="opacity:0.5;">All Time</span>
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module_toptracks toptracks_week" style="display:none;">KEY_TOPTRACKS_WEEK</span>
|
||||
<span class="stat_module_toptracks toptracks_month" style="display:none;">KEY_TOPTRACKS_MONTH</span>
|
||||
<span class="stat_module_toptracks toptracks_year" style="display:none;">KEY_TOPTRACKS_YEAR</span>
|
||||
<span class="stat_module_toptracks toptracks_alltime">KEY_TOPTRACKS_TOTAL</span>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="sidelist">
|
||||
<h1><a href="/scrobbles">Last Scrobbles</a></h1>
|
||||
<span class="stats">Today</span> KEY_SCROBBLE_NUM_TODAY
|
||||
<span class="stats">This Week</span> KEY_SCROBBLE_NUM_WEEK
|
||||
<span class="stats">This Month</span> KEY_SCROBBLE_NUM_MONTH
|
||||
<span class="stats">This Year</span> KEY_SCROBBLE_NUM_YEAR
|
||||
<span class="stats">All Time</span> KEY_SCROBBLE_NUM_TOTAL
|
||||
<br/><br/>
|
||||
|
||||
<span class="stat_module">KEY_SCROBBLES</span>
|
||||
|
||||
|
||||
<br/>
|
||||
|
||||
|
||||
<h1><a class="stat_link_pulse" href="/pulse?trail=1&step=month">Pulse</a></h1>
|
||||
<!--
|
||||
<a href="/pulse?step=day&trail=1">Days</a>
|
||||
<a href="/pulse?step=week&trail=1">Weeks</a>
|
||||
<a href="/pulse?step=month&trail=1">Months</a>
|
||||
<a href="/pulse?step=year&trail=1">Years</a>
|
||||
-->
|
||||
|
||||
<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>
|
||||
<!--
|
||||
### this is for extra views of the current canonical week / month / year
|
||||
<br/>
|
||||
<span onclick="showRange('pulse','week')" class="stat_selector_pulse selector_pulse_week">This Week</span>
|
||||
| <span onclick="showRange('pulse','month')" class="stat_selector_pulse selector_pulse_month">This Month</span>
|
||||
| <span onclick="showRange('pulse','year')" class="stat_selector_pulse selector_pulse_year"">This Year</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>
|
||||
<!--
|
||||
<span class="stat_module_pulse pulse_week" style="display:none;">KEY_PULSE_WEEK</span>
|
||||
<span class="stat_module_pulse pulse_month" style="display:none;">KEY_PULSE_MONTH</span>
|
||||
<span class="stat_module_pulse pulse_year" style="display:none;">KEY_PULSE_YEAR</span>
|
||||
-->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,96 +0,0 @@
|
||||
import urllib
|
||||
from datetime import datetime, timedelta
|
||||
from .. import database
|
||||
from doreah.timing import clock, clockp
|
||||
from doreah.settings import get_settings
|
||||
|
||||
from ..htmlmodules import module_scrobblelist, module_pulse, module_artistcharts_tiles, module_trackcharts_tiles
|
||||
|
||||
|
||||
def instructions(keys):
|
||||
|
||||
# commands to execute on load for default ranges
|
||||
js_command = "showRange('topartists','" + get_settings("DEFAULT_RANGE_CHARTS_ARTISTS") + "');"
|
||||
js_command += "showRange('toptracks','" + get_settings("DEFAULT_RANGE_CHARTS_TRACKS") + "');"
|
||||
js_command += "showRange('pulse','" + get_settings("DEFAULT_STEP_PULSE") + "');"
|
||||
|
||||
|
||||
#clock()
|
||||
|
||||
from ..malojatime import today,thisweek,thismonth,thisyear
|
||||
|
||||
# artists
|
||||
|
||||
topartists_total = module_artistcharts_tiles()
|
||||
topartists_year = module_artistcharts_tiles(timerange=thisyear())
|
||||
topartists_month = module_artistcharts_tiles(timerange=thismonth())
|
||||
topartists_week = module_artistcharts_tiles(timerange=thisweek())
|
||||
|
||||
#clockp("Artists")
|
||||
|
||||
# tracks
|
||||
|
||||
toptracks_total = module_trackcharts_tiles()
|
||||
toptracks_year = module_trackcharts_tiles(timerange=thisyear())
|
||||
toptracks_month = module_trackcharts_tiles(timerange=thismonth())
|
||||
toptracks_week = module_trackcharts_tiles(timerange=thisweek())
|
||||
|
||||
|
||||
#clockp("Tracks")
|
||||
|
||||
|
||||
|
||||
|
||||
# scrobbles
|
||||
html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True,earlystop=True)
|
||||
|
||||
#clockp("Scrobbles")
|
||||
|
||||
# stats
|
||||
|
||||
amount_day = database.get_scrobbles_num(timerange=today())
|
||||
scrobbles_today = "<a href='/scrobbles?in=today'>" + str(amount_day) + "</a>"
|
||||
|
||||
amount_week = database.get_scrobbles_num(timerange=thisweek())
|
||||
scrobbles_week = "<a href='/scrobbles?in=week'>" + str(amount_week) + "</a>"
|
||||
|
||||
amount_month = database.get_scrobbles_num(timerange=thismonth())
|
||||
scrobbles_month = "<a href='/scrobbles?in=month'>" + str(amount_month) + "</a>"
|
||||
|
||||
amount_year = database.get_scrobbles_num(timerange=thisyear())
|
||||
scrobbles_year = "<a href='/scrobbles?in=year'>" + str(amount_year) + "</a>"
|
||||
|
||||
amount_total = database.get_scrobbles_num()
|
||||
scrobbles_total = "<a href='/scrobbles'>" + str(amount_total) + "</a>"
|
||||
|
||||
#clockp("Amounts")
|
||||
|
||||
# pulse
|
||||
|
||||
|
||||
html_pulse_days = module_pulse(max_=7,since=today().next(-6),step="day",trail=1)
|
||||
html_pulse_weeks = module_pulse(max_=12,since=thisweek().next(-11),step="week",trail=1)
|
||||
html_pulse_months = module_pulse(max_=12,since=thismonth().next(-11),step="month",trail=1)
|
||||
html_pulse_years = module_pulse(max_=10,since=thisyear().next(-9),step="year",trail=1)
|
||||
|
||||
|
||||
#html_pulse_week = module_pulse(max_=7,since=weekstart,step="day",trail=1)
|
||||
#html_pulse_month = module_pulse(max_=30,since=[dt.year,dt.month],step="day",trail=1)
|
||||
#html_pulse_year = module_pulse(max_=12,since=[dt.year],step="month",trail=1)
|
||||
|
||||
#clockp("Pulse")
|
||||
|
||||
#pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that
|
||||
pushresources = []
|
||||
|
||||
replace = {
|
||||
"KEY_TOPARTISTS_TOTAL":topartists_total,"KEY_TOPARTISTS_YEAR":topartists_year,"KEY_TOPARTISTS_MONTH":topartists_month,"KEY_TOPARTISTS_WEEK":topartists_week,
|
||||
"KEY_TOPTRACKS_TOTAL":toptracks_total,"KEY_TOPTRACKS_YEAR":toptracks_year,"KEY_TOPTRACKS_MONTH":toptracks_month,"KEY_TOPTRACKS_WEEK":toptracks_week,
|
||||
"KEY_JS_INIT_RANGES":js_command,
|
||||
"KEY_SCROBBLE_NUM_TODAY":scrobbles_today,"KEY_SCROBBLE_NUM_WEEK":scrobbles_week,"KEY_SCROBBLE_NUM_MONTH":scrobbles_month,"KEY_SCROBBLE_NUM_YEAR":scrobbles_year,"KEY_SCROBBLE_NUM_TOTAL":scrobbles_total,
|
||||
"KEY_SCROBBLES":html_scrobbles,
|
||||
"KEY_PULSE_MONTHS":html_pulse_months,"KEY_PULSE_YEARS":html_pulse_years,"KEY_PULSE_DAYS":html_pulse_days,"KEY_PULSE_WEEKS":html_pulse_weeks,
|
||||
#"KEY_PULSE_YEAR":html_pulse_year,"KEY_PULSE_MONTH":html_pulse_month,"KEY_PULSE_WEEK":html_pulse_week
|
||||
}
|
||||
|
||||
return (replace,pushresources)
|
Loading…
Reference in New Issue
Block a user