diff --git a/internal/handlers.go b/internal/handlers.go index 2682826..69f41fc 100644 --- a/internal/handlers.go +++ b/internal/handlers.go @@ -1,7 +1,6 @@ package internal import ( - "errors" "fmt" "html/template" "net/http" @@ -17,14 +16,7 @@ import ( ) const ( - MediaResolution = 720 // 720x576 - AvatarResolution = 360 // 360x360 - AsyncTaskLimit = 5 - MaxFailedLogins = 3 // By default 3 failed login attempts per 5 minutes -) - -var ( - ErrFeedImposter = errors.New("error: imposter detected, you do not own this feed") + MaxFailedLogins = 3 // By default 3 failed login attempts per 5 minutes ) func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request) { @@ -98,3 +90,27 @@ func (s *Server) PageHandler(name string) httprouter.Handle { s.render("page", w, ctx) } } + +// IndexHandler ... +func (s *Server) IndexHandler(name string) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + ctx := NewContext(s.config, s.db, r) + s.render("index", w, ctx) + } +} + +// CachedHandler ... +func (s *Server) CachedHandler(name string) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + ctx := NewContext(s.config, s.db, r) + s.render("cached", w, ctx) + } +} + +// SearchHandler ... +func (s *Server) SearchHandler(name string) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { + ctx := NewContext(s.config, s.db, r) + s.render("search", w, ctx) + } +} diff --git a/internal/support_handlers.go b/internal/support_handlers.go index 949edc2..23dad58 100644 --- a/internal/support_handlers.go +++ b/internal/support_handlers.go @@ -5,10 +5,11 @@ import ( "net/http" "strings" - "git.mills.io/prologic/spyda/internal/session" "github.com/julienschmidt/httprouter" log "github.com/sirupsen/logrus" "github.com/steambap/captcha" + + "git.mills.io/prologic/spyda/internal/session" ) // CaptchaHandler ... diff --git a/internal/templates.go b/internal/templates.go index 9399081..532dfd6 100644 --- a/internal/templates.go +++ b/internal/templates.go @@ -31,7 +31,7 @@ type TemplateManager struct { funcMap template.FuncMap } -func NewTemplateManager(conf *Config, blogs *BlogsCache, cache *Cache) (*TemplateManager, error) { +func NewTemplateManager(conf *Config) (*TemplateManager, error) { templates := make(map[string]*template.Template) funcMap := sprig.FuncMap()