mirror of
https://github.com/documize/community.git
synced 2025-07-21 22:29:41 +02:00
WIP
This commit is contained in:
parent
743eae5aad
commit
d0970c153b
8 changed files with 287 additions and 8 deletions
|
@ -726,3 +726,36 @@ func (h *Handler) Vote(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
response.WriteEmpty(w)
|
||||
}
|
||||
|
||||
// Export returns content as self-enclosed HTML file.
|
||||
func (h *Handler) Export(w http.ResponseWriter, r *http.Request) {
|
||||
method := "document.Export"
|
||||
ctx := domain.GetRequestContext(r)
|
||||
|
||||
defer streamutil.Close(r.Body)
|
||||
body, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
response.WriteBadRequestError(w, method, err.Error())
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
spec := exportSpec{}
|
||||
err = json.Unmarshal(body, &spec)
|
||||
if err != nil {
|
||||
response.WriteBadRequestError(w, method, err.Error())
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
export, err := BuildExport(ctx, *h.Store, spec)
|
||||
if err != nil {
|
||||
response.WriteServerError(w, method, err)
|
||||
h.Runtime.Log.Error(method, err)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
w.Write([]byte(export))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue