chore: split plugin configuration templates
This commit is contained in:
parent
fc77c97547
commit
899ac49336
5 changed files with 60 additions and 31 deletions
|
@ -16,7 +16,7 @@ import (
|
|||
"github.com/gorilla/sessions"
|
||||
)
|
||||
|
||||
//go:embed templates/*.html
|
||||
//go:embed templates/*.html templates/plugins/*.html
|
||||
var templateFS embed.FS
|
||||
|
||||
const (
|
||||
|
@ -90,7 +90,7 @@ func New(cfg *config.Config, database *db.Database, version string) *Admin {
|
|||
}
|
||||
|
||||
// Parse and register all templates
|
||||
templateFiles := []string{
|
||||
mainTemplateFiles := []string{
|
||||
"index.html",
|
||||
"login.html",
|
||||
"change_password.html",
|
||||
|
@ -101,7 +101,13 @@ func New(cfg *config.Config, database *db.Database, version string) *Admin {
|
|||
"channel_plugin_config.html",
|
||||
}
|
||||
|
||||
for _, tf := range templateFiles {
|
||||
pluginTemplateFiles := []string{
|
||||
"plugins/security.domainblock.html",
|
||||
"plugins/social.instagram.html",
|
||||
"plugins/social.twitter.html",
|
||||
}
|
||||
|
||||
for _, tf := range mainTemplateFiles {
|
||||
// Read template content from embedded filesystem
|
||||
content, err := templateFS.ReadFile("templates/" + tf)
|
||||
if err != nil {
|
||||
|
@ -120,6 +126,20 @@ func New(cfg *config.Config, database *db.Database, version string) *Admin {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
// If this is the channel_plugin_config template, also parse plugin templates
|
||||
if tf == "channel_plugin_config.html" {
|
||||
for _, pluginTf := range pluginTemplateFiles {
|
||||
pluginContent, err := templateFS.ReadFile("templates/" + pluginTf)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
t, err = t.Parse(string(pluginContent))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
templates[tf] = t
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue