Auto-LLM für Web-Submits, ID-Footer auf Detailseite, Unpublish-Button
- api_submit: auto_process_bg() im Hintergrund-Thread für Halle/Summary - /beitrag/<id>: Beitrags-ID ganz unten mit DSGVO-Löschhinweis - Neuer /submission/<id>/unpublish POST-Endpoint (published -> new) - Admin-Detailview: 'Veröffentlichung zurücknehmen'-Button (nur bei published) - Toast-Animation + Redirect nach Unpublish
This commit is contained in:
@@ -1227,8 +1227,7 @@ def submission_detail(sub_id: int):
|
||||
<form method="post" action="/submission/{row['id']}/update-summary" style="margin-left:0.5rem;">
|
||||
<button type="submit" class="btn btn-publish-big" name="action" value="publish" {'disabled' if row['status'] in ('published','gdpr_deleted') else ''} style="padding:0.4rem 1.2rem;font-size:0.8rem;white-space:nowrap;">📢 Veröffentlichen</button>
|
||||
</form>
|
||||
</div>
|
||||
</header>
|
||||
{"".join([f'<button type="button" id="unpublish-btn" class="btn btn-publish" style="padding:0.35rem 0.8rem;font-size:0.75rem;white-space:nowrap;background:rgba(255,193,7,0.18);color:#ffc107;border:1px solid rgba(255,193,7,0.3);">\u2b05\ufe0f Ver\u00f6ffentlichung zur\u00fccknehmen</button>' if row['status'] == 'published' else ''])}</header>
|
||||
<main class="detail-main">
|
||||
|
||||
<div class="card">
|
||||
@@ -1301,6 +1300,34 @@ def submission_detail(sub_id: int):
|
||||
|
||||
<script>
|
||||
(function(){{if(localStorage.getItem('theme')==='light')document.body.classList.add('light');}})();
|
||||
var _unpBtn = document.getElementById('unpublish-btn');
|
||||
if (_unpBtn) {{
|
||||
_unpBtn.addEventListener('click', function() {{
|
||||
if (!confirm('Veroffentlichung von Beitrag #' + {row['id']} + ' zurucknehmen? Der Beitrag verschwindet vom Frontend, bleibt aber in der Datenbank.')) return;
|
||||
this.disabled = true;
|
||||
this.textContent = 'Nehme zuruck...';
|
||||
fetch('/submission/' + {row['id']} + '/unpublish', {{method:'POST'}})
|
||||
.then(function(r) {{ return r.json(); }})
|
||||
.then(function(data) {{
|
||||
if (data.ok) {{
|
||||
document.body.innerHTML = '<div style=\"display:flex;align-items:center;justify-content:center;min-height:100vh;background:var(--bg);\"><div style=\"background:rgba(255,193,7,0.12);color:#ffc107;padding:1.5rem 2.5rem;border-radius:12px;font-size:1.15rem;font-weight:600;text-align:center;animation:fadeInOut 1.8s ease forwards;\">Beitrag #' + {row['id']} + ' nicht mehr veroffentlicht</div></div>';
|
||||
var style = document.createElement('style');
|
||||
style.textContent = '@keyframes fadeInOut{{0%{{opacity:0;transform:scale(0.9)}}15%{{opacity:1;transform:scale(1)}}75%{{opacity:1;transform:scale(1)}}100%{{opacity:0;transform:scale(0.95)}}}}';
|
||||
document.head.appendChild(style);
|
||||
setTimeout(function(){{ window.location='/submission/' + {row['id']}; }}, 1800);
|
||||
}} else {{
|
||||
alert(data.error || 'Fehler');
|
||||
_unpBtn.disabled = false;
|
||||
_unpBtn.textContent = 'Veroffentlichung zurucknehmen';
|
||||
}}
|
||||
}})
|
||||
.catch(function(err) {{
|
||||
alert('Fehler: ' + err.message);
|
||||
_unpBtn.disabled = false;
|
||||
_unpBtn.textContent = 'Veroffentlichung zurucknehmen';
|
||||
}});
|
||||
}});
|
||||
}}
|
||||
var _delBtn = document.getElementById('delete-btn');
|
||||
if (_delBtn) {{
|
||||
_delBtn.addEventListener('click', function() {{
|
||||
@@ -1439,6 +1466,19 @@ def submission_update_summary(sub_id: int):
|
||||
return """<script>window.location='/submission/""" + str(sub_id) + """';</script>"""
|
||||
|
||||
|
||||
@app.route("/submission/<int:sub_id>/unpublish", methods=["POST"])
|
||||
def submission_unpublish(sub_id: int):
|
||||
"""Unpublish a submission - set status back to 'new' and clear published_at."""
|
||||
db = get_db()
|
||||
row = db.execute("SELECT id, status FROM submissions WHERE id = ?", (sub_id,)).fetchone()
|
||||
if not row:
|
||||
return jsonify({"error": "Nicht gefunden"}), 404
|
||||
if row["status"] != "published":
|
||||
return jsonify({"error": "Beitrag ist nicht veroffentlicht"}), 400
|
||||
db.execute("UPDATE submissions SET status='new', published_at=NULL WHERE id=?", (sub_id,))
|
||||
db.commit()
|
||||
return jsonify({"ok": True, "new_status": "new"})
|
||||
|
||||
@app.route("/submission/<int:sub_id>/done", methods=["POST"])
|
||||
def submission_done(sub_id: int):
|
||||
"""Mark a submission as done/bearbeitet."""
|
||||
@@ -2515,6 +2555,15 @@ def api_submit():
|
||||
db.commit()
|
||||
sub_id = db.execute("SELECT last_insert_rowid()").fetchone()[0]
|
||||
|
||||
# Auto-summarize via LLM (only if no halle was provided by user)
|
||||
if not halle_valid and text and len(text.strip()) > 20:
|
||||
import threading
|
||||
threading.Thread(
|
||||
target=auto_process_bg,
|
||||
args=(DB_PATH, sub_id),
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
return jsonify({
|
||||
'ok': True,
|
||||
'message': f'Beitrag #{sub_id} erfolgreich übermittelt! 🎲',
|
||||
@@ -2643,6 +2692,9 @@ def public_detail(sub_id: int):
|
||||
<footer class="site-footer">
|
||||
<p>Powered by <a href="https://brettspiel-news.de">brettspiel-news.de</a></p>
|
||||
</footer>
|
||||
<div style="text-align:center;padding:1rem 1.5rem 2.5rem;font-size:0.7rem;color:#aaa;max-width:720px;margin:0 auto;">
|
||||
Beitrags-ID: <strong style="color:#20228a;">#{sub_id}</strong> \u2014 Bei Fragen oder Löschwunsch bitte diese ID angeben.
|
||||
</div>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user