diff --git a/docker-compose.yml b/docker-compose.yml index 4b8a496..65ba04c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: build: ./view/ command: python app.py ports: - - "5000:5000" + - "5050:5000" volumes: - ./view:/app - ./data:/data diff --git a/view/app.py b/view/app.py index 079fadf..61042fe 100644 --- a/view/app.py +++ b/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/") +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') diff --git a/view/static/main.css b/view/static/main.css index 812895e..f4c6e20 100644 --- a/view/static/main.css +++ b/view/static/main.css @@ -227,3 +227,10 @@ td { .changeset details[open] summary { margin-bottom: 1rem; } + +/* Article detail */ + +.diffs-list { + list-style-type: none; + padding: 0; +} diff --git a/view/templates/article_detail.html b/view/templates/article_detail.html new file mode 100644 index 0000000..13daf54 --- /dev/null +++ b/view/templates/article_detail.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} + +{% block body %} +
+

Diffs for the article at {{ article_url }}

+ +
    + {% for diff in diffs %} +
  1. {{ diff.diff_time }} {{ diff.diff_html|safe }}
  2. + {% endfor %} +
+
+{% endblock body %} diff --git a/view/templates/index.html b/view/templates/index.html index 4cd5e91..6310eb7 100644 --- a/view/templates/index.html +++ b/view/templates/index.html @@ -31,13 +31,12 @@ - Display article + Display current article - {# Not implemented yet: Show change history - #} +