diff --git a/maloja/__pkginfo__.py b/maloja/__pkginfo__.py index 5fec19c..0e225c5 100644 --- a/maloja/__pkginfo__.py +++ b/maloja/__pkginfo__.py @@ -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", diff --git a/maloja/server.py b/maloja/server.py index 6e8b8cb..5f33d70 100755 --- a/maloja/server.py +++ b/maloja/server.py @@ -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()}, ] } diff --git a/maloja/web/jinja/start.jinja b/maloja/web/jinja/start.jinja new file mode 100644 index 0000000..ee4beb3 --- /dev/null +++ b/maloja/web/jinja/start.jinja @@ -0,0 +1,105 @@ +{% extends "abstracts/base.jinja" %} +{% block title %}Maloja{% endblock %} + +{% block scripts %} + + + + +{% endblock %} + +{% block content %} + + + +

Top Artists

+ + {% for range in xcurrent %} + + {{ range.localisation }} + + {{ "|" if not loop.last }} + {% endfor %} + +

+ + {% import 'partials/charts_artists_tiles.jinja' as cha %} + + {% for range in xcurrent %} + + {% endfor %} + + + + + +

Top Tracks

+ + {% for range in xcurrent %} + + {{ range.localisation }} + + {{ "|" if not loop.last }} + {% endfor %} + +

+ + {% import 'partials/charts_tracks_tiles.jinja' as cht %} + + {% for range in xcurrent %} + + {% endfor %} + + +
+ + {% import 'partials/scrobbles.jinja' as scr %} + +

Last Scrobbles

+ + {% for range in xcurrent %} + {{ range.localisation }} + {{ db.get_scrobbles_num(timerange=range.range) }} + {% endfor %} +

+ + + + + {{ scr.scrobbles({},{},{"perpage":15,"page":0},shortTimeDesc=True) }} + + + +
+ + + + + + {% import 'partials/pulse.jinja' as pls %} +

Pulse

+ + {% for range in xranges %} + {{ range.localisation }} + {{ "|" if not loop.last }} + {% endfor %} +

+ + {% for range in xranges %} + + {% endfor %} + + +
+ +{% endblock %} diff --git a/maloja/web/start.html b/maloja/web/start.html deleted file mode 100644 index efc2453..0000000 --- a/maloja/web/start.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - Maloja - - - - - - - - - - - - - -

Top Artists

- - - - - This Week - | This Month - | This Year - | All Time - -

- - - - - KEY_TOPARTISTS_TOTAL - - - - -

Top Tracks

- - - This Week - | This Month - | This Year - | All Time - -

- - - - - KEY_TOPTRACKS_TOTAL - - - - - - -
-

Last Scrobbles

- Today KEY_SCROBBLE_NUM_TODAY - This Week KEY_SCROBBLE_NUM_WEEK - This Month KEY_SCROBBLE_NUM_MONTH - This Year KEY_SCROBBLE_NUM_YEAR - All Time KEY_SCROBBLE_NUM_TOTAL -

- - KEY_SCROBBLES - - -
- - -

Pulse

- - - 7 days - | 12 weeks - | 12 months - | 10 years - -

- - KEY_PULSE_MONTHS - - - - -
- - - - - - diff --git a/maloja/web/start.py b/maloja/web/start.py deleted file mode 100644 index 11c6076..0000000 --- a/maloja/web/start.py +++ /dev/null @@ -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 = "" + str(amount_day) + "" - - amount_week = database.get_scrobbles_num(timerange=thisweek()) - scrobbles_week = "" + str(amount_week) + "" - - amount_month = database.get_scrobbles_num(timerange=thismonth()) - scrobbles_month = "" + str(amount_month) + "" - - amount_year = database.get_scrobbles_num(timerange=thisyear()) - scrobbles_year = "" + str(amount_year) + "" - - amount_total = database.get_scrobbles_num() - scrobbles_total = "" + str(amount_total) + "" - - #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)