Add custom API widget
This commit is contained in:
parent
2dd5b29303
commit
84a7f90129
8 changed files with 244 additions and 8 deletions
|
|
@ -40,9 +40,10 @@ var (
|
|||
GroupTemplate = compileTemplate("group.html", "widget-base.html")
|
||||
DNSStatsTemplate = compileTemplate("dns-stats.html", "widget-base.html")
|
||||
SplitColumnTemplate = compileTemplate("split-column.html", "widget-base.html")
|
||||
CustomAPITemplate = compileTemplate("custom-api.html", "widget-base.html")
|
||||
)
|
||||
|
||||
var globalTemplateFunctions = template.FuncMap{
|
||||
var GlobalTemplateFunctions = template.FuncMap{
|
||||
"relativeTime": relativeTimeSince,
|
||||
"formatViewerCount": formatViewerCount,
|
||||
"formatNumber": intl.Sprint,
|
||||
|
|
@ -59,7 +60,7 @@ var globalTemplateFunctions = template.FuncMap{
|
|||
|
||||
func compileTemplate(primary string, dependencies ...string) *template.Template {
|
||||
t, err := template.New(primary).
|
||||
Funcs(globalTemplateFunctions).
|
||||
Funcs(GlobalTemplateFunctions).
|
||||
ParseFS(TemplateFS, append([]string{primary}, dependencies...)...)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
7
internal/assets/templates/custom-api.html
Normal file
7
internal/assets/templates/custom-api.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{{ template "widget-base.html" . }}
|
||||
|
||||
{{ define "widget-content-classes" }}{{ if .Frameless }}widget-content-frameless{{ end }}{{ end }}
|
||||
|
||||
{{ define "widget-content" }}
|
||||
{{ .CompiledHTML }}
|
||||
{{ end }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue