Run go fmt
This commit is contained in:
parent
d924b577d1
commit
9f1204db35
7 changed files with 24 additions and 26 deletions
|
@ -19,5 +19,5 @@ type Book struct {
|
|||
Path string
|
||||
Cover string
|
||||
CoverSmall string
|
||||
Keywords []string
|
||||
Keywords []string
|
||||
}
|
||||
|
|
12
search.go
12
search.go
|
@ -1,10 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"labix.org/v2/mgo"
|
||||
"labix.org/v2/mgo/bson"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -26,9 +26,9 @@ type searchData struct {
|
|||
Search string
|
||||
Found int
|
||||
Books []Book
|
||||
Page int
|
||||
Next string
|
||||
Prev string
|
||||
Page int
|
||||
Next string
|
||||
Prev string
|
||||
}
|
||||
|
||||
func searchHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request) {
|
||||
|
@ -54,11 +54,11 @@ func searchHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request
|
|||
data.Search = req
|
||||
data.Found = len(res)
|
||||
if len(res) > ITEMS_PAGE*(page+1) {
|
||||
data.Books = res[ITEMS_PAGE*page:ITEMS_PAGE*(page+1)]
|
||||
data.Books = res[ITEMS_PAGE*page : ITEMS_PAGE*(page+1)]
|
||||
} else {
|
||||
data.Books = res[ITEMS_PAGE*page:]
|
||||
}
|
||||
data.Page = page+1
|
||||
data.Page = page + 1
|
||||
if len(res) > (page+1)*ITEMS_PAGE {
|
||||
data.Next = "/search/?q=" + req + "&p=" + strconv.Itoa(page+1)
|
||||
}
|
||||
|
|
14
template.go
14
template.go
|
@ -11,13 +11,13 @@ const (
|
|||
|
||||
func loadTemplate(w http.ResponseWriter, tmpl string, data interface{}) {
|
||||
// TODO: when finish devel conver to global:
|
||||
var templates = template.Must(template.ParseFiles(TEMPLATE_DIR + "header.html",
|
||||
TEMPLATE_DIR + "footer.html",
|
||||
TEMPLATE_DIR + "index.html",
|
||||
TEMPLATE_DIR + "about.html",
|
||||
TEMPLATE_DIR + "book.html",
|
||||
TEMPLATE_DIR + "search.html",
|
||||
TEMPLATE_DIR + "upload.html"))
|
||||
var templates = template.Must(template.ParseFiles(TEMPLATE_DIR+"header.html",
|
||||
TEMPLATE_DIR+"footer.html",
|
||||
TEMPLATE_DIR+"index.html",
|
||||
TEMPLATE_DIR+"about.html",
|
||||
TEMPLATE_DIR+"book.html",
|
||||
TEMPLATE_DIR+"search.html",
|
||||
TEMPLATE_DIR+"upload.html"))
|
||||
|
||||
err := templates.ExecuteTemplate(w, tmpl+".html", data)
|
||||
if err != nil {
|
||||
|
|
|
@ -24,13 +24,11 @@ func bookHandler(coll *mgo.Collection) func(http.ResponseWriter, *http.Request)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func fileHandler(path string) {
|
||||
h := http.FileServer(http.Dir(path[1:]))
|
||||
http.Handle(path, http.StripPrefix(path, h))
|
||||
}
|
||||
|
||||
|
||||
type indexData struct {
|
||||
Books []Book
|
||||
Count int
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"labix.org/v2/mgo"
|
||||
"os"
|
||||
"strconv"
|
||||
"labix.org/v2/mgo"
|
||||
//"labix.org/v2/mgo/bson"
|
||||
"net/http"
|
||||
)
|
||||
|
|
|
@ -19,5 +19,5 @@ type Book struct {
|
|||
Path string
|
||||
Cover string
|
||||
CoverSmall string
|
||||
Keywords []string
|
||||
Keywords []string
|
||||
}
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
IP = "127.0.0.1"
|
||||
DB_NAME = "trantor"
|
||||
BOOKS_COLL = "books"
|
||||
PATH = "books/"
|
||||
NEW_PATH = "new/"
|
||||
COVER_PATH = "cover/"
|
||||
RESIZE = "/usr/bin/convert -resize 300 -quality 60 "
|
||||
IP = "127.0.0.1"
|
||||
DB_NAME = "trantor"
|
||||
BOOKS_COLL = "books"
|
||||
PATH = "books/"
|
||||
NEW_PATH = "new/"
|
||||
COVER_PATH = "cover/"
|
||||
RESIZE = "/usr/bin/convert -resize 300 -quality 60 "
|
||||
RESIZE_THUMB = "/usr/bin/convert -resize 60 -quality 60 "
|
||||
)
|
||||
|
||||
|
@ -118,7 +118,7 @@ func store(coll *mgo.Collection, path string) {
|
|||
book.Keywords = keywords(book)
|
||||
coll.Insert(book)
|
||||
|
||||
os.Mkdir(PATH + path[:1], os.ModePerm)
|
||||
os.Mkdir(PATH+path[:1], os.ModePerm)
|
||||
cmd := exec.Command("mv", NEW_PATH+path, book.Path)
|
||||
cmd.Run()
|
||||
}
|
||||
|
|
Reference in a new issue