Added mindflow DB handling.
This commit is contained in:
parent
fb5188d565
commit
cd0d627914
@ -18,14 +18,17 @@ import (
|
|||||||
|
|
||||||
type Handlers struct {
|
type Handlers struct {
|
||||||
guestbookDB guestbook.Guestbook
|
guestbookDB guestbook.Guestbook
|
||||||
|
mindflowDB mindflow.Mindflow
|
||||||
captchaExpire time.Duration
|
captchaExpire time.Duration
|
||||||
guestbookOwner string
|
guestbookOwner string
|
||||||
guestbookPageSize int64
|
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{
|
return &Handlers{
|
||||||
guestbookDB: db,
|
guestbookDB: gdb,
|
||||||
|
mindflowDB: mdb,
|
||||||
captchaExpire: captchaExpire,
|
captchaExpire: captchaExpire,
|
||||||
guestbookOwner: gbOwner,
|
guestbookOwner: gbOwner,
|
||||||
guestbookPageSize: gbPageSize}
|
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) {
|
func (h *Handlers) Mindflow(w http.ResponseWriter, r *http.Request) {
|
||||||
posts := []mindflow.Post{
|
posts, err := h.mindflowDB.GetAll()
|
||||||
{Category: mindflow.Category{ID: 1, Name: "Update"}, Date: time.Now(), Title: "LMAO", Body: "Testing!"},
|
for _, entry := range posts {
|
||||||
|
entry.Body = strings.ReplaceAll(entry.Body, "\\n", "\n")
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
web.Mindflow("/ Mindflow", posts, r, w)
|
web.Mindflow("/ Mindflow", posts, r, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handlers) MindflowAdmin(w http.ResponseWriter, r *http.Request) {
|
func (h *Handlers) MindflowAdmin(w http.ResponseWriter, r *http.Request) {
|
||||||
posts := []mindflow.Post{
|
posts, err := h.mindflowDB.GetAll()
|
||||||
{Category: mindflow.Category{ID: 1, Name: "Update"}, Date: time.Now(), Title: "LMAO", Body: "Testing!"},
|
for _, entry := range posts {
|
||||||
|
entry.Body = strings.ReplaceAll(entry.Body, "\\n", "\n")
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
web.MindflowAdmin("/ Mindflow Administration", posts, r, w)
|
web.MindflowAdmin("/ Mindflow Administration", posts, r, w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user