PhoenixKit.Modules.Publishing.Web.Controller (PhoenixKitPublishing v0.6.0)

Copy Markdown View Source

Public post display controller.

Handles public-facing routes for viewing published posts with multi-language support.

URL patterns: /:language/:group_slug/:post_slug - Slug mode post /:language/:group_slug/:date/:time - Timestamp mode post /:language/:group_slug - Group listing

Architecture

This controller delegates to specialized submodules:

  • Routing - URL path parsing and segment building
  • Language - Language detection and resolution
  • SlugResolution - URL slug resolution and redirects
  • PostFetching - Post retrieval from cache/database
  • Listing - Group listing rendering and pagination
  • PostRendering - Post rendering and version handling
  • Translations - Translation link building
  • Fallback - 404 handling and smart fallback chain

Summary

Functions

Public comment submission (the dead-view POST form on post pages).

Displays a post, group listing, or all groups overview.

Functions

create_comment(conn, params)

Public comment submission (the dead-view POST form on post pages).

Guards, in order: module+public on, the group exists and has comments_enabled, the comments seam is available, honeypot empty, the signed form token is 3s–1day old (bots submit instantly; stale tabs re-render), the post uuid belongs to the group's published set, and the reader is logged in. Plain form posts get a flash + redirect back to the post (or the group listing when the post can't be resolved); requests from the page's fetch enhancement (x-pk-comment-fetch header) get a JSON verdict instead so the client can swap the thread in place.

show(conn, params)

Displays a post, group listing, or all groups overview.

Path parsing determines which action to take:

  • [] -> Invalid request (no group specified)
  • [group_slug] -> Group listing
  • [group_slug, post_slug] -> Slug mode post
  • [group_slug, date] -> Date-only timestamp (resolves to single post or first post)
  • [group_slug, date, time] -> Timestamp mode post