diff --git a/admin.go b/admin.go index 7060430..831d713 100644 --- a/admin.go +++ b/admin.go @@ -172,11 +172,6 @@ func newHandler(w http.ResponseWriter, r *http.Request) { return } - if len(r.URL.Path) > len("/new/") { - http.ServeFile(w, r, NEW_PATH+r.URL.Path[len("/new/"):]) - return - } - err := r.ParseForm() if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/config.go b/config.go index d55d409..3e8daa2 100644 --- a/config.go +++ b/config.go @@ -20,7 +20,6 @@ const ( TEMPLATE_PATH = "templates/" COVER_PATH = "cover/" - NEW_PATH = "new/" CSS_PATH = "css/" JS_PATH = "js/" IMG_PATH = "img/" diff --git a/templates/new.html b/templates/new.html index 7cb976f..8e606e4 100644 --- a/templates/new.html +++ b/templates/new.html @@ -47,7 +47,7 @@

- download + download read it!
diff --git a/trantor.go b/trantor.go index e48a93a..55e8d2e 100644 --- a/trantor.go +++ b/trantor.go @@ -72,9 +72,18 @@ func downloadHandler(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + book := books[0] + + if !book.Active { + sess := GetSession(r) + if sess.User == "" { + http.NotFound(w, r) + return + } + } fs := db.GetFS(FS_BOOKS) - f, err := fs.OpenId(books[0].File) + f, err := fs.OpenId(book.File) if err != nil { http.NotFound(w, r) return @@ -120,10 +129,6 @@ func main() { if err != nil { os.Mkdir(COVER_PATH, os.ModePerm) } - _, err = os.Stat(NEW_PATH) - if err != nil { - os.Mkdir(NEW_PATH, os.ModePerm) - } /* set up web handlers */ http.HandleFunc("/book/", bookHandler)