customize app

This commit is contained in:
lelo 2025-04-14 23:19:55 +02:00
parent e176172e9b
commit 8ac541f597
11 changed files with 70 additions and 32 deletions

2
.gitignore vendored
View File

@ -13,3 +13,5 @@
/folder_permission_config.json
/folder_mount_config.json
/.env
/app_config.json
/custom_logo

50
app.py
View File

@ -20,15 +20,18 @@ import search
import auth
import analytics as a
cache_audio = diskcache.Cache('./filecache_audio', size_limit= 48 * 1024**3) # 48 GB limit
cache_image = diskcache.Cache('./filecache_image', size_limit= 48 * 1024**3) # 48 GB limit
cache_video = diskcache.Cache('./filecache_video', size_limit= 48 * 1024**3) # 48 GB limit
cache_other = diskcache.Cache('./filecache_other', size_limit= 48 * 1024**3) # 48 GB limit
with open("app_config.json", 'r') as file:
config = json.load(file)
cache_audio = diskcache.Cache('./filecache_audio', size_limit= config['filecache_size_limit_audio'] * 1024**3)
cache_image = diskcache.Cache('./filecache_image', size_limit= config['filecache_size_limit_image'] * 1024**3)
cache_video = diskcache.Cache('./filecache_video', size_limit= config['filecache_size_limit_video'] * 1024**3)
cache_other = diskcache.Cache('./filecache_other', size_limit= config['filecache_size_limit_other'] * 1024**3)
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1)
app.config['SECRET_KEY'] = '85c1117eb3a5f2c79f0ff395bada8ff8d9a257b99ef5e143'
app.config['SECRET_KEY'] = config['SECRET_KEY']
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=90)
if os.environ.get('FLASK_ENV') == 'production':
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
@ -65,7 +68,7 @@ thread_lock = threading.Lock()
@lru_cache(maxsize=10)
def get_cached_image(size):
dimensions = tuple(map(int, size.split('-')[1].split('x')))
original_logo_path = os.path.join(app.root_path, 'static', 'logo.png')
original_logo_path = os.path.join(app.root_path, 'custom_logo', 'logoB.png')
with Image.open(original_logo_path) as img:
img = img.convert("RGBA")
@ -153,7 +156,7 @@ def generate_breadcrumbs(subpath=None):
breadcrumbs.append({'name': part, 'path': path_accum})
return breadcrumbs
@app.route('/static/icons/<string:size>.png')
@app.route('/icon/<string:size>.png')
def serve_resized_icon(size):
cached_image_bytes = get_cached_image(size)
response = send_file(
@ -163,6 +166,22 @@ def serve_resized_icon(size):
response.headers['Cache-Control'] = 'public, max-age=86400'
return response
@app.route('/custom_logo/<string:filename>.png')
def custom_logo(filename):
file_path = os.path.join('custom_logo', f"{filename}.png")
if not os.path.exists(file_path):
abort(404)
with open(file_path, 'rb') as file:
image_data = file.read()
# Create a BytesIO object using the binary image data
image_io = io.BytesIO(image_data)
image_io.seek(0) # Important: reset the stream position
response = send_file(image_io, mimetype='image/png')
response.headers['Cache-Control'] = 'public, max-age=86400'
return response
@app.route('/sw.js')
def serve_sw():
return send_from_directory(os.path.join(app.root_path, 'static'), 'sw.js', mimetype='application/javascript')
@ -445,9 +464,20 @@ def handle_request_initial_data():
@app.route('/<path:path>')
@auth.require_secret
def index(path):
title_short = os.environ.get('TITLE_SHORT', 'Default Title')
title_long = os.environ.get('TITLE_LONG', 'Default Title')
return render_template("app.html", title_short=title_short, title_long=title_long)
title_short = config.get('TITLE_SHORT', 'Default Title')
title_long = config.get('TITLE_LONG' , 'Default Title')
header_color = config.get('header_color' , '#000')
header_text_color = config.get('header_text_color', '#fff')
background_color = config.get('background_color', '#fff')
main_text_color = config.get('main_text_color', '#000')
return render_template("app.html",
title_short=title_short,
title_long=title_long,
header_color=header_color,
header_text_color=header_text_color,
main_text_color=main_text_color,
background_color=background_color,
)
if __name__ == '__main__':
socketio.run(app, debug=True, host='0.0.0.0')

View File

@ -7,9 +7,7 @@ html, body {
/* Global Styles */
body {
font-family: 'Helvetica Neue', Arial, sans-serif;
background-color: #f4f7f9;
padding-top: 70px; /* Adjust to your header height */
color: #333;
}
/* Header styles */
.site-header {
@ -20,8 +18,6 @@ body {
display: flex;
align-items: center;
padding: 10px 20px;
background-color: #34495e; /* Using the theme color */
color: #eee;
}
.site-header img.logo {
height: 50px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

View File

@ -7,12 +7,12 @@
"theme_color": "#34495e",
"icons": [
{
"src": "/static/icons/logo-192x192.png",
"src": "/icon/logo-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/static/icons/logo-512x512.png",
"src": "/icon/logo-512x512.png",
"sizes": "512x512",
"type": "image/png"
}

View File

@ -7,10 +7,10 @@ const assets = [
'/static/gallery.js',
'/static/audioplayer.css',
'/static/audioplayer.js',
'/static/icons/logo-192x192.png',
'/static/icons/logo-512x512.png',
'/static/logo.png',
'/static/logoW.png'
'/icon/logo-192x192.png',
'/icon/logo-512x512.png',
'/custom_logo/logoB.png',
'/custom_logo/logoW.png'
];
self.addEventListener('install', e => {

View File

@ -5,21 +5,21 @@
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft." />
<meta property="og:image" content="https://app.bethaus-speyer.de/static/icons/logo-200x200.png" />
<meta property="og:image" content="https://app.bethaus-speyer.de/icon/logo-200x200.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<title>{{ title_short }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft.">
<meta name="author" content="Bethaus Speyer">
<link rel="icon" href="/static/icons/logo-192x192.png" type="image/png" sizes="192x192">
<link rel="icon" href="/icon/logo-192x192.png" type="image/png" sizes="192x192">
<!-- Web App Manifest -->
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}">
<!-- Android Theme Color -->
<meta name="theme-color" content="#34495e">
<meta name="theme-color" content="{{ header_color }}">
<!-- Apple-specific tags -->
<link rel="touch-icon" href="{{ url_for('static', filename='icons/icon-192x192.png') }}">
@ -32,11 +32,21 @@
<link rel="stylesheet" href="{{ url_for('static', filename='gallery.css') }}">
<link rel="stylesheet" href="{{ url_for('static', filename='audioplayer.css') }}">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<style>
body {
background-color: {{ background_color }};
color: {{ main_text_color }};
}
.site-header {
background-color: {{ header_color }};
color: {{ header_text_color }};
}
</style>
</head>
<body>
<header class="site-header">
<a href="#">
<img src="/static/logoW.png" alt="Logo" class="logo">
<img src="/custom_logo/logoW.png" alt="Logo" class="logo">
</a>
<h1>{{ title_long }}</h1>
</header>

View File

@ -5,7 +5,7 @@
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft." />
<meta property="og:image" content="https://app.bethaus-speyer.de/static/icons/logo-300x300.png" />
<meta property="og:image" content="https://app.bethaus-speyer.de/icon/logo-300x300.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<meta property="og:type" content="website" />
@ -16,7 +16,7 @@
</head>
<body>
<header class="site-header">
<img src="https://app.bethaus-speyer.de/static/icons/logo-300x300.png" alt="Logo" class="logo">
<img src="https://app.bethaus-speyer.de/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>Gottesdienste Speyer und Schwegenheim</h1>
</header>

View File

@ -5,7 +5,7 @@
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft." />
<meta property="og:image" content="https://app.bethaus-speyer.de/static/icons/logo-300x300.png" />
<meta property="og:image" content="https://app.bethaus-speyer.de/icon/logo-300x300.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<meta property="og:type" content="website" />
@ -16,7 +16,7 @@
</head>
<body>
<header class="site-header">
<img src="https://app.bethaus-speyer.de/static/icons/logo-300x300.png" alt="Logo" class="logo">
<img src="https://app.bethaus-speyer.de/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>Gottesdienste Speyer und Schwegenheim</h1>
</header>

View File

@ -5,14 +5,14 @@
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft." />
<meta property="og:image" content="https://app.bethaus-speyer.de/static/icons/logo-200x200.png" />
<meta property="og:image" content="https://app.bethaus-speyer.de/icon/logo-200x200.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<title>{{ title_short }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="description" content="... uns aber, die wir gerettet werden, ist es eine Gotteskraft.">
<meta name="author" content="Bethaus Speyer">
<link rel="icon" href="/static/icons/logo-192x192.png" type="image/png" sizes="192x192">
<link rel="icon" href="/icon/logo-192x192.png" type="image/png" sizes="192x192">
<!-- Web App Manifest -->
@ -43,7 +43,7 @@
<body>
<header class="site-header">
<a href="/">
<img src="/static/logoW.png" alt="Logo" class="logo">
<img src="/custom_logo/logoW.png" alt="Logo" class="logo">
</a>
<h1>{{ title_long }}</h1>
</header>