Compare commits

..

3 Commits

Author SHA1 Message Date
Alex Dunmow
d08466ec70 chore: fix SDK downstream paths for consolidated layout
SDK_DOWNSTREAM_DIRS pointed at the pre-consolidation layout
(~/src/blockninja/backend, ~/src/orchestrator/backend, ~/src/blockninja-themes,
~/src/{assumechaos,bidbuddy,...}) — none of which exist after all repos moved
under ~/src/blockninja/. Repoint at cms/backend + orchestrator/backend and
wildcard themes/ sites/ plugins/ so update-sdk/distribute-sdk reach them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 13:18:12 +08:00
Alex Dunmow
d9788abe4c feat(plugin): media deposit SDK surface — Media, MediaDeposit, EnsureMedia
Add the SDK surface for plugins to deposit images into the CMS media library.
MediaDeposit / MediaResult types and a Media interface on CoreServices for
runtime deposits; EnsureMedia on the Provisioner interface for idempotent
seed-time deposits under a plugin-chosen, template-referable UUID. The CMS
implements both against one internal depositor; seeded templates reference
the chosen UUID directly via {% img "<id>" %}.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 13:14:31 +08:00
Alex Dunmow
e309e3d80b chore: bump templ to v0.3.1020
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 13:14:31 +08:00
5 changed files with 55 additions and 11 deletions

View File

@ -2,16 +2,11 @@ SDK_MODULE := git.dev.alexdunmow.com/block/core
SDK_VERSION ?= $(shell git describe --tags --abbrev=0)
SDK_DOWNSTREAM_DIRS := \
$(HOME)/src/blockninja/backend \
$(HOME)/src/orchestrator/backend \
$(wildcard $(HOME)/src/blockninja-themes/*) \
$(HOME)/src/assumechaos \
$(HOME)/src/bidbuddy \
$(HOME)/src/bidmasters \
$(HOME)/src/coterieos \
$(HOME)/src/messenger \
$(HOME)/src/perthplaygrounds \
$(HOME)/src/symposium
$(HOME)/src/blockninja/cms/backend \
$(HOME)/src/blockninja/orchestrator/backend \
$(wildcard $(HOME)/src/blockninja/themes/*) \
$(wildcard $(HOME)/src/blockninja/sites/*) \
$(wildcard $(HOME)/src/blockninja/plugins/*)
.PHONY: install-ninja
install-ninja:

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.26.4
require (
connectrpc.com/connect v1.20.0
github.com/BurntSushi/toml v1.6.0
github.com/a-h/templ v0.3.1001
github.com/a-h/templ v0.3.1020
github.com/flosch/pongo2/v6 v6.1.0
github.com/google/uuid v1.6.0
github.com/jackc/pgx/v5 v5.9.2

2
go.sum
View File

@ -4,6 +4,8 @@ github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/a-h/templ v0.3.1001 h1:yHDTgexACdJttyiyamcTHXr2QkIeVF1MukLy44EAhMY=
github.com/a-h/templ v0.3.1001/go.mod h1:oCZcnKRf5jjsGpf2yELzQfodLphd2mwecwG4Crk5HBo=
github.com/a-h/templ v0.3.1020 h1:ypAT/L5ySWEnZ6Zft/5yfoWXYYkhFNvEFOeeqecg4tw=
github.com/a-h/templ v0.3.1020/go.mod h1:A2DlK61v+K+NRoGnhmYbNYVmtYHcFO5/AisMvBdDxTM=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=

View File

@ -38,6 +38,9 @@ type CoreServices struct {
MediaPath string
AppURL string
// Media library — deposit images through the full upload pipeline
Media Media
// AI
ToolRegistry ai.ToolRegistry
AITextCall func(ctx context.Context, taskKey, systemPrompt, userMessage string) (string, error)
@ -60,6 +63,45 @@ type CoreServices struct {
RAGService RAGService
}
// MediaDeposit describes an image a plugin deposits into the CMS media library.
// The bytes flow through the same pipeline as an admin upload (optimize, WebP,
// thumbnails, LQIP, dimensions); responsive variants are generated on demand.
type MediaDeposit struct {
// ID is the media row's primary key. REQUIRED for Provisioner.EnsureMedia —
// it is the deterministic, template-referable key a seeded {% img %} tag
// resolves by. Optional for Media.Deposit, where a zero value is generated.
ID uuid.UUID
// Filename is the original filename, e.g. "hero.jpg".
Filename string
// Data is the raw image bytes, typically from go:embed.
Data []byte
// AltText is optional accessibility text.
AltText string
// Folder optionally groups the media under a named library folder,
// created if absent.
Folder string
// Source is an optional provenance label, e.g. the plugin name.
Source string
}
// MediaResult reports the outcome of a deposit.
type MediaResult struct {
// ID is the media row's primary key (the supplied ID, or a generated one).
ID uuid.UUID
// Ref is a ready-to-use reference ("media:<uuid>") for a block src or a
// {% img %} tag.
Ref string
// Created is false when an existing row with the supplied ID was reused.
Created bool
}
// Media lets a plugin deposit images into the CMS media library at runtime.
// Seed-time deposits use Provisioner.EnsureMedia instead — it is idempotent
// (skip if the ID exists; on changed bytes it warns rather than overwriting).
type Media interface {
Deposit(ctx context.Context, deposit MediaDeposit) (MediaResult, error)
}
// JobRunner submits background jobs for async processing.
type JobRunner interface {
Submit(ctx context.Context, jobType string, config []byte) error

View File

@ -23,6 +23,11 @@ type Provisioner interface {
DisableOrphanedJobSchedules(registeredTypes []string) error
EnsurePlugin(name string) error
EnsureCustomColor(config CustomColorConfig) error
// EnsureMedia deposits an image under the plugin-chosen MediaDeposit.ID if a
// row with that ID does not already exist. Idempotent: an existing ID is a
// no-op; if the bytes differ from what was first deposited it logs a warning
// rather than overwriting (seeded media is immutable once placed).
EnsureMedia(deposit MediaDeposit) error
}
// DataTableConfig defines a data table to provision.