Allow multiline descriptions
This commit is contained in:
parent
155144d86e
commit
424a0fad8e
3 changed files with 11 additions and 7 deletions
3
store.go
3
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)
|
||||
|
|
|
@ -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"}}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue