From 9f1204db355a5cdcd322f381d8824c3b790cbd0d Mon Sep 17 00:00:00 2001 From: Las Zenow Date: Wed, 15 Aug 2012 15:12:59 +0200 Subject: [PATCH] Run go fmt --- database.go | 2 +- search.go | 12 ++++++------ template.go | 14 +++++++------- trantor.go | 2 -- upload.go | 2 +- upload/database.go | 2 +- upload/upload.go | 16 ++++++++-------- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/database.go b/database.go index ce41a3d..1688b37 100644 --- a/database.go +++ b/database.go @@ -19,5 +19,5 @@ type Book struct { Path string Cover string CoverSmall string - Keywords []string + Keywords []string } diff --git a/search.go b/search.go index 1607083..6b52d7d 100644 --- a/search.go +++ b/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) } diff --git a/template.go b/template.go index ab0b5e1..c6562c2 100644 --- a/template.go +++ b/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 { diff --git a/trantor.go b/trantor.go index ad52a8a..584b7e9 100644 --- a/trantor.go +++ b/trantor.go @@ -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 diff --git a/upload.go b/upload.go index 74a7ca9..0141b4f 100644 --- a/upload.go +++ b/upload.go @@ -1,9 +1,9 @@ package main import ( + "labix.org/v2/mgo" "os" "strconv" - "labix.org/v2/mgo" //"labix.org/v2/mgo/bson" "net/http" ) diff --git a/upload/database.go b/upload/database.go index ce41a3d..1688b37 100644 --- a/upload/database.go +++ b/upload/database.go @@ -19,5 +19,5 @@ type Book struct { Path string Cover string CoverSmall string - Keywords []string + Keywords []string } diff --git a/upload/upload.go b/upload/upload.go index 3d1c778..c2dcb39 100644 --- a/upload/upload.go +++ b/upload/upload.go @@ -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() }