mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-01-15 19:23:58 +01:00
Finished implementation of configuration resolver
This commit is contained in:
parent
8fb0cecfbe
commit
c87c1df10a
15
app/app.py
15
app/app.py
@ -3,6 +3,8 @@ from flask import Flask, render_template
|
||||
import requests
|
||||
import hashlib
|
||||
import yaml
|
||||
from utils.configuration_resolver import ConfigurationResolver
|
||||
from pprint import pprint
|
||||
|
||||
# Verzeichnis mit Dateien, die gelöscht werden sollen
|
||||
TEMP_DIR = "static/cache/"
|
||||
@ -30,7 +32,7 @@ def cache_file(file_url, cache_dir=TEMP_DIR):
|
||||
hash_object = hashlib.blake2s(file_url.encode('utf-8'), digest_size=8)
|
||||
hash_suffix = hash_object.hexdigest()
|
||||
|
||||
splitted_file_url = file_url.split("/");
|
||||
splitted_file_url = file_url.split("/")
|
||||
|
||||
if splitted_file_url[-1] == "download":
|
||||
# Erstelle den Dateinamen mit Hash
|
||||
@ -53,10 +55,16 @@ def cache_file(file_url, cache_dir=TEMP_DIR):
|
||||
return full_path
|
||||
|
||||
def load_config(app):
|
||||
"""Load and resolve the configuration."""
|
||||
# Lade die Konfigurationsdatei
|
||||
with open("config.yaml", "r") as f:
|
||||
config = yaml.safe_load(f)
|
||||
app.config.update(config)
|
||||
|
||||
# Resolve links in the configuration
|
||||
resolver = ConfigurationResolver(config)
|
||||
resolver.resolve_links()
|
||||
# Update the app configuration
|
||||
app.config.update(resolver.get_config())
|
||||
|
||||
app = Flask(__name__)
|
||||
load_config(app)
|
||||
@ -68,6 +76,9 @@ FLASK_ENV = os.getenv("FLASK_ENV", "production")
|
||||
def reload_config_in_dev():
|
||||
if FLASK_ENV == "development":
|
||||
load_config(app)
|
||||
print("DEVELOPMENT ENVIRONMENT")
|
||||
else:
|
||||
print("PRODUCTIVE ENVIRONMENT")
|
||||
|
||||
# Cachen der Icons
|
||||
for card in app.config["cards"]:
|
||||
|
@ -204,13 +204,11 @@ navigation:
|
||||
class: fa-brands fa-telegram
|
||||
target: _blank
|
||||
href: https://t.me/kevinveenbirkenbach
|
||||
subitems: []
|
||||
- name: WhatsApp
|
||||
description: Chat with me on WhatsApp
|
||||
icon:
|
||||
class: fa-brands fa-whatsapp
|
||||
href: https://wa.me/491781798023
|
||||
subitems: []
|
||||
footer:
|
||||
- name: External Accounts
|
||||
description: Me on other plattforms
|
||||
@ -226,22 +224,21 @@ navigation:
|
||||
- name: Instagram
|
||||
description: Follow me on Instagram
|
||||
icon:
|
||||
class: fa-brands fa-instagram
|
||||
class: fa-brands fa-instagram
|
||||
href: https://www.instagram.com/kevinveenbirkenbach/
|
||||
subitems: []
|
||||
- name: Facebook
|
||||
description: Like my Facebook page
|
||||
icon:
|
||||
class: fa-brands fa-facebook
|
||||
class: fa-brands fa-facebook
|
||||
href: https://www.facebook.com/kevinveenbirkenbach
|
||||
subitems: []
|
||||
- name: Communication
|
||||
description: Social and developer networks
|
||||
icon:
|
||||
class: fa-brands fa-meta
|
||||
href:
|
||||
subitems:
|
||||
- link: navigation.header.contact.whatsapp
|
||||
- link: navigation.header.contact.signal
|
||||
- link: navigation.header.contact.telegram
|
||||
- name: Carreer Profiles
|
||||
icon:
|
||||
class: fa-solid fa-user-tie
|
||||
@ -249,13 +246,13 @@ navigation:
|
||||
- name: XING
|
||||
description: Visit my XING profile
|
||||
icon:
|
||||
class: bi bi-building
|
||||
class: bi bi-building
|
||||
href: https://www.xing.com/profile/Kevin_VeenBirkenbach
|
||||
subitems: []
|
||||
- name: LinkedIn
|
||||
description: Connect on LinkedIn
|
||||
icon:
|
||||
class: bi bi-linkedin
|
||||
class: bi bi-linkedin
|
||||
href: https://www.linkedin.com/in/kevinveenbirkenbach
|
||||
subitems: []
|
||||
- name: Sports
|
||||
@ -267,13 +264,13 @@ navigation:
|
||||
- name: Garmin
|
||||
description: My Garmin activities
|
||||
icon:
|
||||
class: fa-solid fa-person-running
|
||||
class: fa-solid fa-person-running
|
||||
href: https://s.veen.world/garmin
|
||||
subitems: []
|
||||
- name: Eversports
|
||||
description: My Eversports sessions
|
||||
icon:
|
||||
class: fa-solid fa-dumbbell
|
||||
class: fa-solid fa-dumbbell
|
||||
href: https://s.veen.world/eversports
|
||||
subitems: []
|
||||
- name: Duolingo
|
||||
|
@ -19,7 +19,11 @@
|
||||
{% else %}
|
||||
<li>
|
||||
<a class="dropdown-item" href="{{ subitem.href }}" target="{{ subitem.target|default('_blank') }}" data-bs-toggle="tooltip" title="{{ subitem.description }}">
|
||||
{% if subitem.icon is defined and subitem.icon.class is defined %}
|
||||
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
||||
{% else %}
|
||||
<p>Fehlendes Icon im Subitem: {{ subitem }}</p>
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
@ -49,7 +49,12 @@ class ConfigurationResolver:
|
||||
(item for item in current if isinstance(item, dict) and item.get("name", "").lower() == part),
|
||||
None
|
||||
)
|
||||
if found is None:
|
||||
if found:
|
||||
print(
|
||||
f"Matching entry for '{part}' in list. Path so far: {' > '.join(parts[:parts.index(part)+1])}. "
|
||||
f"Current list: {current}"
|
||||
)
|
||||
else:
|
||||
raise ValueError(
|
||||
f"No matching entry for '{part}' in list. Path so far: {' > '.join(parts[:parts.index(part)+1])}. "
|
||||
f"Current list: {current}"
|
||||
@ -71,7 +76,7 @@ class ConfigurationResolver:
|
||||
)
|
||||
|
||||
# Navigate into `subitems` if present
|
||||
if isinstance(current, dict) and "subitems" in current:
|
||||
if isinstance(current, dict) and ("subitems" in current and current["subitems"]):
|
||||
current = current["subitems"]
|
||||
|
||||
return current
|
||||
|
Loading…
Reference in New Issue
Block a user