Prechádzať zdrojové kódy

refactor: use publishable instead of public because the latter is too general

Junyu Zhan 4 rokov pred
rodič
commit
6eadb22753

+ 6 - 31
src/main/frontend/components/page.cljs

@@ -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)})
@@ -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)

+ 26 - 26
src/main/frontend/db/model.cljs

@@ -44,7 +44,7 @@
     ;;            [(identity ?vs) [?v ...]]
     ;;            (not-join [?e ?v]
     ;;                      [?e ?a ?v]))]
-])
+    ])
 
 (defn transact-files-db!
   ([tx-data]
@@ -156,7 +156,7 @@
             :where
             [?file :file/path ?path]
             ;; [?file :file/last-modified-at ?modified-at]
-]
+            ]
           conn)
          (seq)
          ;; (sort-by last)
@@ -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
@@ -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
@@ -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)))
@@ -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
@@ -1310,4 +1310,4 @@
                    [(contains? ?refs ?b-ref)]))]
        (conn/get-conn)
        rules
-    page-ids))
+       page-ids))

+ 5 - 5
src/main/frontend/dicts.cljs

@@ -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"
@@ -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"
@@ -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 上的发布"

+ 3 - 3
src/main/frontend/handler/page.cljs

@@ -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]
@@ -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

+ 3 - 3
src/main/frontend/state.cljs

@@ -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?
   []
@@ -376,7 +376,7 @@
      ;;                        (remove #(= leader-parent %)))]
      ;;     (prn "followers: " (count followers))
      ;;     ))
-)))
+     )))
 
 (defn get-edit-input-id
   []