Open platform to collect and prioritize feedback
tooling: add robots txt (#470)
Guilherme Oenningf2ec588b3bb2
diff --git a/Dockerfile b/Dockerfileindex f8724a5fb..20bf982b6 100644--- a/Dockerfile+++ b/Dockerfile@@ -9,6 +9,7 @@ COPY migrations /app/migrationsCOPY views /app/viewsCOPY dist /app/distCOPY LICENSE /app+COPY robots.txt /appCOPY fider /appEXPOSE 3000diff --git a/app/cmd/routes.go b/app/cmd/routes.goindex 49864b835..5aaf38b43 100644--- a/app/cmd/routes.go+++ b/app/cmd/routes.go@@ -16,6 +16,11 @@ func routes(r *web.Engine) *web.Engine {r.Use(middlewares.Secure())r.Use(middlewares.Compress())+ robots := r.Group()+ {+ robots.Get("/robots.txt", handlers.RobotsTXT())+ }+assets := r.Group(){assets.Use(middlewares.CORS())diff --git a/app/handlers/common.go b/app/handlers/common.goindex 1465d8661..69031b537 100644--- a/app/handlers/common.go+++ b/app/handlers/common.go@@ -36,6 +36,17 @@ func LegalPage(title, file string) web.HandlerFunc {}}+//RobotsTXT return content of robots.txt file+func RobotsTXT() web.HandlerFunc {+ return func(c web.Context) error {+ bytes, err := ioutil.ReadFile(env.Path("./robots.txt"))+ if err != nil {+ return c.NotFound()+ }+ return c.String(http.StatusOK, string(bytes))+ }+}+//Page returns a page without propertiesfunc Page(title, description string) web.HandlerFunc {return func(c web.Context) error {diff --git a/app/handlers/common_test.go b/app/handlers/common_test.goindex b62bca740..b269067b2 100644--- a/app/handlers/common_test.go+++ b/app/handlers/common_test.go@@ -48,3 +48,11 @@ func TestLegalPageHandler_Invalid(t *testing.T) {Expect(code).Equals(http.StatusNotFound)}++func TestRobotsTXT(t *testing.T) {+ RegisterT(t)++ server, _ := mock.NewServer()+ code, _ := server.Execute(handlers.RobotsTXT())+ Expect(code).Equals(http.StatusOK)+}diff --git a/robots.txt b/robots.txtnew file mode 100644index 000000000..49a10ad06--- /dev/null+++ b/robots.txt@@ -0,0 +1,4 @@+User-agent: *+Disallow: /api/+Disallow: /admin/+Disallow: /oauth/\ No newline at end of filediff --git a/scripts/git-prune-local.sh b/scripts/git-prune-local.shindex 2d7575e16..39777d7ab 100755--- a/scripts/git-prune-local.sh+++ b/scripts/git-prune-local.sh@@ -1,2 +1,3 @@# https://medium.com/@kcmueller/delete-local-git-branches-that-were-deleted-on-remote-repository-b596b71b530c+git fetch -pgit branch -vv | grep ' gone]' | awk '{print $1}' | xargs git branch -D\ No newline at end of file