From 9f30bd36a07a319e7b32200ef65f4fd10be1aee0 Mon Sep 17 00:00:00 2001 From: Lephe Date: Thu, 5 Sep 2019 23:42:47 +0200 Subject: [PATCH] forum: add the forum index page Also prepare some functions for topic listings for each forum. --- app/__init__.py | 8 +++++- app/routes/forum/index.py | 8 ++++++ app/static/css/table.css | 24 ++++++++++++++++++ app/templates/base/navbar/forum.html | 6 ++++- app/templates/forum/index.html | 38 ++++++++++++++++++++++++++++ app/utils/converters.py | 34 +++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 app/routes/forum/index.py create mode 100644 app/templates/forum/index.html create mode 100644 app/utils/converters.py diff --git a/app/__init__.py b/app/__init__.py index 0e55eed..8b99b51 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -5,12 +5,15 @@ from flask_login import LoginManager from config import Config import time - app = Flask(__name__) app.config.from_object(Config) + db = SQLAlchemy(app) migrate = Migrate(app, db) +from app.utils.converters import * +app.url_map.converters['topicslug'] = TopicSlugConverter +app.url_map.converters['forum'] = ForumConverter @app.before_request def request_time(): @@ -28,8 +31,11 @@ from app.models.thread import Thread from app.models.forum import Forum from app.models.topic import Topic from app.models.notification import Notification + from app.routes import index, search, users # To load routes at initialization from app.routes.account import login, account, notification from app.routes.admin import index, groups, account, trophies, forums +from app.routes.forum import index + from app.utils import pluralize # To use pluralize into the templates from app.utils import is_title diff --git a/app/routes/forum/index.py b/app/routes/forum/index.py new file mode 100644 index 0000000..c20a4c7 --- /dev/null +++ b/app/routes/forum/index.py @@ -0,0 +1,8 @@ +from app.utils.render import render +from app.models.forum import Forum +from app import app + +@app.route('/forum') +def forum(): + main_forum = Forum.query.filter_by(parent=None).first() + return render('/forum/index.html', main_forum=main_forum) diff --git a/app/static/css/table.css b/app/static/css/table.css index 56016ac..b0a0073 100644 --- a/app/static/css/table.css +++ b/app/static/css/table.css @@ -17,3 +17,27 @@ table th { table td { padding: 4px 6px; } + +/* Forum and sub-forum listings */ + +table.forumlist { + border-collapse: separate; + border-spacing: 0; + + margin: 16px 0; + width: 100%; +} + +/* table.forumlist th { + background: #d05950; + border-color: #b04940; + color: white; +} */ + +table.forumlist tr { + background: unset; +} +table.forumlist tr:nth-child(4n+2), +table.forumlist tr:nth-child(4n+3) { + background: rgba(0, 0, 0, .05); +} diff --git a/app/templates/base/navbar/forum.html b/app/templates/base/navbar/forum.html index 491a272..aab3e00 100644 --- a/app/templates/base/navbar/forum.html +++ b/app/templates/base/navbar/forum.html @@ -5,6 +5,10 @@ Forum + Index du forum + +
+ Vie communautaire Projets de programmation Questions et problèmes @@ -12,7 +16,7 @@ Administration CreativeCalc -
+

Derniers commentaires