From 68a132f271b04eb7c1812609c6be4f78960fad22 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 18 Jul 2020 02:48:22 +0100 Subject: [PATCH] Add tags list to homepage --- app/blueprints/homepage/__init__.py | 5 ++++- app/templates/index.html | 14 ++++++++++++++ app/templates/packages/list.html | 10 ++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/blueprints/homepage/__init__.py b/app/blueprints/homepage/__init__.py index f029fde..85f6686 100644 --- a/app/blueprints/homepage/__init__.py +++ b/app/blueprints/homepage/__init__.py @@ -34,5 +34,8 @@ def home(): downloads_result = db.session.query(func.sum(Package.downloads)).one_or_none() downloads = 0 if not downloads_result or not downloads_result[0] else downloads_result[0] - return render_template("index.html", count=count, downloads=downloads, \ + tags = db.session.query(func.count(Tags.c.tag_id), Tag) \ + .select_from(Tag).outerjoin(Tags).group_by(Tag.id).order_by(db.asc(Tag.title)).all() + + return render_template("index.html", count=count, downloads=downloads, tags=tags, \ new=new, updated=updated, pop_mod=pop_mod, pop_txp=pop_txp, pop_gam=pop_gam, reviews=reviews) diff --git a/app/templates/index.html b/app/templates/index.html index 1911058..6fb833e 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -58,6 +58,20 @@ {{ render_pkggrid(pop_txp) }} +

{{ _("Search by Tags") }}

+ {% for pair in tags %} + {% set count = pair[0] %} + {% set tag = pair[1] %} + + + {{ tag.title }} + {{ count }} + + {% endfor %} +
+ + {{ _("See more") }} diff --git a/app/templates/packages/list.html b/app/templates/packages/list.html index ec17f80..49fcdd1 100644 --- a/app/templates/packages/list.html +++ b/app/templates/packages/list.html @@ -27,18 +27,16 @@ {% set tag = pair[1] %} {% if tag in selected_tags %} - - {{ tag.title }} - ({{ count }}) + {{ count }} {% else %} - - {{ tag.title }} - ({{ count }}) + {{ count }} {% endif %} {% endfor %}