2024-07-20 21:56:37 +03:00
// 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"
import (
"context"
"gitrepo.ru/neonxp/gorum/contextlib"
"gitrepo.ru/neonxp/gorum/models"
)
2024-07-29 02:47:35 +03:00
func Layout ( ) templ . Component {
2024-07-20 21:56:37 +03:00
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 )
2024-07-21 19:26:56 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "<!doctype html><html lang=\"ru\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><meta name=\"color-scheme\" content=\"light dark\"><link rel=\"stylesheet\" href=\"" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var2 string
templ_7745c5c3_Var2 , templ_7745c5c3_Err = templ . JoinStringErrs ( "/assets/css/pico." + ctx . Value ( contextlib . ThemeKey ) . ( string ) + ".min.css" )
if templ_7745c5c3_Err != nil {
2024-07-29 02:47:35 +03:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` views/layouts.templ ` , Line : 16 , Col : 107 }
2024-07-20 21:56:37 +03:00
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var2 ) )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-07-29 02:47:35 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "\"><link rel=\"stylesheet\" href=\"/assets/css/style.css\"><title>Gorum</title></head><body><nav class=\"container-fluid\"><ul><li><strong>Gorum BBS</strong></li><li><a href=\"/\">Список тем</a></li>" )
2024-07-21 19:26:56 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-07-29 02:47:35 +03:00
if isAuthorized ( ctx ) {
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "<li><a href=\"/t/new\">Новая тема</a></li>" )
2024-07-21 19:26:56 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "</ul><ul>" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if isAuthorized ( ctx ) {
2024-07-29 02:47:35 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "<li>" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-07-29 02:47:35 +03:00
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3 , templ_7745c5c3_Err = templ . JoinStringErrs ( getUser ( ctx ) . Username )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
2024-07-29 02:47:35 +03:00
return templ . Error { Err : templ_7745c5c3_Err , FileName : ` views/layouts.templ ` , Line : 35 , Col : 33 }
2024-07-20 21:56:37 +03:00
}
2024-07-29 02:47:35 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( templ . EscapeString ( templ_7745c5c3_Var3 ) )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-07-21 19:26:56 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "</li><li><form action=\"/logout\" method=\"POST\"><input type=\"submit\" value=\"Выход\"></form></li>" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
2024-07-21 19:26:56 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "<li><a href=\"/login\">Вход</a></li><li><a href=\"/register\">Регистрация</a></li>" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
2024-07-29 02:47:35 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "</ul></nav><main class=\"container-fluid\">" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templ_7745c5c3_Var1 . Render ( ctx , templ_7745c5c3_Buffer )
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
2024-07-21 19:26:56 +03:00
_ , templ_7745c5c3_Err = templ_7745c5c3_Buffer . WriteString ( "</main><footer class=\"container-fluid\"><small>Работает на <a href=\"https://neonxp.ru/gorum\">Gorum</a>.</small></footer></body></html>" )
2024-07-20 21:56:37 +03:00
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return templ_7745c5c3_Err
} )
}
func isAuthorized ( ctx context . Context ) bool {
_ , authorized := ctx . Value ( contextlib . UserKey ) . ( models . User )
return authorized
}
func getUser ( ctx context . Context ) models . User {
return ctx . Value ( contextlib . UserKey ) . ( models . User )
}