mirror of
https://github.com/penpot/penpot.git
synced 2025-02-11 01:28:30 -05:00
✨ Change tool for exporting artboards and fix some issues
This commit is contained in:
parent
c57219a356
commit
4962e45bd9
6 changed files with 46 additions and 34 deletions
|
@ -5,6 +5,9 @@
|
|||
### :boom: Breaking changes
|
||||
### :sparkles: New features
|
||||
### :bug: Bugs fixed
|
||||
|
||||
- Fix problems when exporting all artboards [Taiga #2234](https://tree.taiga.io/project/penpot/issue/2234).
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
### :heart: Community contributions by (Thank you!)
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ RUN set -ex; \
|
|||
imagemagick \
|
||||
ghostscript \
|
||||
netpbm \
|
||||
poppler-utils \
|
||||
potrace \
|
||||
webp \
|
||||
nginx \
|
||||
|
|
|
@ -12,6 +12,7 @@ RUN set -ex; \
|
|||
brew install ghostscript; \
|
||||
brew install mailhog; \
|
||||
brew install openldap; \
|
||||
brew install poppler-utils; \
|
||||
sudo mkdir -p /var/log/nginx; \
|
||||
sudo chown gitpod:gitpod /var/log/nginx
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ RUN set -ex; \
|
|||
imagemagick \
|
||||
ghostscript \
|
||||
netpbm \
|
||||
poppler-utils \
|
||||
potrace \
|
||||
gconf-service \
|
||||
libasound2 \
|
||||
|
|
|
@ -35,13 +35,13 @@
|
|||
:object-id frame-id
|
||||
:scale 1
|
||||
:save-path spath})]
|
||||
(cons spath spaths)))
|
||||
(conj spaths spath)))
|
||||
|
||||
(defn- join-files
|
||||
[tdpath file-id paths]
|
||||
(let [output-path (path/join tdpath (str file-id ".pdf"))
|
||||
paths-str (str/join " " paths)]
|
||||
(-> (sh/run-cmd! (str "gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile='" output-path "' " paths-str))
|
||||
(-> (sh/run-cmd! (str "pdfunite " paths-str " " output-path))
|
||||
(p/then (constantly output-path)))))
|
||||
|
||||
(defn- clean-tmp-data
|
||||
|
@ -54,16 +54,20 @@
|
|||
[{:keys [params cookies] :as request}]
|
||||
(let [{:keys [name file-id page-id frame-ids]} (us/conform ::handler-params params)
|
||||
token (.get ^js cookies "auth-token")]
|
||||
(p/let [tdpath (sh/create-tmpdir! "pdfexport-")
|
||||
data (-> (reduce (fn [promis frame-id]
|
||||
(p/then promis (partial export-frame tdpath file-id page-id token frame-id)))
|
||||
(p/future [])
|
||||
frame-ids)
|
||||
(p/then (partial join-files tdpath file-id))
|
||||
(p/then sh/read-file)
|
||||
(p/then (partial clean-tmp-data tdpath)))]
|
||||
{:status 200
|
||||
:body data
|
||||
:headers {"content-type" "application/pdf"
|
||||
"content-length" (.-length data)}})))
|
||||
(if (seq frame-ids)
|
||||
(p/let [tdpath (sh/create-tmpdir! "pdfexport-")
|
||||
data (-> (reduce (fn [promis frame-id]
|
||||
(p/then promis (partial export-frame tdpath file-id page-id token frame-id)))
|
||||
(p/future [])
|
||||
(reverse frame-ids))
|
||||
(p/then (partial join-files tdpath file-id))
|
||||
(p/then sh/read-file)
|
||||
(p/then (partial clean-tmp-data tdpath)))]
|
||||
{:status 200
|
||||
:body data
|
||||
:headers {"content-type" "application/pdf"
|
||||
"content-length" (.-length data)}})
|
||||
{:status 204
|
||||
:body ""
|
||||
:headers {"content-type" "text/plain"}})))
|
||||
|
||||
|
|
|
@ -95,9 +95,9 @@
|
|||
(mf/defc menu
|
||||
[{:keys [layout project file team-id page-id] :as props}]
|
||||
(let [show-menu? (mf/use-state false)
|
||||
editing? (mf/use-state false)
|
||||
editing? (mf/use-state false)
|
||||
|
||||
frames (mf/deref refs/workspace-frames)
|
||||
frames (mf/deref refs/workspace-frames)
|
||||
|
||||
edit-input-ref (mf/use-ref nil)
|
||||
|
||||
|
@ -166,23 +166,24 @@
|
|||
|
||||
on-export-frames
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(mf/deps file frames)
|
||||
(fn [_]
|
||||
(let [filename (str (:name file) ".pdf")
|
||||
frame-ids (mapv :id frames)]
|
||||
(st/emit! (dm/info (tr "workspace.options.exporting-object")
|
||||
{:timeout nil}))
|
||||
(->> (rp/query! :export-frames
|
||||
{:name (:name file)
|
||||
:file-id (:id file)
|
||||
:page-id page-id
|
||||
:frame-ids frame-ids})
|
||||
(rx/subs
|
||||
(fn [body]
|
||||
(dom/trigger-download filename body))
|
||||
(fn [_error]
|
||||
(st/emit! (dm/error (tr "errors.unexpected-error"))))
|
||||
(st/emitf dm/hide))))))]
|
||||
(when (seq frames)
|
||||
(let [filename (str (:name file) ".pdf")
|
||||
frame-ids (mapv :id frames)]
|
||||
(st/emit! (dm/info (tr "workspace.options.exporting-object")
|
||||
{:timeout nil}))
|
||||
(->> (rp/query! :export-frames
|
||||
{:name (:name file)
|
||||
:file-id (:id file)
|
||||
:page-id page-id
|
||||
:frame-ids frame-ids})
|
||||
(rx/subs
|
||||
(fn [body]
|
||||
(dom/trigger-download filename body))
|
||||
(fn [_error]
|
||||
(st/emit! (dm/error (tr "errors.unexpected-error"))))
|
||||
(st/emitf dm/hide)))))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps @editing?)
|
||||
|
@ -282,8 +283,9 @@
|
|||
[:li.export-file {:on-click on-export-file}
|
||||
[:span (tr "dashboard.export-single")]]
|
||||
|
||||
[:li.export-file {:on-click on-export-frames}
|
||||
[:span (tr "dashboard.export-frames")]]
|
||||
(when (seq frames)
|
||||
[:li.export-file {:on-click on-export-frames}
|
||||
[:span (tr "dashboard.export-frames")]])
|
||||
|
||||
(when (contains? @cf/flags :user-feedback)
|
||||
[:li.feedback {:on-click (st/emitf (rt/nav :settings-feedback))}
|
||||
|
|
Loading…
Add table
Reference in a new issue