From 0801e841ad3bf178de0818ef53f74e3075fdedae Mon Sep 17 00:00:00 2001
From: Mattia Succurro
Date: Thu, 6 Apr 2023 23:02:07 +0200
Subject: [PATCH] Improve calendar and nl-list
---
CHANGELOG.md | 2 +
app.py | 7 +++-
i18n/salvi.en.json | 5 ++-
i18n/salvi.it.json | 14 ++++++-
static/style.css | 6 +++
templates/calendar.jinja2 | 46 +++++++++++-----------
templates/home.jinja2 | 66 ++++++++++++++++---------------
templates/listrecent.jinja2 | 64 +++++++++++++++---------------
templates/listtag.jinja2 | 77 ++++++++++++++++++++-----------------
templates/month.jinja2 | 61 ++++++++++++++++++-----------
templates/stats.jinja2 | 1 +
templates/view.jinja2 | 7 +++-
12 files changed, 210 insertions(+), 146 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a030905..9855143 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,8 @@
`/manage/accounts`.
+ TOC is now shown in pages where screen width is greater than 960 pixels.
+ Style changes: added a top bar with the site title. It replaces the floating menu on the top right.
++ Now logged-in users have an “Edit” button below the first heading. All users can access page history
+ by clicking the last modified time.
+ Added a built-in installer (`app_init.py`). You still need to manually create `site.conf`.
## 0.7.1
diff --git a/app.py b/app.py
index 0a22c55..36e198d 100644
--- a/app.py
+++ b/app.py
@@ -930,8 +930,10 @@ def calendar_month(y, m):
(datetime.date(y, m, 1) <= Page.calendar) &
(Page.calendar < datetime.date(y+1 if m==12 else y, 1 if m==12 else m+1, 1))
).order_by(Page.calendar)
+ page = int(request.args.get('page', 1))
- return render_template('month.jinja2', d=datetime.date(y, m, 1), notes=notes)
+ return render_template('month.jinja2', d=datetime.date(y, m, 1), notes=notes.paginate(page),
+ page_n=page, total_count=notes.count(), min=min)
@app.route('/history/revision//')
def view_old(revisionid):
@@ -984,7 +986,8 @@ def stats():
notes_count=Page.select().count(),
notes_with_url=Page.select().where(Page.url != None).count(),
revision_count=PageRevision.select().count(),
- users_count = User.select().count()
+ users_count = User.select().count(),
+ groups_count = UserGroup.select().count()
)
## account management ##
diff --git a/i18n/salvi.en.json b/i18n/salvi.en.json
index 42a17cf..91bb088 100644
--- a/i18n/salvi.en.json
+++ b/i18n/salvi.en.json
@@ -61,6 +61,9 @@
"page-created": "Page created",
"write-a-comment": "Write a comment…",
"input-tags": "Tags (comma separated)",
- "no-tags": "No tags"
+ "no-tags": "No tags",
+ "notes-month-empty": "None found :(",
+ "calendar": "Calendar",
+ "groups-count": "User group count"
}
}
\ No newline at end of file
diff --git a/i18n/salvi.it.json b/i18n/salvi.it.json
index c0daee9..2dd878a 100644
--- a/i18n/salvi.it.json
+++ b/i18n/salvi.it.json
@@ -48,9 +48,21 @@
"revision-count": "Numero di revisioni",
"revision-count-per-page": "Media di revisioni per pagina",
"remember-me-for": "Ricordami per",
+ "confirm-password": "Conferma password",
+ "email": "E-mail",
+ "optional": "opzionale",
+ "have-read-terms": "Ho letto i {0} e la {1}",
+ "terms-of-service": "Termini di Servizio",
+ "privacy-policy": "Politica sulla riservatezza",
+ "already-have-account": "Hai già un account?",
+ "logged-in-as": "Autenticato come",
+ "not-logged-in": "Non autenticato",
"owner": "Proprietario",
"write-a-comment": "Scrivi un commento…",
"input-tags": "Etichette (separate da virgola)",
- "no-tags": "Nessuna etichetta"
+ "no-tags": "Nessuna etichetta",
+ "notes-month-empty": "Non c\u2019\u00e8 nulla :(",
+ "calendar": "Calendario",
+ "groups-count": "Numero di gruppi utente"
}
}
\ No newline at end of file
diff --git a/static/style.css b/static/style.css
index 6174cff..c2daa20 100644
--- a/static/style.css
+++ b/static/style.css
@@ -35,6 +35,7 @@ body{font-family:sans-serif;background-color:var(--bg-main); color: var(--fg-mai
/* content styles */
.article-header {text-align: center;}
#firstHeading {font-family:sans-serif; text-align: center;font-size:3em; font-weight: normal}
+@media (min-width:800px) {.homepage #firstHeading {font-size: 4.5em}}
.inner-content{font-family:serif; margin: 1.7em auto; max-width: 1280px; line-height: 1.9; color: var(--fg-main)}
.inner-content em,.inner-content strong{color: var(--fg-sharp)}
.inner-content h1{color: var(--fg-error)}
@@ -64,6 +65,7 @@ body{font-family:sans-serif;background-color:var(--bg-main); color: var(--fg-mai
.nl-new{margin:6px 0 12px 0;display:flex;justify-content:start; float: right}
.nl-new > a{margin-right:12px}
.nl-prev,.nl-next{text-align:center}
+.nl-placeholder {font-style: italic; text-align: center;}
input{border:0;border-bottom:3px solid var(--border);font:inherit;color:var(--fg-main);background-color:transparent}
input:focus{color:var(--fg-sharp);border-bottom-color:var(--border-sharp)}
input.error{border-bottom-color:var(--btn-error)}
@@ -161,6 +163,10 @@ a:hover{color:var(--fg-link-hover)}
.nl-list {display: grid; grid-template-rows: auto; grid-template-columns: 1fr 1fr; column-gap: 1.5em}
.nl-list > .nl-prev, .nl-list > .nl-next {grid-column-end: span 2}
}
+@media (min-width:1200px){
+ .nl-list {grid-template-columns: 1fr 1fr 1fr}
+ .nl-list > .nl-prev, .nl-list > .nl-next {grid-column-end: span 3}
+}
/* dark theme */
diff --git a/templates/calendar.jinja2 b/templates/calendar.jinja2
index 8edcc2a..2d092f8 100644
--- a/templates/calendar.jinja2
+++ b/templates/calendar.jinja2
@@ -3,30 +3,32 @@
{% block title %}Calendar – {{ app_name }}{% endblock %}
{% block content %}
-Calendar
+
+ {{ T('calendar') }}
-
- {% for year in range(till_year, from_year-1, -1) %}
- -
- {{ year }} {% if year == now.year %}(current){% endif %}:
-
-
- {% endfor %}
-
-
-
- Show more years:
-
+
+ {% for year in range(till_year, from_year-1, -1) %}
-
- in the future
-
- -
- in the past
+ {{ year }} {% if year == now.year %}(current){% endif %}:
+
+ {% endfor %}
-
+
+
+ Show more years:
+
+
+
{% endblock %}
\ No newline at end of file
diff --git a/templates/home.jinja2 b/templates/home.jinja2
index fd0f3ad..971648f 100644
--- a/templates/home.jinja2
+++ b/templates/home.jinja2
@@ -3,39 +3,43 @@
{% block title %}{{ T('homepage') }} - {{ app_name }}{% endblock %}
{% block content %}
-{{ T('welcome').format(app_name) }}
+
+ {{ T('welcome').format(app_name) }}
-
+
-{{ T('latest-notes') }}
+ {{ T('latest-notes') }}
-
-
- {% for n in new_notes %}
- -
- {{ n.title }}
-
{{ n.short_desc() }}
- {% if n.tags %}
-
- tag
- {{ T('tags') }}:
- {% for tag in n.tags %}
- {% set tn = tag.name %}
- #{{ tn }}
- {% endfor %}
-
- {% endif %}
- {% if n.calendar %}
-
- calendar_today
-
-
- {% endif %}
-
- {% endfor %}
- - {{ T('show-all') }}
-
+
+
+
{% endblock %}
diff --git a/templates/listrecent.jinja2 b/templates/listrecent.jinja2
index fa6ae03..2634cfe 100644
--- a/templates/listrecent.jinja2
+++ b/templates/listrecent.jinja2
@@ -1,38 +1,42 @@
{% extends "base.jinja2" %}
{% block content %}
-Notes by date
+
+ Notes by date
-
+
-
+
+
{% endblock %}
diff --git a/templates/listtag.jinja2 b/templates/listtag.jinja2
index c7c07aa..46d6ec3 100644
--- a/templates/listtag.jinja2
+++ b/templates/listtag.jinja2
@@ -3,46 +3,51 @@
{% block title %}Notes tagged #{{ tagname }} - {{ app_name }}{% endblock %}
{% block content %}
-{{ T('notes-tagged') }} #{{ tagname }}
+
+ #{{ tagname }}
+ {{ T('notes-tagged') }}
-{% if total_count > 0 %}
-
+ {% if total_count > 0 %}
+
-
- {% if page_n > 1 %}
- - « Previous page
- {% endif %}
- {% for n in tagged_notes %}
- -
- {{ n.title }}
-
{{ n.short_desc() }}
-
- tag
- {{ T('tags') }}:
- {% for tag in n.tags %}
- {% set tn = tag.name %}
- {% if tn == tagname %}
- #{{ tn }}
- {% else %}
- #{{ tn }}
- {% endif %}
- {% endfor %}
- {% if n.calendar %}
-
- calendar_today
-
+
+ {% if page_n > 1 %}
+ - « Previous page
+ {% endif %}
+ {% for n in tagged_notes %}
+ -
+ {{ n.title }}
+
{{ n.short_desc() }}
+
+ tag
+ {{ T('tags') }}:
+ {% for tag in n.tags %}
+ {% set tn = tag.name %}
+ {% if tn == tagname %}
+ #{{ tn }}
+ {% else %}
+ #{{ tn }}
+ {% endif %}
+ {% endfor %}
+ {% if n.calendar %}
+
+ calendar_today
+
+
+
+
+ {% endif %}
- {% endif %}
-
-
- {% endfor %}
- {% if page_n < total_count // 20 %}
- - Next page »
+
+ {% endfor %}
+ {% if page_n < total_count // 20 %}
+ - Next page »
+ {% endif %}
+
+ {% else %}
+ {{ T('notes-tagged-empty') }}
{% endif %}
-
-{% else %}
-{{ T('notes-tagged-empty') }}
-{% endif %}
+
{% endblock %}
diff --git a/templates/month.jinja2 b/templates/month.jinja2
index 55ba03b..3e9cd31 100644
--- a/templates/month.jinja2
+++ b/templates/month.jinja2
@@ -3,30 +3,47 @@
{% block title %}{{ d.strftime("%B %Y") }} – {{ app_name }}{% endblock %}
{% block content %}
-{{ d.strftime("%B %Y") }}
+
+ {{ d.strftime("%B %Y") }}
-
+
+ {% else %}
+ {{ T('notes-month-empty') }}
+ {% endif %}
+ {{ T('back-to') }} {{ T('calendar') }}
+
{% endblock %}
\ No newline at end of file
diff --git a/templates/stats.jinja2 b/templates/stats.jinja2
index 0c0f2b0..1f0812a 100644
--- a/templates/stats.jinja2
+++ b/templates/stats.jinja2
@@ -11,5 +11,6 @@
{{ T("revision-count") }}: {{ revision_count }}
{{ T("revision-count-per-page") }}: {{ (revision_count / notes_count)|round(2) }}
{{ T('users-count') }}: {{ users_count }}
+ {{ T('groups-count') }}: {{ groups_count }}
{% endblock %}
diff --git a/templates/view.jinja2 b/templates/view.jinja2
index 139a63b..0b82b77 100644
--- a/templates/view.jinja2
+++ b/templates/view.jinja2
@@ -12,7 +12,12 @@
{{ p.title }}
{% if p.calendar %}
- calendar_today{{ p.calendar.strftime('%B %-d, %Y') }}
+
+ calendar_today
+
+
+
+
{% endif %}