From 97986063df22142dd467aaa04fd2fc35abc53200 Mon Sep 17 00:00:00 2001 From: Aleksandr Trushkin Date: Mon, 4 Mar 2024 00:03:08 +0300 Subject: [PATCH] bootstrap migrate --- .task/checksum/generate | 2 +- Taskfile.yml | 3 +- htmlexamples/courses.html | 4 +- .../kurious/ports/http/bootstrap/core.templ | 104 +-- .../ports/http/bootstrap/core_templ.go | 157 ++++- .../kurious/ports/http/bootstrap/list.templ | 142 +++- .../ports/http/bootstrap/list_templ.go | 615 +++++++++++++++++- internal/kurious/ports/http/bootstrap/vars.go | 20 +- internal/kurious/ports/http/coursev2.go | 48 +- 9 files changed, 1012 insertions(+), 83 deletions(-) diff --git a/.task/checksum/generate b/.task/checksum/generate index 8b568c3..b4dae54 100644 --- a/.task/checksum/generate +++ b/.task/checksum/generate @@ -1 +1 @@ -898c2e71a27ba82ceae47d2745b8f599 +ba89728e33b4eb652254d64099b17c4 diff --git a/Taskfile.yml b/Taskfile.yml index 096a0de..1801608 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -54,8 +54,9 @@ tasks: cmds: - task: build_dev_cli - task: build_background + - task: build_web run: deps: [build] cmds: - - $GOBIN/sravnicli + - $GOBIN/kuriousweb diff --git a/htmlexamples/courses.html b/htmlexamples/courses.html index ead9c22..5e52083 100644 --- a/htmlexamples/courses.html +++ b/htmlexamples/courses.html @@ -41,7 +41,7 @@
-
+
-
+
diff --git a/internal/kurious/ports/http/bootstrap/core.templ b/internal/kurious/ports/http/bootstrap/core.templ index 993f702..970418f 100644 --- a/internal/kurious/ports/http/bootstrap/core.templ +++ b/internal/kurious/ports/http/bootstrap/core.templ @@ -16,62 +16,78 @@ templ head(title string) { integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"> - } -templ navbar(active int) { - + } templ footer() {
-
+
(c) kurious, 2024. All rights reserved.
} + +templ root(page PageKind, s stats) { + + + @head(string(page)) + + @headerNavbar(page) +
+ { children... } +
+ + @breadcrumbsLoad() + + +} diff --git a/internal/kurious/ports/http/bootstrap/core_templ.go b/internal/kurious/ports/http/bootstrap/core_templ.go index 83743d1..e8dc175 100644 --- a/internal/kurious/ports/http/bootstrap/core_templ.go +++ b/internal/kurious/ports/http/bootstrap/core_templ.go @@ -10,7 +10,7 @@ import "context" import "io" import "bytes" -func head() templ.Component { +func head(title string) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { @@ -27,8 +27,12 @@ func head() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var2 := `Test page` - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2) + var templ_7745c5c3_Var2 string + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/core.templ`, Line: 4, Col: 16} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -36,7 +40,8 @@ func head() templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Var3 := `` + templ_7745c5c3_Var3 := ` + ` _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -52,7 +57,7 @@ func head() templ.Component { }) } -func navbar() templ.Component { +func headerNavbar(page PageKind) templ.Component { return templ.ComponentFunc(func(ctx context.Context, templ_7745c5c3_W io.Writer) (templ_7745c5c3_Err error) { templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templ_7745c5c3_W.(*bytes.Buffer) if !templ_7745c5c3_IsBuffer { @@ -65,7 +70,7 @@ func navbar() templ.Component { templ_7745c5c3_Var4 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -111,17 +176,17 @@ func footer() templ.Component { defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent + templ_7745c5c3_Var12 := templ.GetChildren(ctx) + if templ_7745c5c3_Var12 == nil { + templ_7745c5c3_Var12 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("