Improved calendar view
This commit is contained in:
parent
a8b24f2765
commit
852c40d5fb
5 changed files with 34 additions and 26 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# What’s New
|
||||
|
||||
## 0.7.1
|
||||
|
||||
+ Improved calendar view. Now `/calendar` shows a list of years and months.
|
||||
|
||||
## 0.7
|
||||
|
||||
+ Schema changes:
|
||||
|
|
|
|||
|
|
@ -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
8
app.py
|
|
@ -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
0
migrations/0_7to0_8.py
Normal file
|
|
@ -5,29 +5,28 @@
|
|||
{% block content %}
|
||||
<h1>Calendar</h1>
|
||||
|
||||
<form>
|
||||
<fieldset>
|
||||
<legend>Calendar view</legend>
|
||||
<ul>
|
||||
{% for year in range(till_year, from_year-1, -1) %}
|
||||
<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>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<label><strong>Show as</strong>:</label>
|
||||
<ul class="inline">
|
||||
{% set view_choices = ["month"] %}
|
||||
{% for vch in view_choices %}
|
||||
<li>
|
||||
{% if vch == viewas %}
|
||||
<strong>{{ T(vch) }}</strong>
|
||||
{% else %}
|
||||
<a href="/calendar/{{ vch }}">{{ T(vch) }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" >
|
||||
<div>
|
||||
<label><strong>Show month</strong></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<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 %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue