extend customisation of app

This commit is contained in:
lelo 2025-04-14 21:46:31 +00:00
parent 8ac541f597
commit 7f54aba4af
5 changed files with 64 additions and 34 deletions

24
app.py
View File

@ -21,17 +21,17 @@ import auth
import analytics as a
with open("app_config.json", 'r') as file:
config = json.load(file)
app_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)
cache_audio = diskcache.Cache('./filecache_audio', size_limit= app_config['filecache_size_limit_audio'] * 1024**3)
cache_image = diskcache.Cache('./filecache_image', size_limit= app_config['filecache_size_limit_image'] * 1024**3)
cache_video = diskcache.Cache('./filecache_video', size_limit= app_config['filecache_size_limit_video'] * 1024**3)
cache_other = diskcache.Cache('./filecache_other', size_limit= app_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'] = config['SECRET_KEY']
app.config['SECRET_KEY'] = app_config['SECRET_KEY']
app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=90)
if os.environ.get('FLASK_ENV') == 'production':
app.config['SESSION_COOKIE_SAMESITE'] = 'None'
@ -464,12 +464,12 @@ def handle_request_initial_data():
@app.route('/<path:path>')
@auth.require_secret
def index(path):
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')
title_short = app_config.get('TITLE_SHORT', 'Default Title')
title_long = app_config.get('TITLE_LONG' , 'Default Title')
header_color = app_config.get('header_color' , '#000')
header_text_color = app_config.get('header_text_color', '#fff')
background_color = app_config.get('background_color', '#fff')
main_text_color = app_config.get('main_text_color', '#000')
return render_template("app.html",
title_short=title_short,
title_long=title_long,

19
auth.py
View File

@ -9,6 +9,9 @@ import base64
folder_config = {}
with open("app_config.json", 'r') as file:
app_config = json.load(file)
def require_secret(f):
@wraps(f)
def decorated_function(*args, **kwargs):
@ -79,8 +82,20 @@ def require_secret(f):
session['device_id'] = os.urandom(32).hex()
return f(*args, **kwargs)
else:
return render_template('index.html')
title_short = app_config.get('TITLE_SHORT', 'Default Title')
title_long = app_config.get('TITLE_LONG' , 'Default Title')
header_color = app_config.get('header_color' , '#000')
header_text_color = app_config.get('header_text_color', '#fff')
background_color = app_config.get('background_color', '#fff')
main_text_color = app_config.get('main_text_color', '#000')
return render_template('index.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,
)
return decorated_function
@require_secret

View File

@ -3,15 +3,14 @@
<head>
<meta charset="utf-8">
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:title" content="{{ title_long }}" />
<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/icon/logo-200x200.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<meta property="og:image" content="/icon/logo-200x200.png" />
<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">
<meta name="author" content="{{ title_short }}">
<link rel="icon" href="/icon/logo-192x192.png" type="image/png" sizes="192x192">

View File

@ -3,25 +3,33 @@
<head>
<meta charset="utf-8">
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:title" content="{{ title_long }}" />
<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/icon/logo-300x300.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<meta property="og:type" content="website" />
<meta property="og:image" content="/icon/logo-300x300.png" />
<title>Gottesdienste Speyer und Schwegenheim</title>
<title>{{ title_long }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="{{ url_for('static', filename='app.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">
<img src="https://app.bethaus-speyer.de/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>Gottesdienste Speyer und Schwegenheim</h1>
<img src="/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>{{ title_long }}</h1>
</header>
<div class="container">
<div id="content">Etwas ist schief gelaufen. Entweder ein Link ist veraltet oder die App ist gerade gestört.<br>Versuche den Link aus der Telegram-Gruppe erneut anklicken um dies zu beheben.</div>
<div id="content">Etwas ist schief gelaufen. Entweder ein Link ist veraltet oder die App ist gerade gestört.<br>Versuche den Freigabelink erneut anzuklicken.</div>
</div>
</body>
</html>

View File

@ -3,25 +3,33 @@
<head>
<meta charset="utf-8">
<meta property="og:title" content="Gottesdienste Speyer und Schwegenheim" />
<meta property="og:title" content="{{ title_long }}" />
<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/icon/logo-300x300.png" />
<meta property="og:url" content="https://app.bethaus-speyer.de" />
<meta property="og:type" content="website" />
<meta property="og:image" content="/icon/logo-300x300.png" />
<title>Gottesdienste Speyer und Schwegenheim</title>
<title>{{ title_long }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="{{ url_for('static', filename='app.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">
<img src="https://app.bethaus-speyer.de/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>Gottesdienste Speyer und Schwegenheim</h1>
<img src="/icon/logo-300x300.png" alt="Logo" class="logo">
<h1>{{ title_long }}</h1>
</header>
<div class="container">
<div id="content">Du hast keine gültigen Links im Speicher.<br>Bitte den Link aus der Telegram-Gruppe erneut anklicken.</div>
<div id="content">Du hast keine Links die noch gültig sind.<br>Bitte den Freigabelink erneut anklicken.</div>
</div>
</body>
</html>