This commit is contained in:
pika 2025-04-03 13:51:52 +02:00
parent 78ce15e82d
commit 0a31714a93
10 changed files with 159 additions and 149 deletions

View file

@ -4,34 +4,34 @@ import os
bp = Blueprint("static_assets", __name__)
@bp.route("/static/libs/tabler-icons/tabler-icons.min.css")
def tabler_icons():
"""Serve tabler-icons CSS from node_modules or download if missing"""
icons_path = os.path.join(current_app.static_folder, "libs", "tabler-icons")
# Create directory if it doesn't exist
if not os.path.exists(icons_path):
os.makedirs(icons_path)
css_file = os.path.join(icons_path, "tabler-icons.min.css")
# If file doesn't exist, download from CDN
if not os.path.exists(css_file):
import requests
try:
cdn_url = "https://cdn.jsdelivr.net/npm/@tabler/icons@latest/iconfont/tabler-icons.min.css"
response = requests.get(cdn_url)
if response.status_code == 200:
with open(css_file, "wb") as f:
f.write(response.content)
print(f"Downloaded tabler-icons.min.css from CDN")
else:
print(f"Failed to download tabler-icons CSS: {response.status_code}")
except Exception as e:
print(f"Error downloading tabler-icons CSS: {e}")
return send_from_directory(icons_path, "tabler-icons.min.css")
# @bp.route("/static/libs/tabler-icons/tabler-icons.min.css")
# def tabler_icons():
# """Serve tabler-icons CSS from node_modules or download if missing"""
# icons_path = os.path.join(current_app.static_folder, "libs", "tabler-icons")
#
# # Create directory if it doesn't exist
# if not os.path.exists(icons_path):
# os.makedirs(icons_path)
#
# css_file = os.path.join(icons_path, "tabler-icons.min.css")
#
# # If file doesn't exist, download from CDN
# if not os.path.exists(css_file):
# import requests
#
# try:
# cdn_url = "https://cdn.jsdelivr.net/npm/@tabler/core@1.1.1/dist/css/tabler.min.css"
# response = requests.get(cdn_url)
# if response.status_code == 200:
# with open(css_file, "wb") as f:
# f.write(response.content)
# print(f"Downloaded tabler-icons.min.css from CDN")
# else:
# print(f"Failed to download tabler-icons CSS: {response.status_code}")
# except Exception as e:
# print(f"Error downloading tabler-icons CSS: {e}")
#
# return send_from_directory(icons_path, "tabler-icons.min.css")
@bp.route("/static/css/tabler.min.css")
@ -50,7 +50,7 @@ def tabler_css():
import requests
try:
cdn_url = "https://cdn.jsdelivr.net/npm/@tabler/core@latest/dist/css/tabler.min.css"
cdn_url = "https://cdn.jsdelivr.net/npm/@tabler/core@1.1.1/dist/css/tabler.min.css"
response = requests.get(cdn_url)
if response.status_code == 200:
with open(css_file, "wb") as f:
@ -82,7 +82,7 @@ def favicon():
try:
# Using a simple placeholder favicon
cdn_url = "https://www.google.com/favicon.ico"
cdn_url = "https://www.svgrepo.com/show/529863/server-minimalistic.svg"
response = requests.get(cdn_url)
if response.status_code == 200:
with open(favicon_file, "wb") as f: