Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Improved look of download list
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin committed Jul 22, 2017
1 parent 7fbe49f commit f34f86e
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,55 @@ func DownloadHandler(w http.ResponseWriter, r *http.Request) {

if bid == "download" {
w.Header().Set("Content-Type", "text/html")
var buf bytes.Buffer
buf.WriteString(`
<!DOCTYPE html>
<html>
<head>
<title>BookBrowser</title>
<style>
a,
a:link,
a:visited {
display: block;
white-space: nowrap;
text-overflow: ellipsis;
color: inherit;
text-decoration: none;
font-family: sans-serif;
padding: 5px 7px;
background: #FAFAFA;
border-bottom: 1px solid #DDDDDD;
cursor: pointer;
}
a:hover,
a:active {
background: #EEEEEE;
}
html, body {
background: #FAFAFA;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
`)
sbl := sortedBookList(books, func(b Book) bool {
return true
}, func(a Book, b Book) bool {
return a.Title < b.Title
})
for _, b := range sbl {
io.WriteString(w, fmt.Sprintf("<a href=\"/download/%s.%s\">%s - %s - %s (%v)</a><br>", b.ID, b.FileType, b.Title, b.Author, b.Series.Name, b.Series.Index))
buf.WriteString(fmt.Sprintf("<a href=\"/download/%s.%s\">%s - %s - %s (%v)</a>", b.ID, b.FileType, b.Title, b.Author, b.Series.Name, b.Series.Index))
}
buf.WriteString(`
</body>
</html>
`)
io.WriteString(w, buf.String())
return
}

Expand Down

0 comments on commit f34f86e

Please sign in to comment.