Register the remaining YAML admin screens and the settings singleton so a host can boot Posts, Categories, Tags, and Code journal. Posts update and delete refuse other authors without access_other_posts. Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
2.0 KiB
Go
56 lines
2.0 KiB
Go
package journal
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
|
|
"git.golem15.com/golem15/sm-journal-plugin/controllers"
|
|
"git.golem15.com/golem15/sm-journal-plugin/models"
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// adminFS holds the admin YAML and the nav SVG file by file: the controllers
|
|
// directory also holds Go sources that are not admin assets.
|
|
//
|
|
//go:embed controllers/posts/config_list.yaml controllers/posts/config_form.yaml controllers/posts/config_filter.yaml models/post/fields.yaml models/post/columns.yaml
|
|
//go:embed controllers/categories/config_list.yaml controllers/categories/config_form.yaml models/category/fields.yaml models/category/columns.yaml
|
|
//go:embed controllers/tags/config_list.yaml controllers/tags/config_form.yaml models/tag/fields.yaml models/tag/columns.yaml
|
|
//go:embed models/settings/fields.yaml
|
|
//go:embed assets/images/journal-icon.svg
|
|
var adminFS embed.FS
|
|
|
|
func (p *Plugin) AdminFS() fs.FS { return adminFS }
|
|
|
|
// AdminControllers hands the controllers a lazy accessor of the booted app,
|
|
// so they read the database handle at request time.
|
|
func (p *Plugin) AdminControllers() []pact.AdminController {
|
|
return controllers.AdminControllers(func() *backpack.App {
|
|
if p == nil {
|
|
return nil
|
|
}
|
|
return p.app
|
|
})
|
|
}
|
|
|
|
func (p *Plugin) Settings() []pact.SettingsItem {
|
|
return []pact.SettingsItem{{
|
|
Code: "journal",
|
|
Label: "golem15.journal::lang.journal.menu_label",
|
|
Description: "golem15.journal::lang.journal.settings_description",
|
|
Category: "golem15.journal::lang.journal.menu_label",
|
|
Icon: "icon-pencil",
|
|
Permissions: []string{"golem15.journal.manage_settings"},
|
|
Form: "models/settings/fields.yaml",
|
|
NewModel: func() any { return &models.Settings{} },
|
|
}}
|
|
}
|
|
|
|
var (
|
|
_ pact.AdminAssets = (*Plugin)(nil)
|
|
_ pact.HasAdminControllers = (*Plugin)(nil)
|
|
_ pact.HasPermissions = (*Plugin)(nil)
|
|
_ pact.HasNavigation = (*Plugin)(nil)
|
|
_ pact.HasSettings = (*Plugin)(nil)
|
|
)
|