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

Commit f34f86e

Browse files
committed
Improved look of download list
1 parent 7fbe49f commit f34f86e

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

server.go

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,55 @@ func DownloadHandler(w http.ResponseWriter, r *http.Request) {
6969

7070
if bid == "download" {
7171
w.Header().Set("Content-Type", "text/html")
72+
var buf bytes.Buffer
73+
buf.WriteString(`
74+
<!DOCTYPE html>
75+
<html>
76+
<head>
77+
<title>BookBrowser</title>
78+
<style>
79+
a,
80+
a:link,
81+
a:visited {
82+
display: block;
83+
white-space: nowrap;
84+
text-overflow: ellipsis;
85+
color: inherit;
86+
text-decoration: none;
87+
font-family: sans-serif;
88+
padding: 5px 7px;
89+
background: #FAFAFA;
90+
border-bottom: 1px solid #DDDDDD;
91+
cursor: pointer;
92+
}
93+
94+
a:hover,
95+
a:active {
96+
background: #EEEEEE;
97+
}
98+
99+
html, body {
100+
background: #FAFAFA;
101+
margin: 0;
102+
padding: 0;
103+
}
104+
</style>
105+
</head>
106+
<body>
107+
`)
72108
sbl := sortedBookList(books, func(b Book) bool {
73109
return true
74110
}, func(a Book, b Book) bool {
75111
return a.Title < b.Title
76112
})
77113
for _, b := range sbl {
78-
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))
114+
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))
79115
}
116+
buf.WriteString(`
117+
</body>
118+
</html>
119+
`)
120+
io.WriteString(w, buf.String())
80121
return
81122
}
82123

0 commit comments

Comments
 (0)