Remove dependencies from new/ foder

This commit is contained in:
Las Zenow 2013-04-12 01:44:00 +02:00
parent 6971028b9e
commit 49f824802b
4 changed files with 11 additions and 12 deletions

View file

@ -172,11 +172,6 @@ func newHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
if len(r.URL.Path) > len("/new/") {
http.ServeFile(w, r, NEW_PATH+r.URL.Path[len("/new/"):])
return
}
err := r.ParseForm() err := r.ParseForm()
if err != nil { if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)

View file

@ -20,7 +20,6 @@ const (
TEMPLATE_PATH = "templates/" TEMPLATE_PATH = "templates/"
COVER_PATH = "cover/" COVER_PATH = "cover/"
NEW_PATH = "new/"
CSS_PATH = "css/" CSS_PATH = "css/"
JS_PATH = "js/" JS_PATH = "js/"
IMG_PATH = "img/" IMG_PATH = "img/"

View file

@ -47,7 +47,7 @@
</div> </div>
<div class="row"><p></p></div> <div class="row"><p></p></div>
<div class="row btn-group pull-right"> <div class="row btn-group pull-right">
<a href="/new/{{.Path}}" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a> <a href="/books/{{.Id}}" class="btn btn-inverse"><i class="icon-download-alt icon-white"></i> download</a>
<a href="/read/{{.Id}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a> <a href="/read/{{.Id}}" class="btn btn-warning"><i class="icon-eye-open icon-white"></i> read it!</a>
</div> </div>
</div> </div>

View file

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