diff --git a/config.go b/config.go index 81b7487..96ad221 100644 --- a/config.go +++ b/config.go @@ -32,6 +32,7 @@ const ( CSS_PATH = "css/" JS_PATH = "js/" IMG_PATH = "img/" + ROBOTS_PATH = "robots.txt" LOGGER_CONFIG = "logger.xml" IMG_WIDTH_BIG = 300 diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..748a7f2 --- /dev/null +++ b/robots.txt @@ -0,0 +1,4 @@ +User-agent: * +Disallow: /delete/ +Disallow: /edit/ +Disallow: /save/ diff --git a/trantor.go b/trantor.go index 0195bb6..e8a4111 100644 --- a/trantor.go +++ b/trantor.go @@ -162,32 +162,38 @@ func initRouter(db *database.DB, sg *StatsGatherer) { r.NotFoundHandler = notFoundHandler r.HandleFunc("/", sg.Gather(indexHandler)) + r.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, ROBOTS_PATH) }) + r.HandleFunc("/book/{id:"+id_pattern+"}", sg.Gather(bookHandler)) r.HandleFunc("/search/", sg.Gather(searchHandler)) r.HandleFunc("/upload/", sg.Gather(uploadHandler)).Methods("GET") r.HandleFunc("/upload/", sg.Gather(uploadPostHandler)).Methods("POST") - r.HandleFunc("/login/", sg.Gather(loginHandler)).Methods("GET") - r.HandleFunc("/login/", sg.Gather(loginPostHandler)).Methods("POST") - r.HandleFunc("/create_user/", sg.Gather(createUserHandler)).Methods("POST") - r.HandleFunc("/logout/", sg.Gather(logoutHandler)) - r.HandleFunc("/new/", sg.Gather(newHandler)) - r.HandleFunc("/store/{ids:("+id_pattern+"/)+}", sg.Gather(storeHandler)) - r.HandleFunc("/delete/{ids:("+id_pattern+"/)+}", sg.Gather(deleteHandler)) r.HandleFunc("/read/{id:"+id_pattern+"}", sg.Gather(readStartHandler)) r.HandleFunc("/read/{id:"+id_pattern+"}/{file:.*}", sg.Gather(readHandler)) r.HandleFunc("/content/{id:"+id_pattern+"}/{file:.*}", sg.Gather(contentHandler)) - r.HandleFunc("/edit/{id:"+id_pattern+"}", sg.Gather(editHandler)) - r.HandleFunc("/save/{id:"+id_pattern+"}", sg.Gather(saveHandler)).Methods("POST") r.HandleFunc("/about/", sg.Gather(aboutHandler)) r.HandleFunc("/help/", sg.Gather(helpHandler)) r.HandleFunc("/download/{id:"+id_pattern+"}/{epub:.*}", sg.Gather(downloadHandler)) r.HandleFunc("/cover/{id:"+id_pattern+"}/{size}/{img:.*}", sg.Gather(coverHandler)) + r.HandleFunc("/stats/", sg.Gather(statsHandler)) + + r.HandleFunc("/login/", sg.Gather(loginHandler)).Methods("GET") + r.HandleFunc("/login/", sg.Gather(loginPostHandler)).Methods("POST") + r.HandleFunc("/create_user/", sg.Gather(createUserHandler)).Methods("POST") + r.HandleFunc("/logout/", sg.Gather(logoutHandler)) r.HandleFunc("/dashboard/", sg.Gather(dashboardHandler)) r.HandleFunc("/settings/", sg.Gather(settingsHandler)) - r.HandleFunc("/stats/", sg.Gather(statsHandler)) + + r.HandleFunc("/new/", sg.Gather(newHandler)) + r.HandleFunc("/save/{id:"+id_pattern+"}", sg.Gather(saveHandler)).Methods("POST") + r.HandleFunc("/edit/{id:"+id_pattern+"}", sg.Gather(editHandler)) + r.HandleFunc("/store/{ids:("+id_pattern+"/)+}", sg.Gather(storeHandler)) + r.HandleFunc("/delete/{ids:("+id_pattern+"/)+}", sg.Gather(deleteHandler)) + r.HandleFunc("/news/", sg.Gather(newsHandler)) r.HandleFunc("/news/edit", sg.Gather(editNewsHandler)).Methods("GET") r.HandleFunc("/news/edit", sg.Gather(postNewsHandler)).Methods("POST") + h := http.FileServer(http.Dir(IMG_PATH)) r.Handle("/img/{img}", http.StripPrefix("/img/", h)) h = http.FileServer(http.Dir(CSS_PATH))