Tienson Qin 4 лет назад
Родитель
Сommit
d29b265e28
32 измененных файлов с 370 добавлено и 361 удалено
  1. 2 2
      deps.edn
  2. 6 6
      docs/Build LogSeq Desktop for windows on Ubuntu.md
  3. 28 28
      src/main/frontend/components/block.cljs
  4. 1 1
      src/main/frontend/components/file.cljs
  5. 3 3
      src/main/frontend/components/journal.cljs
  6. 17 17
      src/main/frontend/components/page.cljs
  7. 5 5
      src/main/frontend/components/right_sidebar.cljs
  8. 4 4
      src/main/frontend/components/search.cljs
  9. 1 1
      src/main/frontend/components/sidebar.cljs
  10. 0 0
      src/main/frontend/config.cljs
  11. 5 1
      src/main/frontend/db.cljs
  12. 3 3
      src/main/frontend/db/default.cljs
  13. 75 75
      src/main/frontend/db/model.cljs
  14. 11 11
      src/main/frontend/db/query_dsl.cljs
  15. 2 2
      src/main/frontend/db/react.cljs
  16. 39 35
      src/main/frontend/db_schema.cljs
  17. 7 7
      src/main/frontend/dicts.cljs
  18. 26 23
      src/main/frontend/format/block.cljs
  19. 1 1
      src/main/frontend/graph.cljs
  20. 15 17
      src/main/frontend/handler/block.cljs
  21. 3 3
      src/main/frontend/handler/draw.cljs
  22. 26 26
      src/main/frontend/handler/editor.cljs
  23. 3 3
      src/main/frontend/handler/external.cljs
  24. 21 21
      src/main/frontend/handler/extract.cljs
  25. 2 2
      src/main/frontend/handler/file.cljs
  26. 7 7
      src/main/frontend/handler/graph.cljs
  27. 16 16
      src/main/frontend/handler/page.cljs
  28. 1 1
      src/main/frontend/handler/repo.cljs
  29. 3 3
      src/main/frontend/handler/route.cljs
  30. 1 1
      src/main/frontend/history.cljs
  31. 4 4
      src/main/frontend/search.cljs
  32. 32 32
      src/test/frontend/db/query_dsl_test.cljs

+ 2 - 2
deps.edn

@@ -34,8 +34,8 @@
   thheller/shadow-cljs        {:mvn/version "2.11.14"}
   expound/expound             {:mvn/version "0.8.6"}
   lambdaisland/glogi          {:mvn/version "1.0.74"}
-  nano-id/nano-id             {:mvn/version "1.0.0"}}
-  binaryage/devtools          {:mvn/version "1.0.2"}
+  nano-id/nano-id             {:mvn/version "1.0.0"}
+  binaryage/devtools          {:mvn/version "1.0.2"}}
 
  :aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/" "src/electron/"]
                   :extra-deps  {org.clojure/clojurescript   {:mvn/version "1.10.764"}

+ 6 - 6
docs/Build LogSeq Desktop for windows on Ubuntu.md

@@ -1,12 +1,12 @@
-# Building LogSeq Desktop app for Windows on Ubuntu
+# Building Logseq Desktop app for Windows on Ubuntu
 ## Intro
-My LogSeq dev machine is on Ubuntu 18.x and my production machine is running Windows 10, I needed a way to compile the LogSeq desktop APP for Windows.
+My Logseq dev machine is on Ubuntu 18.x and my production machine is running Windows 10, I needed a way to compile the Logseq desktop APP for Windows.
 I tired & failed to make the "build" run on my windows machine but I did, however, succeed in letting my Ubuntu machine make Windows x64 files
-## Pre-requisites 
-These are the steps I took to make it work on my Ubuntu machine, sharing them hoping it helps someone else. I assume you have all the basic pre-requisites for LogSeq, if not you can find them at https://github.com/logseq/logseq#1-requirements
-1. clone LogSeq repo if you haven't already 
+## Pre-requisites
+These are the steps I took to make it work on my Ubuntu machine, sharing them hoping it helps someone else. I assume you have all the basic pre-requisites for Logseq, if not you can find them at https://github.com/logseq/logseq#1-requirements
+1. clone Logseq repo if you haven't already
 `git clone https://github.com/logseq/logseq/`
-1. Install wine 
+1. Install wine
 ```shell
 sudo dpkg --add-architecture i386
 sudo apt update

+ 28 - 28
src/main/frontend/components/block.cljs

@@ -131,7 +131,7 @@
   (let [path (string/replace path "file:" "")
         block-id (:block/uuid config)
         current-file (and block-id
-                          (:file/path (:page/file (:block/page (db/entity [:block/uuid block-id])))))]
+                          (:file/path (:block/file (:block/page (db/entity [:block/uuid block-id])))))]
     (when current-file
       (let [parts (string/split current-file #"/")
             parts-2 (string/split path #"/")
@@ -327,20 +327,20 @@
 
 (defn page-cp
   [{:keys [html-export? label children contents-page?] :as config} page]
-  (when-let [page-name (:page/name page)]
+  (when-let [page-name (:block/name page)]
     (let [source-page (model/get-alias-source-page (state/get-current-repo)
                                                    (string/lower-case page-name))
-          original-page-name (get page :page/original-name page-name)
+          original-page-name (get page :block/original-name page-name)
           original-page-name (if (date/valid-journal-title? original-page-name)
                                (string/capitalize original-page-name)
                                original-page-name)
           page (string/lower-case page-name)
           redirect-page-name (cond
-                               (:page/alias? config)
+                               (:block/alias? config)
                                page
 
                                (db/page-empty? (state/get-current-repo) page-name)
-                               (or (when source-page (:page/name source-page))
+                               (or (when source-page (:block/name source-page))
                                    page)
 
                                :else
@@ -354,7 +354,7 @@
         :on-click (fn [e]
                     (util/stop e)
                     (if (gobj/get e "shiftKey")
-                      (when-let [page-entity (db/entity [:page/name redirect-page-name])]
+                      (when-let [page-entity (db/entity [:block/name redirect-page-name])]
                         (state/sidebar-add-block!
                          (state/get-current-repo)
                          (:db/id page-entity)
@@ -415,7 +415,7 @@
          [:span.text-gray-500.bracket "[["])
        (page-cp (assoc config
                        :label (mldoc/plain->text label)
-                       :contents-page? contents-page?) {:page/name s})
+                       :contents-page? contents-page?) {:block/name s})
        (when (and (or show-brackets? nested-link?)
                   (not html-export?)
                   (not contents-page?))
@@ -449,7 +449,7 @@
      {:class (if (:sidebar? config) "in-sidebar")}
      [:section.flex.items-center.p-1.embed-header
       [:div.mr-3 svg/page]
-      (page-cp config {:page/name page-name})]
+      (page-cp config {:block/name page-name})]
      (when (and
             (not= (string/lower-case (or current-page ""))
                   page-name)
@@ -470,7 +470,7 @@
 (defn- get-page
   [label]
   (when-let [label-text (get-label-text label)]
-    (db/entity [:page/name (string/lower-case label-text)])))
+    (db/entity [:block/name (string/lower-case label-text)])))
 
 (defn- macro->text
   [name arguments]
@@ -551,7 +551,7 @@
      (let [page-name (subs content 2 (- (count content) 2))]
        (page-cp (assoc config
                        :children children
-                       :nested-link? true) {:page/name page-name}))
+                       :nested-link? true) {:block/name page-name}))
      (when (and show-brackets?
                 (not html-export?)
                 (not (= (:id config) "contents")))
@@ -576,7 +576,7 @@
                :href (rfe/href :page {:name s})
                :on-click (fn [e]
                            (let [repo (state/get-current-repo)
-                                 page (db/pull repo '[*] [:page/name (string/lower-case (util/url-decode s))])]
+                                 page (db/pull repo '[*] [:block/name (string/lower-case (util/url-decode s))])]
                              (when (gobj/get e "shiftKey")
                                (state/sidebar-add-block!
                                 repo
@@ -680,7 +680,7 @@
               (image-link config url href label metadata full_text)
               (let [label-text (get-label-text label)
                     page (if (string/blank? label-text)
-                           {:page/name (db/get-file-page (string/replace href "file:" ""))}
+                           {:block/name (db/get-file-page (string/replace href "file:" ""))}
                            (get-page label))]
                 (if (and page
                          (when-let [ext (util/get-file-ext href)]
@@ -884,7 +884,7 @@
                                    (:block/page)
                                    (:db/id)
                                    (db/entity)
-                                   :page/properties
+                                   :block/properties
                                    :macros
                                    (get name))
                                (get (state/get-macros) name)
@@ -1120,7 +1120,7 @@
      {:class "block-tags"}
      (mapv (fn [tag]
              (when-let [page (db/entity (:db/id tag))]
-               (let [tag (:page/name page)]
+               (let [tag (:block/name page)]
                  [:a.tag.mx-1 {:data-ref tag
                                :key (str "tag-" (:db/id tag))
                                :href (rfe/href :page {:name tag})}
@@ -1232,11 +1232,11 @@
             (let [v (->> (remove string/blank? v)
                          (filter string?))
                   vals (for [v-item v]
-                         (page-cp config {:page/name v-item}))]
+                         (page-cp config {:block/name v-item}))]
               (interpose [:span ", "] vals))
             (let [page-name (string/lower-case (str v))]
-              (if (db/entity [:page/name page-name])
-                (page-cp config {:page/name page-name})
+              (if (db/entity [:block/name page-name])
+                (page-cp config {:block/name page-name})
                 (inline-text (:block/format block) (str v)))))])])))
 
 (rum/defcs timestamp-cp < rum/reactive
@@ -1431,7 +1431,7 @@
   ([config repo block-id format show-page?]
    (let [parents (db/get-block-parents repo block-id 3)
          page (db/get-block-page repo block-id)
-         page-name (:page/name page)]
+         page-name (:block/name page)]
      (when (or (seq parents)
                show-page?
                page-name)
@@ -1439,8 +1439,8 @@
              component [:div.block-parents.flex-row.flex-1
                         (when show-page?
                           [:a {:href (rfe/href :page {:name page-name})}
-                           (or (:page/original-name page)
-                               (:page/name page))])
+                           (or (:block/original-name page)
+                               (:block/name page))])
 
                         (when (and show-page? (seq parents))
                           [:span.mx-2.opacity-50 "➤"])
@@ -1782,7 +1782,7 @@
           only-blocks? (:block/uuid (first result))
           blocks-grouped-by-page? (and (seq result)
                                        (coll? (first result))
-                                       (:page/name (ffirst result))
+                                       (:block/name (ffirst result))
                                        (:block/uuid (first (second (first result))))
                                        true)
           built-in? (built-in-custom-query? title)]
@@ -1817,9 +1817,9 @@
 
             ;; page list
             (and (seq result)
-                 (:page/name (first result)))
+                 (:block/name (first result)))
             [:ul#query-pages.mt-1
-             (for [{:page/keys [name original-name] :as page-entity} result]
+             (for [{:block/keys [name original-name] :as page-entity} result]
                [:li.mt-1
                 [:a {:href (rfe/href :page {:name name})
                      :on-click (fn [e]
@@ -1880,8 +1880,8 @@
                 (let [vals (for [item v]
                              (if (coll? v)
                                (let [config (if (= k :alias)
-                                              (assoc config :page/alias? true))]
-                                 (page-cp config {:page/name item}))
+                                              (assoc config :block/alias? true))]
+                                 (page-cp config {:block/name item}))
                                (inline-text format item)))]
                   (interpose [:span ", "] vals))
                 (inline-text format v))])))]
@@ -1983,7 +1983,7 @@
 
       ["Custom" "warning" options result content]
       (admonition config "warning" options result)
-      
+
       ["Custom" "pinned" options result content]
       (admonition config "pinned" options result)
 
@@ -2108,9 +2108,9 @@
      (assoc :class "doc-mode"))
    (if (:group-by-page? config)
      [:div.flex.flex-col
-      (let [blocks (sort-by (comp :page/journal-day first) > blocks)]
+      (let [blocks (sort-by (comp :block/journal-day first) > blocks)]
         (for [[page blocks] blocks]
-          (let [alias? (:page/alias? page)
+          (let [alias? (:block/alias? page)
                 page (db/entity (:db/id page))]
             [:div.my-2 (cond-> {:key (str "page-" (:db/id page))}
                          (:ref? config)

+ 1 - 1
src/main/frontend/components/file.cljs

@@ -82,7 +82,7 @@
                                   :href (rfe/href :page {:name page})
                                   :on-click (fn [e]
                                               (when (gobj/get e "shiftKey")
-                                                (when-let [page (db/entity [:page/name (string/lower-case page)])]
+                                                (when-let [page (db/entity [:block/name (string/lower-case page)])]
                                                   (state/sidebar-add-block!
                                                    (state/get-current-repo)
                                                    (:db/id page)

+ 3 - 3
src/main/frontend/components/journal.cljs

@@ -77,9 +77,9 @@
                     (not (config/local-db? repo))
                     (not config/publishing?)
                     today?)
-        page-entity (db/pull [:page/name (string/lower-case title)])
-        data-page-tags (when (seq (:page/tags page-entity))
-                         (let [page-names (model/get-page-names-by-ids (map :db/id (:page/tags page)))]
+        page-entity (db/pull [:block/name (string/lower-case title)])
+        data-page-tags (when (seq (:block/tags page-entity))
+                         (let [page-names (model/get-page-names-by-ids (map :db/id (:block/tags page)))]
                            (text/build-data-value page-names)))]
     [:div.flex-1.journal.page (cond->
                                {:class (if intro? "intro" "")}

+ 17 - 17
src/main/frontend/components/page.cljs

@@ -65,9 +65,9 @@
                       (if (empty? raw-page-blocks)
                         (let [content (db/get-file repo file-path)]
                           {:block/page {:db/id (:db/id page)}
-                           :block/file {:db/id (:db/id (:page/file page))}
+                           :block/file {:db/id (:db/id (:block/file page))}
                            :block/meta
-                           (let [file-id (:db/id (:page/file page))]
+                           (let [file-id (:db/id (:block/file page))]
                              {:start-pos (utf8/length (utf8/encode content))
                               :end-pos nil})}))
                       {:journal? journal?
@@ -99,7 +99,7 @@
        (str encoded-page-name "-hiccup"))]))
 
 (defn contents-page
-  [{:page/keys [name original-name file] :as contents}]
+  [{:block/keys [name original-name file] :as contents}]
   (when-let [repo (state/get-current-repo)]
     (let [format (db/get-page-format name)
           file-path (:file/path file)]
@@ -244,7 +244,7 @@
         block? (util/uuid-string? page-name)
         block-id (and block? (uuid page-name))
         format (let [page (if block-id
-                            (:page/name (:block/page (db/entity [:block/uuid block-id])))
+                            (:block/name (:block/page (db/entity [:block/uuid block-id])))
                             page-name)]
                  (db/get-page-format page))
         journal? (db/journal-page? page-name)
@@ -270,15 +270,15 @@
               page (if block?
                      (->> (:db/id (:block/page (db/entity repo [:block/uuid block-id])))
                           (db/entity repo))
-                     (db/entity repo [:page/name page-name]))
+                     (db/entity repo [:block/name page-name]))
               page (if page page (do
-                                   (db/transact! repo [{:page/name page-name
-                                                        :page/original-name path-page-name}])
-                                   (db/entity repo [:page/name page-name])))
-              properties (:page/properties page)
-              page-name (:page/name page)
-              page-original-name (:page/original-name page)
-              file (:page/file page)
+                                   (db/transact! repo [{:block/name page-name
+                                                        :block/original-name path-page-name}])
+                                   (db/entity repo [:block/name page-name])))
+              properties (:block/properties page)
+              page-name (:block/name page)
+              page-original-name (:block/original-name page)
+              file (:block/file page)
               file-path (and (:db/id file) (:file/path (db/entity repo (:db/id file))))
               today? (and
                       journal?
@@ -286,8 +286,8 @@
               developer-mode? (state/sub [:ui/developer-mode?])
               published? (= "true" (:published properties))
               public? (= "true" (:public 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)))]
+          [:div.flex-1.page.relative (if (seq (:block/tags page))
+                                       (let [page-names (model/get-page-names-by-ids (map :db/id (:block/tags page)))]
                                          {:data-page-tags (text/build-data-value page-names)})
                                        {})
            [:div.relative
@@ -387,7 +387,7 @@
               [:a {:on-click (fn [e]
                                (.preventDefault e)
                                (when (gobj/get e "shiftKey")
-                                 (when-let [page (db/pull repo '[*] [:page/name page-name])]
+                                 (when-let [page (db/pull repo '[*] [:block/name page-name])]
                                    (state/sidebar-add-block!
                                     repo
                                     (:db/id page)
@@ -512,7 +512,7 @@
            [:table.table-auto
             [:thead
              [:tr
-              [:th (t :page/name)]
+              [:th (t :block/name)]
               [:th (t :file/last-modified-at)]]]
             [:tbody
              (for [page pages]
@@ -520,7 +520,7 @@
                  [:tr {:key encoded-page}
                   [:td [:a {:on-click (fn [e]
                                         (let [repo (state/get-current-repo)
-                                              page (db/pull repo '[*] [:page/name (string/lower-case page)])]
+                                              page (db/pull repo '[*] [:block/name (string/lower-case page)])]
                                           (when (gobj/get e "shiftKey")
                                             (state/sidebar-add-block!
                                              repo

+ 5 - 5
src/main/frontend/components/right_sidebar.cljs

@@ -64,7 +64,7 @@
                    :href     (rfe/href :page {:name page})
                    :on-click (fn [e]
                                (when (gobj/get e "shiftKey")
-                                 (when-let [page (db/pull [:page/name (string/lower-case page)])]
+                                 (when-let [page (db/pull [:block/name (string/lower-case page)])]
                                    (state/sidebar-add-block!
                                     (state/get-current-repo)
                                     (:db/id page)
@@ -76,7 +76,7 @@
 (rum/defc contents < rum/reactive db-mixins/query
   []
   [:div.contents.flex-col.flex.ml-3
-   (when-let [contents (db/entity [:page/name "contents"])]
+   (when-let [contents (db/entity [:block/name "contents"])]
      (page/contents-page contents))])
 
 (defn build-sidebar-item
@@ -85,7 +85,7 @@
     :contents
     [[:a {:on-click (fn [e]
                       (util/stop e)
-                      (if-not (db/entity [:page/name "contents"])
+                      (if-not (db/entity [:block/name "contents"])
                         (page-handler/create! "contents")
                         (route-handler/redirect! {:to          :page
                                                   :path-params {:name "contents"}})))}
@@ -124,7 +124,7 @@
           (block-cp repo idx block-data)]]))
 
     :page
-    (let [page-name (:page/name block-data)]
+    (let [page-name (:block/name block-data)]
       [[:a {:href     (rfe/href :page {:name page-name})
             :on-click (fn [e]
                         (when (gobj/get e "shiftKey")
@@ -134,7 +134,7 @@
         (page-cp repo page-name)]])
 
     :page-presentation
-    (let [page-name (get-in block-data [:page :page/name])
+    (let [page-name (get-in block-data [:page :block/name])
           journal? (:journal? block-data)
           blocks (db/get-page-blocks repo page-name)
           blocks (if journal?

+ 4 - 4
src/main/frontend/components/search.cljs

@@ -173,7 +173,7 @@
 
                         :block
                         (let [block-uuid (uuid (:block/uuid data))
-                              page (:page/name (:block/page (db/entity [:block/uuid block-uuid])))]
+                              page (:block/name (:block/page (db/entity [:block/uuid block-uuid])))]
                           (route/redirect! {:to :page
                                             :path-params {:name page}
                                             :query-params {:anchor (str "ls-block-" (:block/uuid data))}}))
@@ -181,7 +181,7 @@
          :on-shift-chosen (fn [{:keys [type data]}]
                             (case type
                               :page
-                              (let [page (db/entity [:page/name (string/lower-case data)])]
+                              (let [page (db/entity [:block/name (string/lower-case data)])]
                                 (state/sidebar-add-block!
                                  (state/get-current-repo)
                                  (:db/id page)
@@ -222,8 +222,8 @@
 
                           :block
                           (let [{:block/keys [page content indexes]} data
-                                page (or (:page/original-name page)
-                                         (:page/name page))]
+                                page (or (:block/original-name page)
+                                         (:block/name page))]
                             [:div.flex-1
                              [:div.text-sm.font-medium (str "-> " page)]
                              (highlight-exact-query content search-q)])

+ 1 - 1
src/main/frontend/components/sidebar.cljs

@@ -139,7 +139,7 @@
   []
   (when-let [default-home (state/get-default-home)]
     (when-let [page (:page default-home)]
-      (when (db/entity [:page/name (string/lower-case page)])
+      (when (db/entity [:block/name (string/lower-case page)])
         default-home))))
 
 (defonce sidebar-inited? (atom false))

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
src/main/frontend/config.cljs


+ 5 - 1
src/main/frontend/db.cljs

@@ -124,7 +124,7 @@
                  (let [data (:tx-data tx-report)
                        datoms (filter
                                (fn [datom]
-                                 (contains? #{:page/name :block/content} (:a datom)))
+                                 (contains? #{:block/name :block/content} (:a datom)))
                                data)]
                    (when-let [f @*sync-search-indice-f]
                      (f datoms)))))))
@@ -183,3 +183,7 @@
         (f))
       (recur))
     chan))
+
+(defn new-block-id
+  []
+  (d/squuid))

+ 3 - 3
src/main/frontend/db/default.cljs

@@ -3,7 +3,7 @@
 
 (def built-in-pages
   (mapv (fn [p]
-          {:page/name (string/lower-case p)
-           :page/original-name p
-           :page/journal? false})
+          {:block/name (string/lower-case p)
+           :block/original-name p
+           :block/journal? false})
         #{"NOW" "LATER" "DOING" "DONE" "IN-PROGRESS" "TODO" "WAIT" "WAITING" "A" "B" "C"}))

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

@@ -78,10 +78,10 @@
     (d/q '[:find ?original-name ?name
            :in $ ?tag
            :where
-           [?e :page/name ?tag]
-           [?page :page/tags ?e]
-           [?page :page/original-name ?original-name]
-           [?page :page/name ?name]]
+           [?e :block/name ?tag]
+           [?page :block/tags ?e]
+           [?page :block/original-name ?original-name]
+           [?page :block/name ?name]]
          (conn/get-conn repo)
          (string/lower-case tag-name))))
 
@@ -89,9 +89,9 @@
   [repo]
   (d/q '[:find ?page-name ?tag
          :where
-         [?page :page/tags ?e]
-         [?e :page/name ?tag]
-         [?page :page/name ?page-name]]
+         [?page :block/tags ?e]
+         [?e :block/name ?tag]
+         [?page :block/name ?page-name]]
        (conn/get-conn repo)))
 
 (defn get-pages
@@ -99,8 +99,8 @@
   (->> (d/q
         '[:find ?page-original-name
           :where
-          [?page :page/name ?page-name]
-          [(get-else $ ?page :page/original-name ?page-name) ?page-original-name]]
+          [?page :block/name ?page-name]
+          [(get-else $ ?page :block/original-name ?page-name) ?page-original-name]]
         (conn/get-conn repo))
        (map first)))
 
@@ -109,7 +109,7 @@
   (-> (d/q
        '[:find ?page-name
          :where
-         [?page :page/original-name ?page-name]]
+         [?page :block/original-name ?page-name]]
        (conn/get-conn repo))
       (db-utils/seq-flatten)))
 
@@ -119,8 +119,8 @@
     (some->> (d/q '[:find ?alias
                     :in $ ?page-name
                     :where
-                    [?page :page/name ?page-name]
-                    [?page :page/alias ?alias]]
+                    [?page :block/name ?page-name]
+                    [?page :block/alias ?alias]]
                   conn
                   page-name)
              db-utils/seq-flatten
@@ -133,14 +133,14 @@
                  (d/q '[:find (pull ?p [*])
                         :in $ ?alias
                         :where
-                        [?a :page/name ?alias]
-                        [?p :page/alias ?a]]
+                        [?a :block/name ?alias]
+                        [?p :block/alias ?a]]
                       conn
                       alias)
                  (db-utils/seq-flatten))]
       (when (seq pages)
         (some (fn [page]
-                (let [aliases (->> (get-in page [:page/properties :alias])
+                (let [aliases (->> (get-in page [:block/properties :alias])
                                    (map string/lower-case)
                                    set)]
                   (when (contains? aliases alias)
@@ -222,7 +222,7 @@
              :in $ ?path
              :where
              [?file :file/path ?path]
-             [?page :page/file ?file]]
+             [?page :block/file ?file]]
            (conn/get-conn repo-url) path)
       db-utils/seq-flatten))
 
@@ -305,28 +305,28 @@
 
 (defn get-page-format
   [page-name]
-  (when-let [file (:page/file (db-utils/entity [:page/name page-name]))]
+  (when-let [file (:block/file (db-utils/entity [:block/name page-name]))]
     (when-let [path (:file/path (db-utils/entity (:db/id file)))]
       (format/get-format path))))
 
 (defn page-alias-set
   [repo-url page]
-  (when-let [page-id (:db/id (db-utils/entity repo-url [:page/name page]))]
+  (when-let [page-id (:db/id (db-utils/entity repo-url [:block/name page]))]
     (->>
      (d/q '[:find ?e
             :in $ ?page-name %
             :where
-            [?page :page/name ?page-name]
+            [?page :block/name ?page-name]
             (alias ?page ?e)]
           (conn/get-conn repo-url)
           page
           '[[(alias ?e2 ?e1)
-             [?e2 :page/alias ?e1]]
+             [?e2 :block/alias ?e1]]
             [(alias ?e2 ?e1)
-             [?e1 :page/alias ?e2]]
+             [?e1 :block/alias ?e2]]
             [(alias ?e3 ?e1)
-             [?e1 :page/alias ?e2]
-             [?e2 :page/alias ?e3]]])
+             [?e1 :block/alias ?e2]
+             [?e2 :block/alias ?e3]]])
      db-utils/seq-flatten
      (set)
      (set/union #{page-id}))))
@@ -336,8 +336,8 @@
    (get-page-names-by-ids (state/get-current-repo) ids))
   ([repo ids]
    (when repo
-     (->> (db-utils/pull-many repo '[:page/name] ids)
-          (map :page/name)))))
+     (->> (db-utils/pull-many repo '[:block/name] ids)
+          (map :block/name)))))
 
 (defn get-page-ids-by-names
   ([names]
@@ -345,7 +345,7 @@
   ([repo names]
    (when repo
      (let [lookup-refs (map (fn [name]
-                              [:page/name (string/lower-case name)]) names)]
+                              [:block/name (string/lower-case name)]) names)]
        (->> (db-utils/pull-many repo '[:db/id] lookup-refs)
             (mapv :db/id))))))
 
@@ -386,7 +386,7 @@
 (defn sort-blocks
   [blocks]
   (let [pages-ids (map (comp :db/id :block/page) blocks)
-        pages (db-utils/pull-many '[:db/id :page/name :page/original-name :page/journal-day] pages-ids)
+        pages (db-utils/pull-many '[:db/id :block/name :block/original-name :block/journal-day] pages-ids)
         pages-map (reduce (fn [acc p] (assoc acc (:db/id p) p)) {} pages)
         blocks (map
                 (fn [block]
@@ -417,8 +417,8 @@
 
 (defn get-page-properties
   [page]
-  (when-let [page (db-utils/entity [:page/name page])]
-    (:page/properties page)))
+  (when-let [page (db-utils/entity [:block/name page])]
+    (:block/properties page)))
 
 (defn add-properties!
   [page-format properties-content properties]
@@ -469,8 +469,8 @@
                    :or {use-cache? true
                         pull-keys '[*]}}]
    (let [page (string/lower-case page)
-         page-id (or (:db/id (db-utils/entity repo-url [:page/name page]))
-                     (:db/id (db-utils/entity repo-url [:page/original-name page])))
+         page-id (or (:db/id (db-utils/entity repo-url [:block/name page]))
+                     (:db/id (db-utils/entity repo-url [:block/original-name page])))
          db (conn/get-conn repo-url)]
      (when page-id
        (some->
@@ -492,8 +492,8 @@
   ([repo-url page {:keys [pull-keys]
                    :or {pull-keys '[*]}}]
    (let [page (string/lower-case page)
-         page-id (or (:db/id (db-utils/entity repo-url [:page/name page]))
-                     (:db/id (db-utils/entity repo-url [:page/original-name page])))
+         page-id (or (:db/id (db-utils/entity repo-url [:block/name page]))
+                     (:db/id (db-utils/entity repo-url [:block/original-name page])))
          db (conn/get-conn repo-url)]
      (when page-id
        (let [datoms (d/datoms db :avet :block/page page-id)
@@ -533,7 +533,7 @@
 (defn get-block-page-end-pos
   [repo page-name]
   (or
-   (when-let [page-id (:db/id (db-utils/entity repo [:page/name (string/lower-case page-name)]))]
+   (when-let [page-id (:db/id (db-utils/entity repo [:block/name (string/lower-case page-name)]))]
      (when-let [db (conn/get-conn repo)]
        (let [block-eids (->> (d/datoms db :avet :block/page page-id)
                              (mapv :e))]
@@ -690,29 +690,29 @@
              :in $ ?path
              :where
              [?file :file/path ?path]
-             [?page :page/file ?file]
-             [?page :page/original-name ?page-name]]
+             [?page :block/file ?file]
+             [?page :block/original-name ?page-name]]
            '[:find ?page-name
              :in $ ?path
              :where
              [?file :file/path ?path]
-             [?page :page/file ?file]
-             [?page :page/name ?page-name]])
+             [?page :block/file ?file]
+             [?page :block/name ?page-name]])
          conn file-path)
         db-utils/seq-flatten
         first)))))
 
 (defn get-page-file
   [page-name]
-  (some-> (db-utils/entity [:page/name page-name])
-          :page/file))
+  (some-> (db-utils/entity [:block/name page-name])
+          :block/file))
 
 (defn get-block-file
   [block-id]
   (let [page-id (some-> (db-utils/entity [:block/uuid block-id])
                         :block/page
                         :db/id)]
-    (:page/file (db-utils/entity page-id))))
+    (:block/file (db-utils/entity page-id))))
 
 (defn get-file-page-id
   [file-path]
@@ -724,7 +724,7 @@
           :in $ ?path
           :where
           [?file :file/path ?path]
-          [?page :page/file ?file]]
+          [?page :block/file ?file]]
         conn file-path)
        db-utils/seq-flatten
        first))))
@@ -733,7 +733,7 @@
   [page-name]
   (if (util/uuid-string? page-name)
     (db-utils/entity [:block/uuid (uuid page-name)])
-    (db-utils/entity [:page/name page-name])))
+    (db-utils/entity [:block/name page-name])))
 
 (defn- heading-block?
   [block]
@@ -765,9 +765,9 @@
 (defn get-page-original-name
   [page-name]
   (when page-name
-    (let [page (db-utils/pull [:page/name (string/lower-case page-name)])]
-      (or (:page/original-name page)
-          (:page/name page)))))
+    (let [page (db-utils/pull [:block/name (string/lower-case page-name)])]
+      (or (:block/original-name page)
+          (:block/name page)))))
 
 (defn get-block-content
   [utf8-content block]
@@ -785,8 +785,8 @@
     (d/q '[:find (count ?page) .
            :in $ ?today
            :where
-           [?page :page/journal? true]
-           [?page :page/journal-day ?journal-day]
+           [?page :block/journal? true]
+           [?page :block/journal-day ?journal-day]
            [(<= ?journal-day ?today)]]
          (conn/get-conn (state/get-current-repo))
          today)))
@@ -804,9 +804,9 @@
                            '[:find ?page-name ?journal-day
                              :in $ ?today
                              :where
-                             [?page :page/name ?page-name]
-                             [?page :page/journal? true]
-                             [?page :page/journal-day ?journal-day]
+                             [?page :block/name ?page-name]
+                             [?page :block/journal? true]
+                             [?page :block/journal-day ?journal-day]
                              [(<= ?journal-day ?today)]]
                            today)
                   (react)
@@ -825,7 +825,7 @@
   [repo page]
   (when (conn/get-conn repo)
     (let [pages (page-alias-set repo page)
-          page-id (:db/id (db-utils/entity [:page/name page]))
+          page-id (:db/id (db-utils/entity [:block/name page]))
           ref-pages (->> (react/q repo [:page/ref-pages page-id] {:use-cache? false}
                                   '[:find ?ref-page-name
                                     :in $ ?pages
@@ -833,7 +833,7 @@
                                     [?block :block/page ?p]
                                     [(contains? ?pages ?p)]
                                     [?block :block/ref-pages ?ref-page]
-                                    [?ref-page :page/name ?ref-page-name]]
+                                    [?ref-page :block/name ?ref-page-name]]
                                   pages)
                          react
                          db-utils/seq-flatten)]
@@ -847,11 +847,11 @@
        '[:find [?ref-page ...]
          :in $ % ?page
          :where
-         [?p :page/name ?page]
+         [?p :block/name ?page]
          [?b :block/path-ref-pages ?p]
          [?b :block/ref-pages ?other-p]
          [(not= ?p ?other-p)]
-         [?other-p :page/name ?ref-page]]
+         [?other-p :block/name ?ref-page]]
        conn
        rules
        page)
@@ -865,15 +865,15 @@
      (d/q
       '[:find ?page
         :where
-        [?p :page/name ?page]
-        (not [?p :page/file])]
+        [?p :block/name ?page]
+        (not [?p :block/file])]
       conn)
      (db-utils/seq-flatten)
      (distinct))))
 
 (defn page-empty?
   [repo page]
-  (nil? (:page/file (db-utils/entity repo [:page/name (string/lower-case page)]))))
+  (nil? (:block/file (db-utils/entity repo [:block/name (string/lower-case page)]))))
 
 (defn get-pages-relation
   [repo with-journal?]
@@ -881,17 +881,17 @@
     (let [q (if with-journal?
               '[:find ?page ?ref-page-name
                 :where
-                [?p :page/name ?page]
+                [?p :block/name ?page]
                 [?block :block/page ?p]
                 [?block :block/ref-pages ?ref-page]
-                [?ref-page :page/name ?ref-page-name]]
+                [?ref-page :block/name ?ref-page-name]]
               '[:find ?page ?ref-page-name
                 :where
-                [?p :page/journal? false]
-                [?p :page/name ?page]
+                [?p :block/journal? false]
+                [?p :block/name ?page]
                 [?block :block/page ?p]
                 [?block :block/ref-pages ?ref-page]
-                [?ref-page :page/name ?ref-page-name]])]
+                [?ref-page :block/name ?ref-page-name]])]
       (->>
        (d/q q conn)
        (map (fn [[page ref-page-name]]
@@ -901,7 +901,7 @@
 (defn get-pages-that-mentioned-page
   [repo page]
   (when (conn/get-conn repo)
-    (let [page-id (:db/id (db-utils/entity [:page/name page]))
+    (let [page-id (:db/id (db-utils/entity [:block/name page]))
           pages (page-alias-set repo page)
           mentioned-pages (->> (react/q repo [:page/mentioned-pages page-id] {:use-cache? false}
                                         '[:find ?mentioned-page-name
@@ -910,7 +910,7 @@
                                           [?block :block/ref-pages ?p]
                                           [(contains? ?pages ?p)]
                                           [?block :block/page ?mentioned-page]
-                                          [?mentioned-page :page/name ?mentioned-page-name]]
+                                          [?mentioned-page :block/name ?mentioned-page-name]]
                                         pages
                                         page)
                                react
@@ -953,7 +953,7 @@
   ([repo page]
    (when repo
      (when (conn/get-conn repo)
-       (let [page-id (:db/id (db-utils/entity [:page/name page]))
+       (let [page-id (:db/id (db-utils/entity [:block/name page]))
              pages (page-alias-set repo page)
              aliases (set/difference pages #{page-id})
              query-result (if (seq aliases)
@@ -989,7 +989,7 @@
                          db-utils/group-by-page
                          (map (fn [[k blocks]]
                                 (let [k (if (contains? aliases (:db/id k))
-                                          (assoc k :page/alias? true)
+                                          (assoc k :block/alias? true)
                                           k)]
                                   [k blocks]))))]
          result)))))
@@ -1022,7 +1022,7 @@
               :where
               [?block :block/ref-pages ?page-id]
               [?block :block/page ?p]
-              [?p :page/file ?f]
+              [?p :block/file ?f]
               [?f :file/path ?path]]
             db
             page-id)
@@ -1032,7 +1032,7 @@
   [page]
   (when-let [repo (state/get-current-repo)]
     (when-let [conn (conn/get-conn repo)]
-      (let [page-id (:db/id (db-utils/entity [:page/name page]))
+      (let [page-id (:db/id (db-utils/entity [:block/name page]))
             pages (page-alias-set repo page)
             pattern (re-pattern (str "(?i)" page))]
         (->> (d/q
@@ -1091,7 +1091,7 @@
                                  :block/content
                                  :block/properties
                                  :block/format
-                                 {:block/page [:page/name]}])))))
+                                 {:block/page [:block/name]}])))))
 
 ;; TODO: Does the result preserves the order of the arguments?
 (defn get-blocks-contents
@@ -1102,7 +1102,7 @@
 
 (defn journal-page?
   [page-name]
-  (:page/journal? (db-utils/entity [:page/name page-name])))
+  (:block/journal? (db-utils/entity [:block/name page-name])))
 
 (defn mark-repo-as-cloned!
   [repo-url]
@@ -1145,7 +1145,7 @@
   (-> (d/q
        '[:find ?p
          :where
-         [?p :page/properties ?d]
+         [?p :block/properties ?d]
          [(get ?d :public) ?pub]
          [(= "true" ?pub)]]
        db)
@@ -1259,18 +1259,18 @@
   (let [pages (->> (mapv get-file-page files)
                    (remove nil?))]
     (when (seq pages)
-      (mapv (fn [page] [:db.fn/retractEntity [:page/name page]]) (map string/lower-case pages)))))
+      (mapv (fn [page] [:db.fn/retractEntity [:block/name page]]) (map string/lower-case pages)))))
 
 (defn remove-all-aliases!
   [repo]
   (let [page-ids (->>
                   (d/q '[:find ?e
                          :where
-                         [?e :page/alias]]
+                         [?e :block/alias]]
                        (conn/get-conn repo))
                   (apply concat)
                   (distinct))
-        tx-data (map (fn [page-id] [:db/retract page-id :page/alias]) page-ids)]
+        tx-data (map (fn [page-id] [:db/retract page-id :block/alias]) page-ids)]
     (when (seq tx-data)
       (db-utils/transact! repo tx-data))))
 

+ 11 - 11
src/main/frontend/db/query_dsl.cljs

@@ -146,7 +146,7 @@
        page-ref?
        (let [page-name (-> (text/page-ref-un-brackets! e)
                            (string/lower-case))]
-         [['?b :block/path-ref-pages [:page/name page-name]]])
+         [['?b :block/path-ref-pages [:block/name page-name]]])
 
        (contains? #{'and 'or 'not} fe)
        (let [clauses (->> (map (fn [form]
@@ -192,8 +192,8 @@
              end (->journal-day-int (nth e 2))
              [start end] (sort [start end])]
          [['?b :block/page '?p]
-          ['?p :page/journal? true]
-          ['?p :page/journal-day '?d]
+          ['?p :block/journal? true]
+          ['?p :block/journal-day '?d]
           [(list '>= '?d start)]
           [(list '<= '?d end)]])
 
@@ -273,7 +273,7 @@
        (= 'page fe)
        (let [page-name (string/lower-case (first (rest e)))
              page-name (text/page-ref-un-brackets! page-name)]
-         [['?b :block/page [:page/name page-name]]])
+         [['?b :block/page [:block/name page-name]]])
 
        (= 'page-property fe)
        (let [[k v] (rest e)]
@@ -281,13 +281,13 @@
            (let [v (some->> (name (nth e 2))
                             (text/page-ref-un-brackets!))
                  sym '?v]
-             [['?p :page/properties '?prop]
+             [['?p :block/properties '?prop]
               [(list 'get '?prop (keyword (nth e 1))) sym]
               (list
                'or
                [(list '= sym v)]
                [(list 'contains? sym v)])])
-           [['?p :page/properties '?prop]
+           [['?p :block/properties '?prop]
             [(list 'get '?prop (keyword (nth e 1)))]]))
 
        (= 'page-tags fe)
@@ -300,12 +300,12 @@
              (let [tags (set (map (comp text/page-ref-un-brackets! string/lower-case name) tags))]
                (let [sym-1 (uniq-symbol counter "?t")
                      sym-2 (uniq-symbol counter "?tag")]
-                 [['?p :page/tags sym-1]
-                  [sym-1 :page/name sym-2]
+                 [['?p :block/tags sym-1]
+                  [sym-1 :block/name sym-2]
                   [(list 'contains? tags sym-2)]])))))
 
        (= 'all-page-tags fe)
-       [['?e :page/tags '?p]]
+       [['?e :block/tags '?p]]
 
        :else
        nil))))
@@ -334,13 +334,13 @@
     (if not?
       (cond
         (and b? p?)
-        (concat [['?b :block/uuid] ['?p :page/name] ['?b :block/page '?p]] q)
+        (concat [['?b :block/uuid] ['?p :block/name] ['?b :block/page '?p]] q)
 
         b?
         (concat [['?b :block/uuid]] q)
 
         p?
-        (concat [['?p :page/name]] q)
+        (concat [['?p :block/name]] q)
 
         :else
         q)

+ 2 - 2
src/main/frontend/db/react.cljs

@@ -175,7 +175,7 @@
                (date/journal-name))]
     (when page
       (let [page-name (util/url-decode (string/lower-case page))]
-        (db-utils/entity [:page/name page-name])))))
+        (db-utils/entity [:block/name page-name])))))
 
 (defn get-current-priority
   []
@@ -240,7 +240,7 @@
                              (apply concat
                                     (for [{:block/keys [ref-pages]} blocks]
                                       (map (fn [page]
-                                             (when-let [page (db-utils/entity [:page/name (:page/name page)])]
+                                             (when-let [page (db-utils/entity [:block/name (:block/name page)])]
                                                [:page/refed-blocks (:db/id page)]))
                                            ref-pages)))
 

+ 39 - 35
src/main/frontend/db_schema.cljs

@@ -2,19 +2,19 @@
 
 (defonce version "0.0.1")
 
+;; TODO: remove files db schema
 (def files-db-schema
   {:file/path {:db/unique :db.unique/identity}
    :file/content {}
    :file/size {}
    :file/handle {}})
 
-;; A page can corresponds to multiple files (same title),
-;; a month journal file can have multiple pages,
-;; also, each block can be treated as a page too.
+;; A page is a special block, a page can corresponds to multiple files with the same ":page/name".
 (def schema
   {:schema/version  {}
    :db/type         {}
    :db/ident        {:db/unique :db.unique/identity}
+
    :db/encrypted?    {}
    :db/encryption-keys {}
 
@@ -25,38 +25,15 @@
 
    ;; Git
    :repo/url {:db/unique :db.unique/identity}
-   :repo/cloned? {}
-   :git/status {}
-   :git/last-pulled-at {}
-   ;; last error, better we should record all the errors
-   :git/error {}
-
-   ;; file
-   :file/path {:db/unique :db.unique/identity}
-   :file/created-at {}
-   :file/last-modified-at {}
-
-   ;; toggle to comment this line to force to clone
-   :release/re-clone? {}
 
    :recent/pages {}
 
-   :page/name {:db/unique :db.unique/identity}
-   :page/original-name {:db/unique :db.unique/identity}
-   :page/file {:db/valueType :db.type/ref}
-   :page/properties {}
-   :page/alias {:db/valueType :db.type/ref
-                :db/cardinality :db.cardinality/many}
-   :page/tags {:db/valueType :db.type/ref
-               :db/cardinality :db.cardinality/many}
-   :page/journal? {}
-   :page/journal-day {}
-
-   ;; block
    :block/uuid {:db/unique :db.unique/identity}
-   :block/file {:db/valueType :db.type/ref}
    :block/format {}
+
+   ;; mldoc parsed ast
    :block/title {}
+
    ;; belongs to which page
    :block/page {:db/valueType :db.type/ref
                 :db/index true}
@@ -67,25 +44,25 @@
    :block/path-ref-pages {:db/valueType   :db.type/ref
                           :db/cardinality :db.cardinality/many}
 
-   ;; Referenced pages
-   ;; Notice: it's only for org mode, :tag1:tag2:
-   ;; Markdown tags will be only stored in :block/ref-pages
    :block/tags {:db/valueType :db.type/ref
                 :db/cardinality :db.cardinality/many}
 
+   :block/alias {:db/valueType :db.type/ref
+                 :db/cardinality :db.cardinality/many}
+
    ;; referenced blocks
    :block/ref-blocks {:db/valueType :db.type/ref
                       :db/cardinality :db.cardinality/many}
    :block/embed-blocks {:db/valueType :db.type/ref
                         :db/cardinality :db.cardinality/many}
+
    :block/embed-pages {:db/valueType :db.type/ref
                        :db/cardinality :db.cardinality/many}
    :block/content {}
-   :block/anchor {}
    :block/marker {}
    :block/priority {}
    :block/level {}
-   ;; :start-pos :end-pos
+   ;; TODO: remove :block/meta, :start-pos :end-pos
    :block/meta {}
    :block/properties {}
    :block/body {}
@@ -98,7 +75,34 @@
    :block/scheduled-ast {}
    :block/deadline {}
    :block/deadline-ast {}
-   :block/repeated? {}})
+   :block/repeated? {}
+
+   :block/created-at {}
+   :block/updated-at {}
+
+   ;; page additional attributes
+   :block/name {:db/unique :db.unique/identity}
+   :block/original-name {:db/unique :db.unique/identity}
+   :block/journal? {}
+   :block/journal-day {}
+
+   :block/file {:db/valueType :db.type/ref}
+
+   ;; file
+   :file/path {:db/unique :db.unique/identity}
+   :file/created-at {}
+   :file/last-modified-at {}
+   :file/size {}
+   :file/handle {}
+
+   ;; git
+   :repo/cloned? {}
+   :git/status {}
+   :git/last-pulled-at {}
+   ;; last error, better we should record all the errors
+   :git/error {}
+
+   })
 
 (def outline-schema
   {:schema/version {}

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

@@ -18,7 +18,7 @@ title: $today
 :END:
 ## Logseq is a _privacy-first_, _open-source_ platform for _knowledge_ sharing and management.
 ## This is a 3 minute tutorial on how to use Logseq. Let's get started!
-## (Feel free to edit anything, no change will be saved at this moment. If you do want to persist your work, click the **top-right** corner of the screen to connect LogSeq to either Github or local directory.)
+## (Feel free to edit anything, no change will be saved at this moment. If you do want to persist your work, click the **top-right** corner of the screen to connect Logseq to either Github or local directory.)
 ## Here are some tips might be useful.
 #+BEGIN_TIP
 Click to edit any block.
@@ -240,7 +240,7 @@ title: How to take dummy notes?
         :page/show-journals "Show Journals"
         :page/show-name "Show page name"
         :page/hide-name "Hide page name"
-        :page/name "Page name"
+        :block/name "Page name"
         :page/last-modified "Last modified at"
         :page/new-title "What's your new page title?"
         :publishing/pages "Pages"
@@ -476,7 +476,7 @@ title: How to take dummy notes?
         :page/show-journals "Journal anzeigen"
         :page/show-name "Seitennamen anzeigen"
         :page/hide-name "Seitennamen verbergen"
-        :page/name "Seitenname"
+        :block/name "Seitenname"
         :page/last-modified "Zuletzt geändert am"
         :page/new-title "Wie lautet der neue Seitenname?"
         :publishing/pages "Seiten"
@@ -701,7 +701,7 @@ title: How to take dummy notes?
         :page/show-journals "Afficher le Journal"
         :page/show-name "Afficher le nom de la page"
         :page/hide-name "Cacher le nom de la page"
-        :page/name "Nom de la page"
+        :block/name "Nom de la page"
         :page/last-modified "Dernières modifications à"
         :page/new-title "Quel est le nouveau titre de la page ?"
         :publishing/pages "Pages"
@@ -967,7 +967,7 @@ title: How to take dummy notes?
            :page/show-journals "显示日志"
            :page/show-name "显示页面名"
            :page/hide-name "隐藏页面名"
-           :page/name "页面名称"
+           :block/name "页面名称"
            :page/last-modified "最后更改于"
            :page/new-title "请输入新页面的名字:"
            :publishing/pages "页面"
@@ -1238,7 +1238,7 @@ title: How to take dummy notes?
              :page/show-journals "顯示日志"
              :page/show-name "顯示頁面名"
              :page/hide-name "隱藏頁面名"
-             :page/name "頁面名稱:"
+             :block/name "頁面名稱:"
              :page/last-modified "最後更改於"
              :page/new-title "請輸入新頁面的名字:"
              :publishing/pages "頁面"
@@ -1488,7 +1488,7 @@ title: How to take dummy notes?
         :page/show-journals "Wys joernale"
         :page/show-name "Wys blad naam"
         :page/hide-name "Steek bladnaam weg"
-        :page/name "Page name"
+        :block/name "Page name"
         :page/last-modified "Laaste verander op"
         :page/new-title "Wat is die nuwe blad se titel?"
         :publishing/pages "Pages"

+ 26 - 23
src/main/frontend/format/block.cljs

@@ -219,13 +219,6 @@
                               (assoc :repeated? true))))))]
     (apply merge m)))
 
-(defn block-tags->pages
-  [{:keys [tags] :as block}]
-  (if (seq tags)
-    (assoc block :tags (map (fn [tag]
-                              [:page/name (string/lower-case tag)]) tags))
-    block))
-
 (defn with-page-refs
   [{:keys [title body tags ref-pages] :as block}]
   (let [ref-pages (->> (concat tags ref-pages)
@@ -322,11 +315,18 @@
                                 (map string/lower-case)
                                 (distinct)
                                 (map (fn [p]
-                                       {:page/name p})))]
+                                       {:block/name p})))]
         (recur (rest blocks)
                (conj acc (assoc block :block/path-ref-pages path-ref-pages))
                parents)))))
 
+(defn block-tags->pages
+  [{:keys [tags] :as block}]
+  (if (seq tags)
+    (assoc block :tags (map (fn [tag]
+                              [:block/name (string/lower-case tag)]) tags))
+    block))
+
 (defn extract-blocks
   [blocks last-pos encoded-content]
   (let [blocks
@@ -359,7 +359,7 @@
                                (let [custom-id (string/trim custom-id)]
                                  (when (util/uuid-string? custom-id)
                                    (uuid custom-id))))
-                             (d/squuid))
+                             (db/new-block-id))
                       ref-pages-in-properties (:page-refs properties)
                       block (second block)
                       level (:level block)
@@ -409,12 +409,10 @@
                           (> first-block-start-pos 1)))
                    (cons
                     (merge
-                     (let [content (utf8/substring encoded-content 0 first-block-start-pos)
-                           uuid (d/squuid)]
+                     (let [content (utf8/substring encoded-content 0 first-block-start-pos)]
                        (->
-                        {:uuid uuid
+                        {:uuid (db/new-block-id)
                          :content content
-                         :anchor (str uuid)
                          :level 2
                          :meta {:start-pos 0
                                 :end-pos (or first-block-start-pos
@@ -427,17 +425,22 @@
                    blocks)]
       (with-path-refs blocks))))
 
-(defn- page-with-journal
+(defn- page-name->map
   [original-page-name]
   (when original-page-name
-    (let [page-name (string/lower-case original-page-name)]
+    (let [page-name (string/lower-case original-page-name)
+          id-m (if-let [block (db/entity [:block/name page-name])]
+                 {}
+                 {:block/uuid (db/new-block-id)})
+          m (merge
+             {:block/name page-name
+              :block/original-name original-page-name}
+             id-m)]
       (if-let [d (date/journal-title->int page-name)]
-        {:page/name page-name
-         :page/original-name original-page-name
-         :page/journal? true
-         :page/journal-day d}
-        {:page/name page-name
-         :page/original-name original-page-name}))))
+        (merge m
+         {:block/journal? true
+          :block/journal-day d})
+        m))))
 
 (defn parse-block
   ([block format]
@@ -459,7 +462,7 @@
                       (let [path-ref-pages (->> ref-pages
                                                 (remove string/blank?)
                                                 (map string/lower-case)
-                                                (map (fn [p] [:page/name p]))
+                                                (map (fn [p] [:block/name p]))
                                                 (concat parent-ref-pages))
                             block (merge
                                    block
@@ -480,7 +483,7 @@
                                      {:block/ref-pages
                                       (mapv
                                        (fn [page]
-                                         (let [page (page-with-journal page)]
+                                         (let [page (page-name->map page)]
                                            (swap! ref-pages-atom conj page)
                                            page))
                                        ref-pages)}))]

+ 1 - 1
src/main/frontend/graph.cljs

@@ -158,7 +158,7 @@
                      (let [page-name (string/lower-case (gobj/get node "id"))]
                        (if (gobj/get event "shiftKey")
                          (let [repo (state/get-current-repo)
-                               page (db/entity repo [:page/name page-name])]
+                               page (db/entity repo [:block/name page-name])]
                            (state/sidebar-add-block!
                             repo
                             (:db/id page)

+ 15 - 17
src/main/frontend/handler/block.cljs

@@ -143,7 +143,7 @@
 (defn pre-block-with-only-title?
   [repo block-id]
   (when-let [block (db/entity repo [:block/uuid block-id])]
-    (let [properties (:page/properties (:block/page block))
+    (let [properties (:block/properties (:block/page block))
           property-names (keys properties)]
       (and (every? #(contains? #{:title :filters} %) property-names)
            (let [ast (mldoc/->edn (:block/content block) (mldoc/default-config (:block/format block)))]
@@ -178,20 +178,18 @@
        (let [last-block (last blocks)
              end-pos (get-in last-block [:block/meta :end-pos] 0)
              dummy (merge last-block
-                          (let [uuid (d/squuid)]
-                            {:block/uuid uuid
-                             :block/title ""
-                             :block/content (config/default-empty-block format)
-                             :block/format format
-                             :block/level 2
-                             :block/priority nil
-                             :block/anchor (str uuid)
-                             :block/meta {:start-pos end-pos
-                                          :end-pos end-pos}
-                             :block/body nil
-                             :block/dummy? true
-                             :block/marker nil
-                             :block/pre-block? false})
+                          {:block/uuid (db/new-block-id)
+                           :block/title ""
+                           :block/content (config/default-empty-block format)
+                           :block/format format
+                           :block/level 2
+                           :block/priority nil
+                           :block/meta {:start-pos end-pos
+                                        :end-pos end-pos}
+                           :block/body nil
+                           :block/dummy? true
+                           :block/marker nil
+                           :block/pre-block? false}
                           default-option)]
          (conj blocks dummy))))))
 
@@ -203,8 +201,8 @@
                        (mapcat (fn [b] (concat (:block/ref-pages b) (:block/children-refs b))))
                        (distinct)
                        (map :db/id)
-                       (db/pull-many repo '[:db/id :page/name]))
-        ref-pages (zipmap (map :page/name ref-pages) (map :db/id ref-pages))
+                       (db/pull-many repo '[:db/id :block/name]))
+        ref-pages (zipmap (map :block/name ref-pages) (map :db/id ref-pages))
         exclude-ids (->> (map (fn [page] (get ref-pages page)) (get filters false))
                          (remove nil?)
                          (set))

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

@@ -34,9 +34,9 @@
           (fs/write-file! repo repo-dir path data nil)
           (db/transact! repo
                         [{:file/path path
-                          :page/name file
-                          :page/file [:file/path path]
-                          :page/journal? false}]))
+                          :block/name file
+                          :block/file [:file/path path]
+                          :block/journal? false}]))
          (p/catch (fn [error]
                     (prn "Write file failed, path: " path ", data: " data)
                     (js/console.dir error))))))))

+ 26 - 26
src/main/frontend/handler/editor.cljs

@@ -215,7 +215,7 @@
   [repo block]
   (if (:block/dummy? block)
     (if-let [page-id (:db/id (:block/page block))]
-      (let [page-name (:page/name (db/entity repo page-id))
+      (let [page-name (:block/name (db/entity repo page-id))
             end-pos (db/get-block-page-end-pos repo page-name)]
         (assoc block :block/meta {:start-pos end-pos
                                   :end-pos end-pos}))
@@ -309,7 +309,7 @@
 (defn compute-retract-refs
   "Computes old references to be retracted."
   [eid {:block/keys [ref-pages ref-blocks]} old-ref-pages old-ref-blocks]
-  (let [ref-pages-id    (map #(:db/id (db/get-page (:page/name %))) ref-pages)
+  (let [ref-pages-id    (map #(:db/id (db/get-page (:block/name %))) ref-pages)
         retracted-pages (reduce (fn [done current]
                                   (if (some #(= (:db/id current) %) ref-pages-id)
                                     done
@@ -434,7 +434,7 @@
 (defn- create-file-if-not-exists!
   [repo format page value]
   (let [format (name format)
-        title (string/capitalize (:page/name page))
+        title (string/capitalize (:block/name page))
         journal-page? (date/valid-journal-title? title)
         path (str
               (if journal-page?
@@ -443,7 +443,7 @@
               "/"
               (if journal-page?
                 (date/journal-title->default title)
-                (-> (:page/name page)
+                (-> (:block/name page)
                     (util/page-name-sanity))) "."
               (if (= format "markdown") "md" format))
         file-path (str "/" path)
@@ -459,15 +459,15 @@
         ;; create the file
         (let [value (re-build-block-value nil format value)
               content (str (util/default-content-with-title format
-                             (or (:page/original-name page)
-                                 (:page/name page)))
+                             (or (:block/original-name page)
+                                 (:block/name page)))
                            value)]
           (p/let [_ (fs/create-if-not-exists repo dir file-path content)]
             (file-handler/reset-file! repo path content)
             (ui-handler/re-render-root!)
 
             ;; Continue to edit the last block
-            (let [blocks (db/get-page-blocks repo (:page/name page))
+            (let [blocks (db/get-page-blocks repo (:block/name page))
                   last-block (last blocks)]
               (edit-last-block-for-new-page! last-block :max)
               (state/set-editor-op! nil))))))))
@@ -507,38 +507,38 @@
         page-id (:db/id page)
         page-properties (when pre-block?
                           (if (seq new-properties)
-                            [[:db/retract page-id :page/properties]
+                            [[:db/retract page-id :block/properties]
                              {:db/id page-id
-                              :page/properties new-properties}]
-                            [[:db/retract page-id :page/properties]]))
+                              :block/properties new-properties}]
+                            [[:db/retract page-id :block/properties]]))
         page-tags (when-let [tags (:tags new-properties)]
-                    (mapv (fn [tag] {:page/name (string/lower-case tag)
-                                     :page/original-name tag}) tags))
+                    (mapv (fn [tag] {:block/name (string/lower-case tag)
+                                     :block/original-name tag}) tags))
         page-alias (when-let [alias (:alias new-properties)]
                      (map
                       (fn [alias]
-                        {:page/original-name alias
-                         :page/name (string/lower-case alias)})
-                      (remove #{(:page/name page)} alias)))
+                        {:block/original-name alias
+                         :block/name (string/lower-case alias)})
+                      (remove #{(:block/name page)} alias)))
         pages (if (seq page-tags)
                 (concat pages page-tags)
                 pages)
         pages (remove
                (fn [page]
-                 (string/blank? (:page/name page)))
+                 (string/blank? (:block/name page)))
                pages)
         page-tags (when (and pre-block? (seq page-tags))
                     (if (seq page-tags)
-                      [[:db/retract page-id :page/tags]
+                      [[:db/retract page-id :block/tags]
                        {:db/id page-id
-                        :page/tags page-tags}]
-                      [[:db/retract page-id :page/tags]]))
+                        :block/tags page-tags}]
+                      [[:db/retract page-id :block/tags]]))
         page-alias (when (and pre-block? (seq page-alias))
                      (if (seq page-alias)
-                       [[:db/retract page-id :page/alias]
+                       [[:db/retract page-id :block/alias]
                         {:db/id page-id
-                         :page/alias page-alias}]
-                       [[:db/retract page-id :page/alias]]))]
+                         :block/alias page-alias}]
+                       [[:db/retract page-id :block/alias]]))]
     (profile
      "Save block: "
      (repo-handler/transact-react-and-alter-file!
@@ -591,7 +591,7 @@
          format (or format (state/get-preferred-format))
          page (db/entity repo (:db/id page))
          [old-properties new-properties] (when pre-block?
-                                           [(:page/properties (db/entity (:db/id page)))
+                                           [(:block/properties (db/entity (:db/id page)))
                                             (mldoc/parse-properties value format)])
          properties (compute-new-properties block new-properties value
                                             {:init-properties init-properties
@@ -1089,7 +1089,7 @@
          [[file-path new-content]])
         (when top-block?
           (route-handler/redirect! {:to :page
-                                    :path-params {:name (:page/name page)}})
+                                    :path-params {:name (:block/name page)}})
           (ui-handler/re-render-root!))
         (repo-handler/push-if-auto-enabled! repo)))))
 
@@ -1303,7 +1303,7 @@
           (let [page-id (-> (db/entity [:block/uuid block-id])
                             :block/page
                             :db/id)]
-            (when-let [page-name (:page/name (db/entity repo page-id))]
+            (when-let [page-name (:block/name (db/entity repo page-id))]
               (route-handler/redirect! {:to :page
                                         :path-params {:name page-name}})))))
       (js/window.history.back))))
@@ -1720,7 +1720,7 @@
   (let [block (state/get-edit-block)
         editing-page (and block
                           (when-let [page-id (:db/id (:block/page block))]
-                            (:page/name (db/entity page-id))))]
+                            (:block/name (db/entity page-id))))]
     (let [pages (search/page-search q 20)]
       (if editing-page
         ;; To prevent self references

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

@@ -44,9 +44,9 @@
                              (map
                               (fn [title]
                                 (let [page-name (string/lower-case title)]
-                                  {:page/name page-name
-                                   :page/journal? true
-                                   :page/journal-day (date/journal-title->int title)}))
+                                  {:block/name page-name
+                                   :block/journal? true
+                                   :block/journal-day (date/journal-title->int title)}))
                               titles))]
       (when (seq journal-pages-tx)
         (db/transact! repo journal-pages-tx)))))

+ 21 - 21
src/main/frontend/handler/extract.cljs

@@ -45,10 +45,10 @@
                                     (assoc :block/content (db/get-block-content utf8-content block)
                                            :block/file [:file/path file]
                                            :block/format format
-                                           :block/page [:page/name (string/lower-case page)]
+                                           :block/page [:block/name (string/lower-case page)]
                                            :block/ref-pages (mapv
                                                              (fn [page]
-                                                               (block/page-with-journal page))
+                                                               (block/page-name->map page))
                                                              block-ref-pages)
                                            :block/path-ref-pages block-path-ref-pages))))
                             blocks)))
@@ -66,18 +66,18 @@
                                       (extract-page-list list-content))]
                       (cond->
                         (util/remove-nils
-                         {:page/name (string/lower-case page)
-                          :page/original-name page
-                          :page/file [:file/path file]
-                          :page/journal? journal?
-                          :page/journal-day (if journal?
+                         {:block/name (string/lower-case page)
+                          :block/original-name page
+                          :block/file [:file/path file]
+                          :block/journal? journal?
+                          :block/journal-day (if journal?
                                               (date/journal-title->int page)
                                               0)})
                         (seq properties)
-                        (assoc :page/properties properties)
+                        (assoc :block/properties properties)
 
                         aliases
-                        (assoc :page/alias
+                        (assoc :block/alias
                                (map
                                  (fn [alias]
                                    (let [page-name (string/lower-case alias)
@@ -88,20 +88,20 @@
                                          aliases (if (seq aliases)
                                                    (map
                                                      (fn [alias]
-                                                       {:page/name alias})
+                                                       {:block/name alias})
                                                      aliases))]
                                      (if (seq aliases)
-                                       {:page/name page-name
-                                        :page/alias aliases}
-                                       {:page/name page-name})))
+                                       {:block/name page-name
+                                        :block/alias aliases}
+                                       {:block/name page-name})))
                                  aliases))
 
                         (:tags properties)
-                        (assoc :page/tags (let [tags (->> (:tags properties)
+                        (assoc :block/tags (let [tags (->> (:tags properties)
                                                           (remove string/blank?))]
                                             (swap! ref-tags set/union (set tags))
-                                            (map (fn [tag] {:page/name (string/lower-case tag)
-                                                            :page/original-name tag})
+                                            (map (fn [tag] {:block/name (string/lower-case tag)
+                                                            :block/original-name tag})
                                               tags))))))
                   (->> (map first pages)
                        (remove string/blank?))))
@@ -109,13 +109,13 @@
                  pages
                  (map
                   (fn [page]
-                    {:page/original-name page
-                     :page/name (string/lower-case page)})
+                    {:block/original-name page
+                     :block/name (string/lower-case page)})
                   @ref-tags)
                  (map
                   (fn [page]
-                    {:page/original-name page
-                     :page/name (string/lower-case page)})
+                    {:block/original-name page
+                     :block/name (string/lower-case page)})
                   @ref-pages))
           block-ids (mapv (fn [block]
                             {:block/uuid (:block/uuid block)})
@@ -162,7 +162,7 @@
         (let [[pages block-ids blocks] (apply map concat result)
               block-ids-set (set (map (fn [{:block/keys [uuid]}] [:block/uuid uuid]) block-ids))
               ;; To prevent "unique constraint" on datascript
-              pages-index (map #(select-keys % [:page/name]) pages)
+              pages-index (map #(select-keys % [:block/name]) pages)
               blocks (map (fn [b]
                             (-> b
                                 (update :block/ref-blocks #(set/intersection (set %) block-ids-set))

+ 2 - 2
src/main/frontend/handler/file.cljs

@@ -178,8 +178,8 @@
       (do
         (when-let [page-id (db/get-file-page-id path)]
           (db/transact! repo
-            [[:db/retract page-id :page/alias]
-             [:db/retract page-id :page/tags]]))
+            [[:db/retract page-id :block/alias]
+             [:db/retract page-id :block/tags]]))
         (reset-file! repo path content))
       (db/set-file-content! repo path content))
     (util/p-handle (write-file!)

+ 7 - 7
src/main/frontend/handler/graph.cljs

@@ -52,9 +52,9 @@
                                     (map :source links)
                                     (map :target links)]))
                        (map string/lower-case))
-        names (db/pull-many '[:page/name :page/original-name] (mapv (fn [page] [:page/name page]) all-pages))
-        names (zipmap (map :page/name names)
-                      (map (fn [x] (get x :page/original-name (:page/name x))) names))
+        names (db/pull-many '[:block/name :block/original-name] (mapv (fn [page] [:block/name page]) all-pages))
+        names (zipmap (map :block/name names)
+                      (map (fn [x] (get x :block/original-name (:block/name x))) names))
         nodes (mapv (fn [node] (assoc node :id (get names (:id node)))) nodes)
         links (mapv (fn [{:keys [source target]}]
                       {:source (get names source)
@@ -66,7 +66,7 @@
 (defn build-global-graph
   [theme show-journal?]
   (let [dark? (= "dark" theme)
-        current-page (:page/name (db/get-current-page))]
+        current-page (:block/name (db/get-current-page))]
     (when-let [repo (state/get-current-repo)]
       (let [relation (db/get-pages-relation repo show-journal?)
             tagged-pages (db/get-all-tagged-pages repo)
@@ -105,9 +105,9 @@
   (let [dark? (= "dark" theme)]
     (when-let [repo (state/get-current-repo)]
       (let [page (string/lower-case page)
-            page-entity (db/entity [:page/name page])
-            original-page-name (:page/original-name page-entity)
-            tags (:tags (:page/properties page-entity))
+            page-entity (db/entity [:block/name page])
+            original-page-name (:block/original-name page-entity)
+            tags (:tags (:block/properties page-entity))
             tags (remove #(= page %) tags)
             ref-pages (db/get-page-referenced-pages repo page)
             mentioned-pages (db/get-pages-that-mentioned-page repo page)

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

@@ -88,16 +88,16 @@
 
 (defn page-add-properties!
   [page-name properties]
-  (let [page (db/entity [:page/name page-name])
-        page-title (:or (:page/original-name page) (:page/name page))
-        file (:page/file page)]
+  (let [page (db/entity [:block/name page-name])
+        page-title (:or (:block/original-name page) (:block/name page))
+        file (:block/file page)]
     (if file
       (let [page-format (db/get-page-format page-name)
             properties-content (db/get-page-properties-content page-name)
             properties-content (if properties-content
                                  (string/trim properties-content)
                                  (config/properties-wrapper page-format))
-            file (db/entity (:db/id (:page/file page)))
+            file (db/entity (:db/id (:block/file page)))
             file-path (:file/path file)
             file-content (db/get-file file-path)
             after-content (subs file-content (inc (count properties-content)))
@@ -114,8 +114,8 @@
 (defn page-remove-property!
   [page-name k]
   (when-let [properties-content (string/trim (db/get-page-properties-content page-name))]
-    (let [page (db/entity [:page/name page-name])
-          file (db/entity (:db/id (:page/file page)))
+    (let [page (db/entity [:block/name page-name])
+          file (db/entity (:db/id (:block/file page)))
           file-path (:file/path file)
           file-content (db/get-file file-path)
           after-content (subs file-content (count properties-content))
@@ -290,7 +290,7 @@
                (p/catch (fn [err]
                           (js/console.error "error: " err))))))
 
-          (db/transact! [[:db.fn/retractEntity [:page/name page-name]]])
+          (db/transact! [[:db.fn/retractEntity [:block/name page-name]]])
 
           (ok-handler))))))
 
@@ -338,16 +338,16 @@
   (when (and old-name new-name
              (not= (string/lower-case old-name) (string/lower-case new-name)))
     (when-let [repo (state/get-current-repo)]
-      (if (db/entity [:page/name (string/lower-case new-name)])
+      (if (db/entity [:block/name (string/lower-case new-name)])
         (notification/show! "Page already exists!" :error)
-        (when-let [page (db/entity [:page/name (string/lower-case old-name)])]
-          (let [old-original-name (:page/original-name page)
-                file (:page/file page)
-                journal? (:page/journal? page)]
+        (when-let [page (db/entity [:block/name (string/lower-case old-name)])]
+          (let [old-original-name (:block/original-name page)
+                file (:block/file page)
+                journal? (:block/journal? page)]
             (d/transact! (db/get-conn repo false)
                          [{:db/id (:db/id page)
-                           :page/name (string/lower-case new-name)
-                           :page/original-name new-name}])
+                           :block/name (string/lower-case new-name)
+                           :block/original-name new-name}])
 
             (when (and file (not journal?))
               (rename-file! file new-name
@@ -437,7 +437,7 @@
                                    :file/path)]
       (if (and edit-block-file-path
                (state/org-mode-file-link? (state/get-current-repo)))
-        (if-let [ref-file-path (:file/path (:page/file (db/entity [:page/name page-name])))]
+        (if-let [ref-file-path (:file/path (:block/file (db/entity [:block/name page-name])))]
           (util/format "[[file:%s][%s]]"
                        (util/get-relative-path edit-block-file-path ref-file-path)
                        page)
@@ -534,7 +534,7 @@
 (defn page-exists?
   [page-name]
   (when page-name
-    (db/entity [:page/name page-name])))
+    (db/entity [:block/name page-name])))
 
 ;; Editor
 (defn page-not-exists-handler

+ 1 - 1
src/main/frontend/handler/repo.cljs

@@ -135,7 +135,7 @@
            path (str config/default-journals-directory "/" file-name "."
                      (config/get-file-extension format))
            file-path (str "/" path)
-           page-exists? (db/entity repo-url [:page/name (string/lower-case title)])
+           page-exists? (db/entity repo-url [:block/name (string/lower-case title)])
            empty-blocks? (empty? (db/get-page-blocks-no-cache repo-url (string/lower-case title)))]
        (when (or empty-blocks?
                  (not page-exists?))

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

@@ -56,9 +56,9 @@
               content))
           "Page no longer exists!!")
         (let [page (util/url-decode name)
-              page (db/pull [:page/name (string/lower-case page)])]
-          (or (:page/original-name page)
-              (:page/name page)
+              page (db/pull [:block/name (string/lower-case page)])]
+          (or (:block/original-name page)
+              (:block/name page)
               "Logseq"))))
     :tag
     (str "#" (util/url-decode (:name path-params)))

+ 1 - 1
src/main/frontend/history.cljs

@@ -76,7 +76,7 @@
       (doseq [path paths]
         (when-let [page (db/get-file-page path false)]
           (when (not= page current-page)
-            (let [db-id (:db/id (db/entity [:page/name page]))]
+            (let [db-id (:db/id (db/entity [:block/name page]))]
               (state/sidebar-add-block! repo db-id :page {:page page}))))))))
 
 ;; TODO: history should ignore rename transactions

+ 4 - 4
src/main/frontend/search.cljs

@@ -215,17 +215,17 @@
   (when (seq datoms)
     (when-let [repo (state/get-current-repo)]
       (let [datoms (group-by :a datoms)
-            pages (:page/name datoms)
+            pages (:block/name datoms)
             blocks (:block/content datoms)]
         (when (seq pages)
-          (let [pages-result (db/pull-many '[:db/id :page/name :page/original-name] (set (map :e pages)))
+          (let [pages-result (db/pull-many '[:db/id :block/name :block/original-name] (set (map :e pages)))
                 pages-to-add-set (->> (filter :added pages)
                                       (map :e)
                                       (set))
                 pages-to-add (->> (filter (fn [page]
                                             (contains? pages-to-add-set (:db/id page))) pages-result)
-                                  (map (fn [p] {:name (or (:page/original-name p)
-                                                          (:page/name p))})))
+                                  (map (fn [p] {:name (or (:block/original-name p)
+                                                          (:block/name p))})))
                 pages-to-remove-set (->> (remove :added pages)
                                          (map :v))]
             (swap! search-db/indices update-in [repo :pages]

+ 32 - 32
src/test/frontend/db/query_dsl_test.cljs

@@ -136,11 +136,11 @@ parent: child page 2
   (testing "Single page query"
     (are [x y] (= (q-count x) y)
       "[[page 1]]"
-      {:query '[[?b :block/path-ref-pages [:page/name "page 1"]]]
+      {:query '[[?b :block/path-ref-pages [:block/name "page 1"]]]
        :count 6}
 
       "[[page 2]]"
-      {:query '[[?b :block/path-ref-pages [:page/name "page 2"]]]
+      {:query '[[?b :block/path-ref-pages [:block/name "page 2"]]]
        :count 4}))
 
   (testing "Block properties query"
@@ -252,45 +252,45 @@ parent: child page 2
   (testing "all-page-tags queries"
     (are [x y] (= (q-count x) y)
       "(all-page-tags)"
-      {:query '[[?e :page/tags ?p]]
+      {:query '[[?e :block/tags ?p]]
        :count 3}))
 
   (testing "page-tags queries"
     (are [x y] (= (q-count x) y)
       "(page-tags [[page-tag-1]])"
-      {:query '[[?p :page/tags ?t]
-                [?t :page/name ?tag1]
+      {:query '[[?p :block/tags ?t]
+                [?t :block/name ?tag1]
                 [(contains? #{"page-tag-1"} ?tag1)]]
        :count 1}
 
       "(page-tags page-tag-2)"
-      {:query '[[?p :page/tags ?t]
-                [?t :page/name ?tag1]
+      {:query '[[?p :block/tags ?t]
+                [?t :block/name ?tag1]
                 [(contains? #{"page-tag-2"} ?tag1)]]
        :count 2}
 
       "(page-tags page-tag-1 page-tag-2)"
-      {:query '[[?p :page/tags ?t]
-                [?t :page/name ?tag1]
+      {:query '[[?p :block/tags ?t]
+                [?t :block/name ?tag1]
                 [(contains? #{"page-tag-1" "page-tag-2"} ?tag1)]]
        :count 2}
 
       "(page-tags page-TAG-1 page-tag-2)"
-      {:query '[[?p :page/tags ?t]
-                [?t :page/name ?tag1]
+      {:query '[[?p :block/tags ?t]
+                [?t :block/name ?tag1]
                 [(contains? #{"page-tag-1" "page-tag-2"} ?tag1)]]
        :count 2}
 
       "(page-tags [page-tag-1 page-tag-2])"
-      {:query '[[?p :page/tags ?t]
-                [?t :page/name ?tag1]
+      {:query '[[?p :block/tags ?t]
+                [?t :block/name ?tag1]
                 [(contains? #{"page-tag-1" "page-tag-2"} ?tag1)]]
        :count 2}))
 
   (testing "page-property queries"
     (are [x y] (= (q-count x) y)
       "(page-property parent [[child page 1]])"
-      {:query '[[?p :page/properties ?prop]
+      {:query '[[?p :block/properties ?prop]
                 [(get ?prop :parent) ?v]
                 (or
                  [(= ?v "child page 1")]
@@ -298,7 +298,7 @@ parent: child page 2
        :count 2}
 
       "(page-property parent \"child page 1\")"
-      {:query '[[?p :page/properties ?prop]
+      {:query '[[?p :block/properties ?prop]
                 [(get ?prop :parent) ?v]
                 (or
                  [(= ?v "child page 1")]
@@ -306,7 +306,7 @@ parent: child page 2
        :count 2}
 
       "(and (page-property parent [[child page 1]]) (page-property parent [[child page 2]]))"
-      {:query '([?p :page/properties ?prop]
+      {:query '([?p :block/properties ?prop]
                 [(get ?prop :parent) ?v]
                 (or [(= ?v "child page 1")] [(contains? ?v "child page 1")])
                 (or [(= ?v "child page 2")] [(contains? ?v "child page 2")]))
@@ -314,11 +314,11 @@ parent: child page 2
 
       "(or (page-property parent [[child page 1]]) (page-property parent [[child page 2]]))"
       {:query '(or (and
-                    [?p :page/properties ?prop]
+                    [?p :block/properties ?prop]
                     [(get ?prop :parent) ?v]
                     (or [(= ?v "child page 1")] [(contains? ?v "child page 1")]))
                    (and
-                    [?p :page/properties ?prop]
+                    [?p :block/properties ?prop]
                     [(get ?prop :parent) ?v]
                     (or [(= ?v "child page 2")] [(contains? ?v "child page 2")])))
        :count 3}))
@@ -327,29 +327,29 @@ parent: child page 2
   (testing "AND queries"
     (are [x y] (= (q-count x) y)
       "(and [[tag1]] [[page 2]])"
-      {:query '([?b :block/path-ref-pages [:page/name "tag1"]]
-                [?b :block/path-ref-pages [:page/name "page 2"]])
+      {:query '([?b :block/path-ref-pages [:block/name "tag1"]]
+                [?b :block/path-ref-pages [:block/name "page 2"]])
        :count 1})
 
     (are [x y] (= (q-count x) y)
       "(and [[tag1]] [[page 2]])"
-      {:query '([?b :block/path-ref-pages [:page/name "tag1"]]
-                [?b :block/path-ref-pages [:page/name "page 2"]])
+      {:query '([?b :block/path-ref-pages [:block/name "tag1"]]
+                [?b :block/path-ref-pages [:block/name "page 2"]])
        :count 1}))
 
   (testing "OR queries"
     (are [x y] (= (q-count x) y)
       "(or [[tag1]] [[page 2]])"
       {:query '(or
-                (and [?b :block/path-ref-pages [:page/name "tag1"]])
-                (and [?b :block/path-ref-pages [:page/name "page 2"]]))
+                (and [?b :block/path-ref-pages [:block/name "tag1"]])
+                (and [?b :block/path-ref-pages [:block/name "page 2"]]))
        :count 4}))
 
   (testing "NOT queries"
     (are [x y] (= (q-count x) y)
       "(not [[page 1]])"
       {:query '([?b :block/uuid]
-                (not [?b :block/path-ref-pages [:page/name "page 1"]]))
+                (not [?b :block/path-ref-pages [:block/name "page 1"]]))
        :count 8}))
 
   (testing "Between query"
@@ -375,15 +375,15 @@ parent: child page 2
       {:query '([?b :block/uuid]
                 [?b :block/marker ?marker]
                 [(contains? #{"DONE"} ?marker)]
-                (not [?b :block/path-ref-pages [:page/name "page 1"]]))
+                (not [?b :block/path-ref-pages [:block/name "page 1"]]))
        :count 0})
 
     (are [x y] (= (q-count x) y)
       "(and (todo now later) (or [[page 1]] [[page 2]]))"
       {:query '([?b :block/marker ?marker]
                 [(contains? #{"NOW" "LATER"} ?marker)]
-                (or (and [?b :block/path-ref-pages [:page/name "page 1"]])
-                    (and [?b :block/path-ref-pages [:page/name "page 2"]])))
+                (or (and [?b :block/path-ref-pages [:block/name "page 1"]])
+                    (and [?b :block/path-ref-pages [:block/name "page 2"]])))
        :count 3})
 
     (are [x y] (= (q-count x) y)
@@ -393,8 +393,8 @@ parent: child page 2
                  [?b :block/marker ?marker]
                  [(contains? #{"NOW" "LATER"} ?marker)]
                  (or
-                  (and [?b :block/path-ref-pages [:page/name "page 1"]])
-                  (and [?b :block/path-ref-pages [:page/name "page 2"]]))))
+                  (and [?b :block/path-ref-pages [:block/name "page 1"]])
+                  (and [?b :block/path-ref-pages [:block/name "page 2"]]))))
        :count 11})
 
     ;; FIXME: not working
@@ -412,8 +412,8 @@ parent: child page 2
                 [?b :block/marker ?marker]
                 [(contains? #{"NOW" "LATER" "DONE"} ?marker)]
                 (or
-                 (and [?b :block/path-ref-pages [:page/name "page 1"]])
-                 (and (not [?b :block/path-ref-pages [:page/name "page 1"]]))))
+                 (and [?b :block/path-ref-pages [:block/name "page 1"]])
+                 (and (not [?b :block/path-ref-pages [:block/name "page 1"]]))))
        :count 5}))
 
   (testing "sort-by (created_at defaults to desc)"

Некоторые файлы не были показаны из-за большого количества измененных файлов