mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
refactor: refactor migrations and add fixtures
feat: introduce key-value store feat: imprint page (resolve #23) chore: remove default user chore: remove packr
This commit is contained in:
@ -12,17 +12,19 @@ import (
|
||||
)
|
||||
|
||||
type IndexHandler struct {
|
||||
config *models.Config
|
||||
userSrvc *services.UserService
|
||||
config *models.Config
|
||||
userSrvc *services.UserService
|
||||
keyValueSrvc *services.KeyValueService
|
||||
}
|
||||
|
||||
var loginDecoder = schema.NewDecoder()
|
||||
var signupDecoder = schema.NewDecoder()
|
||||
|
||||
func NewIndexHandler(userService *services.UserService) *IndexHandler {
|
||||
func NewIndexHandler(userService *services.UserService, keyValueService *services.KeyValueService) *IndexHandler {
|
||||
return &IndexHandler{
|
||||
config: models.GetConfig(),
|
||||
userSrvc: userService,
|
||||
config: models.GetConfig(),
|
||||
userSrvc: userService,
|
||||
keyValueSrvc: keyValueService,
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,6 +53,21 @@ func (h *IndexHandler) Index(w http.ResponseWriter, r *http.Request) {
|
||||
templates["index.tpl.html"].Execute(w, nil)
|
||||
}
|
||||
|
||||
func (h *IndexHandler) Imprint(w http.ResponseWriter, r *http.Request) {
|
||||
if h.config.IsDev() {
|
||||
loadTemplates()
|
||||
}
|
||||
|
||||
text := "failed to load content"
|
||||
if data, err := h.keyValueSrvc.GetString(models.ImprintKey); err == nil {
|
||||
text = data.Value
|
||||
}
|
||||
|
||||
templates["imprint.tpl.html"].Execute(w, &struct {
|
||||
HtmlText string
|
||||
}{HtmlText: text})
|
||||
}
|
||||
|
||||
func (h *IndexHandler) Login(w http.ResponseWriter, r *http.Request) {
|
||||
if h.config.IsDev() {
|
||||
loadTemplates()
|
||||
|
Reference in New Issue
Block a user