Add tree multiselection, batch actions and Markdown export

This commit is contained in:
eezd committed 2026-10-21 16:10:49 +08:00
1 parent f473ec64b6
commit ffc95d6dbc
14 files changed
+532 -46

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package api
import (
"mime"
"net/http"
"os"
"strings"
"time"
)
func (s *Server) export(w http.ResponseWriter, r *http.Request) {
var body struct {
Paths []string `json:"paths"`
}
if !readJSON(w, r, &body) {
return
}
file, name, err := s.vault.Export(r.Context(), body.Paths)
if err != nil {
vaultError(w, r, err)
return
}
defer file.Close()
defer os.Remove(file.Name())
contentType := "application/zip"
if strings.HasSuffix(name, ".md") {
contentType = "text/markdown; charset=utf-8"
}
w.Header().Set("Content-Type", contentType)
w.Header().Set("Content-Disposition", mime.FormatMediaType("attachment", map[string]string{"filename": name}))
http.ServeContent(w, r, name, time.Time{}, file)
}