diff --git a/config/emacs.el b/config/emacs.el
index d0634552..3b42fb3b 100644
--- a/config/emacs.el
+++ b/config/emacs.el
@@ -6,7 +6,7 @@
(setq org-todo-keywords (quote ((sequence "TODO(t)" "DOING(d)" "WAITING(w)" "|" "CANCEL(C)" "DEFERRED(F)" "DONE(D)"))))
;; html export
-(setq org-html-head "")
+(setq org-html-head "")
(setq org-html-validation-link nil)
(setq org-html-creator-string "Using Filestash")
diff --git a/docker/prod/Dockerfile b/docker/prod/Dockerfile
index 0c4fd44c..1a58e83e 100644
--- a/docker/prod/Dockerfile
+++ b/docker/prod/Dockerfile
@@ -50,7 +50,7 @@ RUN mkdir -p $GOPATH/src/github.com/mickael-kerjean/ && \
go build -buildmode=plugin -o ./dist/data/plugin/image.so server/plugin/plg_image_light/index.go && \
#################
# External dependencies: emacs and pdflatex
- apk --no-cache add curl emacs texlive && \
+ apk --no-cache add curl emacs texlive zip && \
curl https://raw.githubusercontent.com/mickael-kerjean/filestash_latex/master/wrapfig.sty > /usr/share/texmf-dist/tex/latex/base/wrapfig.sty && \
curl https://raw.githubusercontent.com/mickael-kerjean/filestash_latex/master/capt-of.sty > /usr/share/texmf-dist/tex/latex/base/capt-of.sty && \
curl https://raw.githubusercontent.com/mickael-kerjean/filestash_latex/master/sectsty.sty > /usr/share/texmf-dist/tex/latex/base/sectsty.sty && \
diff --git a/server/ctrl/export.go b/server/ctrl/export.go
index 44889e84..50219e95 100644
--- a/server/ctrl/export.go
+++ b/server/ctrl/export.go
@@ -44,7 +44,8 @@ func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
var cmd *exec.Cmd
var emacsPath string
var outPath string
- if GetMimeType(path) == "text/org" {
+ reqMimeType := GetMimeType(path)
+ if reqMimeType == "text/org" {
if emacsPath, err = exec.LookPath("emacs"); err != nil {
SendErrorResult(res, ErrMissingDependency)
return
@@ -117,7 +118,9 @@ func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
tmpPath + "/index.org", "-f", "org-odt-export-to-odt",
)
outPath = "index.odt"
- }else {
+ } else if mimeType == "text/org" {
+ outPath = "index.org"
+ } else {
SendErrorResult(res, ErrNotImplemented)
return
}
@@ -135,15 +138,16 @@ func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
return
}
io.Copy(f, file)
- // TODO: insert related resources: eg: images
- var stdout, stderr bytes.Buffer
- cmd.Stdout = &stdout
- cmd.Stderr = &stderr
- if err = cmd.Run(); err != nil {
- Log.Error(fmt.Sprintf("stdout:%s | stderr:%s", string(stdout.Bytes()), string(stderr.Bytes())))
- SendErrorResult(res, NewError(fmt.Sprintf("emacs has quitted: '%s'", err.Error()), 400))
- return
+ if cmd != nil {
+ var stdout, stderr bytes.Buffer
+ cmd.Stdout = &stdout
+ cmd.Stderr = &stderr
+ if err = cmd.Run(); err != nil {
+ Log.Error(fmt.Sprintf("stdout:%s | stderr:%s", string(stdout.Bytes()), string(stderr.Bytes())))
+ SendErrorResult(res, NewError(fmt.Sprintf("emacs has quitted: '%s'", err.Error()), 400))
+ return
+ }
}
f, err = os.OpenFile(tmpPath + "/"+outPath, os.O_RDONLY, os.ModePerm)
@@ -154,6 +158,15 @@ func FileExport(ctx App, res http.ResponseWriter, req *http.Request) {
res.Header().Set("Content-Type", mimeType)
io.Copy(res, f)
return
+ } else if strings.HasPrefix(reqMimeType, "image/") {
+ file, err := ctx.Backend.Cat(path)
+ if err != nil {
+ SendErrorResult(res, err)
+ return
+ }
+ res.Header().Set("Content-Type", reqMimeType)
+ io.Copy(res, file)
+ return
}
SendErrorResult(res, ErrNotImplemented)