Compare commits
No commits in common. "e43883e2bfd36b1735d3677dbf00d72358d85587" and "0c580090dd709b4059b5c7c92398115c01907786" have entirely different histories.
e43883e2bf
...
0c580090dd
22
app.py
22
app.py
@ -103,11 +103,6 @@ def list_directory_contents(directory, subpath):
|
|||||||
transcription_dir = os.path.join(directory, "Transkription")
|
transcription_dir = os.path.join(directory, "Transkription")
|
||||||
transcription_exists = os.path.isdir(transcription_dir)
|
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.
|
# Define allowed file extensions.
|
||||||
music_exts = ('.mp3',)
|
music_exts = ('.mp3',)
|
||||||
image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp')
|
image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp')
|
||||||
@ -130,16 +125,7 @@ def list_directory_contents(directory, subpath):
|
|||||||
if entry.name in ["Transkription", "@eaDir"]:
|
if entry.name in ["Transkription", "@eaDir"]:
|
||||||
continue
|
continue
|
||||||
rel_path = os.path.join(subpath, entry.name) if subpath else entry.name
|
rel_path = os.path.join(subpath, entry.name) if subpath else entry.name
|
||||||
|
directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/')})
|
||||||
# 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})
|
|
||||||
|
|
||||||
elif entry.is_file(follow_symlinks=False):
|
elif entry.is_file(follow_symlinks=False):
|
||||||
lower_name = entry.name.lower()
|
lower_name = entry.name.lower()
|
||||||
|
|
||||||
@ -152,10 +138,7 @@ def list_directory_contents(directory, subpath):
|
|||||||
file_type = 'image'
|
file_type = 'image'
|
||||||
else:
|
else:
|
||||||
file_type = 'other'
|
file_type = 'other'
|
||||||
|
|
||||||
# build file entry
|
|
||||||
file_entry = {'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'file_type': file_type}
|
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.
|
# Only check for transcription if it's a audio file.
|
||||||
if file_type == 'music' and transcription_exists:
|
if file_type == 'music' and transcription_exists:
|
||||||
base_name = os.path.splitext(entry.name)[0]
|
base_name = os.path.splitext(entry.name)[0]
|
||||||
@ -223,7 +206,7 @@ def serve_sw():
|
|||||||
def api_browse(subpath):
|
def api_browse(subpath):
|
||||||
if subpath == '': # root directory
|
if subpath == '': # root directory
|
||||||
foldernames = []
|
foldernames = []
|
||||||
for foldername, _ in session['folders'].items():
|
for foldername, folderpath in session['folders'].items():
|
||||||
foldernames.append({'name': foldername, 'path': foldername})
|
foldernames.append({'name': foldername, 'path': foldername})
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
@ -438,6 +421,7 @@ def create_share(subpath):
|
|||||||
return "Unauthorized", 403
|
return "Unauthorized", 403
|
||||||
|
|
||||||
paths = {}
|
paths = {}
|
||||||
|
|
||||||
for item in folder_config:
|
for item in folder_config:
|
||||||
for folder in item['folders']:
|
for folder in item['folders']:
|
||||||
paths[folder['foldername']] = folder['folderpath']
|
paths[folder['foldername']] = folder['folderpath']
|
||||||
|
|||||||
@ -81,7 +81,7 @@ function renderContent(data) {
|
|||||||
if (areAllShort && data.breadcrumbs.length !== 1) {
|
if (areAllShort && data.breadcrumbs.length !== 1) {
|
||||||
contentHTML += '<div class="directories-grid">';
|
contentHTML += '<div class="directories-grid">';
|
||||||
data.directories.forEach(dir => {
|
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>`;
|
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>
|
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 {
|
} else {
|
||||||
contentHTML += '<ul>';
|
contentHTML += '<ul>';
|
||||||
data.directories.forEach(dir => {
|
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>`;
|
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>
|
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));
|
.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);
|
document.addEventListener('DOMContentLoaded', syncThemeColor);
|
||||||
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -35,7 +35,6 @@
|
|||||||
<script> const admin_enabled = {{ admin_enabled | tojson | safe }}; </script>
|
<script> const admin_enabled = {{ admin_enabled | tojson | safe }}; </script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="{{ url_for('static', filename='functions.js') }}"></script>
|
|
||||||
<header class="site-header">
|
<header class="site-header">
|
||||||
<a href="/">
|
<a href="/">
|
||||||
<img src="/custom_logo/logoW.png" alt="Logo" class="logo">
|
<img src="/custom_logo/logoW.png" alt="Logo" class="logo">
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script src="{{ url_for('static', filename='functions.js') }}"></script>
|
|
||||||
<!-- Navigation Bar -->
|
<!-- Navigation Bar -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary mb-3">
|
||||||
<div class="container-fluid">
|
<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">
|
<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">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Geheimnis: {{ secret }}</h5>
|
<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">
|
<p class="card-text">
|
||||||
<small class="text-muted">Gültig bis: {{ secret_valid_to[secret] }}</small>
|
<small class="text-muted">Gültig bis: {{ secret_valid_to[secret] }}</small>
|
||||||
</p>
|
</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">
|
<form method="post" action="{{ url_for('remove_secret') }}" class="mt-3">
|
||||||
<input type="hidden" name="secret" value="{{ secret }}">
|
<input type="hidden" name="secret" value="{{ secret }}">
|
||||||
<button type="submit" class="btn btn-danger btn-sm">Link entfernen</button>
|
<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">
|
<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">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Token-Link:</h5>
|
<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">
|
<p class="card-text">
|
||||||
<small class="text-muted">Gültig bis: {{ token_valid_to[token] }}</small>
|
<small class="text-muted">Gültig bis: {{ token_valid_to[token] }}</small>
|
||||||
</p>
|
</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">
|
<form method="post" action="{{ url_for('remove_token') }}" class="mt-3">
|
||||||
<input type="hidden" name="token" value="{{ token }}">
|
<input type="hidden" name="token" value="{{ token }}">
|
||||||
<button type="submit" class="btn btn-danger btn-sm">Link entfernen</button>
|
<button type="submit" class="btn btn-danger btn-sm">Link entfernen</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user