chore: Recover v1.6.0-rc.2 source from production image
The v1.6.0 work (webmentions, reply contexts, rate limiter, migration 010) was built and deployed as git.thesatelliteoflove.com/phil/starpunk:v1.6.0-rc.2 but never committed. This restores the application code from /app in the running container so later work builds on what production runs. Tests and docs for v1.6.0 were not in the image and are not recovered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
06a8aabc01
commit
d3fa5b7a2a
24 files changed
+3982
-78
No files matched your search
+220
-4
@@ -6,10 +6,13 @@ editing, and deletion. All routes require authentication.
|
||||
"""
|
||||
|
||||
from flask import Blueprint, flash, g, jsonify, redirect, render_template, request, url_for
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
from starpunk.auth import require_auth
|
||||
from starpunk.notes import (
|
||||
create_note,
|
||||
@@ -32,17 +35,51 @@ def dashboard():
|
||||
Displays all notes (published and drafts) with management controls.
|
||||
Requires authentication.
|
||||
|
||||
Per v1.6.0: Added pagination (25 items per page)
|
||||
|
||||
Returns:
|
||||
Rendered dashboard template with complete note list
|
||||
Rendered dashboard template with paginated note list
|
||||
|
||||
Decorator: @require_auth
|
||||
Template: templates/admin/dashboard.html
|
||||
Access: g.user_me (set by require_auth decorator)
|
||||
"""
|
||||
# Get all notes (published and drafts)
|
||||
notes = list_notes()
|
||||
from flask import current_app
|
||||
import math
|
||||
|
||||
return render_template("admin/dashboard.html", notes=notes, user_me=g.me)
|
||||
# Get pagination params (v1.6.0)
|
||||
page = int(request.args.get('page', 1))
|
||||
per_page = 25
|
||||
|
||||
# Get all notes (published and drafts)
|
||||
all_notes = list_notes()
|
||||
|
||||
# Calculate pagination
|
||||
total_notes = len(all_notes)
|
||||
total_pages = math.ceil(total_notes / per_page) if total_notes > 0 else 1
|
||||
|
||||
# Slice for current page
|
||||
start_idx = (page - 1) * per_page
|
||||
end_idx = start_idx + per_page
|
||||
notes = all_notes[start_idx:end_idx]
|
||||
|
||||
# Get pending webmention count (v1.6.0)
|
||||
webmention_pending_count = 0
|
||||
if current_app.config.get('WEBMENTION_ENABLED', False):
|
||||
try:
|
||||
from starpunk.webmention_queries import count_webmentions
|
||||
webmention_pending_count = count_webmentions(status_filter='pending')
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return render_template(
|
||||
"admin/dashboard.html",
|
||||
notes=notes,
|
||||
page=page,
|
||||
total_pages=total_pages,
|
||||
webmention_pending_count=webmention_pending_count,
|
||||
user_me=g.me
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/new", methods=["GET"])
|
||||
@@ -600,3 +637,182 @@ def health_diagnostics():
|
||||
diagnostics["status"] = "healthy" if overall_healthy else "unhealthy"
|
||||
|
||||
return jsonify(diagnostics), 200 if overall_healthy else 500
|
||||
|
||||
|
||||
# Webmention Admin Routes (v1.6.0)
|
||||
|
||||
@bp.route("/webmentions")
|
||||
@require_auth
|
||||
def webmentions():
|
||||
"""
|
||||
Webmention list with filtering and pagination (v1.6.0 Phase 5)
|
||||
|
||||
Lists all webmentions with status filters and pagination.
|
||||
|
||||
Query params:
|
||||
status: Filter by moderation_status ('pending', 'approved', 'hidden')
|
||||
page: Page number (default: 1)
|
||||
|
||||
Returns:
|
||||
Rendered webmentions list template
|
||||
|
||||
Decorator: @require_auth
|
||||
Template: templates/admin/webmentions.html
|
||||
"""
|
||||
from starpunk.webmention_queries import list_webmentions
|
||||
|
||||
status_filter = request.args.get('status')
|
||||
page = int(request.args.get('page', 1))
|
||||
|
||||
webmentions, total_pages = list_webmentions(
|
||||
status_filter=status_filter,
|
||||
page=page,
|
||||
per_page=25
|
||||
)
|
||||
|
||||
return render_template(
|
||||
"admin/webmentions.html",
|
||||
webmentions=webmentions,
|
||||
status_filter=status_filter,
|
||||
page=page,
|
||||
total_pages=total_pages,
|
||||
user_me=g.me
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/webmentions/<int:id>")
|
||||
@require_auth
|
||||
def webmention_detail(id: int):
|
||||
"""
|
||||
Webmention detail view (v1.6.0 Phase 5)
|
||||
|
||||
Shows full details of a single webmention with moderation actions.
|
||||
|
||||
Args:
|
||||
id: Webmention database ID
|
||||
|
||||
Returns:
|
||||
Rendered webmention detail template or 404 if not found
|
||||
|
||||
Decorator: @require_auth
|
||||
Template: templates/admin/webmention_detail.html
|
||||
"""
|
||||
from starpunk.webmention_queries import get_webmention
|
||||
|
||||
webmention = get_webmention(id)
|
||||
|
||||
if not webmention:
|
||||
flash("Webmention not found", "error")
|
||||
return redirect(url_for("admin.webmentions")), 404
|
||||
|
||||
return render_template(
|
||||
"admin/webmention_detail.html",
|
||||
webmention=webmention,
|
||||
user_me=g.me
|
||||
)
|
||||
|
||||
|
||||
@bp.route("/webmentions/<int:id>/action", methods=["POST"])
|
||||
@require_auth
|
||||
def webmention_action(id: int):
|
||||
"""
|
||||
Individual webmention moderation action (v1.6.0 Phase 5)
|
||||
|
||||
Approve, hide, or delete a single webmention.
|
||||
|
||||
Args:
|
||||
id: Webmention database ID
|
||||
|
||||
Form data:
|
||||
action: 'approve', 'hide', or 'delete'
|
||||
|
||||
Returns:
|
||||
Redirect to webmention detail or list
|
||||
|
||||
Decorator: @require_auth
|
||||
"""
|
||||
from starpunk.webmention_queries import update_webmention_status, delete_webmentions
|
||||
|
||||
action = request.form.get('action')
|
||||
|
||||
if action not in ('approve', 'hide', 'delete'):
|
||||
flash("Invalid action", "error")
|
||||
return redirect(url_for("admin.webmention_detail", id=id))
|
||||
|
||||
try:
|
||||
if action == 'delete':
|
||||
deleted = delete_webmentions([id])
|
||||
if deleted > 0:
|
||||
flash("Webmention deleted", "success")
|
||||
else:
|
||||
flash("Webmention not found", "error")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
else:
|
||||
# Approve or hide
|
||||
status = 'approved' if action == 'approve' else 'hidden'
|
||||
updated = update_webmention_status([id], status)
|
||||
if updated > 0:
|
||||
flash(f"Webmention {status}", "success")
|
||||
else:
|
||||
flash("Webmention not found", "error")
|
||||
return redirect(url_for("admin.webmention_detail", id=id))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error performing webmention action: {e}")
|
||||
flash(f"Error: {e}", "error")
|
||||
return redirect(url_for("admin.webmention_detail", id=id))
|
||||
|
||||
|
||||
@bp.route("/webmentions/bulk-action", methods=["POST"])
|
||||
@require_auth
|
||||
def webmention_bulk_action():
|
||||
"""
|
||||
Bulk webmention moderation actions (v1.6.0 Phase 5)
|
||||
|
||||
Approve, hide, or delete multiple webmentions at once.
|
||||
|
||||
Form data:
|
||||
action: 'approve', 'hide', or 'delete'
|
||||
ids[]: List of webmention IDs
|
||||
|
||||
Returns:
|
||||
Redirect to webmentions list
|
||||
|
||||
Decorator: @require_auth
|
||||
"""
|
||||
from starpunk.webmention_queries import update_webmention_status, delete_webmentions
|
||||
|
||||
action = request.form.get('action')
|
||||
ids = request.form.getlist('ids')
|
||||
|
||||
if not ids:
|
||||
flash("No webmentions selected", "warning")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
|
||||
# Convert IDs to integers
|
||||
try:
|
||||
webmention_ids = [int(id) for id in ids]
|
||||
except ValueError:
|
||||
flash("Invalid webmention IDs", "error")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
|
||||
if action not in ('approve', 'hide', 'delete'):
|
||||
flash("Invalid action", "error")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
|
||||
try:
|
||||
if action == 'delete':
|
||||
deleted = delete_webmentions(webmention_ids)
|
||||
flash(f"Deleted {deleted} webmention(s)", "success")
|
||||
else:
|
||||
# Approve or hide
|
||||
status = 'approved' if action == 'approve' else 'hidden'
|
||||
updated = update_webmention_status(webmention_ids, status)
|
||||
flash(f"Updated {updated} webmention(s) to {status}", "success")
|
||||
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error performing bulk action: {e}")
|
||||
flash(f"Error: {e}", "error")
|
||||
return redirect(url_for("admin.webmentions"))
|
||||
Reference in new issue
Block a user