diff --git a/.task/checksum/generate b/.task/checksum/generate index f654668..8b568c3 100644 --- a/.task/checksum/generate +++ b/.task/checksum/generate @@ -1 +1 @@ -cf55887b91f81f789d59205c41f8368 +898c2e71a27ba82ceae47d2745b8f599 diff --git a/Taskfile.yml b/Taskfile.yml index 33040ce..096a0de 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -24,8 +24,10 @@ tasks: - "$GOBIN/templ generate" sources: - "internal/kurious/ports/http/templ/*.templ" + - "internal/kurious/ports/http/bootstrap/*.templ" generates: - "internal/kurious/ports/http/templ/*.go" + - "internal/kurious/ports/http/bootstrap/*.go" check: cmds: - "$GOBIN/golangci-lint run ./..." diff --git a/cmd/kuriweb/http.go b/cmd/kuriweb/http.go index 64efce2..08e2a07 100644 --- a/cmd/kuriweb/http.go +++ b/cmd/kuriweb/http.go @@ -11,6 +11,7 @@ import ( "git.loyso.art/frx/kurious/internal/common/generator" "git.loyso.art/frx/kurious/internal/common/xcontext" xhttp "git.loyso.art/frx/kurious/internal/kurious/ports/http" + "github.com/gorilla/mux" ) diff --git a/go.mod b/go.mod index 8d6aec8..f324ca9 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module git.loyso.art/frx/kurious go 1.21 require ( + github.com/a-h/templ v0.2.513 github.com/go-resty/resty/v2 v2.10.0 github.com/gorilla/mux v1.8.1 github.com/robfig/cron/v3 v3.0.0 @@ -15,7 +16,6 @@ require ( ) require ( - github.com/a-h/templ v0.2.513 // indirect github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/uuid v1.4.0 // indirect diff --git a/go.sum b/go.sum index 0b17c3c..db61a11 100644 --- a/go.sum +++ b/go.sum @@ -648,8 +648,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= diff --git a/htmlexamples/core.html b/htmlexamples/core.html index 78c7205..fd1f3bb 100644 --- a/htmlexamples/core.html +++ b/htmlexamples/core.html @@ -34,8 +34,9 @@ diff --git a/htmlexamples/courses.html b/htmlexamples/courses.html new file mode 100644 index 0000000..abcef18 --- /dev/null +++ b/htmlexamples/courses.html @@ -0,0 +1,209 @@ + + + + + Test page + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ Filter categories + + + + + +
+ +
+ +
+ +
+

Languages

+

A languages category provides all courses to help learn language

+ +
+ +
+ +
+ +
+ +
+ +
+
Promocodes
+
+
+ +
+

Japanese

+

Looking for a course to learn japanese language?

+ +
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+
+ ... +
+
Card title with a long naming
+
+ Open > + 500$ +
+
+
+
+ +
+ +
+ +
+ +
+ + +
+ + diff --git a/htmlexamples/index.html b/htmlexamples/index.html index 326cf8d..53a246e 100644 --- a/htmlexamples/index.html +++ b/htmlexamples/index.html @@ -1,126 +1,93 @@ - - - - - - - - - - + -

- Привет мир! -

+ + Test page + + + + + + -
-
- ChitChat Logo -
-
-
ChitChat
-

У вас новое сообщение!

-
-
- -
- Женское лицо -
-
-

- Эрин Линдфорд -

-

- Инженер по продукту -

+ +
+ +
+ +
+
+

Some header about courses

+
+ +
+
+
    +

    Category 1

    +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
+
+
+
    +

    Category 2

    +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
+
+
+
    +

    Category 3

    +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
  • +
    item
    +
  • +
- - - - -
    -
  • - -
    -

    {person.name}

    -

    {person.email}

    -
    -
  • -
- -
-
- - -
-
- - -
- -

Новый проект

-
-

Создайте новый проект из множества начальных шаблонов.

-
- -
-
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
hello
-
-
- - - +
+ diff --git a/htmlexamples/new.html b/htmlexamples/new.html deleted file mode 100644 index 88330c4..0000000 --- a/htmlexamples/new.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - - Test page - - - - - - - - -
- -
- -
- - - -
- - Filter categories - - - - - - - -
- -
-

Languages

- A languages category provides all courses to help learn language - -
- -
- -
- -
- -
- -
-
-
Promocodes
-
-
- -
- -
- -

Japanese

- Looking for a course to learn japanese language? - -
- -
- -
-
- ... -
-
Card title with a long naming
-
- Open > - 500$ -
-
-
-
- -
-
-
- -
- -
-
- -
-
-

(c) All right reserved

-
-
- diff --git a/internal/kurious/ports/http/bootstrap/common_templ.go b/internal/kurious/ports/http/bootstrap/common_templ.go new file mode 100644 index 0000000..9ce5bb5 --- /dev/null +++ b/internal/kurious/ports/http/bootstrap/common_templ.go @@ -0,0 +1,116 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.513 +package bootstrap + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +func button(title string, attributes templ.Attributes) 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func buttonRedirect(id, title string, linkTo 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = onclickRedirect("origin-link-"+id, linkTo).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func onclickRedirect(id, to string) templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_onclickRedirect_47ae`, + Function: `function __templ_onclickRedirect_47ae(id, to){document.getElementById(id).onclick = () => { + location.href = to + }}`, + Call: templ.SafeScript(`__templ_onclickRedirect_47ae`, id, to), + CallInline: templ.SafeScriptInline(`__templ_onclickRedirect_47ae`, id, to), + } +} diff --git a/internal/kurious/ports/http/bootstrap/core_templ.go b/internal/kurious/ports/http/bootstrap/core_templ.go new file mode 100644 index 0000000..83743d1 --- /dev/null +++ b/internal/kurious/ports/http/bootstrap/core_templ.go @@ -0,0 +1,137 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.513 +package bootstrap + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +func head() 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var2 := `Test page` + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var2) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func navbar() 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + 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 + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func footer() 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + 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 + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Var9 := `(c) kurious, 2024. All rights reserved.` + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} diff --git a/internal/kurious/ports/http/bootstrap/list.templ b/internal/kurious/ports/http/bootstrap/list.templ index 05dce57..10a5f58 100644 --- a/internal/kurious/ports/http/bootstrap/list.templ +++ b/internal/kurious/ports/http/bootstrap/list.templ @@ -1,10 +1,5 @@ package bootstrap -import ( - "strconv" - "fmt" -) - script breadcrumbsLoad() { const formFilterOnSubmit = event => { event.preventDefault(); diff --git a/internal/kurious/ports/http/bootstrap/list_templ.go b/internal/kurious/ports/http/bootstrap/list_templ.go new file mode 100644 index 0000000..79ebda5 --- /dev/null +++ b/internal/kurious/ports/http/bootstrap/list_templ.go @@ -0,0 +1,156 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.513 +package bootstrap + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import "context" +import "io" +import "bytes" + +func breadcrumbsLoad() templ.ComponentScript { + return templ.ComponentScript{ + Name: `__templ_breadcrumbsLoad_9a1d`, + Function: `function __templ_breadcrumbsLoad_9a1d(){const formFilterOnSubmit = event => { + event.preventDefault(); + + const lt = document.getElementById('learning-type-filter'); + const ct = document.getElementById('course-thematic-filter'); + + const prefix = (lt !== null && lt.value !== '') ? ` + "`" + `/courses/${lt.value}` + "`" + ` : ` + "`" + `/courses` + "`" + `; + const out = (ct !== null && ct.value !== '') ? ` + "`" + `${prefix}/${ct.value}` + "`" + ` : prefix; + + document.location.assign(out); + return false; + }; + + document.addEventListener('DOMContentLoaded', () => { + const ff = document.getElementById('filter-form'); + if (ff === null) return; + ff.addEventListener('submit', formFilterOnSubmit); + });}`, + Call: templ.SafeScript(`__templ_breadcrumbsLoad_9a1d`), + CallInline: templ.SafeScriptInline(`__templ_breadcrumbsLoad_9a1d`), + } +} + +func breadcrumbsItem(text, link string, isActive bool) 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + var templ_7745c5c3_Var2 = []any{"breadcrumb-item", templ.KV("active", isActive)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if link != "" { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var4 string + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(text) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/list.templ`, Line: 27, Col: 33} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var5 string + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(text) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/kurious/ports/http/bootstrap/list.templ`, Line: 30, Col: 47} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
  • ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +} + +func breadcrumNode(params BreadcrumbsParams) 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 { + templ_7745c5c3_Buffer = templ.GetBuffer() + defer templ.ReleaseBuffer(templ_7745c5c3_Buffer) + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var6 := templ.GetChildren(ctx) + if templ_7745c5c3_Var6 == nil { + templ_7745c5c3_Var6 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !templ_7745c5c3_IsBuffer { + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteTo(templ_7745c5c3_W) + } + return templ_7745c5c3_Err + }) +}