From 363592119197d2c02941124e0dd4c43ad6316d9e Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 9 May 2018 16:12:02 -0500 Subject: [PATCH] typos in comments --- app/rest/api/import.go | 1 + app/rest/api/rest.go | 24 ++++++++++++------------ app/rest/auth/avatar.go | 2 +- app/rest/cache.go | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/rest/api/import.go b/app/rest/api/import.go index 883b64f5..dde76fb5 100644 --- a/app/rest/api/import.go +++ b/app/rest/api/import.go @@ -11,6 +11,7 @@ import ( "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/render" + "github.com/umputun/remark/app/migrator" "github.com/umputun/remark/app/rest" ) diff --git a/app/rest/api/rest.go b/app/rest/api/rest.go index 60a38ed6..c2722a2a 100644 --- a/app/rest/api/rest.go +++ b/app/rest/api/rest.go @@ -32,13 +32,12 @@ type Rest struct { Version string DataService store.Service Authenticator auth.Authenticator + Exporter migrator.Exporter Cache rest.LoadingCache WebRoot string - Exporter migrator.Exporter - - httpServer *http.Server - amdminService admin + httpServer *http.Server + adminService admin } const hardBodyLimit = 1024 * 64 // limit size of body @@ -55,7 +54,7 @@ func (s *Rest) Run(port int) { log.Printf("[DEBUG] admins %+v", s.Authenticator.Admins) } - s.amdminService = admin{ + s.adminService = admin{ dataService: s.DataService, exporter: s.Exporter, cache: s.Cache, @@ -107,14 +106,15 @@ func (s *Rest) Run(port int) { rauth.Put("/vote/{id}", s.voteCtrl) // admin routes, admin users only - rauth.Mount("/admin", s.amdminService.routes(s.Authenticator.AdminOnly)) + rauth.Mount("/admin", s.adminService.routes(s.Authenticator.AdminOnly)) }) }) - // add robots and file server for static content from /web router.Get("/robots.txt", func(w http.ResponseWriter, r *http.Request) { render.PlainText(w, r, "User-agent: *\nDisallow: /auth/\nDisallow: /api/\n") }) + + // file server for static content from /web addFileServer(router, "/web", http.Dir(s.WebRoot)) s.httpServer = &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: router} @@ -150,7 +150,7 @@ func (s *Rest) createCommentCtrl(w http.ResponseWriter, r *http.Request) { log.Printf("[DEBUG] create comment %+v", comment) // check if user blocked - if s.amdminService.checkBlocked(comment.Locator.SiteID, comment.User) { + if s.adminService.checkBlocked(comment.Locator.SiteID, comment.User) { rest.SendErrorJSON(w, r, http.StatusForbidden, errors.New("rejected"), "user blocked") return } @@ -251,7 +251,7 @@ func (s *Rest) findCommentsCtrl(w http.ResponseWriter, r *http.Request) { if e != nil { return nil, e } - maskedComments := s.amdminService.alterComments(comments, r) + maskedComments := s.adminService.alterComments(comments, r) var b []byte switch r.URL.Query().Get("format") { case "tree": @@ -284,7 +284,7 @@ func (s *Rest) lastCommentsCtrl(w http.ResponseWriter, r *http.Request) { if e != nil { return nil, e } - comments = s.amdminService.alterComments(comments, r) + comments = s.adminService.alterComments(comments, r) return encodeJSONWithHTML(comments) }) @@ -309,7 +309,7 @@ func (s *Rest) commentByIDCtrl(w http.ResponseWriter, r *http.Request) { rest.SendErrorJSON(w, r, http.StatusBadRequest, err, "can't get comment by id") return } - comment = s.amdminService.alterComments([]store.Comment{comment}, r)[0] + comment = s.adminService.alterComments([]store.Comment{comment}, r)[0] render.Status(r, http.StatusOK) renderJSONWithHTML(w, r, comment) } @@ -337,7 +337,7 @@ func (s *Rest) findUserCommentsCtrl(w http.ResponseWriter, r *http.Request) { if e != nil { return nil, e } - comments = s.amdminService.alterComments(comments, r) + comments = s.adminService.alterComments(comments, r) resp.Comments, resp.Count = comments, count return encodeJSONWithHTML(resp) }) diff --git a/app/rest/auth/avatar.go b/app/rest/auth/avatar.go index 8f2928ac..fdaf8f35 100644 --- a/app/rest/auth/avatar.go +++ b/app/rest/auth/avatar.go @@ -114,7 +114,7 @@ func (p *AvatarProxy) Routes() (string, chi.Router) { return p.RoutePath, router } -// get location for user id by adding partion to final path in order to keep files +// get location for user id by adding partition to final path in order to keep files // in different subdirectories and avoid too many files in a single place. // the end result is a full path like this - /tmp/avatars.test/92 func (p *AvatarProxy) location(id string) string { diff --git a/app/rest/cache.go b/app/rest/cache.go index d830ea31..c6ff889c 100644 --- a/app/rest/cache.go +++ b/app/rest/cache.go @@ -54,7 +54,7 @@ func (lc *loadingCache) Flush() { func URLKey(r *http.Request) string { adminPrefix := "admin!!" key := strings.TrimPrefix(r.URL.String(), adminPrefix) // prevents attach with fake url to get admin view - if user, err := GetUserInfo(r); err == nil && user.Admin { // make seprate cache key for admins + if user, err := GetUserInfo(r); err == nil && user.Admin { // make separate cache key for admins key = adminPrefix + key } return key