Improved calendar view

This commit is contained in:
Yusur 2023-03-17 11:40:34 +01:00
parent a8b24f2765
commit 852c40d5fb
5 changed files with 34 additions and 26 deletions

View file

@ -1,5 +1,9 @@
# Whats New
## 0.7.1
+ Improved calendar view. Now `/calendar` shows a list of years and months.
## 0.7
+ Schema changes:

View file

@ -14,6 +14,7 @@ suitable as a community or team knowledge base.
+ Stored in SQLite/MySQL databases
+ Material Icons
+ Light/dark theme
+ Calendar
+ Works fine even with JavaScript disabled.
## Requirements

8
app.py
View file

@ -29,7 +29,7 @@ from configparser import ConfigParser
import i18n
import gzip
__version__ = '0.7.0'
__version__ = '0.7.1'
#### CONSTANTS ####
@ -791,7 +791,11 @@ def contributions(username):
@app.route('/calendar/')
def calendar_view():
return render_template('calendar.jinja2')
now = datetime.datetime.now()
return render_template('calendar.jinja2', now=now,
from_year=int(request.args.get('from_year', now.year - 12)),
till_year=int(request.args.get('till_year', now.year + 5))
)
@app.route('/calendar/<int:y>/<int:m>')
def calendar_month(y, m):

0
migrations/0_7to0_8.py Normal file
View file

View file

@ -5,29 +5,28 @@
{% block content %}
<h1>Calendar</h1>
<form>
<fieldset>
<legend>Calendar view</legend>
<div>
<label><strong>Show as</strong>:</label>
<ul class="inline">
{% set view_choices = ["month"] %}
{% for vch in view_choices %}
<ul>
{% for year in range(till_year, from_year-1, -1) %}
<li>
{% if vch == viewas %}
<strong>{{ T(vch) }}</strong>
{% else %}
<a href="/calendar/{{ vch }}">{{ T(vch) }}</a>
{% endif %}
</li>
<strong>{{ year }} {% if year == now.year %}(current){% endif %}:</strong>
<ul class="inline">
{% for month in range(1, 13) %}
<li><a href="/calendar/{{year}}/{{month}}">{{ year }}.{{ month }}</a></li>
{% endfor %}
</ul>
</div>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" >
<div>
<label><strong>Show month</strong></label>
</div>
</fieldset>
</form>
</li>
{% endfor %}
</ul>
<p>
Show more years:
<ul class="inline">
<li>
<a href="?till_year={{ till_year + 15 }}">in the future</a>
</li>
<li>
<a href="?from_year={{ from_year - 15 }}">in the past</a>
</li>
</ul>
</p>
{% endblock %}