1
0

Added mindflow DB handling.

This commit is contained in:
Alexander Andreev 2023-05-19 21:54:46 +04:00
parent fb5188d565
commit cd0d627914
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -18,14 +18,17 @@ import (
type Handlers struct {
guestbookDB guestbook.Guestbook
mindflowDB mindflow.Mindflow
captchaExpire time.Duration
guestbookOwner string
guestbookPageSize int64
}
func NewHandlers(captchaExpire time.Duration, gbOwner string, gbPageSize int64, db guestbook.Guestbook) *Handlers {
func NewHandlers(captchaExpire time.Duration, gbOwner string, gbPageSize int64,
gdb guestbook.Guestbook, mdb mindflow.Mindflow) *Handlers {
return &Handlers{
guestbookDB: db,
guestbookDB: gdb,
mindflowDB: mdb,
captchaExpire: captchaExpire,
guestbookOwner: gbOwner,
guestbookPageSize: gbPageSize}
@ -49,16 +52,26 @@ func (h *Handlers) Stuff(w http.ResponseWriter, r *http.Request) {
}
func (h *Handlers) Mindflow(w http.ResponseWriter, r *http.Request) {
posts := []mindflow.Post{
{Category: mindflow.Category{ID: 1, Name: "Update"}, Date: time.Now(), Title: "LMAO", Body: "Testing!"},
posts, err := h.mindflowDB.GetAll()
for _, entry := range posts {
entry.Body = strings.ReplaceAll(entry.Body, "\\n", "\n")
}
if err != nil {
return
}
web.Mindflow("/ Mindflow", posts, r, w)
}
func (h *Handlers) MindflowAdmin(w http.ResponseWriter, r *http.Request) {
posts := []mindflow.Post{
{Category: mindflow.Category{ID: 1, Name: "Update"}, Date: time.Now(), Title: "LMAO", Body: "Testing!"},
posts, err := h.mindflowDB.GetAll()
for _, entry := range posts {
entry.Body = strings.ReplaceAll(entry.Body, "\\n", "\n")
}
if err != nil {
return
}
web.MindflowAdmin("/ Mindflow Administration", posts, r, w)
}