mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-07-19 15:44:24 +02:00
Added include svgs
This commit is contained in:
parent
55d309b2d7
commit
b0446dcd29
14
app/app.py
14
app/app.py
@ -11,6 +11,8 @@ FLASK_ENV = os.getenv("FLASK_ENV", "production")
|
|||||||
FLASK_PORT = int(os.getenv("PORT", 5000))
|
FLASK_PORT = int(os.getenv("PORT", 5000))
|
||||||
print(f"🔧 Starting app on port {FLASK_PORT}, FLASK_ENV={FLASK_ENV}")
|
print(f"🔧 Starting app on port {FLASK_PORT}, FLASK_ENV={FLASK_ENV}")
|
||||||
|
|
||||||
|
from flask import Flask, render_template, current_app
|
||||||
|
from markupsafe import Markup
|
||||||
|
|
||||||
# Initialize the CacheManager
|
# Initialize the CacheManager
|
||||||
cache_manager = CacheManager()
|
cache_manager = CacheManager()
|
||||||
@ -48,6 +50,18 @@ app = Flask(__name__)
|
|||||||
load_config(app)
|
load_config(app)
|
||||||
cache_icons_and_logos(app)
|
cache_icons_and_logos(app)
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
def utility_processor():
|
||||||
|
def include_svg(path):
|
||||||
|
full_path = os.path.join(current_app.root_path, 'static', path)
|
||||||
|
try:
|
||||||
|
with open(full_path, 'r', encoding='utf-8') as f:
|
||||||
|
svg = f.read()
|
||||||
|
return Markup(svg)
|
||||||
|
except IOError:
|
||||||
|
return Markup(f'<!-- SVG not found: {path} -->')
|
||||||
|
return dict(include_svg=include_svg)
|
||||||
|
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def reload_config_in_dev():
|
def reload_config_in_dev():
|
||||||
"""Reload config and recache icons before each request in development mode."""
|
"""Reload config and recache icons before each request in development mode."""
|
||||||
|
@ -96,9 +96,11 @@ h3.footer-title {
|
|||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-img-top i, .card-img-top object{
|
.card-img-top i, .card-img-top svg{
|
||||||
font-size: 100px;
|
font-size: 100px;
|
||||||
fill: currentColor;
|
fill: currentColor;
|
||||||
|
width: 100px;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
div#navbarNavheader li.nav-item {
|
div#navbarNavheader li.nav-item {
|
||||||
|
@ -2,17 +2,9 @@
|
|||||||
<div class="card h-100 d-flex flex-column">
|
<div class="card h-100 d-flex flex-column">
|
||||||
<div class="card-body d-flex flex-column">
|
<div class="card-body d-flex flex-column">
|
||||||
<div class="card-img-top">
|
<div class="card-img-top">
|
||||||
{% if card.icon.cache %}
|
{% if card.icon.cache and card.icon.cache.endswith('.svg') %}
|
||||||
{% if card.icon.cache.endswith('.svg') %}
|
{{ include_svg(card.icon.cache) }}
|
||||||
<object
|
{% elif card.icon.cache %}
|
||||||
type="image/svg+xml"
|
|
||||||
data="{{ url_for('static', filename=card.icon.cache) }}"
|
|
||||||
style="width:100px; height:auto;">
|
|
||||||
{% if card.icon.class %}
|
|
||||||
<i class="{{ card.icon.class }}"></i>
|
|
||||||
{% endif %}
|
|
||||||
</object>
|
|
||||||
{% else %}
|
|
||||||
<img
|
<img
|
||||||
src="{{ url_for('static', filename=card.icon.cache) }}"
|
src="{{ url_for('static', filename=card.icon.cache) }}"
|
||||||
alt="{{ card.title }}"
|
alt="{{ card.title }}"
|
||||||
@ -21,7 +13,6 @@
|
|||||||
{% if card.icon.class %}
|
{% if card.icon.class %}
|
||||||
<i class="{{ card.icon.class }}" style="display:none;"></i>
|
<i class="{{ card.icon.class }}" style="display:none;"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
{% elif card.icon.class %}
|
{% elif card.icon.class %}
|
||||||
<i class="{{ card.icon.class }}"></i>
|
<i class="{{ card.icon.class }}"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user