Remove dependencies from new/ foder
This commit is contained in:
parent
6971028b9e
commit
49f824802b
4 changed files with 11 additions and 12 deletions
5
admin.go
5
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)
|
||||
|
|
|
@ -20,7 +20,6 @@ const (
|
|||
|
||||
TEMPLATE_PATH = "templates/"
|
||||
COVER_PATH = "cover/"
|
||||
NEW_PATH = "new/"
|
||||
CSS_PATH = "css/"
|
||||
JS_PATH = "js/"
|
||||
IMG_PATH = "img/"
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
</div>
|
||||
<div class="row"><p></p></div>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
15
trantor.go
15
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)
|
||||
|
|
Reference in a new issue