From ce3111b0efe91e275ce070f9511b5b1b9801a46d Mon Sep 17 00:00:00 2001 From: Alexander NeonXP Kiryukhin Date: Sun, 21 Jul 2024 19:26:56 +0300 Subject: Множество улучшений MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- views/csrf.templ | 3 +- views/csrf_templ.go | 31 ++++++ views/error.templ | 8 +- views/error_templ.go | 6 +- views/error_templ.txt | 1 - views/layouts.templ | 27 +++-- views/layouts_templ.go | 76 ++++++++++--- views/layouts_templ.txt | 7 -- views/login.templ | 2 +- views/login_templ.go | 6 +- views/login_templ.txt | 2 - views/new-node.templ | 30 ------ views/new-node_templ.go | 85 --------------- views/new-node_templ.txt | 5 - views/new.templ | 51 +++++++++ views/new_templ.go | 271 +++++++++++++++++++++++++++++++++++++++++++++++ views/nodes.templ | 93 +++++++++------- views/nodes_templ.go | 254 +++++++++++++++++++++++++++++++------------- views/nodes_templ.txt | 18 ---- views/register.templ | 2 +- views/register_templ.go | 8 +- views/register_templ.txt | 3 - 22 files changed, 687 insertions(+), 302 deletions(-) create mode 100644 views/csrf_templ.go delete mode 100644 views/error_templ.txt delete mode 100644 views/layouts_templ.txt delete mode 100644 views/login_templ.txt delete mode 100644 views/new-node.templ delete mode 100644 views/new-node_templ.go delete mode 100644 views/new-node_templ.txt create mode 100644 views/new.templ create mode 100644 views/new_templ.go delete mode 100644 views/nodes_templ.txt delete mode 100644 views/register_templ.txt (limited to 'views') diff --git a/views/csrf.templ b/views/csrf.templ index 2bb3545..c019d4c 100644 --- a/views/csrf.templ +++ b/views/csrf.templ @@ -1,7 +1,6 @@ package views -import "github.com/labstack/echo/v4" templ CSRF() { - + // } diff --git a/views/csrf_templ.go b/views/csrf_templ.go new file mode 100644 index 0000000..53a7118 --- /dev/null +++ b/views/csrf_templ.go @@ -0,0 +1,31 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.747 +package views + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func CSRF() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + return templ_7745c5c3_Err + }) +} diff --git a/views/error.templ b/views/error.templ index d3a4a32..3e857ef 100644 --- a/views/error.templ +++ b/views/error.templ @@ -1,8 +1,8 @@ package views templ ErrorPage(err error) { - @Layout() { -

Ошибка

- {err.Error()} - } + @Layout(nil) { +

Ошибка

+ { err.Error() } + } } diff --git a/views/error_templ.go b/views/error_templ.go index 66d40fd..8513d1d 100644 --- a/views/error_templ.go +++ b/views/error_templ.go @@ -38,14 +38,14 @@ func ErrorPage(err error) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templ.WriteWatchModeString(templ_7745c5c3_Buffer, 1) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("

Ошибка

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(err.Error()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/error.templ`, Line: 6, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `views/error.templ`, Line: 6, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -53,7 +53,7 @@ func ErrorPage(err error) templ.Component { } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = Layout().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = Layout(nil).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/views/error_templ.txt b/views/error_templ.txt deleted file mode 100644 index d3a792d..0000000 --- a/views/error_templ.txt +++ /dev/null @@ -1 +0,0 @@ -

Ошибка

diff --git a/views/layouts.templ b/views/layouts.templ index 3db6f1b..f1c2deb 100644 --- a/views/layouts.templ +++ b/views/layouts.templ @@ -2,11 +2,12 @@ package views import ( "context" + "fmt" "gitrepo.ru/neonxp/gorum/contextlib" "gitrepo.ru/neonxp/gorum/models" ) -templ Layout() { +templ Layout(parent *models.Node) { @@ -14,7 +15,7 @@ templ Layout() { - + Gorum @@ -23,9 +24,23 @@ templ Layout() {
  • Gorum BBS
  • -
  • - Список тем -
  • + if parent != nil { +
  • + Список тем +
  • +
  • + switch parent.Type { + case models.PostType: + На уровень выше + case models.TopicType: + К предыдущей теме + } +
  • + } else { +
  • + Список тем +
  • + }