mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-07 00:31:34 +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
|
import xml.etree.ElementTree as et
|
||||||
|
|
||||||
# paths
|
# paths
|
||||||
SECTIONS_DIR = "sections/"
|
SECTIONS_DIR = "sections/"
|
||||||
NEWS_DIR = "news/"
|
NEWS_DIR = "news/"
|
||||||
PICTURES_DIR = "pictures/"
|
PICTURES_DIR = "pictures/"
|
||||||
|
MAIN_LINKS_DIR = "mainLinks/"
|
||||||
|
|
||||||
# json config keys
|
# json config keys
|
||||||
TIMEOUT_RELATIVE = "timeout-relative-weeks"
|
TIMEOUT_RELATIVE = "timeout-relative-weeks"
|
||||||
@@ -128,6 +129,7 @@ def invalidateEventCache():
|
|||||||
@app.route("/")
|
@app.route("/")
|
||||||
def root():
|
def root():
|
||||||
return flask.render_template("index.html", conf=app.config,
|
return flask.render_template("index.html", conf=app.config,
|
||||||
|
mainLinks=readJsonDir(app.config["MAIN_LINKS_DIR"]),
|
||||||
events=getEventsCache(),
|
events=getEventsCache(),
|
||||||
moreEvents=len(getEventsCache())>3,
|
moreEvents=len(getEventsCache())>3,
|
||||||
sections=readJsonDir(app.config["SECTIONS_DIR"]),
|
sections=readJsonDir(app.config["SECTIONS_DIR"]),
|
||||||
@@ -242,8 +244,9 @@ def siteMap():
|
|||||||
|
|
||||||
@app.before_first_request
|
@app.before_first_request
|
||||||
def init():
|
def init():
|
||||||
app.config["SECTIONS_DIR"] = os.path.join(app.config["CONTENT_DIR"], SECTIONS_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["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"]:
|
if app.config["RELOAD_CALENDAR_ON_START"]:
|
||||||
updateEventsFromCalDav()
|
updateEventsFromCalDav()
|
||||||
|
|||||||
@@ -30,13 +30,33 @@
|
|||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- main links -->
|
|
||||||
<div class="bg-secondary">
|
<div class="bg-secondary">
|
||||||
<div class="container container-responsive pb-2 pt-2">
|
<div class="container container-responsive pb-2 pt-2">
|
||||||
{% include 'events.html' %}
|
{% include 'events.html' %}
|
||||||
</div>
|
</div>
|
||||||
</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 -->
|
<!-- announcements -->
|
||||||
{% if announcements %}
|
{% if announcements %}
|
||||||
<div class="bg-secondary">
|
<div class="bg-secondary">
|
||||||
|
|||||||
Reference in New Issue
Block a user