2024-05-07 13:27:11 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
"log/slog"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
2024-05-18 16:15:20 +03:00
|
|
|
var infoTemplate = template.Must(template.New("").Funcs(templateFuncs).ParseFS(Pages, "pages/base.html", "pages/info.html"))
|
2024-05-07 13:27:11 +03:00
|
|
|
|
2024-05-08 15:56:11 +03:00
|
|
|
type AppInfo struct {
|
2024-05-07 13:27:11 +03:00
|
|
|
Version string
|
|
|
|
SourceLink string
|
|
|
|
}
|
|
|
|
|
2024-06-17 00:54:55 +03:00
|
|
|
// Info contains app information.
|
2024-05-08 15:56:11 +03:00
|
|
|
var Info = AppInfo{
|
2024-08-28 14:53:54 +03:00
|
|
|
Version: "1.1.4",
|
2024-05-07 13:27:11 +03:00
|
|
|
SourceLink: "https://git.a71.su/Andrew71/hibiscus",
|
|
|
|
}
|
|
|
|
|
2024-06-17 00:54:55 +03:00
|
|
|
// GetInfo renders the info page.
|
2024-05-07 13:27:11 +03:00
|
|
|
func GetInfo(w http.ResponseWriter, r *http.Request) {
|
|
|
|
err := infoTemplate.ExecuteTemplate(w, "base", Info)
|
|
|
|
if err != nil {
|
|
|
|
slog.Error("error executing template", "error", err)
|
|
|
|
InternalError(w, r)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2024-06-17 00:54:55 +03:00
|
|
|
|
|
|
|
// GetVersionApi returns current app version.
|
|
|
|
func GetVersionApi(w http.ResponseWriter, r *http.Request) {
|
|
|
|
HandleWrite(w.Write([]byte(Info.Version)))
|
|
|
|
w.WriteHeader(http.StatusOK)
|
|
|
|
}
|