diff --git a/cmd/converge/pagehandler.go b/cmd/converge/pagehandler.go index 4e441ac..86c987a 100644 --- a/cmd/converge/pagehandler.go +++ b/cmd/converge/pagehandler.go @@ -35,6 +35,8 @@ func pageHandler(w http.ResponseWriter, r *http.Request) { templates.UsageTab(secure, r.URL.Host, username).Render(r.Context(), w) case "downloads.html": templates.DownloadsTab().Render(r.Context(), w) + case "sessions.html": + templates.SessionsTab().Render(r.Context(), w) default: http.NotFound(w, r) } diff --git a/cmd/templaterender/render.go b/cmd/templaterender/render.go index 54dd66e..7c4ecfc 100644 --- a/cmd/templaterender/render.go +++ b/cmd/templaterender/render.go @@ -9,20 +9,9 @@ import ( "path/filepath" ) -type RenderFunc func(secure string, host string, username string) templ.Component +type RenderFunc func() templ.Component -type Params struct { - secure string - host string - username string -} - -type Rendering struct { - params Params - render RenderFunc -} - -func render(dir string, name string, params Params, render RenderFunc) { +func render(dir string, name string, render RenderFunc) { fname := filepath.Join(dir, name) log.Printf("Writing to %s", fname) f, err := os.Create(fname) @@ -31,7 +20,7 @@ func render(dir string, name string, params Params, render RenderFunc) { } defer f.Close() - err = render(params.secure, params.host, params.username).Render(context.Background(), f) + err = render().Render(context.Background(), f) if err != nil { panic(err) } @@ -40,11 +29,15 @@ func render(dir string, name string, params Params, render RenderFunc) { func main() { dir := "html/docs" - params := Params{ - secure: "s", - host: "example.com", - username: "converge", + fullindex := func() templ.Component { + return templates.Index("s", "example.com", "converge") + } + usage := func() templ.Component { + return templates.UsageTab("s", "example.com", "converge") } - render(dir, "index.html", params, templates.Index) + render(dir, "fullindex.html", fullindex) + render(dir, "index.html", templates.AboutTab) + render(dir, "usage.html", usage) + render(dir, "downloads.html", templates.Downloads) } diff --git a/pkg/templates/about.templ b/pkg/templates/about.templ index 900c240..003875e 100644 --- a/pkg/templates/about.templ +++ b/pkg/templates/about.templ @@ -44,7 +44,7 @@ templ About() { templ AboutTab() { - @BasePage() { + @BasePage(1) { @About() } } diff --git a/pkg/templates/basepage.templ b/pkg/templates/basepage.templ index dc54fd9..d4de252 100644 --- a/pkg/templates/basepage.templ +++ b/pkg/templates/basepage.templ @@ -1,7 +1,15 @@ package templates -templ BasePage() { +func active(actual int, active int) string { + res := "nav-item nav-link" + if actual == active { + return res + " active" + } + return res +} + +templ BasePage(tab int) { @@ -19,12 +27,34 @@ templ BasePage() {
-
- { children... } -
+ +
+
+
+
+ { children... }
-
diff --git a/pkg/templates/constants.go b/pkg/templates/constants.go new file mode 100644 index 0000000..dac8432 --- /dev/null +++ b/pkg/templates/constants.go @@ -0,0 +1 @@ +package templates diff --git a/pkg/templates/downloads.templ b/pkg/templates/downloads.templ index 9efabc9..b024072 100644 --- a/pkg/templates/downloads.templ +++ b/pkg/templates/downloads.templ @@ -40,7 +40,7 @@ templ Downloads() { templ DownloadsTab() { - @BasePage() { + @BasePage(3) { @Downloads() } } \ No newline at end of file diff --git a/pkg/templates/index.templ b/pkg/templates/index.templ index 8252680..8914d90 100644 --- a/pkg/templates/index.templ +++ b/pkg/templates/index.templ @@ -1,7 +1,7 @@ package templates templ Index(secure string, host string, username string) { - @BasePage() { + @BasePage(0) { @About() @Usage(secure, host, username) @Downloads() diff --git a/pkg/templates/sessions.templ b/pkg/templates/sessions.templ new file mode 100644 index 0000000..4828917 --- /dev/null +++ b/pkg/templates/sessions.templ @@ -0,0 +1,15 @@ +package templates + + +templ Sessions() { +
+ To be done +
+} + + +templ SessionsTab() { + @BasePage(4) { + @Sessions() + } +} \ No newline at end of file diff --git a/pkg/templates/usage.templ b/pkg/templates/usage.templ index 0599b9a..1cbd56f 100644 --- a/pkg/templates/usage.templ +++ b/pkg/templates/usage.templ @@ -123,7 +123,7 @@ templ Usage(secure string, host string, username string) { templ UsageTab(secure string, host string, username string) { - @BasePage() { + @BasePage(2) { @Usage(secure, host, username) } }