diff options
author | rubenwardy <rw@rubenwardy.com> | 2018-05-27 16:51:46 +0100 |
---|---|---|
committer | rubenwardy <rw@rubenwardy.com> | 2018-05-27 18:01:27 +0100 |
commit | f4c9348b7f36b31980f7629478fdc8b2877801cc (patch) | |
tree | 8a62a179b1e48a9d84833f69f7798a707ecb1754 | |
parent | 7b6ad051c49818b69b32a8a5db834001d5626bfe (diff) | |
download | cheatdb-f4c9348b7f36b31980f7629478fdc8b2877801cc.tar.xz |
Add metapackages pages
-rw-r--r-- | app/templates/meta/list.html | 15 | ||||
-rw-r--r-- | app/templates/meta/view.html | 12 | ||||
-rw-r--r-- | app/templates/packages/view.html | 7 | ||||
-rw-r--r-- | app/views/__init__.py | 2 | ||||
-rw-r--r-- | app/views/meta.py | 34 |
5 files changed, 68 insertions, 2 deletions
diff --git a/app/templates/meta/list.html b/app/templates/meta/list.html new file mode 100644 index 0000000..5fec732 --- /dev/null +++ b/app/templates/meta/list.html @@ -0,0 +1,15 @@ +{% extends "base.html" %} + +{% block title %} +Meta Packages +{% endblock %} + +{% block content %} + <ul> + {% for meta in mpackages %} + <li><a href="{{ url_for('meta_package_page', name=meta.name) }}">{{ meta.name }}</a> ({{ meta.packages | count }} packages)</li> + {% else %} + <li><i>No meta packages found.</i></li> + {% endfor %} + </ul> +{% endblock %} diff --git a/app/templates/meta/view.html b/app/templates/meta/view.html new file mode 100644 index 0000000..c5473b9 --- /dev/null +++ b/app/templates/meta/view.html @@ -0,0 +1,12 @@ +{% extends "base.html" %} + +{% block title %} +Packages providing '{{ mpackage.name }}'' +{% endblock %} + +{% block content %} + <h1>Packages providing '{{ mpackage.name }}''</h1> + + {% from "macros/packagegridtile.html" import render_pkggrid %} + {{ render_pkggrid(mpackage.packages) }} +{% endblock %} diff --git a/app/templates/packages/view.html b/app/templates/packages/view.html index 1f6ada5..1623f1c 100644 --- a/app/templates/packages/view.html +++ b/app/templates/packages/view.html @@ -69,7 +69,12 @@ </tr> <tr> <td>Provides</td> - <td>{{ package.provides | join(', ') }}</td> + <td>{% for meta in package.provides %} + <a href="{{ url_for('meta_package_page', name=meta.name) }}">{{ meta.name }}</a> + {%- if not loop.last %} + , + {% endif %} + {% endfor %}</td> </tr> <tr> <td>Author</td> diff --git a/app/views/__init__.py b/app/views/__init__.py index c584bb8..8fff788 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -43,7 +43,7 @@ def home_page(): packages = query.order_by(db.desc(Package.created_at)).limit(15).all() return render_template("index.html", packages=packages, count=count) -from . import users, githublogin, packages, sass, tasks, admin, notifications, tagseditor +from . import users, githublogin, packages, sass, tasks, admin, notifications, tagseditor, meta @menu.register_menu(app, ".help", "Help", order=19, endpoint_arguments_constructor=lambda: { 'path': 'help' }) @app.route('/<path:path>/') diff --git a/app/views/meta.py b/app/views/meta.py new file mode 100644 index 0000000..fe1a05a --- /dev/null +++ b/app/views/meta.py @@ -0,0 +1,34 @@ +# Content DB +# Copyright (C) 2018 rubenwardy +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + + +from flask import * +from flask_user import * +from app import app +from app.models import * + +@app.route("/metapackages/") +def meta_package_list_page(): + mpackages = MetaPackage.query.order_by(db.desc(MetaPackage.name)).all() + return render_template("meta/list.html", mpackages=mpackages) + +@app.route("/metapackages/<name>/") +def meta_package_page(name): + mpackage = MetaPackage.query.filter_by(name=name).first() + if mpackage is None: + abort(404) + + return render_template("meta/view.html", mpackage=mpackage) |