diff --git a/store.go b/store.go index 8e3c5c7..e50e65f 100644 --- a/store.go +++ b/store.go @@ -87,7 +87,8 @@ func parseAuthr(creator []string) []string { } func parseDescription(description []string) string { - str := cleanStr(strings.Join(description, ", ")) + str := cleanStr(strings.Join(description, "\n")) + str = strings.Replace(str, "</p>", "\n", -1) exp, _ := regexp.Compile("<[^>]*>") str = exp.ReplaceAllString(str, "") str = strings.Replace(str, "&", "&", -1) diff --git a/templates/book.html b/templates/book.html index 02f273f..efb4eed 100644 --- a/templates/book.html +++ b/templates/book.html @@ -60,16 +60,16 @@ function delBook(){ </div> </div> </div> +{{end}} <div class="row"> - {{if .Description}} <div class="span8"> - <p>{{.Description}}</p> - </div> + {{range .Description}} + <p>{{.}}</p> {{end}} </div> </div> + </div> </div> -{{end}} {{template "footer.html"}} diff --git a/trantor.go b/trantor.go index 418f53e..155309c 100644 --- a/trantor.go +++ b/trantor.go @@ -6,6 +6,7 @@ import ( "labix.org/v2/mgo/bson" "log" "net/http" + "strings" ) type aboutData struct { @@ -43,8 +44,9 @@ func loginHandler(w http.ResponseWriter, r *http.Request, sess *Session) { } type bookData struct { - S Status - Book Book + S Status + Book Book + Description []string } func bookHandler(w http.ResponseWriter, r *http.Request, sess *Session) { @@ -64,6 +66,7 @@ func bookHandler(w http.ResponseWriter, r *http.Request, sess *Session) { } db.IncVisit(id) data.Book = books[0] + data.Description = strings.Split(data.Book.Description, "\n") loadTemplate(w, "book", data) }