Add download button
This commit is contained in:
parent
36675bc4ff
commit
ac2eb12dfb
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
5
main.go
5
main.go
|
@ -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)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue