Migrate misc
This commit is contained in:
parent
c961db9fae
commit
37872dda87
@ -1,13 +1,15 @@
|
||||
package misc
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template" // sic! TODO: make it html/template after the template library migration
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/internal/cfg"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/user"
|
||||
"github.com/bouncepaw/mycorrhiza/internal/version"
|
||||
"github.com/bouncepaw/mycorrhiza/l18n"
|
||||
"log"
|
||||
"strings"
|
||||
"text/template" // sic!
|
||||
)
|
||||
|
||||
type L10nEntry struct {
|
||||
@ -95,7 +97,8 @@ func AboutHTML(lc *l18n.Localizer) string {
|
||||
}
|
||||
temp, err := template.New("about wiki").Funcs(template.FuncMap{"get": get}).Parse(aboutTemplateString)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
slog.Error("Failed to parse About template", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
data := aboutData
|
||||
data.Version = version.Short
|
||||
@ -112,7 +115,8 @@ func AboutHTML(lc *l18n.Localizer) string {
|
||||
var out strings.Builder
|
||||
err = temp.Execute(&out, data)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
slog.Error("Failed to execute About template", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return out.String()
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ package misc
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"math/rand"
|
||||
"mime"
|
||||
"net/http"
|
||||
@ -133,7 +134,7 @@ func handlerAbout(w http.ResponseWriter, rq *http.Request) {
|
||||
map[string]string{},
|
||||
))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
slog.Error("Failed to write About template", "err", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package misc
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
||||
"github.com/bouncepaw/mycorrhiza/internal/hyphae"
|
||||
"github.com/bouncepaw/mycorrhiza/web/viewutil"
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user