Commit 2a742483 authored by ale's avatar ale

render the book description as HTML

parent 885b31c4
......@@ -52,9 +52,10 @@ func testEbook() *Book {
return &Book{
Id: NewID(),
Metadata: &Metadata{
Title: "20,000 Leagues under the sea",
Creator: []string{"Jules Verne"},
ISBN: []string{"1234"},
Title: "20,000 Leagues under the sea",
Creator: []string{"Jules Verne"},
ISBN: []string{"1234"},
Description: "A pretty cool book.",
},
}
}
......
......@@ -28,8 +28,8 @@
</p>
{{end}}
{{if .Book.Metadata.Description}}
<p>{{.Book.Metadata.Description}}</p>
{{if .Description}}
<p>{{.Description}}</p>
{{end}}
{{range $i, $f := .Files}}
......
......@@ -149,11 +149,18 @@ func (s *uiServer) handleShowBook(book *Book, w http.ResponseWriter, req *http.R
return
}
// The book's Description, if present, should be rendered
// directly as HTML. So we deal with it separately.
ctx := struct {
Query string
Book *Book
Files []*File
}{Book: book, Files: files}
Query string
Book *Book
Files []*File
Description template.HTML
}{
Book: book,
Files: files,
Description: template.HTML(book.Metadata.Description),
}
render("book.html", w, &ctx)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment