refactor: rename :block/original-name to :block/title

This commit is contained in:
Tienson Qin
2024-07-10 21:29:39 +08:00
parent 2a48486ac1
commit a1f352773b
105 changed files with 559 additions and 563 deletions

View File

@@ -110,7 +110,7 @@
(into [(merge page
{:db/id page-id
:block/uuid page-uuid
:block/original-name (string/capitalize (:block/name page))
:block/title (string/capitalize (:block/name page))
:block/created-at created-at
:block/updated-at created-at})]
(mapv #(merge %

View File

@@ -40,7 +40,7 @@
(->> name
(d/q '[:find [(pull ?b [*]) ...]
:in $ ?name
:where [?b :block/original-name ?name]]
:where [?b :block/title ?name]]
db)
first))
@@ -145,8 +145,8 @@
;; Don't count pages like url.md that have properties but no content
(is (= 5
(count (->> (d/q '[:find [(pull ?b [:block/original-name :block/type]) ...]
:where [?b :block/original-name] [_ :block/page ?b]] @conn)
(count (->> (d/q '[:find [(pull ?b [:block/title :block/type]) ...]
:where [?b :block/title] [_ :block/page ?b]] @conn)
(filter #(= ["page"] (:block/type %))))))
"Correct number of pages with block content")
(is (= 2 (count @(:ignored-properties import-state)))
@@ -164,8 +164,8 @@
(->>
(ldb/get-page-blocks @conn
(:db/id (ldb/get-page @conn common-config/favorites-page-name))
{:pull-keys '[* {:block/link [:block/original-name]}]})
(map #(get-in % [:block/link :block/original-name]))
{:pull-keys '[* {:block/link [:block/title]}]})
(map #(get-in % [:block/link :block/title]))
set))))
(testing "user properties"
@@ -205,7 +205,7 @@
(is (= #{"prop-num" "prop-string" "prop-bool"}
(->> (d/entity @conn (:db/id (find-block-by-content @conn "b1")))
:block/refs
(map :block/original-name)
(map :block/title)
set))
"Block with properties has correct refs")

View File

@@ -135,7 +135,7 @@
:block/format :markdown}),
:pages
({:block/format :markdown,
:block/original-name "Foo"
:block/title "Foo"
:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"
:block/properties {:title "my whiteboard foo"}})})
@@ -145,5 +145,5 @@
(is (= (get-in page [:block/file :file/path]) "/whiteboards/foo.edn"))
(is (= (:block/name page) "foo"))
(is (= (:block/type page) #{"whiteboard" "page"}))
(is (= (:block/original-name page) "Foo"))
(is (= (:block/title page) "Foo"))
(is (every? #(= (:block/parent %) [:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"]) blocks))))

View File

@@ -20,7 +20,7 @@
:pages
({:block/format :markdown,
:block/name "foo"
:block/original-name "Foo"
:block/title "Foo"
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"
:block/properties {:title "my whiteboard foo"}})})
@@ -34,7 +34,7 @@
:pages
({:block/format :markdown,
:block/name "foo conflicted"
:block/original-name "Foo conflicted"
:block/title "Foo conflicted"
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"})})
(def bar-edn
@@ -51,7 +51,7 @@
:pages
({:block/format :markdown,
:block/name "bar"
:block/original-name "Bar"
:block/title "Bar"
:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3"})})
(defn- parse-file
@@ -89,7 +89,7 @@
(parse-file conn "/whiteboards/foo.edn" (pr-str foo-edn))
(let [blocks (d/q '[:find (pull ?b [* {:block/page
[:block/name
:block/original-name
:block/title
:block/type
{:block/file
[:file/path]}]}])
@@ -98,7 +98,7 @@
@conn)
parent (:block/page (ffirst blocks))]
(is (= {:block/name "foo"
:block/original-name "Foo"
:block/title "Foo"
:block/type ["page" "whiteboard"]
:block/file {:file/path "/whiteboards/foo.edn"}}
parent)
@@ -168,7 +168,7 @@
(:block/properties block))
"Quoted value is unparsed")
(is (= ["desc"]
(map :block/original-name (:block/refs block)))
(map :block/title (:block/refs block)))
"No refs from property value")))
(deftest non-string-property-values
@@ -242,12 +242,12 @@
blocks (->> (d/q '[:find (pull ?b [:block/pre-block?
:block/properties
:block/properties-text-values
{:block/refs [:block/original-name]}])
{:block/refs [:block/title]}])
:in $
:where [?b :block/properties] [(missing? $ ?b :block/name)]]
@conn)
(map first)
(map (fn [m] (update m :block/refs #(map :block/original-name %)))))
(map (fn [m] (update m :block/refs #(map :block/title %)))))
block-db-properties (block-property-transform db-properties)]
(testing "Page properties"
@@ -356,7 +356,7 @@
:in $
:where [?b :block/name]]
@conn)
(map (comp :block/original-name first))
(map (comp :block/title first))
(remove built-in-pages)
set))))))