Browse Source

fix: add more file graph concepts to db linter

Gabriel Horner 1 year ago
parent
commit
d431f62c97

+ 3 - 1
scripts/src/logseq/tasks/dev/db_and_file_graphs.clj

@@ -92,11 +92,13 @@
                        (map str)
                        (into [;; e.g. block/properties :title
                               "block/properties :"
+                              "block/name"
                               ;; anything org mode
                               "org"
                               "pre-block"
                               "namespace"
-                              "db/get-page"]))
+                              "db/get-page"
+                              "/page-name-sanity-lc"]))
         res (apply shell {:out :string :continue true}
                    "git grep -E" (str "(" (string/join "|" file-concepts) ")")
                    db-graph-paths)]

+ 1 - 1
src/main/frontend/components/property/value.cljs

@@ -612,7 +612,7 @@
               (property-normal-block-value block property v-block)
 
               ;; page/class/etc.
-              (:block/name v-block)
+              (ldb/page? v-block)
               (rum/with-key
                 (page-cp {:disable-preview? true
                           :hide-close-button? true

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

@@ -6,6 +6,7 @@
             [logseq.db.sqlite.util :as sqlite-util]
             [datascript.core :as d]
             [logseq.common.config :as common-config]
+            [logseq.common.util :as common-util]
             [logseq.db.frontend.content :as db-content]
             [frontend.worker.handler.page.db-based.page :as db-worker-page]
             [frontend.worker.handler.page.file-based.page :as file-worker-page]))
@@ -14,7 +15,8 @@
   [conn config title {:keys [uuid]}]
   (assert (uuid? uuid) (str "rtc-create-page! `uuid` is not a uuid " uuid))
   (let [date-formatter    (common-config/get-date-formatter config)
-        [title page-name] (db-worker-page/get-title-and-pagename title)
+        title (db-worker-page/sanitize-title title)
+        page-name (common-util/page-name-sanity-lc title)
         page              (-> (gp-block/page-name->map title @conn true date-formatter
                                                        {:page-uuid uuid
                                                         :skip-existing-page-check? true})

+ 7 - 8
src/main/frontend/worker/handler/page/db_based/page.cljs

@@ -42,15 +42,14 @@
                      (db-property-build/build-properties-with-ref-values property-vals-tx-m)))))))
 
 ;; TODO: Revisit title cleanup as this was copied from file implementation
-(defn get-title-and-pagename
+(defn sanitize-title
   [title]
   (let [title      (-> (string/trim title)
                        (text/page-ref-un-brackets!)
                         ;; remove `#` from tags
                        (string/replace #"^#+" ""))
-        title      (common-util/remove-boundary-slashes title)
-        page-name  (common-util/page-name-sanity-lc title)]
-    [title page-name]))
+        title      (common-util/remove-boundary-slashes title)]
+    title))
 
 (defn build-first-block-tx
   [page-uuid format]
@@ -64,7 +63,7 @@
        :block/format format})]))
 
 (defn create!
-  [conn title
+  [conn title*
    {:keys [create-first-block? properties uuid persist-op? whiteboard? class? today-journal?]
     :or   {create-first-block?      true
            properties               nil
@@ -72,7 +71,7 @@
            persist-op?              true}
     :as options}]
   (let [date-formatter (:logseq.property.journal/title-format (d/entity @conn :logseq.class/Journal))
-        [title page-name] (get-title-and-pagename title)
+        title (sanitize-title title*)
         type (cond class?
                    "class"
                    whiteboard?
@@ -104,5 +103,5 @@
                                            :outliner-op :create-page}
                                     today-journal?
                                     (assoc :create-today-journal? true
-                                           :today-journal-name page-name))))
-        [page-name page-uuid]))))
+                                           :today-journal-name title))))
+        [title page-uuid]))))