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
|
Random page
|
||||||
|
|
||||||
Download DB support
|
|
||||||
|
|
||||||
Ban support
|
Ban support
|
||||||
|
|
||||||
Extend command-line tool to support remaining features (bans, ...)
|
Extend command-line tool to support remaining features (bans, ...)
|
||||||
|
@ -2,6 +2,7 @@ package yatwiki3
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -67,6 +68,12 @@ func (this *WikiServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.ServeFile(w, r, this.opts.FaviconFilePath)
|
http.ServeFile(w, r, this.opts.FaviconFilePath)
|
||||||
return
|
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" {
|
} else if r.URL.Path == this.opts.ExpectBaseURL+"formatting" {
|
||||||
this.routeFormatting(w, r)
|
this.routeFormatting(w, r)
|
||||||
return
|
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}}random"><div class="sprite rn"></div> Random Page</a>
|
||||||
<a href="{{.BaseURL}}index"><div class="sprite no"></div> Article Index</a>
|
<a href="{{.BaseURL}}index"><div class="sprite no"></div> Article Index</a>
|
||||||
{{if .AllowDownload}}
|
{{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}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
Loading…
Reference in New Issue
Block a user