mirror of
https://github.com/FAUSheppy/flask-json-dream-website
synced 2025-12-06 00:01:36 +01:00
Merge branch 'dev'
This commit is contained in:
12
README.md
12
README.md
@@ -69,8 +69,16 @@ The order is again specified by the alpha-numeric order of the files.
|
||||
You can add new subpages in the *content*-location via a *subpages.json* file denoting an identifier as key and a HTML-template as value, like this:
|
||||
|
||||
{
|
||||
"identifiert-1" : "html-template-1.html",
|
||||
"identifiert-2" : "html-template-2.html"
|
||||
"identifier-1" : "html-template-1.html",
|
||||
"identifier-2" : "html-template-2.html"
|
||||
}
|
||||
|
||||
You can also give identifier complex objects pointing to another config dir which will be parsed by *readJsonDir* and passed to *render_template* as a list of dictionary objects called *"extraConfig"*:
|
||||
|
||||
{
|
||||
"identifier-1" : {
|
||||
"template" : "html-template-1.html",
|
||||
"config-dir" : "config_dir_in_content_dir"
|
||||
}
|
||||
|
||||
# Contact Page
|
||||
|
||||
@@ -22,6 +22,8 @@ SITE_LOGO_URL = "Site Logo URL"
|
||||
SITE_BASE_URL = "Site Base URL"
|
||||
|
||||
WALLPAPER_URL = "/picture/example.png"
|
||||
SITE_WELLCOME_TITLE = "Title on the Wallpaper"
|
||||
SITE_WELLCOME_SUBTITLE = "Subtitle on the Wallpaper"
|
||||
|
||||
TEAMSPEAK_SERVER = "teamspeak.com"
|
||||
DISCORD_SERVER = "https://discord.gg/"
|
||||
@@ -31,3 +33,5 @@ TWITTER = "https://twitter.com/its_a_sheppy"
|
||||
|
||||
TWITCH_CHANNEL = "esports_erlangen"
|
||||
TWITCH_PLACEHOLDER_IMG = "placeholder.png"
|
||||
|
||||
ADDITIONAL_HEADER_CONTENT = "<!-- additional content you want in <head> -->"
|
||||
|
||||
19
server.py
19
server.py
@@ -46,6 +46,7 @@ WRITE = "w"
|
||||
|
||||
# subpages
|
||||
IDENTIFIER_PREFIX = "PAGE_"
|
||||
CONFIG_POSTFIX = "_EXTRA_CONFIG"
|
||||
SUBPAGE_CONFIG_FILE = "subpages.json"
|
||||
SUBPAGE_CONTENT_DIR = "subpages/"
|
||||
|
||||
@@ -169,7 +170,6 @@ def impressum():
|
||||
with open(impressumTextPath) as f:
|
||||
impressumText = flask.Markup(f.read())
|
||||
|
||||
#impressumText = flask.Markup(impressumTextPath)
|
||||
with open(impressumPath) as f:
|
||||
impressumFull = flask.render_template_string(f.read(), conf=app.config, text=impressumText)
|
||||
return flask.render_template("stub.html", content=impressumFull)
|
||||
@@ -183,7 +183,14 @@ def people():
|
||||
def content():
|
||||
identifier = IDENTIFIER_PREFIX + flask.request.args.get("id")
|
||||
if identifier in app.config:
|
||||
markupText = flask.Markup(flask.render_template(app.config[identifier]))
|
||||
|
||||
# check for extra config #
|
||||
extraConfigDir = app.config[identifier + CONFIG_POSTFIX]
|
||||
extraConfig = None
|
||||
if extraConfigDir:
|
||||
extraConfig = readJsonDir(os.path.join(app.config["CONTENT_DIR"], extraConfigDir))
|
||||
|
||||
markupText = flask.Markup(flask.render_template(app.config[identifier], extraConfig=extraConfig))
|
||||
return flask.render_template("default_content.html", conf=app.config, markupText=markupText)
|
||||
else:
|
||||
return (EMPTY_STRING, HTTP_NOT_FOUND)
|
||||
@@ -317,7 +324,13 @@ def init():
|
||||
|
||||
# set template paths for identifier in app config #
|
||||
for identifier in subpages.keys():
|
||||
app.config[IDENTIFIER_PREFIX + identifier] = subpages[identifier]
|
||||
if type(subpages[identifier]) == dict:
|
||||
app.config[IDENTIFIER_PREFIX + identifier] = subpages[identifier]["template"]
|
||||
configKey = IDENTIFIER_PREFIX + identifier + CONFIG_POSTFIX
|
||||
app.config[configKey] = subpages[identifier]["config-dir"]
|
||||
else:
|
||||
app.config[IDENTIFIER_PREFIX + identifier] = subpages[identifier]
|
||||
app.config[IDENTIFIER_PREFIX + identifier + CONFIG_POSTFIX] = None
|
||||
|
||||
# set custom loader to support second template dir #
|
||||
subpageContentDirTmp = os.path.join(app.config["CONTENT_DIR"], SUBPAGE_CONTENT_DIR)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{% include 'head.html' %}
|
||||
|
||||
</head>
|
||||
<body class="bg-special">
|
||||
<body class="bg-special" {% if "FORCE_BG_COLOR" in conf %} style="background-color: {{ conf['FORCE_BG_COLOR'] }} !important;" {% endif %}>
|
||||
|
||||
{% include 'navbar.html' %}
|
||||
<div class="container mt-5 mb-5 h-100">
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
<meta property="og:url" content="{{ url_for(request.endpoint) }}" />
|
||||
<meta property="og:image" content="{{ conf['SITE_LOG_URL'] }}">
|
||||
|
||||
{{ conf['ADDITIONAL_HEADER_CONTENT'] | safe }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
<div class="container h-50">
|
||||
<div class="row h-100 align-items-center">
|
||||
<div class="col-12 text-center">
|
||||
<div style="opacity: 0;"></div>
|
||||
<div style="opacity: 0;"></div> <!-- TODO color for text configurable -->
|
||||
<div class="mt-5" style="opacity: 0;"></div>
|
||||
{% if "SITE_WELLCOME_TITLE" in conf %} <h1 class="font-weight-light">{{ conf["SITE_WELLCOME_TITLE"] }}</h1> {% endif %}
|
||||
{% if "SITE_WELLCOME_SUBTITLE" in conf %} <p class="lead">{{ conf["SITE_WELLCOME_SUBTITLE"] }}</p> {% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="col image-min-dimensions">
|
||||
<img class="img-responsive w-100 image-max-dimensions"
|
||||
src="{{ p['image'] }}"></img>
|
||||
<img class="img-responsive w-100 image-max-dimensions"
|
||||
src="{{ p['image'] }}" alt="{{ 'title' }}"></img>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user