Improved calendar month view
This commit is contained in:
parent
a24386c45e
commit
ba3ed04b44
4 changed files with 30 additions and 2 deletions
14
app.py
14
app.py
|
|
@ -950,6 +950,18 @@ def contributions(username):
|
|||
min=min
|
||||
)
|
||||
|
||||
def _advance_calendar(date, offset=0):
|
||||
if offset == -2:
|
||||
return datetime.date(date.year - 1, date.month, 1)
|
||||
elif offset == -1:
|
||||
return datetime.date(date.year, date.month - 1, 1) if date.month > 1 else datetime.date(date.year - 1, 12, 1)
|
||||
elif offset == 1:
|
||||
return datetime.date(date.year, date.month + 1, 1) if date.month < 12 else datetime.date(date.year + 1, 1, 1)
|
||||
elif offset == 2:
|
||||
return datetime.date(date.year + 1, date.month, 1)
|
||||
else:
|
||||
return date
|
||||
|
||||
@app.route('/calendar/')
|
||||
def calendar_view():
|
||||
now = datetime.datetime.now()
|
||||
|
|
@ -967,7 +979,7 @@ def calendar_month(y, m):
|
|||
page = int(request.args.get('page', 1))
|
||||
|
||||
return render_template('month.jinja2', d=datetime.date(y, m, 1), notes=notes.paginate(page),
|
||||
page_n=page, total_count=notes.count(), min=min)
|
||||
page_n=page, total_count=notes.count(), min=min, advance_calendar=_advance_calendar)
|
||||
|
||||
@app.route('/history/revision/<int:revisionid>/')
|
||||
def view_old(revisionid):
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ body{font-family:sans-serif;background-color:var(--bg-main); color: var(--fg-mai
|
|||
|
||||
/* header styles */
|
||||
.header{padding:1em;display:flex;flex-direction:row;justify-content:space-between;position:sticky;top:0;background-color:var(--bg-alt); z-index: 99}
|
||||
.header-app-name{font-size: 1.5em; font-weight: bold}
|
||||
.header .header-blank {flex: 1; margin: 0 .5em}
|
||||
.header ul{list-style:none;padding:0;margin:0;font-size:0.9em;border-left:var(--border) 1px solid}
|
||||
.header ul > li{display:inline-block;padding-right:1em}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,9 @@
|
|||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li><a href="/p/most_recent/">{{ T('show-all') }}</a></li>
|
||||
<li class="nl-next"><a href="/p/most_recent/">{{ T('show-all') }}</a></li>
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,20 @@
|
|||
<p class="nl-placeholder">{{ T('notes-month-empty') }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% set past_year = advance_calendar(d, -2) %}
|
||||
{% set past_month = advance_calendar(d, -1) %}
|
||||
{% set next_month = advance_calendar(d, 1) %}
|
||||
{% set next_year = advance_calendar(d, 2) %}
|
||||
<div class="calendar-navigation">
|
||||
<ul class="inline">
|
||||
<li>« <a href="/calendar/{{ past_year.year }}/{{ past_year.month }}">{{ past_year.strftime("%B %Y") }}</a></li>
|
||||
<li><a href="/calendar/{{ past_month.year }}/{{ past_month.month }}">{{ past_month.strftime("%B %Y") }}</a></li>
|
||||
<li><strong>{{ d.strftime("%B %Y") }}</strong></li>
|
||||
<li><a href="/calendar/{{ next_month.year }}/{{ next_month.month }}">{{ next_month.strftime("%B %Y") }}</a></li>
|
||||
<li><a href="/calendar/{{ next_year.year }}/{{ next_year.month }}">{{ next_year.strftime("%B %Y") }}</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<p>{{ T('back-to') }} <a href="/calendar">{{ T('calendar') }}</a></p>
|
||||
</article>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue