- definitions singleton controller (theme default, first or create) with a repeater on data: type dropdown (url plus registry types), reference dependsOn type through signpost.ReferenceOptions - Settings page entries: Sitemap (link to the controller) and Sitemap settings (form), both behind golem15.sitemap.access_definitions - en and pl phrasebooks with the PHP keys - README with the PHP parity rules, tiers, hooks, commands and the Winter YAML adaptations - TestSitemapAdminSmoke: singleton, PHP-keyed rows, 422 on a foreign reference, settings save, 403 without the permission
73 lines
2.3 KiB
Go
73 lines
2.3 KiB
Go
package sitemap
|
|
|
|
import (
|
|
"embed"
|
|
"io/fs"
|
|
|
|
"git.golem15.com/golem15/sm-sitemap-plugin/controllers"
|
|
"git.golem15.com/golem15/sm-sitemap-plugin/models"
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
)
|
|
|
|
// adminFS holds the admin YAML file by file: the controllers directory also
|
|
// holds Go sources.
|
|
//
|
|
//go:embed controllers/definitions/config_form.yaml models/definition/fields.yaml models/settings/fields.yaml
|
|
var adminFS embed.FS
|
|
|
|
//go:embed lang
|
|
var langFS embed.FS
|
|
|
|
// AdminFS serves the admin YAML.
|
|
func (p *Plugin) AdminFS() fs.FS { return adminFS }
|
|
|
|
// LangFS is the embedded English and Polish phrasebooks.
|
|
func (p *Plugin) LangFS() fs.FS { return langFS }
|
|
|
|
// AdminControllers hands the controllers a lazy accessor of the booted app,
|
|
// so they read the database and the menu item type registry at request
|
|
// time.
|
|
func (p *Plugin) AdminControllers() []pact.AdminController {
|
|
return controllers.AdminControllers(func() *backpack.App {
|
|
if p == nil {
|
|
return nil
|
|
}
|
|
return p.app
|
|
})
|
|
}
|
|
|
|
// Settings registers the two PHP settings entries in the CMS category: the
|
|
// sitemap definition (a link to the singleton definitions controller) and
|
|
// the sitemap settings form. Both require golem15.sitemap.access_definitions.
|
|
func (p *Plugin) Settings() []pact.SettingsItem {
|
|
return []pact.SettingsItem{
|
|
{
|
|
Code: "sitemap",
|
|
Label: "golem15.sitemap::lang.plugin.name",
|
|
Description: "golem15.sitemap::lang.plugin.description",
|
|
Category: "golem15.sitemap::lang.settings.category",
|
|
Icon: "network",
|
|
Permissions: []string{controllers.PermissionAccessDefinitions},
|
|
Controller: controllers.DefinitionsControllerID,
|
|
},
|
|
{
|
|
Code: "sitemap_settings",
|
|
Label: "golem15.sitemap::lang.settings.label",
|
|
Description: "golem15.sitemap::lang.settings.description",
|
|
Category: "golem15.sitemap::lang.settings.category",
|
|
Icon: "settings",
|
|
Permissions: []string{controllers.PermissionAccessDefinitions},
|
|
Form: "models/settings/fields.yaml",
|
|
NewModel: func() any { return &models.Settings{} },
|
|
},
|
|
}
|
|
}
|
|
|
|
var (
|
|
_ pact.AdminAssets = (*Plugin)(nil)
|
|
_ pact.HasAdminControllers = (*Plugin)(nil)
|
|
_ pact.HasSettings = (*Plugin)(nil)
|
|
_ pact.HasLang = (*Plugin)(nil)
|
|
)
|