Skip to content

Commit

Permalink
Add a UI to download html for the current document
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Nov 21, 2024
1 parent be9f451 commit 918fc22
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/cljc/daisyproducer2/i18n.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
:epub3 "EPUB3"
:online-player "Online Player"
:open-document "Open Document"
:html "HTML"
;; Download Forms
:grade
{:g0 "Uncontracted"
Expand Down Expand Up @@ -312,6 +313,7 @@
:epub3 "EPUB3"
:online-player "Online Player"
:open-document "Open Document"
:html "HTML"
;; Download Forms
:grade
{:g0 "Basisschrift"
Expand Down
2 changes: 2 additions & 0 deletions src/cljs/daisyproducer2/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
:controllers [{:parameters {:path [:id]}}]}]
["/preview/open-document" {:name :document-preview-open-document :view #'document/preview-open-document
:controllers [{:parameters {:path [:id]}}]}]
["/preview/html" {:name :document-preview-html :view #'document/preview-html
:controllers [{:parameters {:path [:id]}}]}]
["/markup" {:name :document-markup :view #'document/markup
:controllers [{:parameters {:path [:id]}}]}]
["/versions" {:name :document-versions :view #'document/versions
Expand Down
9 changes: 8 additions & 1 deletion src/cljs/daisyproducer2/documents/document.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
:document-preview-large-print-library :document-preview-large-print-sale
:document-preview-large-print-configurable
:document-preview-epub :document-preview-epub-in-player
:document-preview-open-document}]
:document-preview-open-document :document-preview-html}]
;; only show the unknown and local words for German books
(when german?
[tab-link-with-total (str "#/documents/" id "/unknown") (tr [:unknown-words]) :document-unknown [::unknown/words-total]
Expand Down Expand Up @@ -203,6 +203,13 @@
[tabs document]
[forms/open-document document]]))

(defn preview-html []
(let [document @(rf/subscribe [::current])]
[:section.section>div.container>div.content
[summary document]
[tabs document]
[forms/html document]]))

(defn markup []
(let [document @(rf/subscribe [::current])]
[:section.section>div.container>div.content
Expand Down
10 changes: 9 additions & 1 deletion src/cljs/daisyproducer2/documents/preview.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
{:href (str "#/documents/" id "/preview/open-document")}
[:span (tr [:preview])]]]])

(defn- html-buttons [id]
[:div.field
[:p.control
[:a.button
{:href (str "#/documents/" id "/preview/html")}
[:span (tr [:preview])]]]])

(defn preview-links [{id :id}]
[:div.block
[:table.table.is-fullwidth
Expand All @@ -53,6 +60,7 @@
[:tr [:th (tr [:braille])] [:td [braille-buttons id]]]
[:tr [:th (tr [:large-print])] [:td [large-print-buttons id]]]
[:tr [:th (tr [:epub3])] [:td [epub-buttons id]]]
[:tr [:th (tr [:open-document])] [:td [open-document-buttons id]]]]]])
[:tr [:th (tr [:open-document])] [:td [open-document-buttons id]]]
[:tr [:th (tr [:html])] [:td [html-buttons id]]]]]])


14 changes: 14 additions & 0 deletions src/cljs/daisyproducer2/documents/preview/forms.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,17 @@
(checkbox props {:name :floating-page-numbers :text (tr [:forms/floating-page-numbers])})
(input props {:name :answer-markup :label (tr [:forms/answer-markup]) :type "text"})
(submit-button props {:name :submit :label (tr [:preview])})]))])

(defn html [{id :id}]
[fork/form {:initial-values {}
:path [:form :html]
:prevent-default? true
:clean-on-unmount? true
:on-submit #(rf/dispatch [::submit-handler :html id %])
:keywordize-keys true
}
(fn [{:keys [path form-id on-submit-server-message handle-submit] :as props}]
(if on-submit-server-message
[error-notification on-submit-server-message path]
[:form {:id form-id :on-submit handle-submit}
(submit-button props {:name :submit :label (tr [:preview])})]))])

0 comments on commit 918fc22

Please sign in to comment.