diff --git a/internal/dis/component/control/home/public.go b/internal/dis/component/control/home/public.go index fbacbca..cf635da 100644 --- a/internal/dis/component/control/home/public.go +++ b/internal/dis/component/control/home/public.go @@ -51,7 +51,7 @@ func (home *Home) updateRender(ctx context.Context, io stream.IOStream) { //go:embed "home.html" var homeHTMLStr string -var homeTemplate = static.AssetsHomeHome.MustParse(homeHTMLStr) +var homeTemplate = static.AssetsHomeHome.MustParse(nil, homeHTMLStr) func (home *Home) homeRender() ([]byte, error) { var context HomeContext diff --git a/internal/dis/component/control/info/components.go b/internal/dis/component/control/info/components.go index a3f8900..2d8a052 100644 --- a/internal/dis/component/control/info/components.go +++ b/internal/dis/component/control/info/components.go @@ -2,6 +2,7 @@ package info import ( _ "embed" + "html/template" "net/http" "time" @@ -9,9 +10,22 @@ import ( "github.com/FAU-CDI/wisski-distillery/pkg/lazy" ) -//go:embed "html/components.html" +//go:embed "html/base.html" +var baseTemplateString string +var baseTemplate = template.Must(template.New("base.html").Parse(baseTemplateString)) + +func base(name string) *template.Template { + clone := template.Must(baseTemplate.Clone()) + clone.Tree.Name = name + return clone +} + +//go:embed "html/info_components.html" var componentsTemplateString string -var componentsTemplate = static.AssetsComponentsIndex.MustParse(componentsTemplateString) +var componentsTemplate = static.AssetsComponentsIndex.MustParse( + base("info_components.html"), + componentsTemplateString, +) type componentsPageContext struct { Time time.Time diff --git a/internal/dis/component/control/info/html/base.html b/internal/dis/component/control/info/html/base.html new file mode 100644 index 0000000..16c8b14 --- /dev/null +++ b/internal/dis/component/control/info/html/base.html @@ -0,0 +1,26 @@ + + + + + + {{ block "title" . }}Distillery Control Page{{ end }} + {{ block "head" . }}head{{ end }} + + + +
+

{{ template "title" . }}

+ Generated at {{ .Time.Format "2006-01-02T15:04:05Z07:00" }} + {{ block "header" . }}header{{ end }} +
+
+
+ {{ block "content" . }}content{{ end }} +
+
+ + + {{ block "footer" . }}footer{{ end }} + \ No newline at end of file diff --git a/internal/dis/component/control/info/html/components.html b/internal/dis/component/control/info/html/components.html deleted file mode 100644 index a35e5f6..0000000 --- a/internal/dis/component/control/info/html/components.html +++ /dev/null @@ -1,143 +0,0 @@ - - - - - Distillery Control Page - Components Page - {{ CSS }} - - - -
-

Distillery Control Page - Components Page

- Generated at {{ .Time.Format "2006-01-02T15:04:05Z07:00" }} -

- Control > - Components -

-
- -
-
-
-

Components

-
- - {{ range $name, $comp := .Analytics.Components }} -
-
- -
- - - - - - - - {{ range .Groups }} - - - - - {{ end }} - {{ range $name, $comp := .CFields }} - - - - - - {{ end }} - {{ range $name, $iface := .IFields }} - - - - - - {{ end }} - {{ range $name, $sig := $comp.Methods }} - - - - - - {{ end }} - -
- {{ $name }} -
- Implements - - {{ . }}
-
Component Pointer - {{ $name }} - - {{ $comp }} -
Interface Slice - {{ $name }} - - []{{ $iface }} -
- Method - - {{ $name }} - - {{ $sig }} -
-
-
-
-
- {{ end }} - -
-

Interfaces

-
- - {{ range $name, $group := .Analytics.Groups }} -
-
- -
- - - - - - - - {{ range $name, $sig := $group.Methods }} - - - - - - {{ end }} - {{ range $group.Components }} - - - - - {{ end }} - -
- {{ $name }} -
- Method - - {{ $name }} - - {{ $sig }} -
- Implemented By - - {{ . }} -
-
-
-
- - {{ end }} -
- - {{ JS }} - \ No newline at end of file diff --git a/internal/dis/component/control/info/html/index.html b/internal/dis/component/control/info/html/index.html deleted file mode 100644 index 7d031c5..0000000 --- a/internal/dis/component/control/info/html/index.html +++ /dev/null @@ -1,294 +0,0 @@ - - - - - Distillery Control Page - {{ CSS }} - - - -
-

Distillery Control Page

- Generated at {{ .Time.Format "2006-01-02T15:04:05Z07:00" }} -

- Control -

-

- Components -

-
-
-
-
-

Distillery Configuration

-
-
-
-
- - - - - - - - - - - - - - - - - - - - -
- Domains -
- Primary - - {{.Config.DefaultDomain}} -
- Extra - - {{ range .Config.SelfExtraDomains }} - {{.}}
- {{ end }} -
- Email (HTTPS) - - {{.Config.CertbotEmail}} -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Database Settings -
- MySQL User Prefix - - {{.Config.MysqlUserPrefix}} -
- MySQL Database Prefix - - {{.Config.MysqlDatabasePrefix}} -
- GraphDB User Prefix - - {{.Config.GraphDBUserPrefix}} -
- GraphDB Database Prefix - - {{.Config.GraphDBRepoPrefix}} -
- Bookkeeping Database - - {{.Config.DistilleryDatabase}} -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- Directory Settings -
- root - - {{.Config.DeployRoot}} -
- config - - {{.Config.ConfigPath}} -
- authorized_keys - - {{.Config.GlobalAuthorizedKeysFile}} -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - -
- Misc Settings -
- Homepage - - {{.Config.SelfRedirect}} -
- Docker Network Name - - {{.Config.DockerNetworkName}} -
- Backup Age - - {{.Config.MaxBackupAge}} Day(s) -
-
-
-
- -
-

Backups

-
- -
- - - - - - - - - - {{ range .Backups }} - - - - - - {{ end}} - -
PathCreatedPacked
- {{ .Path }} - - {{ .Created.Format "2006-01-02T15:04:05Z07:00" }} - - {{ .Packed }} -
-
- -
-

Instances

- - - - - - - - - - - - - - - - -
TotalRunningStopped
- {{ .TotalCount }} - - {{ .RunningCount }} - - {{ .StoppedCount }} -
- - -
- - {{range .Instances}} -
-
-

- {{.Slug}} - {{ if not .Running }} not running{{ end }} -

-

- {{.URL}}
- - Details -

-
-
- {{end}} - -
-
- - - - {{ JS }} - \ No newline at end of file diff --git a/internal/dis/component/control/info/html/info_components.html b/internal/dis/component/control/info/html/info_components.html new file mode 100644 index 0000000..adc7627 --- /dev/null +++ b/internal/dis/component/control/info/html/info_components.html @@ -0,0 +1,131 @@ +{{ define "title" }}Distillery Control Page - Components Page{{ end }} + +{{ define "head" }}{{ CSS }}{{ end }} +{{ define "footer" }}{{ JS }}{{ end }} + +{{ define "header"}} +

+ Control > + Components +

+{{ end }} + +{{ define "content" }} +
+

Components

+
+ +{{ range $name, $comp := .Analytics.Components }} +
+
+
+ + + + + + + + {{ range .Groups }} + + + + + {{ end }} + {{ range $name, $comp := .CFields }} + + + + + + {{ end }} + {{ range $name, $iface := .IFields }} + + + + + + {{ end }} + {{ range $name, $sig := $comp.Methods }} + + + + + + {{ end }} + +
+ {{ $name }} +
+ Implements + + {{ . }}
+
Component Pointer + {{ $name }} + + {{ $comp }} +
Interface Slice + {{ $name }} + + []{{ $iface }} +
+ Method + + {{ $name }} + + {{ $sig }} +
+
+
+
+ +{{ end }} + +
+

Interfaces

+
+ +{{ range $name, $group := .Analytics.Groups }} +
+
+ +
+ + + + + + + + {{ range $name, $sig := $group.Methods }} + + + + + + {{ end }} + {{ range $group.Components }} + + + + + {{ end }} + +
+ {{ $name }} +
+ Method + + {{ $name }} + + {{ $sig }} +
+ Implemented By + + {{ . }} +
+
+
+
+{{ end }} +{{ end }} \ No newline at end of file diff --git a/internal/dis/component/control/info/html/info_index.html b/internal/dis/component/control/info/html/info_index.html new file mode 100644 index 0000000..3c256b0 --- /dev/null +++ b/internal/dis/component/control/info/html/info_index.html @@ -0,0 +1,279 @@ +{{ define "title" }}Distillery Control Page{{ end }} + +{{ define "head" }}{{ CSS }}{{ end }} +{{ define "footer" }}{{ JS }}{{ end }} + +{{ define "header"}} +

+ Control +

+

+ Components +

+{{ end }} + +{{ define "content" }} +
+

Distillery Configuration

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + +
+ Domains +
+ Primary + + {{.Config.DefaultDomain}} +
+ Extra + + {{ range .Config.SelfExtraDomains }} + {{.}}
+ {{ end }} +
+ Email (HTTPS) + + {{.Config.CertbotEmail}} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Database Settings +
+ MySQL User Prefix + + {{.Config.MysqlUserPrefix}} +
+ MySQL Database Prefix + + {{.Config.MysqlDatabasePrefix}} +
+ GraphDB User Prefix + + {{.Config.GraphDBUserPrefix}} +
+ GraphDB Database Prefix + + {{.Config.GraphDBRepoPrefix}} +
+ Bookkeeping Database + + {{.Config.DistilleryDatabase}} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Directory Settings +
+ root + + {{.Config.DeployRoot}} +
+ config + + {{.Config.ConfigPath}} +
+ authorized_keys + + {{.Config.GlobalAuthorizedKeysFile}} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ Misc Settings +
+ Homepage + + {{.Config.SelfRedirect}} +
+ Docker Network Name + + {{.Config.DockerNetworkName}} +
+ Backup Age + + {{.Config.MaxBackupAge}} Day(s) +
+
+
+
+ +
+

Backups

+
+ +
+ + + + + + + + + + {{ range .Backups }} + + + + + + {{ end}} + +
PathCreatedPacked
+ {{ .Path }} + + {{ .Created.Format "2006-01-02T15:04:05Z07:00" }} + + {{ .Packed }} +
+
+ +
+

Instances

+ + + + + + + + + + + + + + + + +
TotalRunningStopped
+ {{ .TotalCount }} + + {{ .RunningCount }} + + {{ .StoppedCount }} +
+ + +
+ +{{range .Instances}} +
+
+

+ {{.Slug}} + {{ if not .Running }} not running{{ end }} +

+

+ {{.URL}}
+ + Details +

+
+
+{{end}} +{{ end }} \ No newline at end of file diff --git a/internal/dis/component/control/info/html/info_instance.html b/internal/dis/component/control/info/html/info_instance.html new file mode 100644 index 0000000..d933754 --- /dev/null +++ b/internal/dis/component/control/info/html/info_instance.html @@ -0,0 +1,300 @@ +{{ define "title" }}Distillery Control Page - {{ .Info.Slug }}{{ end }} + +{{ define "head" }}{{ CSS }}{{ end }} +{{ define "footer" }}{{ JS }}{{ end }} + +{{ define "header"}} +

+ Control > + Instance +

+{{ end }} + +{{ define "content" }} +
+

Info & Status

+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ Overview +
+ Slug + + {{ .Info.Slug }} +
+ URL + + {{ .Info.URL }} +
+ Running + + {{ .Info.Running }} +
+ Locked + + {{ .Info.Locked }} +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Component Settings +
+ Directory + + {{ .Instance.FilesystemBase }} +
+ SQL DB + + {{ .Instance.SqlDatabase }} +
+ SQL User + + {{ .Instance.SqlUsername }} +
+ TS Repo + + {{ .Instance.GraphDBRepository }} +
+ TS User + + {{ .Instance.GraphDBUsername }} +
+
+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ Build Status +
+ Created + + {{ .Instance.Created.Format "2006-01-02T15:04:05Z07:00" }} +
+ Last Rebuild
+ +
+ {{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }} +
+ Last Cron
+ +
+ {{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }} +
+ Last Update
+ +
+ {{ .Info.LastUpdate.Format "2006-01-02T15:04:05Z07:00" }}
+ (Automatic: {{ .Instance.AutoBlindUpdateEnabled }}) +
+
+
+
+ +
+ +
+ +
+

WissKI Data

+
+ +
+
+
+ + + + + + + + + {{ range $name, $xml := .Info.Pathbuilders }} + + + + + {{ end }} + +
+ Pathbuilders +
+ {{ $name }} + + {{ $xml }} +
+
+
+
+
+
+
+ + + + + + + + {{ range $index, $prefix := .Info.Prefixes }} + + + + {{ end }} + +
+ URI Prefixes + + {{ if .Info.NoPrefixes }} + (excluded from resolver) + {{ end }} +
+ {{ $prefix }} +
+
+
+
+ +
+

Snapshots

+

+ +

+
+ +
+ + + + + + + + + + {{ range .Info.Snapshots }} + + + + + + {{ end}} + +
PathCreatedPacked
+ {{ .Path }} + + {{ .Created.Format "2006-01-02T15:04:05Z07:00" }} + + {{ .Packed }} +
+
+{{ end }} \ No newline at end of file diff --git a/internal/dis/component/control/info/html/instance.html b/internal/dis/component/control/info/html/instance.html deleted file mode 100644 index 3a66104..0000000 --- a/internal/dis/component/control/info/html/instance.html +++ /dev/null @@ -1,312 +0,0 @@ - - - - - Distillery Control Page - {{ .Info.Slug }} - {{ CSS }} - - - -
-

Distillery Control Page - {{ .Info.Slug }}

- Generated at {{ .Time.Format "2006-01-02T15:04:05Z07:00" }} -

- Control > - Instance -

-
- -
-
-
-

Info & Status

-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
- Overview -
- Slug - - {{ .Info.Slug }} -
- URL - - {{ .Info.URL }} -
- Running - - {{ .Info.Running }} -
- Locked - - {{ .Info.Locked }} -
-
-
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Component Settings -
- Directory - - {{ .Instance.FilesystemBase }} -
- SQL DB - - {{ .Instance.SqlDatabase }} -
- SQL User - - {{ .Instance.SqlUsername }} -
- TS Repo - - {{ .Instance.GraphDBRepository }} -
- TS User - - {{ .Instance.GraphDBUsername }} -
-
-
-
- -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
- Build Status -
- Created - - {{ .Instance.Created.Format "2006-01-02T15:04:05Z07:00" }} -
- Last Rebuild
- -
- {{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }} -
- Last Cron
- -
- {{ .Info.LastRebuild.Format "2006-01-02T15:04:05Z07:00" }} -
- Last Update
- -
- {{ .Info.LastUpdate.Format "2006-01-02T15:04:05Z07:00" }}
- (Automatic: {{ .Instance.AutoBlindUpdateEnabled }}) -
-
-
-
- -
- -
- -
-

WissKI Data

-
- -
-
-
- - - - - - - - - {{ range $name, $xml := .Info.Pathbuilders }} - - - - - {{ end }} - -
- Pathbuilders -
- {{ $name }} - - {{ $xml }} -
-
-
-
-
-
-
- - - - - - - - {{ range $index, $prefix := .Info.Prefixes }} - - - - {{ end }} - -
- URI Prefixes - - {{ if .Info.NoPrefixes }} - (excluded from resolver) - {{ end }} -
- {{ $prefix }} -
-
-
-
- -
-

Snapshots

-

- -

-
- -
- - - - - - - - - - {{ range .Info.Snapshots }} - - - - - - {{ end}} - -
PathCreatedPacked
- {{ .Path }} - - {{ .Created.Format "2006-01-02T15:04:05Z07:00" }} - - {{ .Packed }} -
-
-
- -
- - {{ JS }} - \ No newline at end of file diff --git a/internal/dis/component/control/info/index.go b/internal/dis/component/control/info/index.go index c9f2b1d..3d26739 100644 --- a/internal/dis/component/control/info/index.go +++ b/internal/dis/component/control/info/index.go @@ -13,9 +13,12 @@ import ( "golang.org/x/sync/errgroup" ) -//go:embed "html/index.html" +//go:embed "html/info_index.html" var indexTemplateStr string -var indexTemplate = static.AssetsControlIndex.MustParse(indexTemplateStr) +var indexTemplate = static.AssetsControlIndex.MustParse( + base("info_index.html"), + indexTemplateStr, +) type indexPageContext struct { Time time.Time diff --git a/internal/dis/component/control/info/instance.go b/internal/dis/component/control/info/instance.go index 8a8f2f0..b37ee3b 100644 --- a/internal/dis/component/control/info/instance.go +++ b/internal/dis/component/control/info/instance.go @@ -13,9 +13,12 @@ import ( "github.com/FAU-CDI/wisski-distillery/pkg/httpx" ) -//go:embed "html/instance.html" +//go:embed "html/info_instance.html" var instanceTemplateString string -var instanceTemplate = static.AssetsControlInstance.MustParse(instanceTemplateString) +var instanceTemplate = static.AssetsControlInstance.MustParse( + base("info_instance.html"), + instanceTemplateString, +) type instancePageContext struct { Time time.Time diff --git a/internal/dis/component/control/static/assets.go b/internal/dis/component/control/static/assets.go index 6afe929..025ad59 100644 --- a/internal/dis/component/control/static/assets.go +++ b/internal/dis/component/control/static/assets.go @@ -27,8 +27,11 @@ type Assets struct { // MustParse parses a new template from the given source // and registers the Asset functions to it. // See [Assets.RegisterFuncs]. -func (assets *Assets) MustParse(value string) *template.Template { - return template.Must(assets.RegisterFuncs(template.New("")).Parse(value)) +func (assets *Assets) MustParse(t *template.Template, value string) *template.Template { + if t == nil { + t = template.New("") + } + return template.Must(assets.RegisterFuncs(t).Parse(value)) } // RegisterFuncs registers three new template functions called "JS", "CSS" and "json".