Skip to content

Commit

Permalink
refactor: use publishable instead of public because the latter is too…
Browse files Browse the repository at this point in the history
… general
  • Loading branch information
thezjy authored and tiensonqin committed Mar 16, 2021
1 parent 18cfedf commit 6eadb22
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 68 deletions.
37 changes: 6 additions & 31 deletions src/main/frontend/components/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@
(= page-name (string/lower-case (date/journal-name))))
developer-mode? (state/sub [:ui/developer-mode?])
published? (= "true" (:published properties))
public? (= "true" (:public properties))]
publishable? (= "true" (:publishable properties))]
[:div.flex-1.page.relative (if (seq (:page/tags page))
(let [page-names (model/get-page-names-by-ids (map :db/id (:page/tags page)))]
{:data-page-tags (text/build-data-value page-names)})
Expand Down Expand Up @@ -313,38 +313,13 @@
{:title (t :page/delete)
:options {:on-click #(state/set-modal! (delete-page-dialog page-name))}})

{:title (t :page/action-publish)
{:title (t (if publishable? :page/make-private :page/make-public))
:options {:on-click
(fn []
(state/set-modal!
(fn []
[:div.cp__page-publish-actions
(mapv (fn [{:keys [title options]}]
(when title
[:div.it
(apply (partial ui/button title) (flatten (seq options)))]))
[(if published?
{:title (t :page/unpublish)
:options {:on-click (fn []
(page-handler/unpublish-page! page-name))}}
{:title (t :page/publish)
:options {:on-click (fn []
(page-handler/publish-page!
page-name project/add-project
html-export/export-page))}})
(when-not published?
{:title (t :page/publish-as-slide)
:options {:on-click (fn []
(page-handler/publish-page-as-slide!
page-name project/add-project
html-export/export-page))}})
{:title (t (if public? :page/make-private :page/make-public))
:options {:background (if public? "gray" "indigo")
:on-click (fn []
(page-handler/update-public-attribute!
page-name
(if public? false true))
(state/close-modal!))}}])])))}}
(page-handler/update-public-attribute!
page-name
(if publishable? false true))
(state/close-modal!))}}

(when file
{:title (t :page/re-index)
Expand Down
52 changes: 26 additions & 26 deletions src/main/frontend/db/model.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
;; [(identity ?vs) [?v ...]]
;; (not-join [?e ?v]
;; [?e ?a ?v]))]
])
])

(defn transact-files-db!
([tx-data]
Expand Down Expand Up @@ -156,7 +156,7 @@
:where
[?file :file/path ?path]
;; [?file :file/last-modified-at ?modified-at]
]
]
conn)
(seq)
;; (sort-by last)
Expand Down Expand Up @@ -845,17 +845,17 @@
(when-let [conn (conn/get-conn repo)]
(->
(d/q
'[:find [?ref-page ...]
:in $ % ?page
:where
[?p :page/name ?page]
[?b :block/path-ref-pages ?p]
[?b :block/ref-pages ?other-p]
[(not= ?p ?other-p)]
[?other-p :page/name ?ref-page]]
conn
rules
page)
'[:find [?ref-page ...]
:in $ % ?page
:where
[?p :page/name ?page]
[?b :block/path-ref-pages ?p]
[?b :block/ref-pages ?other-p]
[(not= ?p ?other-p)]
[?other-p :page/name ?ref-page]]
conn
rules
page)
(distinct))))

;; Ignore files with empty blocks for now
Expand Down Expand Up @@ -934,15 +934,15 @@
(when (seq blocks)
(let [block-ids (set (map :db/id blocks))
refs (d/q
'[:find ?p ?ref
:in $ % ?block-ids
:where
(parent ?p ?b)
[(contains? ?block-ids ?p)]
[?b :block/ref-pages ?ref]]
conn
rules
block-ids)
'[:find ?p ?ref
:in $ % ?block-ids
:where
(parent ?p ?b)
[(contains? ?block-ids ?p)]
[?b :block/ref-pages ?ref]]
conn
rules
block-ids)
refs (->> (group-by first refs)
(medley/map-vals #(set (map (fn [[_ id]] {:db/id id}) %))))]
(map (fn [block] (assoc block :block/children-refs
Expand Down Expand Up @@ -1147,7 +1147,7 @@
'[:find ?p
:where
[?p :page/properties ?d]
[(get ?d :public) ?pub]
[(get ?d :publishable) ?pub]
[(= "true" ?pub)]]
db)
(db-utils/seq-flatten)))
Expand Down Expand Up @@ -1178,8 +1178,8 @@
@blocks-count-cache
(when-let [conn (conn/get-conn)]
(let [n (count (d/datoms conn :avet :block/uuid))]
(reset! blocks-count-cache n)
n)))))
(reset! blocks-count-cache n)
n)))))

;; block/uuid and block/content
(defn get-all-block-contents
Expand Down Expand Up @@ -1310,4 +1310,4 @@
[(contains? ?refs ?b-ref)]))]
(conn/get-conn)
rules
page-ids))
page-ids))
10 changes: 5 additions & 5 deletions src/main/frontend/dicts.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ title: How to take dummy notes?
:page/open-in-finder "Open in directory"
:page/open-with-default-app "Open with default app"
:page/action-publish "Publish"
:page/make-public "Publish it when exporting to an html file"
:page/make-private "Make it private"
:page/make-public "Set publishable"
:page/make-private "Set non-publishable"
:page/delete "Delete page"
:page/publish "Publish this page on Logseq"
:page/cancel-publishing "Cancel publishing on Logseq"
Expand Down Expand Up @@ -320,7 +320,7 @@ title: How to take dummy notes?
:graph "Graph"
:graph-view "View Graph"
:publishing "Publishing"
:export "Export public pages"
:export "Export publishable pages"
:all-graphs "All graphs"
:all-pages "All pages"
:all-files "All files"
Expand Down Expand Up @@ -956,8 +956,8 @@ title: How to take dummy notes?
:page/open-in-finder "打开文件对应目录"
:page/open-with-default-app "用默认应用打开文件"
:page/action-publish "发布"
:page/make-public "导出 HTML 时发布本页面"
:page/make-private "导出 HTML 时取消发布本页面"
:page/make-public "发布时包括"
:page/make-private "发布时排除"
:page/delete "删除本页"
:page/publish "将本页发布至 Logseq"
:page/cancel-publishing "撤回本页在 Logseq 上的发布"
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/handler/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@

(defn update-public-attribute!
[page-name value]
(page-add-properties! page-name {:public value}))
(page-add-properties! page-name {:publishable value}))

(defn get-page-ref-text
[page]
Expand Down Expand Up @@ -516,8 +516,8 @@
(defn ls-dir-files!
[]
(web-nfs/ls-dir-files-with-handler!
(fn []
(init-commands!))))
(fn []
(init-commands!))))


;; TODO: add use :file/last-modified-at
Expand Down
6 changes: 3 additions & 3 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@
[]
(:custom-css-url (get-config)))

(defn all-pages-public?
(defn all-pages-publishable?
[]
(true? (:all-pages-public? (get-config))))
(true? (:all-pages-publishable? (get-config))))

(defn enable-grammarly?
[]
Expand Down Expand Up @@ -376,7 +376,7 @@
;; (remove #(= leader-parent %)))]
;; (prn "followers: " (count followers))
;; ))
)))
)))

(defn get-edit-input-id
[]
Expand Down

0 comments on commit 6eadb22

Please sign in to comment.