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