Skip to content

Commit b83a398

Browse files
committed
Add Images/Routes for Tags
1 parent 3f4a243 commit b83a398

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ def homepage():
1414

1515
@app.route('/catalog')
1616
def catalogpage():
17+
tag = flask.request.args.get("tag")
1718
games = requests.get(app.config["DEVCADE_API_URI"] + "games/").json()
19+
if tag:
20+
games = list(filter(lambda g: tag in map(lambda t: t['name'], g['tags']), games))
1821
return flask.render_template('catalog.html', gamelist=games)
1922

2023
@app.route('/user')

src/init.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from flask_sqlalchemy import SQLAlchemy
66
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
77
from flask_pyoidc.provider_configuration import ProviderConfiguration, ClientMetadata
8+
from urllib.parse import quote_plus
89

910

1011
app = flask.Flask(__name__)
12+
app.jinja_env.filters['quote_plus'] = lambda u: quote_plus(u)
1113
try:
1214
app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
1315
except:

src/templates/catalog.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{% extends "header.html" %} {% block headertext %} Game Catalog {%endblock%} {%
22
block content %}
3+
<div class="card-wrapper">
4+
{% for tag in tags %}
5+
<a class="btn btn-red" href="/catalog?tag={{tag.name|quote_plus}}">{{tag.name}}</a>
6+
{% endfor %}
7+
</div>
38
<div class="card-wrapper">
49
{% for i in range(0,gamelist|length) %}
510
{% if "CSH Only" not in gamelist[i].tags|map(attribute="name") or current_user.user_type == "CSH" %}

src/templates/game.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
{% extends "header.html" %} {% block title %}Devcade - {{game.name}}
22
{%endblock %} {% block content %}
33
<div class="card-wrapper">{{ gamecard(game) }}</div>
4+
<div class="card-wrapper">
5+
{% for tag in game.tags %}
6+
<a class="btn btn-red" href="/catalog?tag={{tag.name|quote_plus}}">{{tag.name}}</a>
7+
{% endfor %}
8+
</div>
49
<div class="card-wrapper">
510
<a class="btn btn-red" href="/download/{{ game.id }}">Download Game</a>
611
</div>

0 commit comments

Comments
 (0)