Allow multiline descriptions

This commit is contained in:
Las Zenow 2013-05-31 00:34:11 +02:00
parent 155144d86e
commit 424a0fad8e
3 changed files with 11 additions and 7 deletions

View file

@ -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, "&amp;", "&", -1)

View file

@ -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"}}

View file

@ -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)
}