add main links option

This commit is contained in:
Yannik Schmidt
2020-07-26 23:18:48 +02:00
parent c9838954eb
commit 1a93930675
3 changed files with 34 additions and 6 deletions

View File

@@ -0,0 +1,5 @@
{
"headline" : "Headline",
"link" : "https://example.com",
"picture" :"example.png"
}

View File

@@ -13,9 +13,10 @@ from werkzeug.routing import BuildError
import xml.etree.ElementTree as et
# paths
SECTIONS_DIR = "sections/"
NEWS_DIR = "news/"
PICTURES_DIR = "pictures/"
SECTIONS_DIR = "sections/"
NEWS_DIR = "news/"
PICTURES_DIR = "pictures/"
MAIN_LINKS_DIR = "mainLinks/"
# json config keys
TIMEOUT_RELATIVE = "timeout-relative-weeks"
@@ -128,6 +129,7 @@ def invalidateEventCache():
@app.route("/")
def root():
return flask.render_template("index.html", conf=app.config,
mainLinks=readJsonDir(app.config["MAIN_LINKS_DIR"]),
events=getEventsCache(),
moreEvents=len(getEventsCache())>3,
sections=readJsonDir(app.config["SECTIONS_DIR"]),
@@ -242,8 +244,9 @@ def siteMap():
@app.before_first_request
def init():
app.config["SECTIONS_DIR"] = os.path.join(app.config["CONTENT_DIR"], SECTIONS_DIR)
app.config["NEWS_DIR"] = os.path.join(app.config["CONTENT_DIR"], NEWS_DIR)
app.config["SECTIONS_DIR"] = os.path.join(app.config["CONTENT_DIR"], SECTIONS_DIR)
app.config["NEWS_DIR"] = os.path.join(app.config["CONTENT_DIR"], NEWS_DIR)
app.config["MAIN_LINKS_DIR"] = os.path.join(app.config["CONTENT_DIR"], MAIN_LINKS_DIR)
if app.config["RELOAD_CALENDAR_ON_START"]:
updateEventsFromCalDav()

View File

@@ -30,13 +30,33 @@
</div>
</header>
<!-- main links -->
<div class="bg-secondary">
<div class="container container-responsive pb-2 pt-2">
{% include 'events.html' %}
</div>
</div>
<!-- picture links -->
{% if mainLinks %}
<div class="bg-dark pt-5">
<div class="container">
<div class="row">
{% for card in mainLinks %}
<div class="col-md-3">
<div class="card mb-4 box-shadow border-0 hover-to-75">
<img class="card-img-top" src="{{ card['picture'] }}">
<div class="card-img-overlay">
<a href="{{ card['link'] }}" class="stretched-link"></a>
</div>
</div>
</div>
{% endfor %}
<hr>
</div>
</div>
</div>
{% endif %}
<!-- announcements -->
{% if announcements %}
<div class="bg-secondary">