export.cljs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. (ns frontend.components.export
  2. (:require [rum.core :as rum]
  3. [frontend.ui :as ui]
  4. [frontend.util :as util]
  5. [frontend.handler.export :as export]
  6. [frontend.state :as state]
  7. [frontend.context.i18n :as i18n]))
  8. (rum/defc export
  9. []
  10. (when-let [current-repo (state/get-current-repo)]
  11. (rum/with-context [[t] i18n/*tongue-context*]
  12. [:div.export.w-96
  13. [:h1.title "Export"]
  14. [:ul.mr-1
  15. [:li.mb-4
  16. [:a.font-medium {:on-click #(export/convert-repo-markdown-v2! current-repo)}
  17. (t :convert-markdown)]]
  18. (when (util/electron?)
  19. [:li.mb-4
  20. [:a.font-medium {:on-click #(export/export-repo-as-html! current-repo)}
  21. (t :export-public-pages)]])
  22. [:li.mb-4
  23. [:a.font-medium {:on-click #(export/export-repo-as-markdown! current-repo)}
  24. (t :export-markdown)]]
  25. [:li.mb-4
  26. [:a.font-medium {:on-click #(export/export-repo-as-opml! current-repo)}
  27. (t :export-opml)]]
  28. [:li.mb-4
  29. [:a.font-medium {:on-click #(export/export-repo-as-edn-v2! current-repo)}
  30. (t :export-edn)]]
  31. [:li.mb-4
  32. [:a.font-medium {:on-click #(export/export-repo-as-json-v2! current-repo)}
  33. (t :export-json)]]
  34. ]
  35. [:a#download-as-edn.hidden]
  36. [:a#download-as-edn-v2.hidden]
  37. [:a#download-as-json-v2.hidden]
  38. [:a#download-as-html.hidden]
  39. [:a#download-as-zip.hidden]
  40. [:a#export-as-markdown.hidden]
  41. [:a#export-as-opml.hidden]
  42. [:a#convert-markdown-to-unordered-list-or-heading.hidden]])))
  43. (rum/defc export-page
  44. []
  45. (when-let [current-repo (state/get-current-repo)]
  46. (when-let [page (state/get-current-page)]
  47. (rum/with-context [[t] i18n/*tongue-context*]
  48. [:div.export.w-96
  49. [:h1.title "Export"]
  50. [:ul.mr-1
  51. [:li.mb-4
  52. [:a.font-medium {:on-click #(export/export-page-as-markdown! page)}
  53. (t :export-markdown)]]
  54. [:li.mb-4
  55. [:a.font-medium {:on-click #(export/export-page-as-opml! page)}
  56. (t :export-opml)]]]
  57. [:a#export-page-as-markdown.hidden]
  58. [:a#export-page-as-opml.hidden]
  59. [:a#convert-markdown-to-unordered-list-or-heading.hidden]]))))