Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
liber
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
liber
Commits
2a742483
Commit
2a742483
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
render the book description as HTML
parent
885b31c4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
database_test.go
+4
-3
4 additions, 3 deletions
database_test.go
htdocs/templates/book.html
+2
-2
2 additions, 2 deletions
htdocs/templates/book.html
web.go
+11
-4
11 additions, 4 deletions
web.go
with
17 additions
and
9 deletions
database_test.go
+
4
−
3
View file @
2a742483
...
...
@@ -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."
,
},
}
}
...
...
This diff is collapsed.
Click to expand it.
htdocs/templates/book.html
+
2
−
2
View file @
2a742483
...
...
@@ -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}}
...
...
This diff is collapsed.
Click to expand it.
web.go
+
11
−
4
View file @
2a742483
...
...
@@ -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
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment