summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grimtube.go7
-rw-r--r--templates/search.html5
2 files changed, 12 insertions, 0 deletions
diff --git a/grimtube.go b/grimtube.go
index c635418..bd700fb 100644
--- a/grimtube.go
+++ b/grimtube.go
@@ -14,6 +14,7 @@ import (
)
var docPath string
+var dlsrv string
func getLangs() []string {
return []string{"en", "fr", "de", "ja", "ru"}
@@ -67,6 +68,7 @@ func index(w http.ResponseWriter, r *http.Request) {
Items []ytparser.Item
Page int
Lang string
+ Dlsrv string
}{
getLangs(),
getOrders(),
@@ -75,6 +77,7 @@ func index(w http.ResponseWriter, r *http.Request) {
items,
page,
lang,
+ dlsrv,
}
serve(w, "templates/search.html", data)
}
@@ -118,6 +121,7 @@ func search(w http.ResponseWriter, r *http.Request) {
Langs []string
Order string
Orders []string
+ Dlsrv string
}{
items,
term,
@@ -126,6 +130,7 @@ func search(w http.ResponseWriter, r *http.Request) {
getLangs(),
order,
getOrders(),
+ dlsrv,
}
serve(w, "templates/search.html", data)
}
@@ -150,8 +155,10 @@ func favicon(w http.ResponseWriter, r *http.Request) {
func main() {
port := flag.Int("p", 8080, "The port to bind to.")
dir := flag.String("d", "", "Location of the templates and static resources.")
+ dl := flag.String("dlsrv", "", "Link to a download server.")
flag.Parse()
docPath = *dir
+ dlsrv = *dl
fs := http.FileServer(http.Dir("static"))
http.Handle("/static/", http.StripPrefix(path.Join(docPath, "/static/"), fs))
http.HandleFunc("/favicon.ico", favicon)
diff --git a/templates/search.html b/templates/search.html
index 8cbf200..e5cff9a 100644
--- a/templates/search.html
+++ b/templates/search.html
@@ -41,6 +41,11 @@
<td>
{{.LengthText}}
</td>
+ {{if ne $.Dlsrv ""}}
+ <td>
+ <a href="{{$.Dlsrv}}{{.Url}}">Download</a>
+ </td>
+ {{end}}
</tr>
{{end}}
</table>