2023-01-16 05:24:07 +04:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2023-02-05 00:52:14 +04:00
|
|
|
"strings"
|
2023-01-16 05:24:07 +04:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.arav.top/Arav/dwelling-home/web"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Handlers struct {
|
|
|
|
captchaExpire time.Duration
|
|
|
|
databasesPath string
|
|
|
|
guestbookOwner string
|
|
|
|
guestbookPageSize int
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewHandlers(captchaExpire time.Duration, dbPath, gbOwner string, gbPageSize int) *Handlers {
|
|
|
|
return &Handlers{
|
|
|
|
captchaExpire: captchaExpire,
|
|
|
|
databasesPath: dbPath,
|
|
|
|
guestbookOwner: gbOwner,
|
|
|
|
guestbookPageSize: gbPageSize}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) AssetsFS() http.FileSystem {
|
|
|
|
return web.Assets()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) {
|
2023-02-05 00:52:14 +04:00
|
|
|
web.Index("", w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) Stuff(w http.ResponseWriter, r *http.Request) {
|
|
|
|
web.Stuff("/ Stuff", "", "", w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) Mindflow(w http.ResponseWriter, r *http.Request) {
|
|
|
|
web.Mindflow("/ Mindflow", nil, r, w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) About(w http.ResponseWriter, r *http.Request) {
|
|
|
|
web.About("/ About", "", nil, w)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) Article(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if strings.HasSuffix(r.URL.Path, "hardening_mikrotik") {
|
|
|
|
web.ArticleHardeningMikrotik("/ Article / Hardening Mikrotik", w)
|
|
|
|
} else if strings.HasSuffix(r.URL.Path, "nginx_recipes_and_tips") {
|
|
|
|
web.ArticleNginxRecipesAndTips("/ Article / NGiNX's recipes & tips", w)
|
|
|
|
} else if strings.HasSuffix(r.URL.Path, "setting_up_a_mail_server") {
|
|
|
|
web.ArticleSettingUpAMailServer("/ Article / Setting up a mail server", w)
|
|
|
|
} else if strings.HasSuffix(r.URL.Path, "setting_up_a_tor_proxy_relay_hiddenserv") {
|
|
|
|
web.ArticleSettingUpATorProxyRelayHiddenserv("/ Article / Setting up a Tor proxy, relay and hidden service", w)
|
|
|
|
} else if strings.HasSuffix(r.URL.Path, "rpi_root_on_external_drive") {
|
|
|
|
web.ArticleSettingUpATorProxyRelayHiddenserv("/ Article / How to move a root partition from SD card off to external drive on Raspberry Pi", w)
|
|
|
|
} else {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) RSS(w http.ResponseWriter, r *http.Request) {
|
|
|
|
web.RSS(r.Host, "Arav", nil, r, w)
|
2023-01-16 05:24:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Handlers) Robots(w http.ResponseWriter, r *http.Request) {
|
|
|
|
data, _ := web.AssetsGetFile("robots.txt")
|
|
|
|
w.Write(data)
|
|
|
|
}
|