2022-09-16 04:21:05 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"embed"
|
|
|
|
"fmt"
|
|
|
|
"text/template"
|
2022-12-21 09:48:14 +00:00
|
|
|
|
|
|
|
"github.com/authelia/authelia/v4/internal/templates"
|
2022-09-16 04:21:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed templates/*
|
|
|
|
var templatesFS embed.FS
|
|
|
|
|
|
|
|
var (
|
|
|
|
tmplCodeConfigurationSchemaKeys = template.Must(newTMPL("internal_configuration_schema_keys.go"))
|
|
|
|
tmplGitHubIssueTemplateBug = template.Must(newTMPL("github_issue_template_bug_report.yml"))
|
|
|
|
tmplIssueTemplateFeature = template.Must(newTMPL("github_issue_template_feature.yml"))
|
|
|
|
tmplWebI18NIndex = template.Must(newTMPL("web_i18n_index.ts"))
|
|
|
|
tmplDotCommitLintRC = template.Must(newTMPL("dot_commitlintrc.js"))
|
|
|
|
tmplDocsCommitMessageGuidelines = template.Must(newTMPL("docs-contributing-development-commitmsg.md"))
|
|
|
|
tmplScriptsGen = template.Must(newTMPL("cmd-authelia-scripts-gen.go"))
|
2022-10-22 11:19:32 +00:00
|
|
|
tmplServer = template.Must(newTMPL("server_gen.go"))
|
2022-09-16 04:21:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func newTMPL(name string) (tmpl *template.Template, err error) {
|
2022-12-23 10:58:54 +00:00
|
|
|
funcs := templates.FuncMap()
|
|
|
|
|
|
|
|
funcs["joinX"] = templates.FuncStringJoinX
|
|
|
|
|
|
|
|
return template.New(name).Funcs(funcs).Parse(mustLoadTmplFS(name))
|
2022-09-16 04:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func mustLoadTmplFS(tmpl string) string {
|
|
|
|
var (
|
|
|
|
content []byte
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
if content, err = templatesFS.ReadFile(fmt.Sprintf("templates/%s.tmpl", tmpl)); err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return string(content)
|
|
|
|
}
|