implement download-database support
This commit is contained in:
parent
c39d563dc6
commit
92bcb013d2
2
TODO.txt
2
TODO.txt
@ -7,8 +7,6 @@ RSS
|
||||
|
||||
Random page
|
||||
|
||||
Download DB support
|
||||
|
||||
Ban support
|
||||
|
||||
Extend command-line tool to support remaining features (bans, ...)
|
||||
|
@ -2,6 +2,7 @@ package yatwiki3
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@ -67,6 +68,12 @@ func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, this.opts.FaviconFilePath)
|
||||
return
|
||||
|
||||
} else if r.URL.Path == this.opts.ExpectBaseURL+"download-database" {
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
w.Header().Set("Content-Disposition", `attachment; filename="database-`+fmt.Sprintf("%d", time.Now().Unix())+`.db"`)
|
||||
http.ServeFile(w, r, this.opts.DBFilePath)
|
||||
return
|
||||
|
||||
} else if r.URL.Path == this.opts.ExpectBaseURL+"formatting" {
|
||||
this.routeFormatting(w, r)
|
||||
return
|
||||
|
@ -101,7 +101,7 @@ function els(e,s){ // no js exec in innerHTML
|
||||
<a href="{{.BaseURL}}random"><div class="sprite rn"></div> Random Page</a>
|
||||
<a href="{{.BaseURL}}index"><div class="sprite no"></div> Article Index</a>
|
||||
{{if .AllowDownload}}
|
||||
<a href="{{.BaseURL}}download-database"><div class="sprite no"></div> Download DB backup</a>
|
||||
<a href="{{.BaseURL}}download-database" download><div class="sprite no"></div> Download DB backup</a>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="content">
|
||||
|
Loading…
Reference in New Issue
Block a user