]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add tags list to homepage
authorrubenwardy <rw@rubenwardy.com>
Sat, 18 Jul 2020 01:48:22 +0000 (02:48 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sat, 18 Jul 2020 01:48:22 +0000 (02:48 +0100)
app/blueprints/homepage/__init__.py
app/templates/index.html
app/templates/packages/list.html

index f029fdeccac4051f0f3be4cf18c141fc72696b74..85f6686bd43e9ed97e273e62235914348f6c0cb4 100644 (file)
@@ -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)
index 191105822068b61d53fe59d5938ea28e42ddfdd3..6fb833e74a304551d2bdcb1546fe5de38781d1ad 100644 (file)
        {{ render_pkggrid(pop_txp) }}
 
 
+       <h2 class="my-3">{{ _("Search by Tags") }}</h2>
+       {% for pair in tags %}
+               {% set count = pair[0] %}
+               {% set tag = pair[1] %}
+
+               <a class="btn btn-sm btn-secondary m-1" rel="nofollow"
+                               href="{{ url_for('packages.list_all', tag=tag.name) }}">
+                       {{ tag.title }}
+                       <span class="badge badge-pill badge-light ml-1">{{ count }}</span>
+               </a>
+       {% endfor %}
+       <div class="clearfix mb-4"></div>
+
+
        <a href="{{ url_for('packages.list_reviews') }}" class="btn btn-secondary float-right">
                {{ _("See more") }}
        </a>
index ec17f801e66056137b981f4aeedac4f941de56f9..49fcdd1520e66c2a3d1e762408c8152da13a2db7 100644 (file)
                        {% set tag = pair[1] %}
 
                        {% if tag in selected_tags %}
-                               <a class="badge badge-primary" rel="nofollow"
+                               <a class="btn btn-sm btn-primary m-1" rel="nofollow"
                                                href="{{ url_set_query(page=1, _remove={ 'tag': tag.name }) }}">
-
                                        {{ tag.title }}
-                                       ({{ count }})
+                                       <span class="badge badge-pill badge-light ml-1">{{ count }}</span>
                                </a>
                        {% else %}
-                               <a class="badge badge-secondary" rel="nofollow"
+                               <a class="btn btn-sm btn-secondary m-1" rel="nofollow"
                                                href="{{ url_set_query(page=1, _add={ 'tag': tag.name }) }}">
-
                                        {{ tag.title }}
-                                       ({{ count }})
+                                       <span class="badge badge-pill badge-light ml-1">{{ count }}</span>
                                </a>
                        {% endif %}
                {% endfor %}