Add download button
This commit is contained in:
parent
36675bc4ff
commit
ac2eb12dfb
|
@ -37,6 +37,7 @@
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="{{.Home}}" class="btn btn-raised btn-primary">Home</a>
|
<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>
|
<a href="{{.Raw}}" class="btn btn-raised btn-primary">Raw</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<a href="%s" class="btn btn-raised btn-primary">Home</a>
|
<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>
|
<a href="%s" class="btn btn-raised btn-primary">Raw</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
5
main.go
5
main.go
|
@ -43,6 +43,7 @@ type Page struct {
|
||||||
Body []byte
|
Body []byte
|
||||||
Raw string
|
Raw string
|
||||||
Home string
|
Home string
|
||||||
|
Download string
|
||||||
}
|
}
|
||||||
|
|
||||||
func check(err error) {
|
func check(err error) {
|
||||||
|
@ -235,12 +236,14 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
lang := vars["lang"]
|
lang := vars["lang"]
|
||||||
s := getPaste(paste, lang)
|
s := getPaste(paste, lang)
|
||||||
link := ADDRESS + "/raw/" + paste
|
link := ADDRESS + "/raw/" + paste
|
||||||
|
download := ADDRESS + "/download/" + paste
|
||||||
if lang == "" {
|
if lang == "" {
|
||||||
p := &Page{
|
p := &Page{
|
||||||
Title: paste,
|
Title: paste,
|
||||||
Body: []byte(s),
|
Body: []byte(s),
|
||||||
Raw: link,
|
Raw: link,
|
||||||
Home: ADDRESS,
|
Home: ADDRESS,
|
||||||
|
Download: download,
|
||||||
}
|
}
|
||||||
err := templates.ExecuteTemplate(w, "paste.html", p)
|
err := templates.ExecuteTemplate(w, "paste.html", p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -248,7 +251,7 @@ func pasteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} 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