Commit 42024978 authored by shadMod's avatar shadMod 💬

added navs to get all categories

added generate_navbar() to show all categories

Fixes: #38
parent 022769a4
......@@ -27,14 +27,17 @@ CACHE_FILE = "news-cache.json"
class News:
@staticmethod
def prepare_blueprint(app):
def __init__(self, debug: bool = False):
self.navs = []
def prepare_blueprint(self, app):
"""
Prepare a blueprint with the news pages
"""
bp = flask.Blueprint("news", __name__)
nw_cl = GetNews(os.path.join(app.instance_path, "news"))
self.navs = nw_cl.category
@bp.route("/")
@cache.enable
......@@ -57,3 +60,16 @@ class News:
)
return bp
def generate_navbar(self):
"""Generate the sub-navbar for /news"""
result = []
for name in self.navs:
result.append(
{
"name": name.capitalize(),
"endpoint": "news.list",
"endpoint-args": {"category": name},
}
)
return result
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment