reverseproxy

This commit is contained in:
2026-09-07 12:46:58 +02:00
parent 93051f791d
commit cbe4726c07
16 changed files with 519 additions and 32 deletions

View File

@@ -160,16 +160,19 @@ document.querySelectorAll('.tab-btn').forEach((btn) => {
document.getElementById('blockType').value = selectedType;
const fileWrap = document.getElementById('blockFileWrap');
const textWrap = document.getElementById('blockTextWrap');
const coverWrap = document.getElementById('blockCoverWrap');
const fileLabel = document.getElementById('blockFileLabel');
const fileInput = document.getElementById('blockFile');
if (selectedType === 'text') {
fileWrap.style.display = 'none';
textWrap.style.display = 'block';
coverWrap.style.display = 'none';
} else {
fileWrap.style.display = 'block';
textWrap.style.display = 'none';
fileLabel.textContent = selectedType === 'image' ? 'Bild auswählen' : 'MP3 auswählen';
fileInput.accept = selectedType === 'image' ? 'image/*' : 'audio/*';
coverWrap.style.display = selectedType === 'audio' ? 'block' : 'none';
}
});
});
@@ -185,12 +188,17 @@ document.getElementById('blockForm').addEventListener('submit', async (e) => {
const file = document.getElementById('blockFile').files[0];
if (!file) { alert('Bitte eine Datei auswählen.'); return; }
fd.append('file', file);
if (selectedType === 'audio') {
const coverFile = document.getElementById('blockCover').files[0];
if (coverFile) fd.append('cover', coverFile);
}
}
const res = await fetch(`/api/friends/${friendId}/blocks`, { method: 'POST', body: fd });
const data = await res.json();
if (res.ok) {
currentFriend = data.friend;
document.getElementById('blockForm').reset();
document.getElementById('blockCoverWrap').style.display = selectedType === 'audio' ? 'block' : 'none';
renderBlocks();
} else {
alert(data.error || 'Hinzufügen fehlgeschlagen.');
@@ -209,6 +217,9 @@ function renderBlocks() {
if (b.type === 'image') {
inner += `<img src="${uploadUrl(b.filename)}" />`;
} else if (b.type === 'audio') {
inner += b.coverFilename
? `<img src="${uploadUrl(b.coverFilename)}" style="margin-bottom:0.4em;" />`
: '';
inner += `<audio controls src="${uploadUrl(b.filename)}"></audio>`;
} else {
inner += `<textarea data-content-for="${b.id}">${escapeHtml(b.content)}</textarea>`;

View File

@@ -67,6 +67,11 @@
<label>Text</label>
<textarea id="blockContent" placeholder="Schreib etwas Schönes..."></textarea>
</div>
<div id="blockCoverWrap" style="display:none; margin-top:0.8em;">
<label>Cover-Bild (optional)</label>
<input type="file" id="blockCover" accept="image/*" />
<p class="muted" style="margin:0.3em 0 0; font-size:0.82rem;">Wird kein Cover ausgewählt, versuchen wir automatisch ein in der MP3 eingebettetes Cover zu verwenden.</p>
</div>
<label style="margin-top:0.8em;">Bildunterschrift (optional)</label>
<input type="text" id="blockCaption" placeholder="z. B. Sommer 2026" />
<button type="submit" style="margin-top:0.8em;">+ Hinzufügen</button>