fix: publishing not working at all

pull/1113/head
Tienson Qin 2021-01-14 14:26:21 +08:00
parent 27712fd6c3
commit 9b8c2caf02
7 changed files with 58 additions and 41 deletions

View File

@ -295,21 +295,24 @@
(when title
[:div.it
(apply (partial ui/button title) (flatten (seq options)))]))
[{:title (t :page/publish)
:options {:on-click (fn []
(page-handler/publish-page! page-name project/add-project))}}
{:title (t :page/publish-as-slide)
:options {:on-click (fn []
(page-handler/publish-page-as-slide! page-name project/add-project))}}
(when published?
[(if published?
{:title (t :page/unpublish)
:options {:on-click (fn []
(page-handler/unpublish-page! page-name))}})
(page-handler/unpublish-page! page-name))}}
{:title (t :page/publish)
:options {:on-click (fn []
(page-handler/publish-page! page-name project/add-project))}})
(when-not published?
{:title (t :page/publish-as-slide)
:options {:on-click (fn []
(page-handler/publish-page-as-slide! page-name project/add-project))}})
{:title (t (if public? :page/make-private :page/make-public))
:options {:background (if public? "gray" "indigo")
:on-click #(page-handler/update-public-attribute!
:on-click (fn []
(page-handler/update-public-attribute!
page-name
(if public? false true))}}])])))}}
(if public? false true))
(state/close-modal!))}}])])))}}
(when developer-mode?
{:title "(Dev) Show page data"
:options {:on-click (fn []

View File

@ -1,7 +1,9 @@
(ns frontend.components.project
(:require [rum.core :as rum]
[frontend.util :as util :refer-macros [profile]]
[frontend.handler.project :as project-handler]))
[frontend.handler.project :as project-handler]
[frontend.handler.config :as config-handler]
[clojure.string :as string]))
(rum/defcs add-project <
(rum/local "" ::project)
@ -40,7 +42,8 @@
:on-click (fn []
(let [value @project]
(when (and value (>= (count value) 2))
(project-handler/add-project! value))))}
(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

View File

@ -216,7 +216,7 @@ title: How to take dummy notes?
:page/presentation-mode "Presentation mode (Powered by Reveal.js)"
:page/edit-properties-placeholder "Click here to edit this page's properties"
:page/delete-success "Page {1} was deleted successfully!"
:page/delete-confirmation "Are you sure you want to delete this page?"
:page/delete-confirmation "Are you sure you want to delete this page and its file?"
:page/rename-to "Rename \"{1}\" to:"
:page/priority "Priority \"{1}\""
:page/re-index "Re-index this page"
@ -225,7 +225,7 @@ title: How to take dummy notes?
:page/action-publish "Publish"
:page/make-public "Publish it when exporting to an html file"
:page/make-private "Make it private"
:page/delete "Delete page (will delete the file too)"
:page/delete "Delete page"
:page/publish "Publish this page on Logseq"
:page/cancel-publishing "Cancel publishing on Logseq"
:page/publish-as-slide "Publish this page as a slide on Logseq"
@ -696,7 +696,7 @@ title: How to take dummy notes?
:page/edit-properties-placeholder "点击这里编辑当前页面的属性 (标签,别名等)"
:page/presentation-mode "演讲模式 (由 Reveal.js 驱动)"
:page/delete-success "页面 {1} 删除成功!"
:page/delete-confirmation "您确定要删除此页面吗?"
:page/delete-confirmation "您确定要删除此页面和文件吗?"
:page/rename-to "重命名 \"{1}\" 至:"
:page/priority "优先级 \"{1}\""
:page/re-index "对此页面重新建立索引"
@ -705,7 +705,7 @@ title: How to take dummy notes?
:page/action-publish "发布"
:page/make-public "导出 HTML 时发布本页面"
:page/make-private "导出 HTML 时取消发布本页面"
:page/delete "删除本页(并删除文件)"
:page/delete "删除本页"
:page/publish "将本页发布至 Logseq"
:page/cancel-publishing "撤回本页在 Logseq 上的发布"
:page/publish-as-slide "将本页作为幻灯片发布至 Logseq"

View File

@ -3,7 +3,8 @@
[frontend.handler.repo :as repo-handler]
[borkdude.rewrite-edn :as rewrite]
[frontend.config :as config]
[frontend.db :as db]))
[frontend.db :as db]
[clojure.string :as string]))
(defn set-config!
[k v]
@ -25,3 +26,8 @@
(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)))

View File

@ -14,6 +14,7 @@
[frontend.handler.editor :as editor-handler]
[frontend.handler.project :as project-handler]
[frontend.handler.notification :as notification]
[frontend.handler.config :as config-handler]
[frontend.handler.ui :as ui-handler]
[frontend.commands :as commands]
[frontend.date :as date]
@ -171,6 +172,7 @@
([page-name blocks project-add-modal]
(project-handler/exists-or-create!
(fn [project]
(config-handler/set-config! [:project :name] project)
(page-add-properties! page-name {"published" true
"slide" true})
(let [properties (db/get-page-properties page-name)
@ -202,6 +204,7 @@
(= "true" slide)))
blocks (db/get-page-blocks page-name)
plugins (get-plugins blocks)]
(p/let [_ (config-handler/set-config! [:project :name] project)]
(if slide?
(publish-page-as-slide! page-name blocks project-add-modal)
(do
@ -216,12 +219,14 @@
(util/post (str config/api "pages")
data
(published-success-handler page-name)
published-failed-handler))))))
published-failed-handler))))
(state/close-modal!))))
project-add-modal))
(defn unpublished-success-handler
[page-name]
(fn [result]
(state/close-modal!)
(notification/show!
"Un-publish successfully!"
:success)))

View File

@ -40,6 +40,7 @@
update-in [:me :projects]
(fn [projects]
(util/distinct-by :name (conj projects (:result result)))))
;; update config
(ok-handler project)))
(fn [error]
(js/console.dir error)
@ -55,10 +56,11 @@
(state/set-modal! modal-content))))
(defn add-project!
[project]
[project ok-handler]
(when (state/logged?)
(create-project! project
(fn []
(fn [project]
(when ok-handler (ok-handler project))
(notification/show! (util/format "Project \"%s\" was created successfully." project) :success)
(state/close-modal!)))))
@ -83,7 +85,7 @@
(when (and settings
(not (string/blank? (:name settings)))
(>= (count (string/trim (:name settings))) 2))
(add-project! (:name settings))))))))
(add-project! (:name settings) nil)))))))
(defn update-project
[project-name data]

View File

@ -820,11 +820,9 @@
(defn get-current-project
[]
(when-let [repo (get-current-repo)]
(let [projects (:projects (get-me))
project (:name (first (filter (fn [p] (= (:repo p) repo)) projects)))]
(when-let [project (get-in (get-config) [:project :name])]
(when-not (string/blank? project)
project))))
project)))
(defn update-current-project
[& kv]