diff --git a/TODO.txt b/TODO.txt index d58d749..5b72c56 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,8 +7,6 @@ RSS Random page -Download DB support - Ban support Extend command-line tool to support remaining features (bans, ...) diff --git a/WikiServer.go b/WikiServer.go index aec2b8f..8a7cdf9 100644 --- a/WikiServer.go +++ b/WikiServer.go @@ -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 diff --git a/pageTemplate.go b/pageTemplate.go index 5be41be..5a0baf4 100644 --- a/pageTemplate.go +++ b/pageTemplate.go @@ -101,7 +101,7 @@ function els(e,s){ // no js exec in innerHTML
Random Page
Article Index
{{if .AllowDownload}} -
Download DB backup
+
Download DB backup
{{end}}