Add article detail page
This commit is contained in:
parent
9105df77fb
commit
f5abb93df7
5 changed files with 34 additions and 6 deletions
|
@ -4,7 +4,7 @@ services:
|
|||
build: ./view/
|
||||
command: python app.py
|
||||
ports:
|
||||
- "5000:5000"
|
||||
- "5050:5000"
|
||||
volumes:
|
||||
- ./view:/app
|
||||
- ./data:/data
|
||||
|
|
13
view/app.py
13
view/app.py
|
@ -56,8 +56,8 @@ def index():
|
|||
page = request.args.get(get_page_parameter(), type=int, default=1)
|
||||
|
||||
pagination = Pagination(page=page, total=diff_count, record_name='diffs', css_framework='bootstrap5')
|
||||
|
||||
|
||||
|
||||
|
||||
page_skip = pagination.skip
|
||||
per_page = pagination.per_page
|
||||
if query:
|
||||
|
@ -80,6 +80,15 @@ def index():
|
|||
)
|
||||
|
||||
|
||||
@app.route("/article/<path:article_url>")
|
||||
def article_detail(article_url: str):
|
||||
db = get_db().cursor()
|
||||
db.execute("SELECT * FROM diffs WHERE article_url = ?", (article_url,))
|
||||
result = db.fetchall()
|
||||
# TODO: Handle if nothing is found and return 404 in that case.
|
||||
return render_template("article_detail.html", article_url=article_url, diffs=result )
|
||||
|
||||
|
||||
@app.route('/about')
|
||||
def about():
|
||||
return render_template('about.html')
|
||||
|
|
|
@ -227,3 +227,10 @@ td {
|
|||
.changeset details[open] summary {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* Article detail */
|
||||
|
||||
.diffs-list {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
|
13
view/templates/article_detail.html
Normal file
13
view/templates/article_detail.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<h1>Diffs for the article at {{ article_url }}</h1>
|
||||
|
||||
<ol class="diffs-list">
|
||||
{% for diff in diffs %}
|
||||
<li>{{ diff.diff_time }} {{ diff.diff_html|safe }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</div>
|
||||
{% endblock body %}
|
|
@ -31,13 +31,12 @@
|
|||
<time class="changeset-time">{{ diff.diff_time }}</time>
|
||||
<a class="changeset-action" href="{{ diff.article_url }}">
|
||||
<svg class="inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V11H19L18.9999 6.413L11.2071 14.2071L9.79289 12.7929L17.5849 5H13V3H21Z"></path></svg>
|
||||
Display article
|
||||
Display current article
|
||||
</a>
|
||||
{# Not implemented yet:
|
||||
<a class="changeset-action" href="/article/{{ diff.article_url }}">
|
||||
<svg class="inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z"></path></svg>
|
||||
Show change history
|
||||
</a> #}
|
||||
</a>
|
||||
</p>
|
||||
<details>
|
||||
<summary class="changeset-title">
|
||||
|
|
Loading…
Reference in a new issue