mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-06 08:11:35 +01:00
add main links option
This commit is contained in:
5
content.example/mainLinks/example.json
Normal file
5
content.example/mainLinks/example.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"headline" : "Headline",
|
||||
"link" : "https://example.com",
|
||||
"picture" :"example.png"
|
||||
}
|
||||
13
server.py
13
server.py
@@ -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()
|
||||
|
||||
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user