package views import ( "foobar/database" "foobar/model" "fmt" "time" ) templ indexLayout() { Mude meu título! // { children... } } templ mainCenterBody() { @indexLayout() {
{ children... }
} } const toggleButtonInMeUntilLoad = `on every htmx:beforeSend tell
See what's inside Front page
{ children... }
} } templ BoxUpload(box model.Box) { @boxUploadSidebar(box.Url()) {
@templ.Raw(box.Header())
} } templ NewBox(boxURL model.BoxURL, templateReadme model.Markdown) { @boxUploadSidebar(boxURL) {
@templ.Raw(templateReadme)
} } templ Box(boxURL model.BoxURL, files []model.File) { @boxUploadSidebar(boxURL) {
if len(files) == 0 {

Empty box.

} else { for i := range files { @fileCard(files[i]) } }
} } func fileDisplay(file model.File) templ.Component { switch { case file.Mime().IsImage(): return fileImageFigure(file) case file.Mime().IsVideo(): return fileVideoFigure(file) default: return unknownFileFigure() // panic(fmt.Errorf("unrecognized mime: %s", file.Mime)) } } templ fileCard(file model.File) {
@fileDisplay(file)
} templ fileImageFigure(file model.File) { {file.Name()} } templ fileVideoFigure(file model.File) { } templ unknownFileFigure() {
unknown format!
} func shorten(text string) string { if len(text) > 41 { return fmt.Sprintf("%s...", text[:41-3]) } else { return text } } func formatSize(size int64) string { units := []string{"b", "Kb", "Mb", "Gb"} i := 0 fSize := float64(size) for fSize >= 1000 && i < len(units)-1 { fSize /= 1000 i++ } return fmt.Sprintf("%.2f %s", fSize, units[i]) } templ FourOfour() { @indexLayout() {
404
} } templ Logged(usuario *database.Usuario) { @indexLayout() {

Logado como: { usuario.Nome }

index

logout

} } templ errorTarget() {
} templ ErrorBox(msg string) { }