From e9fe27ea2d6a3ee528775cf92ff0df2a375b834d Mon Sep 17 00:00:00 2001 From: Eliot Whalan Date: Fri, 24 Jun 2016 12:17:23 +1000 Subject: [PATCH] Add download button --- assets/paste.html | 1 + assets/syntax.html | 1 + main.go | 21 ++++++++++++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/assets/paste.html b/assets/paste.html index 19fc1d2..c8fb3c4 100644 --- a/assets/paste.html +++ b/assets/paste.html @@ -37,6 +37,7 @@
diff --git a/assets/syntax.html b/assets/syntax.html index 2791a1f..59005c2 100644 --- a/assets/syntax.html +++ b/assets/syntax.html @@ -37,6 +37,7 @@
diff --git a/main.go b/main.go index c4e86bd..2ed7d5c 100644 --- a/main.go +++ b/main.go @@ -39,10 +39,11 @@ type Response struct { } type Page struct { - Title string - Body []byte - Raw string - Home string + Title string + Body []byte + Raw string + Home string + Download string } func check(err error) { @@ -235,12 +236,14 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { lang := vars["lang"] s := getPaste(paste, lang) link := ADDRESS + "/raw/" + paste + download := ADDRESS + "/download/" + paste if lang == "" { p := &Page{ - Title: paste, - Body: []byte(s), - Raw: link, - Home: ADDRESS, + Title: paste, + Body: []byte(s), + Raw: link, + Home: ADDRESS, + Download: download, } err := templates.ExecuteTemplate(w, "paste.html", p) if err != nil { @@ -248,7 +251,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) { } } else { - fmt.Fprintf(w, string(syntax), paste, paste, s, ADDRESS, link) + fmt.Fprintf(w, string(syntax), paste, paste, s, ADDRESS, download, link) } }