diff --git a/app/prod/package.json b/app/prod/package.json index 1289dad..69b6977 100644 --- a/app/prod/package.json +++ b/app/prod/package.json @@ -1,5 +1,5 @@ { "name": "Madek", - "version": "0.1.0", + "version": "0.3.0", "main": "js/main.js" } diff --git a/electron_front/src/all/madek/app/front/download/step2.cljs b/electron_front/src/all/madek/app/front/download/step2.cljs index a40c0a0..6a8cc16 100644 --- a/electron_front/src/all/madek/app/front/download/step2.cljs +++ b/electron_front/src/all/madek/app/front/download/step2.cljs @@ -39,7 +39,8 @@ (defn submit [] (let [req {:method :patch - :json-params (assoc (select-keys @form-data* [:prefix_meta_key :recursive]) + :json-params (assoc (select-keys @form-data* + [:prefix_meta_key :recursive :skip_media_files]) :step2-completed true) :path "/download"}] (request/send-off @@ -56,18 +57,31 @@ ;;; recursive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defn recursive-from-group-component [] +(defn recursive-component [] (when (= :collection (-> @download* :entity :type)) + [:div.recursive + [:h4 "Recursion on sets"] [:div.form-group - [:label "Recursive export: "] - [:br] [:input {:type :checkbox :on-click #(set-value :recursive (-> @form-data* :recursive not)) :checked (-> @form-data* :recursive)} ] " recurse" [:p.help-block "Sets and media-entries which are descendants of the selected set " - " will be exported if this option is enabled.." + " will be exported if this option is enabled." "Recurring entities will be replaced by symbolic links the file system and " - "therefore infinite recursion is avoided." ]])) + "therefore infinite recursion is avoided." ]]])) + +;;; recursive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defn skip-media-files [] + [:div.recursive + [:h4 "Skip files"] + [:div.form-group + [:input {:type :checkbox + :on-click #(set-value :skip_media_files (-> @form-data* :skip_media_files not)) + :checked (-> @form-data* :skip_media_files)} ] " skip files" + [:p.help-block "The download of any media-files will be skipped if this is checked. " + "This means that only the meta-data of media-entries or sets will be downloaded. " ]]]) + ;;; prefix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -153,8 +167,9 @@ (defn form-component [] [:div.form - [recursive-from-group-component] + [recursive-component] [prefix-component] + [skip-media-files] [:div.pull-left [:button.btn.btn-info {:on-click back} diff --git a/electron_front/src/all/madek/app/front/download/step3.cljs b/electron_front/src/all/madek/app/front/download/step3.cljs index bb67c02..aca112c 100644 --- a/electron_front/src/all/madek/app/front/download/step3.cljs +++ b/electron_front/src/all/madek/app/front/download/step3.cljs @@ -38,15 +38,20 @@ (defn summary-component [] [:div.summary - [:p " Export/Download the set " + [:p " Export/Download the " (case (-> @state/jvm-main-db :download :entity :type) + :collection "set" + :media-entry "media-entry" + "???") " " [:a {:href "#" :on-click #(.openExternal shell (-> @state/jvm-main-db :download :entity :url))} [:em (-> @state/jvm-main-db :download :entity :title)]]] [:p "Export to " [:code (-> @state/jvm-main-db :download :target-directory)] "."] + [:p "Recursive: " [:code (-> @state/jvm-main-db :download :recursive not not str)] "."] [:p "Meta-key used for prefixing entities: " (if-let [pmk (-> @state/jvm-main-db :download :prefix_meta_key presence)] - [:code pmk] - [:span "none"]) "."]]) + [:code pmk] + [:span "none"]) "."] + [:p "Skip media-files " [:code (-> @state/jvm-main-db :download :skip_media_files not not str)]"."]]) (defn debug-component [] (when (:debug @state/client-db) diff --git a/jvm_main/src/madek/app/server/export.clj b/jvm_main/src/madek/app/server/export.clj index 62e2d33..f31fefe 100644 --- a/jvm_main/src/madek/app/server/export.clj +++ b/jvm_main/src/madek/app/server/export.clj @@ -82,15 +82,15 @@ id)) (defn download-media-entry - ([id target-dir prefix-meta-key api-entry-point api-http-opts] + ([id target-dir skip-media-files? prefix-meta-key api-entry-point api-http-opts] (catcher/with-logging {} (let [media-entry (I> identity-with-logging (roa/get-root api-entry-point :default-conn-opts api-http-opts) (roa/relation :media-entry) (roa/get {:id id}))] - (download-media-entry prefix-meta-key target-dir media-entry)))) - ([prefix-meta-key dir-path media-entry] + (download-media-entry skip-media-files? prefix-meta-key target-dir media-entry)))) + ([skip-media-files? prefix-meta-key dir-path media-entry] (catcher/with-logging {} (let [id (-> media-entry roa/data :id) entry-prefix-path (path-prefix prefix-meta-key media-entry) @@ -109,7 +109,8 @@ :download_started-at (str (time/now)))) (io/make-parents entry-dir-path) (write-meta-data entry-dir-path meta-data id) - (download-media-files entry-dir-path media-entry) + (when-not skip-media-files? + (download-media-files entry-dir-path media-entry)) (set-item-to-finished id))))))) @@ -126,7 +127,7 @@ (declare download-set) -(defn download-media-entries-for-set [id target-dir-path prefix-meta-key +(defn download-media-entries-for-set [id target-dir-path skip-media-files? prefix-meta-key api-entry-point api-http-opts] (let [me-get-opts (merge {:collection_id id} (if (or (:basic-auth api-http-opts) @@ -139,7 +140,7 @@ (roa/relation :media-entries) (roa/get me-get-opts) roa/coll-seq)] - (download-media-entry prefix-meta-key target-dir-path (roa/get me-rel {}))))) + (download-media-entry skip-media-files? prefix-meta-key target-dir-path (roa/get me-rel {}))))) (defn download-collections-for-collection [collection target-dir-path recursive? prefix-meta-key api-entry-point api-http-opts] @@ -158,7 +159,7 @@ (-> collection roa/data :id) target-dir-path recursive? prefix-meta-key api-entry-point api-http-opts)))) -(defn download-set [id dl-path recursive? prefix-meta-key +(defn download-set [id dl-path recursive? skip-media-files? prefix-meta-key api-entry-point api-http-opts] (let [collection (-> (roa/get-root api-entry-point :default-conn-opts api-http-opts) @@ -183,7 +184,7 @@ (io/make-parents target-dir-path) (write-meta-data target-dir-path meta-data id) (download-media-entries-for-set - id target-dir-path prefix-meta-key api-entry-point api-http-opts) + id target-dir-path skip-media-files? prefix-meta-key api-entry-point api-http-opts) (when recursive? (download-collections-for-collection collection target-dir-path recursive? prefix-meta-key diff --git a/jvm_main/src/madek/app/server/web.clj b/jvm_main/src/madek/app/server/web.clj index 1a4d9f4..08c2b39 100644 --- a/jvm_main/src/madek/app/server/web.clj +++ b/jvm_main/src/madek/app/server/web.clj @@ -96,7 +96,7 @@ e)) :throwable Throwable}) -(defn start-download-future [id target-dir recursive? prefix-meta-key entry-point http-options] +(defn start-download-future [id target-dir recursive? skip-media-files? prefix-meta-key entry-point http-options] (reset! download-future (future (catcher/snatch @@ -111,10 +111,10 @@ :throwable Throwable} (case (-> @state/db :download :entity :type) :collection (export/download-set - id target-dir recursive? prefix-meta-key - entry-point http-options) + id target-dir recursive? skip-media-files? + prefix-meta-key entry-point http-options) :media-entry (export/download-media-entry - id target-dir prefix-meta-key + id target-dir skip-media-files? prefix-meta-key entry-point http-options)) (swap! state/db (fn [db] (assoc-in db [:download :download-finished] true))))))) @@ -135,10 +135,11 @@ (let [id (-> @state/db :download :entity :uuid) target-dir (-> @state/db :download :target-directory) recursive? (-> @state/db :download :recursive not not) + skip-media-files? (-> @state/db :download :skip_media_files not not) prefix-meta-key (-> @state/db :download :prefix_meta_key presence) entry-point (str (-> @state/db :connection :url) "/api") http-options (-> @state/db :connection :http-options)] - (start-download-future id target-dir recursive? prefix-meta-key entry-point http-options)) + (start-download-future id target-dir recursive? skip-media-files? prefix-meta-key entry-point http-options)) {:status 202}))) (defn patch-download-item [request] diff --git a/project.clj b/project.clj index 7bda1e6..1c11a22 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject madek "0.2.0" +(defproject madek "0.3.0" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "GPL"