mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix: remove remaining uses of file graph specific attributes
Removed all file graph uses of :block/namespace, :block/file, :block/type and :block/properties except for graph-parser which still uses them for db importer. Removed all uses of :block/format except for graph-parser and src/main/frontend
This commit is contained in:
@@ -61,14 +61,14 @@
|
||||
|
||||
;;; internal utils
|
||||
(defn ^:api get-blocks-contents
|
||||
[repo root-block-uuid & {:keys [init-level]
|
||||
[root-block-uuid & {:keys [init-level]
|
||||
:or {init-level 1}}]
|
||||
(let [block (d/entity *current-db* [:block/uuid root-block-uuid])
|
||||
link (:block/link block)
|
||||
block' (or link block)
|
||||
root-id (:block/uuid block')
|
||||
blocks (ldb/get-block-and-children *current-db* root-id)
|
||||
tree (otree/blocks->vec-tree repo *current-db* blocks root-id {:link link})]
|
||||
tree (otree/blocks->vec-tree *current-db* blocks root-id {:link link})]
|
||||
(common-file/tree->file-content *current-repo* *current-db* tree
|
||||
{:init-level init-level :link link}
|
||||
*content-config*)))
|
||||
@@ -87,7 +87,7 @@
|
||||
|
||||
(defn- block-uuid->ast-with-children
|
||||
[block-uuid]
|
||||
(let [content (get-blocks-contents *current-repo* block-uuid)
|
||||
(let [content (get-blocks-contents block-uuid)
|
||||
format :markdown]
|
||||
(when content
|
||||
(removev Properties-block-ast?
|
||||
|
||||
2
deps/cli/src/logseq/cli/common/file.cljs
vendored
2
deps/cli/src/logseq/cli/common/file.cljs
vendored
@@ -89,7 +89,7 @@
|
||||
1))
|
||||
blocks (->> (d/pull-many db '[*] (keep :db/id (ldb/get-block-and-children db root-block-uuid)))
|
||||
(map #(update-block-content db % (:db/id %))))
|
||||
tree (otree/blocks->vec-tree repo db blocks (str root-block-uuid))]
|
||||
tree (otree/blocks->vec-tree db blocks (str root-block-uuid))]
|
||||
(tree->file-content repo db tree
|
||||
(assoc tree->file-opts :init-level init-level)
|
||||
context)))
|
||||
|
||||
@@ -74,8 +74,7 @@
|
||||
block-eids (mapv :e datoms)
|
||||
block-ents (map #(d/entity db %) block-eids)
|
||||
blocks (map #(assoc % :block/title (db-content/recur-replace-uuid-in-block-title %)) block-ents)]
|
||||
;; Use repo stub since this is a DB only tool
|
||||
(->> (otree/blocks->vec-tree "logseq_db_repo_stub" db blocks page-id)
|
||||
(->> (otree/blocks->vec-tree db blocks page-id)
|
||||
(map #(update % :block/uuid str)))))
|
||||
|
||||
(defn ^:api remove-hidden-properties
|
||||
|
||||
1
deps/db/README.md
vendored
1
deps/db/README.md
vendored
@@ -15,7 +15,6 @@ This library is under the parent namespace `logseq.db`. It provides the followin
|
||||
* `logseq.db` - main entry point serving both file and DB graphs
|
||||
* `logseq.db.frontend.*` - frontend namespaces for DB graphs
|
||||
* `logseq.db.sqlite.*` - backend/sqlite namespaces for DB graphs
|
||||
* `logseq.db.file-based.*` - namespaces for file graphs, mostly old namespaces
|
||||
* `logseq.db.common.*` - namespaces for both file and DB graphs
|
||||
|
||||
## Usage
|
||||
|
||||
4
deps/db/script/query.cljs
vendored
4
deps/db/script/query.cljs
vendored
@@ -39,9 +39,7 @@
|
||||
results (if (:entity options)
|
||||
(map #(when-let [ent (d/entity @conn
|
||||
(if (string? %) (edn/read-string %) %))]
|
||||
(cond-> (into {:db/id (:db/id ent)} ent)
|
||||
(seq (:block/properties ent))
|
||||
(update :block/properties (fn [props] (map (fn [m] (into {} m)) props)))))
|
||||
(into {:db/id (:db/id ent)} ent))
|
||||
(:entity options))
|
||||
;; assumes no :in are in queries
|
||||
(let [query (into (edn/read-string (first args'')) [:in '$ '%])
|
||||
|
||||
37
deps/db/src/logseq/db.cljs
vendored
37
deps/db/src/logseq/db.cljs
vendored
@@ -421,7 +421,6 @@
|
||||
(contains? #{"" "-" "*"} (string/trim (:block/title first-child))))))
|
||||
(not (contains? built-in-pages name'))
|
||||
(not (whiteboard? page))
|
||||
(not (:block/_namespace page))
|
||||
(not (property? page))
|
||||
;; a/b/c might be deleted but a/b/c/d still exists (for backward compatibility)
|
||||
(not (and (string/includes? name' "/")
|
||||
@@ -620,30 +619,18 @@
|
||||
|
||||
(defn get-pages-relation
|
||||
[db with-journal?]
|
||||
(if (entity-plus/db-based-graph? db)
|
||||
(let [q (if with-journal?
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
[?block :block/refs ?ref-page]]
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
[?p :block/tags]
|
||||
(not [?p :block/tags :logseq.class/Journal])
|
||||
[?block :block/refs ?ref-page]])]
|
||||
(d/q q db))
|
||||
(let [q (if with-journal?
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
[?block :block/refs ?ref-page]]
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
(not [?p :block/type "journal"])
|
||||
[?block :block/refs ?ref-page]])]
|
||||
(d/q q db))))
|
||||
(let [q (if with-journal?
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
[?block :block/refs ?ref-page]]
|
||||
'[:find ?p ?ref-page
|
||||
:where
|
||||
[?block :block/page ?p]
|
||||
[?p :block/tags]
|
||||
(not [?p :block/tags :logseq.class/Journal])
|
||||
[?block :block/refs ?ref-page]])]
|
||||
(d/q q db)))
|
||||
|
||||
(defn get-all-tagged-pages
|
||||
[db]
|
||||
|
||||
18
deps/db/src/logseq/db/common/property_util.cljs
vendored
18
deps/db/src/logseq/db/common/property_util.cljs
vendored
@@ -25,20 +25,18 @@
|
||||
(get-file-pid db-ident)))
|
||||
|
||||
(defn lookup
|
||||
"Get the property value by a built-in property's db-ident from coll. For file and db graphs"
|
||||
[repo block db-ident]
|
||||
(if (sqlite-util/db-based-graph? repo)
|
||||
(let [val (get block db-ident)]
|
||||
(if (db-property/built-in-has-ref-value? db-ident) (db-property/property-value-content val) val))
|
||||
(get (:block/properties block) (get-pid repo db-ident))))
|
||||
"Get the property value by a built-in property's db-ident from coll"
|
||||
[block db-ident]
|
||||
(let [val (get block db-ident)]
|
||||
(if (db-property/built-in-has-ref-value? db-ident) (db-property/property-value-content val) val)))
|
||||
|
||||
(defn get-block-property-value
|
||||
"Get the value of built-in block's property by its db-ident"
|
||||
[repo db block db-ident]
|
||||
[db block db-ident]
|
||||
(when db
|
||||
(let [block (or (d/entity db (:db/id block)) block)]
|
||||
(lookup repo block db-ident))))
|
||||
(lookup block db-ident))))
|
||||
|
||||
(defn shape-block?
|
||||
[repo db block]
|
||||
(= :whiteboard-shape (get-block-property-value repo db block :logseq.property/ls-type)))
|
||||
[db block]
|
||||
(= :whiteboard-shape (get-block-property-value db block :logseq.property/ls-type)))
|
||||
|
||||
3
deps/db/src/logseq/db/frontend/class.cljs
vendored
3
deps/db/src/logseq/db/frontend/class.cljs
vendored
@@ -111,8 +111,7 @@
|
||||
:logseq.class/Asset})
|
||||
|
||||
(def private-tags
|
||||
"Built-in classes that are private and should not be used by a user directly.
|
||||
These used to be in block/type"
|
||||
"Built-in classes that are private and should not be used by a user directly."
|
||||
(set/union (disj internal-tags :logseq.class/Root)
|
||||
#{:logseq.class/Journal :logseq.class/Whiteboard
|
||||
:logseq.class/Pdf-annotation}))
|
||||
|
||||
26
deps/outliner/src/logseq/outliner/core.cljs
vendored
26
deps/outliner/src/logseq/outliner/core.cljs
vendored
@@ -243,8 +243,7 @@
|
||||
(let [data (if (de/entity? this)
|
||||
(assoc (.-kv ^js this) :db/id (:db/id this))
|
||||
this)
|
||||
data' (->> (dissoc data :block/properties)
|
||||
(remove-disallowed-inline-classes db))
|
||||
data' (remove-disallowed-inline-classes db data)
|
||||
collapse-or-expand? (= outliner-op :collapse-expand-blocks)
|
||||
m* (cond->
|
||||
(-> data'
|
||||
@@ -268,19 +267,16 @@
|
||||
(not= block-title (:block/title block-entity)))
|
||||
_ (when (and page? block-title)
|
||||
(outliner-validate/validate-page-title-characters block-title {:node m*}))
|
||||
m* (if page-title-changed?
|
||||
(let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*})
|
||||
page-name (common-util/page-name-sanity-lc (:block/title m*))]
|
||||
(assoc m* :block/name page-name))
|
||||
m*)
|
||||
m (if page-title-changed?
|
||||
(let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*})
|
||||
page-name (common-util/page-name-sanity-lc (:block/title m*))]
|
||||
(assoc m* :block/name page-name))
|
||||
m*)
|
||||
_ (when (and ;; page or object changed?
|
||||
(or (ldb/page? block-entity) (ldb/object? block-entity))
|
||||
(:block/title m*)
|
||||
(not= (:block/title m*) (:block/title block-entity)))
|
||||
(outliner-validate/validate-block-title db (:block/title m*) block-entity))
|
||||
m (cond-> m*
|
||||
true
|
||||
(dissoc :block/format))]
|
||||
(:block/title m)
|
||||
(not= (:block/title m) (:block/title block-entity)))
|
||||
(outliner-validate/validate-block-title db (:block/title m) block-entity))]
|
||||
;; Ensure block UUID never changes
|
||||
(let [e (d/entity db db-id)]
|
||||
(when (and e block-uuid)
|
||||
@@ -747,9 +743,7 @@
|
||||
update-timestamps?
|
||||
(mapv #(dissoc % :block/created-at :block/updated-at))
|
||||
true
|
||||
(mapv block-with-timestamps)
|
||||
true
|
||||
(mapv #(-> % (dissoc :block/properties)))))
|
||||
(mapv block-with-timestamps)))
|
||||
insert-opts {:sibling? sibling?
|
||||
:replace-empty-target? replace-empty-target?
|
||||
:keep-uuid? keep-uuid?
|
||||
|
||||
@@ -699,7 +699,7 @@
|
||||
(let [block (d/entity db eid)]
|
||||
(->>
|
||||
(concat
|
||||
(map (fn [ident] (d/entity db ident)) (keys (:block/properties block)))
|
||||
(map (fn [ident] (d/entity db ident)) (keys (entity-plus/lookup-kv-then-entity block :block/properties)))
|
||||
(:classes-properties (get-block-classes-properties db eid)))
|
||||
(common-util/distinct-by :db/id))))
|
||||
|
||||
|
||||
8
deps/outliner/src/logseq/outliner/tree.cljs
vendored
8
deps/outliner/src/logseq/outliner/tree.cljs
vendored
@@ -10,9 +10,9 @@
|
||||
(-del [this *txs-state db]))
|
||||
|
||||
(defn- blocks->vec-tree-aux
|
||||
[repo db blocks root]
|
||||
[db blocks root]
|
||||
(let [root-id (:db/id root)
|
||||
blocks (remove #(db-property-util/shape-block? repo db %) blocks)
|
||||
blocks (remove #(db-property-util/shape-block? db %) blocks)
|
||||
parent-blocks (group-by #(get-in % [:block/parent :db/id]) blocks) ;; exclude whiteboard shapes
|
||||
sort-fn (fn [parent]
|
||||
(when-let [children (get parent-blocks parent)]
|
||||
@@ -53,14 +53,14 @@
|
||||
;; TODO: entity can already be used as a tree
|
||||
(defn blocks->vec-tree
|
||||
"`blocks` need to be in the same page."
|
||||
[repo db blocks root-id & {:as option}]
|
||||
[db blocks root-id & {:as option}]
|
||||
(let [blocks (map (fn [b] (if (de/entity? b)
|
||||
(assoc (into {} b) :db/id (:db/id b))
|
||||
b)) blocks)
|
||||
[page? root] (get-root-and-page db root-id)]
|
||||
(if-not root ; custom query
|
||||
blocks
|
||||
(let [result (blocks->vec-tree-aux repo db blocks root)]
|
||||
(let [result (blocks->vec-tree-aux db blocks root)]
|
||||
(if (and page? (not (:link option)))
|
||||
result
|
||||
;; include root block
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"Provides db fns and associated util fns for publishing"
|
||||
(:require [clojure.set :as set]
|
||||
[datascript.core :as d]
|
||||
[logseq.db.common.entity-plus :as entity-plus]
|
||||
[logseq.db.frontend.malli-schema :as db-malli-schema]
|
||||
[logseq.db.frontend.rules :as rules]))
|
||||
|
||||
@@ -25,7 +26,7 @@
|
||||
(when (seq tag-pages*)
|
||||
(some-> (d/entity db :block/tags) :db/id vector)))
|
||||
property-pages (mapcat (fn [ent]
|
||||
(->> (keys (:block/properties ent))
|
||||
(->> (keys (entity-plus/lookup-kv-then-entity ent :block/properties))
|
||||
(map #(:db/id (d/entity db %)))))
|
||||
page-ents)]
|
||||
(concat pages tag-pages property-pages)))
|
||||
|
||||
Reference in New Issue
Block a user