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" ...@@ -27,14 +27,17 @@ CACHE_FILE = "news-cache.json"
class News: class News:
@staticmethod def __init__(self, debug: bool = False):
def prepare_blueprint(app): self.navs = []
def prepare_blueprint(self, app):
""" """
Prepare a blueprint with the news pages Prepare a blueprint with the news pages
""" """
bp = flask.Blueprint("news", __name__) bp = flask.Blueprint("news", __name__)
nw_cl = GetNews(os.path.join(app.instance_path, "news")) nw_cl = GetNews(os.path.join(app.instance_path, "news"))
self.navs = nw_cl.category
@bp.route("/") @bp.route("/")
@cache.enable @cache.enable
...@@ -57,3 +60,16 @@ class News: ...@@ -57,3 +60,16 @@ class News:
) )
return bp 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