Add download button

This commit is contained in:
Eliot Whalan 2016-06-24 12:17:23 +10:00
parent 36675bc4ff
commit ac2eb12dfb
3 changed files with 14 additions and 9 deletions

View File

@ -37,6 +37,7 @@
<div class="pull-right">
<div class="row">
<a href="{{.Home}}" class="btn btn-raised btn-primary">Home</a>
<a href="{{.Download}}" class="btn btn-raised btn-primary">Download</a>
<a href="{{.Raw}}" class="btn btn-raised btn-primary">Raw</a>
</div>

View File

@ -37,6 +37,7 @@
<div class="pull-right">
<div class="row">
<a href="%s" class="btn btn-raised btn-primary">Home</a>
<a href="%s" class="btn btn-raised btn-primary">Download</a>
<a href="%s" class="btn btn-raised btn-primary">Raw</a>
</div>

View File

@ -43,6 +43,7 @@ type Page struct {
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,
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)
}
}