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 # Whats New
## 0.7.1
+ Improved calendar view. Now `/calendar` shows a list of years and months.
## 0.7 ## 0.7
+ Schema changes: + Schema changes:

View file

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

8
app.py
View file

@ -29,7 +29,7 @@ from configparser import ConfigParser
import i18n import i18n
import gzip import gzip
__version__ = '0.7.0' __version__ = '0.7.1'
#### CONSTANTS #### #### CONSTANTS ####
@ -791,7 +791,11 @@ def contributions(username):
@app.route('/calendar/') @app.route('/calendar/')
def calendar_view(): 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>') @app.route('/calendar/<int:y>/<int:m>')
def calendar_month(y, m): def calendar_month(y, m):

0
migrations/0_7to0_8.py Normal file
View file

View file

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