feat: MCP tools for settings, headings and image alt

- POST /_journal/api/v1/images/alt {dry_run, changes} sets alt on the
  matching img of default or translated content through the tokenizer,
  all or nothing (422), with a RecordSaved per changed post
- MCP journal_get_settings, journal_update_settings, journal_fix_headings
  (manage_settings) and journal_set_image_alt (access_posts, destructive)
- journal:fix-headings help names its output and the refusal
This commit is contained in:
Jakub Zych
2026-11-04 10:10:52 +01:00
parent 5210b64e0f
commit af25eaa677
10 changed files with 597 additions and 15 deletions

View File

@@ -13,7 +13,13 @@ import (
// FixHeadings is journal:fix-headings: it converts H1 to H2 in stored
// Journal rich text (post content in every locale and category pillar text)
// while the Journal H1 setting is on. It is a dry run unless --apply is
// given; with the setting off it refuses with exit code 1.
// given; with the setting off it refuses with exit code 1. Its output (UI-SPEC
// C27 with the P33-54 wording, English only):
//
// - dry run: "Would convert :count H1 headings in :posts posts and :categories categories. Run with --apply to save."
// - applied: "Converted :count H1 headings in :posts posts and :categories categories."
// - nothing to do: "No H1 headings found in post or category content."
// - refused (classes.H1ConversionOffText): "H1 to H2 conversion is turned off in the Journal settings (Headings and links). Turn it on first, or keep the H1 headings."
func FixHeadings(app *backpack.App) bonfire.Command {
return bonfire.Command{
Name: "journal:fix-headings",
@@ -28,8 +34,10 @@ categories. Run with --apply to save."). With --apply it converts them in
one transaction, fires a record event per changed post and category (so an
SEO or search plugin hears about it) and queues the site cache purge.
While the H1 setting is off the command refuses and exits with code 1. The
MCP tool journal_fix_headings runs the same conversion.`,
While the H1 setting is off the command prints "H1 to H2 conversion is
turned off in the Journal settings (Headings and links). Turn it on first, or
keep the H1 headings." and exits with code 1. The MCP tool
journal_fix_headings runs the same conversion.`,
Flags: []bonfire.Flag{
{Name: "apply", Description: "Save the converted content (default: dry run)", Bare: true},
{Name: "dry-run", Description: "Only count the H1 headings (the default)", Bare: true},

View File

@@ -16,8 +16,8 @@ import (
translate "git.golem15.com/golem15/sm-translate-plugin/classes"
"git.golem15.com/golem15/summercms/modules/backpack"
"git.golem15.com/golem15/summercms/modules/bonfire"
"git.golem15.com/golem15/summercms/modules/compass"
"git.golem15.com/golem15/summercms/modules/cabana"
"git.golem15.com/golem15/summercms/modules/compass"
"gorm.io/gorm"
)