Compare commits

..

No commits in common. "e43883e2bfd36b1735d3677dbf00d72358d85587" and "0c580090dd709b4059b5c7c92398115c01907786" have entirely different histories.

5 changed files with 45 additions and 57 deletions

22
app.py
View File

@ -103,11 +103,6 @@ def list_directory_contents(directory, subpath):
transcription_dir = os.path.join(directory, "Transkription")
transcription_exists = os.path.isdir(transcription_dir)
direct_directories = []
for item in folder_config:
for folder in item['folders']:
direct_directories.append(folder['foldername'])
# Define allowed file extensions.
music_exts = ('.mp3',)
image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp')
@ -130,16 +125,7 @@ def list_directory_contents(directory, subpath):
if entry.name in ["Transkription", "@eaDir"]:
continue
rel_path = os.path.join(subpath, entry.name) if subpath else entry.name
# check if path is inside a direct directory --> shareable
if subpath.split('/')[0] in direct_directories:
allow_share = True
else:
allow_share = False
# build directory entry
directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'share': allow_share})
directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/')})
elif entry.is_file(follow_symlinks=False):
lower_name = entry.name.lower()
@ -152,10 +138,7 @@ def list_directory_contents(directory, subpath):
file_type = 'image'
else:
file_type = 'other'
# build file entry
file_entry = {'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'file_type': file_type}
# Only check for transcription if it's a audio file.
if file_type == 'music' and transcription_exists:
base_name = os.path.splitext(entry.name)[0]
@ -223,7 +206,7 @@ def serve_sw():
def api_browse(subpath):
if subpath == '': # root directory
foldernames = []
for foldername, _ in session['folders'].items():
for foldername, folderpath in session['folders'].items():
foldernames.append({'name': foldername, 'path': foldername})
return jsonify({
@ -438,6 +421,7 @@ def create_share(subpath):
return "Unauthorized", 403
paths = {}
for item in folder_config:
for folder in item['folders']:
paths[folder['foldername']] = folder['folderpath']

View File

@ -81,7 +81,7 @@ function renderContent(data) {
if (areAllShort && data.breadcrumbs.length !== 1) {
contentHTML += '<div class="directories-grid">';
data.directories.forEach(dir => {
if (admin_enabled && data.breadcrumbs.length != 1 && dir.share) {
if (admin_enabled && data.breadcrumbs.length != 1) {
share_link = `<a href="#" class="create-share" data-url="${dir.path}">⚙️</a>`;
}
contentHTML += `<div class="directory-item"><a href="#" class="directory-link" data-path="${dir.path}">📁 ${dir.name}</a>
@ -92,7 +92,7 @@ function renderContent(data) {
} else {
contentHTML += '<ul>';
data.directories.forEach(dir => {
if (admin_enabled && data.breadcrumbs.length != 1 && dir.share) {
if (admin_enabled && data.breadcrumbs.length != 1) {
share_link = `<a href="#" class="create-share" data-url="${dir.path}">⚙️</a>`;
}
contentHTML += `<li class="directory-item"><a href="#" class="directory-link" data-path="${dir.path}">📁 ${dir.name}</a>
@ -542,4 +542,34 @@ function syncThemeColor() {
.forEach(svg => svg.setAttribute('fill', cssVar));
}
function copyTokenUrl(url) {
if (navigator.clipboard && window.isSecureContext) {
// Modern approach
navigator.clipboard.writeText(url)
.then(() => {
alert('Token-URL in die Zwischenablage kopiert!');
})
.catch(err => {
console.error('Fehler beim Kopieren: ', err);
});
} else {
// Fallback for older browsers
const textarea = document.createElement('textarea');
textarea.value = url;
textarea.style.position = 'fixed'; // Verhindert Scrollen
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
try {
document.execCommand('copy');
alert('Token-URL in die Zwischenablage kopiert!');
} catch (err) {
console.error('Fallback: Kopieren fehlgeschlagen', err);
}
document.body.removeChild(textarea);
}
}
document.addEventListener('DOMContentLoaded', syncThemeColor);

View File

@ -1,28 +0,0 @@
function toClipboard(url) {
if (navigator.clipboard && window.isSecureContext) {
// Modern approach
navigator.clipboard.writeText(url)
.then(() => {
alert('Link in die Zwischenablage kopiert!');
})
.catch(err => {
console.error('Fehler beim Kopieren: ', err);
});
} else {
// Fallback for older browsers
const textarea = document.createElement('textarea');
textarea.value = url;
textarea.style.position = 'fixed'; // Verhindert Scrollen
textarea.style.opacity = '0';
document.body.appendChild(textarea);
textarea.focus();
textarea.select();
try {
document.execCommand('copy');
alert('Token-URL in die Zwischenablage kopiert!');
} catch (err) {
console.error('Fallback: Kopieren fehlgeschlagen', err);
}
document.body.removeChild(textarea);
}
}

View File

@ -35,7 +35,6 @@
<script> const admin_enabled = {{ admin_enabled | tojson | safe }}; </script>
</head>
<body>
<script src="{{ url_for('static', filename='functions.js') }}"></script>
<header class="site-header">
<a href="/">
<img src="/custom_logo/logoW.png" alt="Logo" class="logo">

View File

@ -24,7 +24,6 @@
</style>
</head>
<body>
<script src="{{ url_for('static', filename='functions.js') }}"></script>
<!-- Navigation Bar -->
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
<div class="container-fluid">
@ -50,12 +49,14 @@
<img src="data:image/png;base64,{{ secret_qr_codes[secret] }}" class="card-img-top qr-code p-3" alt="QR Code for secret">
<div class="card-body">
<h5 class="card-title">Geheimnis: {{ secret }}</h5>
<p class="card-text">
<a href="https://{{ request.host }}?secret={{ secret }}" class="text-decoration-none">
{{ secret_url[secret] }}
</a>
</p>
<p class="card-text">
<small class="text-muted">Gültig bis: {{ secret_valid_to[secret] }}</small>
</p>
<a href="{{ secret_url[secret] }}" class="btn btn-secondary btn-sm">Link öffnen</a>
<button class="btn btn-secondary btn-sm" onclick="toClipboard('{{ secret_url[secret] }}')">Link kopieren</button>
<br>
<form method="post" action="{{ url_for('remove_secret') }}" class="mt-3">
<input type="hidden" name="secret" value="{{ secret }}">
<button type="submit" class="btn btn-danger btn-sm">Link entfernen</button>
@ -84,12 +85,14 @@
<img src="data:image/png;base64,{{ token_qr_codes[token] }}" class="card-img-top qr-code p-3" alt="QR Code for token">
<div class="card-body">
<h5 class="card-title">Token-Link:</h5>
<p class="card-text">
<a href="https://{{ request.host }}?token={{ token }}" class="text-decoration-none">
{{ token_url[token] }}
</a>
</p>
<p class="card-text">
<small class="text-muted">Gültig bis: {{ token_valid_to[token] }}</small>
</p>
<a href="{{ token_url[token] }}" class="btn btn-secondary btn-sm">Link öffnen</a>
<button class="btn btn-secondary btn-sm" onclick="toClipboard('{{ token_url[token] }}')">Link kopieren</button>
<br>
<form method="post" action="{{ url_for('remove_token') }}" class="mt-3">
<input type="hidden" name="token" value="{{ token }}">
<button type="submit" class="btn btn-danger btn-sm">Link entfernen</button>