diff --git a/src/main/frontend/components/file.cljs b/src/main/frontend/components/file.cljs index d17f769381..f1a62db0d7 100644 --- a/src/main/frontend/components/file.cljs +++ b/src/main/frontend/components/file.cljs @@ -1,7 +1,6 @@ (ns frontend.components.file (:require [rum.core :as rum] [frontend.util :as util] - [frontend.handler.project :as project] [frontend.handler.export :as export-handler] [frontend.config :as config] [frontend.state :as state] @@ -97,9 +96,6 @@ :display "inline-block"}}) [:span.ml-1 "Please don't remove the page's title property (you can still modify it)."]]) - (when (and config? (state/logged?)) - [:a.mb-8.block {:on-click (fn [_e] (project/sync-project-settings!))} - (tongue :project/sync-settings)]) (cond ;; image type (and format (contains? (config/img-formats) format)) diff --git a/src/main/frontend/components/header.cljs b/src/main/frontend/components/header.cljs index 0fd6eba5f9..57002441a7 100644 --- a/src/main/frontend/components/header.cljs +++ b/src/main/frontend/components/header.cljs @@ -16,7 +16,6 @@ [frontend.components.search :as search] [frontend.components.export :as export] [frontend.components.right-sidebar :as sidebar] - [frontend.handler.project :as project-handler] [frontend.handler.page :as page-handler] [frontend.handler.web.nfs :as nfs] [goog.dom :as gdom] @@ -110,18 +109,6 @@ :options {:href (rfe/href :all-journals)} :icon svg/calendar-sm}) - (when (project-handler/get-current-project current-repo projects) - {:title (t :my-publishing) - :options {:href (rfe/href :my-publishing)}}) - - (when-let [project (and current-repo - (project-handler/get-current-project current-repo projects))] - (let [link (str config/website "/" project)] - {:title (str (t :go-to) "/" project) - :options {:href link - :target "_blank"} - :icon svg/external-link})) - (when current-repo {:title (t :settings) :options {:on-click #(ui-handler/toggle-settings-modal!)} diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index 61a9c12811..ddac6861f0 100644 --- a/src/main/frontend/components/page.cljs +++ b/src/main/frontend/components/page.cljs @@ -20,7 +20,6 @@ [frontend.extensions.graph-2d :as graph-2d] [frontend.ui :as ui] [frontend.components.content :as content] - [frontend.components.project :as project] [frontend.config :as config] [frontend.db :as db] [frontend.db.model :as model] diff --git a/src/main/frontend/components/project.cljs b/src/main/frontend/components/project.cljs deleted file mode 100644 index d78e8b273f..0000000000 --- a/src/main/frontend/components/project.cljs +++ /dev/null @@ -1,51 +0,0 @@ -(ns frontend.components.project - (:require [rum.core :as rum] - [frontend.util :as util :refer-macros [profile]] - [frontend.handler.project :as project-handler] - [frontend.handler.config :as config-handler] - [clojure.string :as string])) - -(rum/defcs add-project < - (rum/local "" ::project) - [state close-fn] - (let [project (get state ::project)] - [:div - [:div.sm:flex.sm:items-start - [:div.mx-auto.flex-shrink-0.flex.items-center.justify-center.h-12.w-12.rounded-full.bg-red-100.sm:mx-0.sm:h-10.sm:w-10 - [:svg.h-6.w-6.text-red-600 - {:stroke "currentColor", :view-box "0 0 24 24", :fill "none"} - [:path - {:d - "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z", - :stroke-width "2", - :stroke-linejoin "round", - :stroke-linecap "round"}]]] - [:div.mt-3.text-center.sm:mt-0.sm:ml-4.sm:text-left - [:h3#modal-headline.text-lg.leading-6.font-medium - "Setup a public project on Logseq"] - [:div.mt-2 - [:p.text-sm.leading-5.text-gray-500 - "All published pages will be located under " - [:b "/project/"] - "."]]]] - - [:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2 - {:auto-focus true - :on-change (fn [e] - (reset! project (util/evalue e)))}] - - [:div.mt-5.sm:mt-4.sm:flex.sm:flex-row-reverse - [:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto - [:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5 - {:type "button" - :on-click (fn [] - (let [value @project] - (when (and value (>= (count value) 2)) - (project-handler/add-project! value - config-handler/set-project!))))} - "Submit"]] - [:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto - [:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5 - {:type "button" - :on-click close-fn} - "Cancel"]]]])) diff --git a/src/main/frontend/components/publishing.cljs b/src/main/frontend/components/publishing.cljs deleted file mode 100644 index eb7ca8bf62..0000000000 --- a/src/main/frontend/components/publishing.cljs +++ /dev/null @@ -1,136 +0,0 @@ -(ns frontend.components.publishing - (:require [rum.core :as rum] - [frontend.context.i18n :as i18n] - [frontend.db :as db] - [frontend.state :as state] - [frontend.util :as util] - [reitit.frontend.easy :as rfe] - [frontend.db-mixins :as db-mixins] - [frontend.config :as config] - [lambdaisland.glogi :as log] - [promesa.core :as p] - [frontend.handler.page :as page-handler] - [frontend.handler.notification :as notification] - [frontend.ui :as ui] - [frontend.components.svg :as svg] - [frontend.handler.project :as project-handler])) - - -(rum/defcs project - < (rum/local :display ::project-state) - [state current-project pages] - (let [editor-state (get state ::project-state)] - (rum/with-context [[t] i18n/*tongue-context*] - (if (= :display @editor-state) - (when current-project - [:div.cp__publishing-pj - [:span.cp__publishing-pj-name current-project] - [:a.cp__publishing-edit - {:on-click - (fn [_] - (reset! editor-state :editor))} - (t :publishing/edit)]]) - [:div.flex.cp__publishing_pj_edit - [:input#cp__publishing-project-input - {:placeholder current-project - :auto-focus true - :default-value current-project}] - [:div.cp__publishing-pj-bt - (ui/button - (t :publishing/save) - :on-click (fn [e] - (util/stop e) - (let [editor (.getElementById js/document "cp__publishing-project-input") - v (.-value editor) - data {:name v}] - (-> (p/let [result (project-handler/update-project current-project data)] - (when (:result result) - (state/update-current-project :name v) - (notification/show! "Updated project name successfully." :success) - (reset! editor-state :display))) - (p/catch - (fn [error] - (notification/show! "Failed to update project name." :failed)))))) - :background "green")] - - [:div.cp__publishing-pj-bt - (ui/button - (t :publishing/delete) - :on-click (fn [e] - (util/stop e) - (let [confirm-message - (util/format - "This operation will delete all the published pages under the project \"%s\", are you sure?" - current-project)] - (when (.confirm js/window confirm-message) - (p/let [result (project-handler/delete-project current-project)] - (when (:result result) - (reset! editor-state :display) - (state/remove-current-project) - (state/reset-published-pages) - (doseq [{:keys [title]} pages] - (page-handler/page-add-properties! title {:published false})) - (notification/show! "The project was deleted successfully." :success)))))) - :background "red")] - - [:div.cp__publishing-pj-bt - (ui/button - (t :publishing/cancel) - :on-click (fn [e] - (util/stop e) - (reset! editor-state :display)) - :background "pink")]])))) - -(rum/defc my-publishing - < rum/reactive db-mixins/query - (rum/local :display ::project-state) - [] - (let [current-repo (state/sub :git/current-repo) - projects (state/sub [:me :projects]) - current-project (project-handler/get-current-project current-repo projects)] - (when current-repo - (p/let [_ (page-handler/get-page-list-by-project-name current-project)] - (let [publishing-pages (state/sub [:me :published-pages]) - pages (get publishing-pages current-repo)] - (rum/with-context [[t] i18n/*tongue-context*] - [:div.flex-1 - [:h1.title (t :my-publishing)] - [:div#cp__publishing-pj-ct - [:span (t :publishing/current-project)] - (project current-project pages)] - [:div#cp__publishing-pg-ct - [:div (t :publishing/pages)] - [:table.table-auto - [:thead - [:tr - [:th (t :publishing/page-name)] - [:th (t :publishing/delete-from-logseq)]]] - [:tbody - (for [{:keys [title permalink]} pages] - [:tr {:key permalink} - [:td [:div.flex {} - [:span [:a {:on-click (fn [e] (util/stop e)) - :href (rfe/href :page {:name title})} - title]] - [:span [:a {:href (util/format "%s/%s/%s" config/website current-project title) - :target "_blank"} - svg/external-link]]] - ] - [:td [:span.text-gray-500.text-sm - [:a {:on-click - (fn [e] - (util/stop e) - (-> (p/let [_ (page-handler/delete-page-from-logseq current-project permalink)] - (page-handler/update-state-and-notify title)) - (p/catch - (fn [error] - (let [status (.-status error) - not-found-on-server 404] - (if (= not-found-on-server status) - (page-handler/update-state-and-notify title) - (let [message (util/format "Failed to remove the page \"%s\" from Logseq" - title)] - (notification/show! message :failed))))))))} - (t :publishing/delete)]]]])]]]])))))) - - diff --git a/src/main/frontend/components/publishing.css b/src/main/frontend/components/publishing.css deleted file mode 100644 index 2492f3d7ba..0000000000 --- a/src/main/frontend/components/publishing.css +++ /dev/null @@ -1,49 +0,0 @@ -#cp__publishing-pj-ct{ - padding: 10px; - background-color: var(--ls-quaternary-background-color); -} - -.cp__publishing-pj{ - padding: 5px; - margin: 5px; -} - -.cp__publishing-pj-name { - font-size: 25px; - color: var(--ls-primary-text-color); -} - -.cp__publishing-edit{ - font-size: 20px; - margin-left: 40px; - opacity: .5; -} - -.cp__publishing-edit:hover{ - font-size: 20px; - margin-left: 40px; - opacity: .6; -} - -.cp__publishing_pj_edit { - padding: 5px; - margin: 5px; -} - -.cp__publishing-pj-bt { - margin: 5px 5px; -} - -#cp__publishing-project-input{ - border-width: thin; - padding: 0 10px; - display: inline-block; - margin: 5px; - border-radius: var(--ls-border-radius-low); - border-color: var(--ls-border-color); -} - -#cp__publishing-pg-ct { - margin-top: 30px; - padding: 10px; -} \ No newline at end of file diff --git a/src/main/frontend/handler/config.cljs b/src/main/frontend/handler/config.cljs index 885744ce11..a20b9243e4 100644 --- a/src/main/frontend/handler/config.cljs +++ b/src/main/frontend/handler/config.cljs @@ -12,8 +12,3 @@ (defn toggle-ui-show-brackets! [] (let [show-brackets? (state/show-brackets?)] (set-config! :ui/show-brackets? (not show-brackets?)))) - -(defn set-project! - [project] - (when-not (string/blank? project) - (set-config! [:project :name] project))) diff --git a/src/main/frontend/handler/file.cljs b/src/main/frontend/handler/file.cljs index 0532e93f48..7d136e6ed6 100644 --- a/src/main/frontend/handler/file.cljs +++ b/src/main/frontend/handler/file.cljs @@ -15,7 +15,6 @@ [frontend.config :as config] [frontend.format :as format] [clojure.string :as string] - [frontend.handler.project :as project-handler] [lambdaisland.glogi :as log] [clojure.core.async :as async] [cljs.core.async.interop :refer-macros [= (count (string/trim (:name settings))) 2)) - (add-project! (:name settings) nil))))))) - -(defn update-project - [project-name data] - (let [url (util/format "%sprojects/%s" config/api project-name)] - (js/Promise. - (fn [resolve reject] - (util/post url data - (fn [result] - (resolve result)) - (fn [error] - (log/error :project/http-update-failed error) - (reject error))))))) - -(defn delete-project - [project-name] - (let [url (util/format "%sprojects/%s" config/api project-name)] - (js/Promise. - (fn [resolve reject] - (util/delete url - (fn [result] - (resolve result)) - (fn [error] - (log/error :project/http-delete-failed error) - (reject error))))))) diff --git a/src/main/frontend/routes.cljs b/src/main/frontend/routes.cljs index 47434eb2e5..9962a33e11 100644 --- a/src/main/frontend/routes.cljs +++ b/src/main/frontend/routes.cljs @@ -7,8 +7,7 @@ [frontend.components.journal :as journal] [frontend.components.search :as search] [frontend.components.settings :as settings] - [frontend.components.external :as external] - [frontend.components.publishing :as publishing])) + [frontend.components.external :as external])) ;; http://localhost:3000/#?anchor=fn.1 (def routes @@ -66,8 +65,4 @@ ["/all-journals" {:name :all-journals - :view journal/all-journals}] - - ["/my-publishing" - {:name :my-publishing - :view publishing/my-publishing}]]) + :view journal/all-journals}]])