Files
summercms/internal/build/stubs/artifacts.tmpl
Jakub Zych c87148a34f feat(10-02): backend strings, controller messages and declarative toolbar
- phrasebook ships the backend::lang admin strings (pl, en) with CLDR
  plural maps, loads them as namespace backend, applies
  pact.HasLangOverrides trees (lang/<locale>/<namespace>/<group>.yaml)
  after every namespace, and fails activation when a backend key cannot
  convert to plural forms
- Translator.Forms, Bundle, Resolved and Has serve keys as CLDR form maps
- Public GET /lang returns every backend::lang key for the request
  locale over the fallback locale, Cache-Control no-cache
- config_list, config_form and config_relation accept a strict messages
  block; omitted keys take framework defaults, schemas serve every message
  as CLDR forms, and activation fails on a missing phrase key
- toolbar.buttons is an ordered [create, delete] list; the Winter string
  form, duplicates, unknown actions and delete without showCheckboxes fail
  at boot, and create is dropped when the controller has no form
- Form schema serves the raw Winter redirects; scaffold emits the list
  syntax; form and relation schema routes are typed in the admin OpenAPI
2026-09-27 16:16:32 +02:00

144 lines
3.3 KiB
Cheetah

{{define "model.go"}}// Code generated by summer make. DO NOT EDIT.
package models
import "time"
// {{.Ident}} is a generated GORM model for {{.PluginID}}.
type {{.Ident}} struct {
ID uint `gorm:"primaryKey"`
CreatedAt time.Time
UpdatedAt time.Time
}
func ({{.Ident}}) TableName() string { return {{printf "%q" .Table}} }
{{end}}
{{define "migration.go"}}// Code generated by summer make. DO NOT EDIT.
package updates
import (
"github.com/go-gormigrate/gormigrate/v2"
"gorm.io/gorm"
)
// {{.Func}} returns the {{.MigrationID}} gormigrate entry.
func {{.Func}}() *gormigrate.Migration {
return &gormigrate.Migration{
ID: {{printf "%q" .MigrationID}},
Migrate: func(tx *gorm.DB) error {
return tx.Exec({{printf "%q" .UpSQL}}).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Exec({{printf "%q" .DownSQL}}).Error
},
}
}
{{end}}
{{define "command.go"}}// Code generated by summer make. DO NOT EDIT.
package console
import (
"context"
"git.golem15.com/golem15/summercms/bonfire"
)
// {{.Func}} returns the {{.CommandName}} console command.
func {{.Func}}() bonfire.Command {
return bonfire.Command{
Name: {{printf "%q" .CommandName}},
Description: {{printf "%q" .Description}},
Run: func(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
out.Printf({{printf "%q" .CommandName}} + "\n")
return nil
},
}
}
{{end}}
{{define "job.go"}}// Code generated by summer make. DO NOT EDIT.
package jobs
import (
"context"
"fmt"
"git.golem15.com/golem15/summercms/pact"
)
// {{.Ident}}Args is the typed payload for {{.Kind}}.
type {{.Ident}}Args struct{}
func ({{.Ident}}Args) Kind() string { return {{printf "%q" .Kind}} }
type {{.Worker}} struct{}
func ({{.Worker}}) Work(ctx context.Context, args pact.JobArgs) error {
if _, ok := args.({{.Ident}}Args); !ok {
return fmt.Errorf("jobs: unexpected args type %T", args)
}
return nil
}
// {{.Func}} returns the {{.Kind}} job.
func {{.Func}}() pact.Job { return {{.Worker}}{} }
{{end}}
{{define "admin_controller.go"}}// Code generated by summer make. DO NOT EDIT.
package controllers
import "git.golem15.com/golem15/summercms/pact"
type {{.Worker}} struct{}
func ({{.Worker}}) ID() string { return {{printf "%q" .Kind}} }
func ({{.Worker}}) ModelName() string { return {{printf "%q" .Ident}} }
func ({{.Worker}}) ConfigDir() string { return {{printf "%q" .ConfigDir}} }
// {{.Func}} returns the {{.Kind}} admin controller.
func {{.Func}}() pact.AdminController { return {{.Worker}}{} }
{{end}}
{{define "config_form.yaml"}}name: {{.Ident}}
form: ~/plugins/{{.PluginPath}}/models/{{.Snake}}/fields.yaml
modelClass: {{.Ident}}
defaultRedirect: {{.PluginPath}}/{{.Snake}}
create:
redirect: {{.PluginPath}}/{{.Snake}}/update/:id
redirectClose: {{.PluginPath}}/{{.Snake}}
update:
redirect: {{.PluginPath}}/{{.Snake}}
redirectClose: {{.PluginPath}}/{{.Snake}}
{{end}}
{{define "config_list.yaml"}}list: ~/plugins/{{.PluginPath}}/models/{{.Snake}}/columns.yaml
modelClass: {{.Ident}}
title: {{.Ident}}
recordsPerPage: 20
toolbar:
buttons: [create]
search:
prompt: backend::lang.list.search_prompt
{{end}}
{{define "fields.yaml"}}fields:
id:
label: ID
span: auto
type: number
{{end}}
{{define "columns.yaml"}}columns:
id:
label: ID
searchable: true
{{end}}