1
0

guestbookOwner was renamed to just owner. Also, pass an owner to web.RSS() instead of a hardcoded nickname.

This commit is contained in:
Alexander Andreev 2024-04-20 04:51:11 +04:00
parent 70b45a628b
commit dca3804090
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
2 changed files with 9 additions and 9 deletions

View File

@ -24,7 +24,7 @@ var (
showVersion = flag.Bool("v", false, "show version")
listenAddress = flag.String("listen", "/var/run/dwelling-home/sock", "listen address (ip:port|unix_path)")
captchaExpiry = flag.Duration("captcha-expiry", 10*time.Minute, "CAPTCHA expiry (e.g. 5m, 60s)")
guestbookOwner = "Arav"
owner = "Arav"
guestbookPageSize = flag.Int64("guestbook-page-size", 60, "size of a guestbook page")
databasesPath = flag.String("database-path", "/var/lib/dwelling-home", "path to a directory where to store DB files")
)
@ -51,7 +51,7 @@ func main() {
}
defer mindflowDB.Close()
hand := dwhttp.NewHandlers(*captchaExpiry, guestbookOwner, *guestbookPageSize, guestbookDB, mindflowDB)
hand := dwhttp.NewHandlers(*captchaExpiry, owner, *guestbookPageSize, guestbookDB, mindflowDB)
r := httpr.New()
@ -82,7 +82,7 @@ func main() {
s.Handler(http.MethodPost, "/:id", captchaApi.Solve)
s.Handler(http.MethodGet, "/:id/image", captchaApi.Image)
guestbookApi := dwhttp.NewGuestbookApiHandlers(guestbookOwner, *guestbookPageSize, guestbookDB)
guestbookApi := dwhttp.NewGuestbookApiHandlers(owner, *guestbookPageSize, guestbookDB)
s = r.Sub("/api/guestbook")
s.Handler(http.MethodPost, "/", guestbookApi.New)

View File

@ -21,17 +21,17 @@ type Handlers struct {
guestbookDB justguestbook.Guestbook
mindflowDB mindflow.Mindflow
captchaExpire time.Duration
guestbookOwner string
owner string
guestbookPageSize int64
}
func NewHandlers(captchaExpire time.Duration, gbOwner string, gbPageSize int64,
func NewHandlers(captchaExpire time.Duration, owner string, gbPageSize int64,
gdb justguestbook.Guestbook, mdb mindflow.Mindflow) *Handlers {
return &Handlers{
guestbookDB: gdb,
mindflowDB: mdb,
captchaExpire: captchaExpire,
guestbookOwner: gbOwner,
owner: owner,
guestbookPageSize: gbPageSize}
}
@ -146,7 +146,7 @@ func (h *Handlers) Guestbook(w http.ResponseWriter, r *http.Request) {
dwc := dwcaptcha.NewDwellingCaptcha(h.captchaExpire)
_, id := inmemdb.New(r.RemoteAddr, dwc)
web.Guestbook("/ Guestbook", h.guestbookOwner, string(id), pageCount, entries, r, w)
web.Guestbook("/ Guestbook", h.owner, string(id), pageCount, entries, r, w)
}
func (h *Handlers) GuestbookAdmin(w http.ResponseWriter, r *http.Request) {
@ -160,7 +160,7 @@ func (h *Handlers) GuestbookAdmin(w http.ResponseWriter, r *http.Request) {
entry.Message = strings.ReplaceAll(entry.Message, "\\n", "\n")
}
web.GuestbookAdmin("/ Guestbook Administration", h.guestbookOwner, entries, r, w)
web.GuestbookAdmin("/ Guestbook Administration", h.owner, entries, r, w)
}
func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {
@ -175,7 +175,7 @@ func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {
scheme = "http"
}
web.RSS(scheme+"://"+r.Host, "Arav", posts, r, w)
web.RSS(scheme+"://"+r.Host, h.owner, posts, r, w)
}
func FaviconIco(w http.ResponseWriter, r *http.Request) {