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 {
|
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("<[^>]*>")
|
exp, _ := regexp.Compile("<[^>]*>")
|
||||||
str = exp.ReplaceAllString(str, "")
|
str = exp.ReplaceAllString(str, "")
|
||||||
str = strings.Replace(str, "&", "&", -1)
|
str = strings.Replace(str, "&", "&", -1)
|
||||||
|
|
|
@ -60,16 +60,16 @@ function delBook(){
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{{if .Description}}
|
|
||||||
<div class="span8">
|
<div class="span8">
|
||||||
<p>{{.Description}}</p>
|
{{range .Description}}
|
||||||
</div>
|
<p>{{.}}</p>
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{template "footer.html"}}
|
{{template "footer.html"}}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"labix.org/v2/mgo/bson"
|
"labix.org/v2/mgo/bson"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type aboutData struct {
|
type aboutData struct {
|
||||||
|
@ -43,8 +44,9 @@ func loginHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type bookData struct {
|
type bookData struct {
|
||||||
S Status
|
S Status
|
||||||
Book Book
|
Book Book
|
||||||
|
Description []string
|
||||||
}
|
}
|
||||||
|
|
||||||
func bookHandler(w http.ResponseWriter, r *http.Request, sess *Session) {
|
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)
|
db.IncVisit(id)
|
||||||
data.Book = books[0]
|
data.Book = books[0]
|
||||||
|
data.Description = strings.Split(data.Book.Description, "\n")
|
||||||
loadTemplate(w, "book", data)
|
loadTemplate(w, "book", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue