""" Public routes for StarPunk Handles public-facing pages including homepage and note permalinks. No authentication required for these routes. """ from flask import Blueprint, abort, render_template from starpunk.notes import list_notes, get_note # Create blueprint bp = Blueprint("public", __name__) @bp.route("/") def index(): """ Homepage displaying recent published notes Returns: Rendered homepage template with note list Template: templates/index.html Microformats: h-feed containing h-entry items """ # Get recent published notes (limit 20) notes = list_notes(published_only=True, limit=20) return render_template("index.html", notes=notes) @bp.route("/note/") def note(slug: str): """ Individual note permalink page Args: slug: URL-safe note identifier Returns: Rendered note template with full content Raises: 404: If note not found or not published Template: templates/note.html Microformats: h-entry """ # Get note by slug note_obj = get_note(slug=slug) # Return 404 if note doesn't exist or isn't published if not note_obj or not note_obj.published: abort(404) return render_template("note.html", note=note_obj)