mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 14:14:55 +00:00
refactor: rename :block/original-name to :block/title
This commit is contained in:
4
deps/common/src/logseq/common/util.cljs
vendored
4
deps/common/src/logseq/common/util.cljs
vendored
@@ -285,9 +285,9 @@
|
||||
[]
|
||||
(tc/to-long (t/now)))
|
||||
|
||||
(defn get-page-original-name
|
||||
(defn get-page-title
|
||||
[page]
|
||||
(or (:block/original-name page)
|
||||
(or (:block/title page)
|
||||
(:block/name page)))
|
||||
|
||||
(defn string-join-path
|
||||
|
||||
8
deps/db/script/create_graph/inferred.edn
vendored
8
deps/db/script/create_graph/inferred.edn
vendored
@@ -15,7 +15,7 @@
|
||||
:attendee {:block/schema {:type :object :cardinality :many}
|
||||
:build/schema-classes [:Person]}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "Matt-Damon" :build/tags [:Person]}}
|
||||
{:page {:block/original-name "Ben-Affleck" :build/tags [:Person]}}
|
||||
{:page {:block/original-name "Tienson" :build/tags [:Person]}}
|
||||
{:page {:block/original-name "Zhiyuan" :build/tags [:Person]}}]}
|
||||
[{:page {:block/title "Matt-Damon" :build/tags [:Person]}}
|
||||
{:page {:block/title "Ben-Affleck" :build/tags [:Person]}}
|
||||
{:page {:block/title "Tienson" :build/tags [:Person]}}
|
||||
{:page {:block/title "Zhiyuan" :build/tags [:Person]}}]}
|
||||
|
||||
16
deps/db/src/logseq/db.cljs
vendored
16
deps/db/src/logseq/db.cljs
vendored
@@ -44,7 +44,7 @@
|
||||
:block/heading-level
|
||||
:block/file
|
||||
:class/parent
|
||||
{:block/page [:db/id :block/name :block/original-name :block/journal-day]}
|
||||
{:block/page [:db/id :block/name :block/title :block/journal-day]}
|
||||
{:block/_parent ...}])
|
||||
|
||||
(defonce *transact-fn (atom nil))
|
||||
@@ -176,10 +176,10 @@
|
||||
(defn get-pages
|
||||
[db]
|
||||
(->> (d/q
|
||||
'[:find ?page-original-name
|
||||
'[:find ?page-title
|
||||
:where
|
||||
[?page :block/name ?page-name]
|
||||
[(get-else $ ?page :block/original-name ?page-name) ?page-original-name]]
|
||||
[(get-else $ ?page :block/title ?page-name) ?page-title]]
|
||||
db)
|
||||
(map first)
|
||||
(remove hidden-page?)))
|
||||
@@ -208,7 +208,7 @@
|
||||
(if-let [id (if (uuid? page-name-or-uuid) page-name-or-uuid
|
||||
(parse-uuid page-name-or-uuid))]
|
||||
(d/entity db [:block/uuid id])
|
||||
(d/entity db (sqlite-common-db/get-first-page-by-original-name db page-name-or-uuid)))))
|
||||
(d/entity db (sqlite-common-db/get-first-page-by-title db page-name-or-uuid)))))
|
||||
|
||||
(defn page-empty?
|
||||
"Whether a page is empty. Does it has a non-page block?
|
||||
@@ -473,7 +473,7 @@
|
||||
[(sqlite-util/block-with-timestamps
|
||||
{:block/uuid (common-uuid/gen-uuid)
|
||||
:block/name common-config/favorites-page-name
|
||||
:block/original-name common-config/favorites-page-name
|
||||
:block/title common-config/favorites-page-name
|
||||
:block/type #{"page" "hidden"}
|
||||
:block/format :markdown})]))
|
||||
|
||||
@@ -493,7 +493,7 @@
|
||||
[(sqlite-util/block-with-timestamps
|
||||
{:block/uuid page-id
|
||||
:block/name common-config/views-page-name
|
||||
:block/original-name common-config/views-page-name
|
||||
:block/title common-config/views-page-name
|
||||
:block/type #{"page" "hidden"}
|
||||
:block/format :markdown})
|
||||
(sqlite-util/block-with-timestamps
|
||||
@@ -530,7 +530,7 @@
|
||||
[db namespace {:keys [db-graph?]}]
|
||||
(assert (string? namespace))
|
||||
(let [namespace (common-util/page-name-sanity-lc namespace)
|
||||
pull-attrs (cond-> [:db/id :block/name :block/original-name :block/namespace]
|
||||
pull-attrs (cond-> [:db/id :block/name :block/title :block/namespace]
|
||||
(not db-graph?)
|
||||
(conj {:block/file [:db/id :file/path]}))]
|
||||
(d/q
|
||||
@@ -554,7 +554,7 @@
|
||||
(map :e))]
|
||||
(when (seq ids)
|
||||
(d/pull-many db
|
||||
'[:db/id :block/name :block/original-name]
|
||||
'[:db/id :block/name :block/title]
|
||||
ids)))))
|
||||
|
||||
(defn get-all-properties
|
||||
|
||||
12
deps/db/src/logseq/db/frontend/class.cljs
vendored
12
deps/db/src/logseq/db/frontend/class.cljs
vendored
@@ -5,13 +5,13 @@
|
||||
|
||||
(def ^:large-vars/data-var built-in-classes
|
||||
"Map of built-in classes for db graphs with their :db/ident as keys"
|
||||
{:logseq.class/Root {:original-name "Root class"}
|
||||
{:logseq.class/Root {:title "Root class"}
|
||||
|
||||
:logseq.class/task
|
||||
{:original-name "Task"
|
||||
{:title "Task"
|
||||
:schema {:properties [:logseq.task/status :logseq.task/priority :logseq.task/deadline]}}
|
||||
|
||||
:logseq.class/Card {:original-name "Card"
|
||||
:logseq.class/Card {:title "Card"
|
||||
;; :schema {:property []}
|
||||
}
|
||||
;; TODO: Add more classes such as :book, :paper, :movie, :music, :project
|
||||
@@ -27,12 +27,12 @@
|
||||
"Builds a new class with a unique :db/ident. Also throws exception for user
|
||||
facing messages when name is invalid"
|
||||
[db page-m]
|
||||
{:pre [(string? (:block/original-name page-m))]}
|
||||
(let [db-ident (try (create-user-class-ident-from-name (:block/original-name page-m))
|
||||
{:pre [(string? (:block/title page-m))]}
|
||||
(let [db-ident (try (create-user-class-ident-from-name (:block/title page-m))
|
||||
(catch :default e
|
||||
(throw (ex-info (str e)
|
||||
{:type :notification
|
||||
:payload {:message "Failed to create class. Please try a different class name."
|
||||
:type :error}}))))
|
||||
db-ident' (db-ident/ensure-unique-db-ident db db-ident)]
|
||||
(sqlite-util/build-new-class (assoc page-m :db/ident db-ident'))))
|
||||
(sqlite-util/build-new-class (assoc page-m :db/ident db-ident'))))
|
||||
|
||||
14
deps/db/src/logseq/db/frontend/content.cljs
vendored
14
deps/db/src/logseq/db/frontend/content.cljs
vendored
@@ -28,11 +28,11 @@
|
||||
page-ref-special-chars
|
||||
(:block/uuid ref)
|
||||
page-ref/right-brackets)
|
||||
(:block/original-name ref))
|
||||
(:block/title ref))
|
||||
(string/replace
|
||||
(str "#" page-ref-special-chars
|
||||
(:block/uuid ref))
|
||||
(str "#" (:block/original-name ref))))
|
||||
(str "#" (:block/title ref))))
|
||||
content))
|
||||
content
|
||||
refs))
|
||||
@@ -53,12 +53,12 @@
|
||||
page-ref-special-chars
|
||||
(:block/uuid ref)
|
||||
page-ref/right-brackets)
|
||||
(page-ref/->page-ref (:block/original-name ref)))
|
||||
(page-ref/->page-ref (:block/title ref)))
|
||||
;; Replace tags
|
||||
(string/replace
|
||||
(str "#" page-ref-special-chars
|
||||
(:block/uuid ref))
|
||||
(str "#" (:block/original-name ref))))
|
||||
(str "#" (:block/title ref))))
|
||||
|
||||
content))
|
||||
content
|
||||
@@ -80,7 +80,7 @@
|
||||
(fn [content ref]
|
||||
(string/replace content
|
||||
(str page-ref/left-brackets
|
||||
(:block/original-name ref)
|
||||
(:block/title ref)
|
||||
page-ref/right-brackets)
|
||||
(str page-ref/left-brackets
|
||||
page-ref-special-chars
|
||||
@@ -122,10 +122,10 @@
|
||||
(fn [content tag]
|
||||
(common-util/replace-ignore-case
|
||||
content
|
||||
(str "#" (:block/original-name tag))
|
||||
(str "#" (:block/title tag))
|
||||
(str page-ref/left-brackets
|
||||
page-ref-special-chars
|
||||
(:block/uuid tag)
|
||||
page-ref/right-brackets)))
|
||||
content
|
||||
(sort-by :block/original-name > tags)))
|
||||
(sort-by :block/title > tags)))
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
(sort-by :block/order))
|
||||
|
||||
:object/name
|
||||
(or (lookup-entity e :block/original-name nil)
|
||||
(or (lookup-entity e :block/title nil)
|
||||
(lookup-entity e :block/content nil))
|
||||
|
||||
(or (get (.-kv e) k)
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
(def page-attrs
|
||||
"Common attributes for pages"
|
||||
[[:block/name :string]
|
||||
[:block/original-name :string]
|
||||
[:block/title :string]
|
||||
[:block/type [:set [:enum "page" "class" "property" "whiteboard" "journal" "hidden"]]]
|
||||
[:block/alias {:optional true} [:set :int]]
|
||||
;; TODO: Should this be here or in common?
|
||||
|
||||
20
deps/db/src/logseq/db/frontend/property.cljs
vendored
20
deps/db/src/logseq/db/frontend/property.cljs
vendored
@@ -19,25 +19,25 @@
|
||||
* :view-context - Keyword to indicate which view contexts a property can be
|
||||
seen in when :public? is set. Valid values are :page and :block. Property can
|
||||
be viewed in any context if not set
|
||||
* :original-name - Property's :block/original-name
|
||||
* :title - Property's :block/title
|
||||
* :name - Property's :block/name as a keyword. If none given, one is derived from the db/ident
|
||||
* :attribute - Property keyword that is saved to a datascript attribute outside of :block/properties
|
||||
* :closed-values - Vec of closed-value maps for properties with choices. Map
|
||||
has keys :value, :db-ident, :uuid and :icon"
|
||||
(ordered-map
|
||||
:block/alias {:original-name "Alias"
|
||||
:block/alias {:title "Alias"
|
||||
:attribute :block/alias
|
||||
:schema {:type :page
|
||||
:cardinality :many
|
||||
:view-context :page
|
||||
:public? true}}
|
||||
:block/tags {:original-name "Tags"
|
||||
:block/tags {:title "Tags"
|
||||
:attribute :block/tags
|
||||
:schema {:type :page
|
||||
:cardinality :many
|
||||
:public? true
|
||||
:classes #{:logseq.class/Root}}}
|
||||
:logseq.property/page-tags {:original-name "pageTags"
|
||||
:logseq.property/page-tags {:title "pageTags"
|
||||
:schema {:type :page
|
||||
:public? true
|
||||
:view-context :page
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
;; Task props
|
||||
:logseq.task/status
|
||||
{:original-name "Status"
|
||||
{:title "Status"
|
||||
:schema
|
||||
{:type :default
|
||||
:public? true
|
||||
@@ -117,7 +117,7 @@
|
||||
[:logseq.task/status.done "Done" "Done"]
|
||||
[:logseq.task/status.canceled "Canceled" "Cancelled"]])}
|
||||
:logseq.task/priority
|
||||
{:original-name "Priority"
|
||||
{:title "Priority"
|
||||
:schema
|
||||
{:type :default
|
||||
:public? true
|
||||
@@ -133,14 +133,14 @@
|
||||
[:logseq.task/priority.medium "Medium" "priorityLvlMedium"]
|
||||
[:logseq.task/priority.low "Low" "priorityLvlLow"]])}
|
||||
:logseq.task/deadline
|
||||
{:original-name "Deadline"
|
||||
{:title "Deadline"
|
||||
:schema {:type :date
|
||||
:public? true
|
||||
:position :block-below}}
|
||||
|
||||
;; TODO: Add more props :Assignee, :Estimate, :Cycle, :Project
|
||||
|
||||
:logseq.property/icon {:original-name "Icon"
|
||||
:logseq.property/icon {:title "Icon"
|
||||
:schema {:type :map}}
|
||||
:logseq.property/public {:schema
|
||||
{:type :checkbox
|
||||
@@ -259,7 +259,7 @@
|
||||
(or (:block/content ent)
|
||||
(if-some [content (:property.value/content ent)]
|
||||
content
|
||||
(:block/original-name ent))))
|
||||
(:block/title ent))))
|
||||
|
||||
(defn ref->property-value-content
|
||||
"Given a ref from a pulled query e.g. `{:db/id X}`, gets a readable name for
|
||||
@@ -317,6 +317,6 @@
|
||||
[db block]
|
||||
(->> (properties block)
|
||||
(map (fn [[k v]]
|
||||
[(:block/original-name (d/entity db k))
|
||||
[(:block/title (d/entity db k))
|
||||
(ref->property-value-contents db v)]))
|
||||
(into {})))
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
the hidden page and closed value blocks as needed"
|
||||
[db-ident prop-name property {:keys [property-attributes]}]
|
||||
(let [property-schema (:block/schema property)
|
||||
property-tx (merge (sqlite-util/build-new-property db-ident property-schema {:original-name prop-name
|
||||
property-tx (merge (sqlite-util/build-new-property db-ident property-schema {:title prop-name
|
||||
:ref-type? true})
|
||||
property-attributes)]
|
||||
(into [property-tx]
|
||||
|
||||
@@ -43,8 +43,8 @@
|
||||
|
||||
(def ref-property-types
|
||||
"User facing ref types. Property values that users see are stored in either
|
||||
:property.value/content, :block/content or :block/original-name.
|
||||
:block/original-name is for all the page related types"
|
||||
:property.value/content, :block/content or :block/title.
|
||||
:block/title is for all the page related types"
|
||||
(into #{:page :date :object} value-ref-property-types))
|
||||
|
||||
(assert (set/subset? ref-property-types
|
||||
@@ -120,7 +120,7 @@
|
||||
(defn- page?
|
||||
[db val]
|
||||
(when-let [ent (d/entity db val)]
|
||||
(some? (:block/original-name ent))))
|
||||
(some? (:block/title ent))))
|
||||
|
||||
(defn- object-entity?
|
||||
[db val]
|
||||
@@ -130,7 +130,7 @@
|
||||
(defn- date?
|
||||
[db val]
|
||||
(when-let [ent (d/entity db val)]
|
||||
(and (some? (:block/original-name ent))
|
||||
(and (some? (:block/title ent))
|
||||
(contains? (:block/type ent) "journal"))))
|
||||
|
||||
|
||||
|
||||
4
deps/db/src/logseq/db/frontend/rules.cljc
vendored
4
deps/db/src/logseq/db/frontend/rules.cljc
vendored
@@ -173,7 +173,7 @@
|
||||
[?p ?prop ?pv]
|
||||
(or [?pv :block/content ?val]
|
||||
[?pv :property.value/content ?val]
|
||||
[?pv :block/original-name ?val])
|
||||
[?pv :block/title ?val])
|
||||
[?prop-e :db/ident ?prop]
|
||||
[?prop-e :block/type "property"]]
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
[?b ?prop ?pv]
|
||||
(or [?pv :block/content ?val]
|
||||
[?pv :property.value/content ?val]
|
||||
[?pv :block/original-name ?val])
|
||||
[?pv :block/title ?val])
|
||||
[(missing? $ ?b :block/name)]
|
||||
[?prop-e :db/ident ?prop]
|
||||
[?prop-e :block/type "property"]]
|
||||
|
||||
3
deps/db/src/logseq/db/frontend/schema.cljs
vendored
3
deps/db/src/logseq/db/frontend/schema.cljs
vendored
@@ -52,7 +52,6 @@
|
||||
:block/alias {:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/many}
|
||||
|
||||
;; full-text for current block
|
||||
:block/content {}
|
||||
|
||||
;; todo keywords, e.g. "TODO", "DOING", "DONE"
|
||||
@@ -88,7 +87,7 @@
|
||||
:block/name {:db/unique :db.unique/identity}
|
||||
|
||||
;; page's original name
|
||||
:block/original-name {:db/index true}
|
||||
:block/title {:db/index true}
|
||||
|
||||
;; page's journal day
|
||||
:block/journal-day {}
|
||||
|
||||
44
deps/db/src/logseq/db/sqlite/build.cljs
vendored
44
deps/db/src/logseq/db/sqlite/build.cljs
vendored
@@ -68,7 +68,7 @@
|
||||
[pages-and-blocks]
|
||||
(->> pages-and-blocks
|
||||
(map :page)
|
||||
(map (juxt :block/original-name :block/uuid))
|
||||
(map (juxt :block/title :block/uuid))
|
||||
(into {})))
|
||||
|
||||
(def current-db-id (atom 0))
|
||||
@@ -132,10 +132,10 @@
|
||||
(let [block-refs (mapv #(hash-map :block/uuid
|
||||
(or (page-uuids %)
|
||||
(throw (ex-info (str "No uuid for page ref name" (pr-str %)) {})))
|
||||
:block/original-name %)
|
||||
:block/title %)
|
||||
ref-names)]
|
||||
{:block/content (db-content/page-ref->special-id-ref (:block/content m) block-refs)
|
||||
:block/refs (map #(dissoc % :block/original-name) block-refs)})))))))
|
||||
:block/refs block-refs})))))))
|
||||
|
||||
(defn- build-properties-tx [properties page-uuids all-idents]
|
||||
(let [property-db-ids (->> (keys properties)
|
||||
@@ -186,7 +186,7 @@
|
||||
(let [new-block
|
||||
(sqlite-util/build-new-class
|
||||
{:block/name (common-util/page-name-sanity-lc (name class-name))
|
||||
:block/original-name (name class-name)
|
||||
:block/title (name class-name)
|
||||
:block/uuid (or (:block/uuid class-m) (d/squuid))
|
||||
:db/ident (get-ident all-idents class-name)
|
||||
:db/id (or (class-db-ids class-name)
|
||||
@@ -228,14 +228,14 @@
|
||||
[:build/tags {:optional true} [:vector Class]]]}}
|
||||
[:page [:and
|
||||
[:map
|
||||
[:block/original-name {:optional true} :string]
|
||||
[:block/title {:optional true} :string]
|
||||
[:build/journal {:optional true} :int]
|
||||
[:build/properties {:optional true} User-properties]
|
||||
[:build/tags {:optional true} [:vector Class]]]
|
||||
[:fn {:error/message ":block/original-name or :build/journal required"
|
||||
:error/path [:block/original-name]}
|
||||
[:fn {:error/message ":block/title or :build/journal required"
|
||||
:error/path [:block/title]}
|
||||
(fn [m]
|
||||
(or (:block/original-name m) (:build/journal m)))]]]
|
||||
(or (:block/title m) (:build/journal m)))]]]
|
||||
[:blocks {:optional true} [:vector ::block]]])
|
||||
|
||||
(def Properties
|
||||
@@ -338,11 +338,11 @@
|
||||
(let [new-page (merge
|
||||
;; TODO: Use sqlite-util/build-new-page
|
||||
{:db/id (or (:db/id page) (new-db-id))
|
||||
:block/original-name (or (:block/original-name page) (string/capitalize (:block/name page)))
|
||||
:block/name (or (:block/name page) (common-util/page-name-sanity-lc (:block/original-name page)))
|
||||
:block/title (or (:block/title page) (string/capitalize (:block/name page)))
|
||||
:block/name (or (:block/name page) (common-util/page-name-sanity-lc (:block/title page)))
|
||||
:block/type #{"page"}
|
||||
:block/format :markdown}
|
||||
(dissoc page :build/properties :db/id :block/name :block/original-name :build/tags))
|
||||
(dissoc page :build/properties :db/id :block/name :block/title :build/tags))
|
||||
pvalue-tx-m (->property-value-tx-m new-page (:build/properties page) properties all-idents)]
|
||||
(into
|
||||
;; page tx
|
||||
@@ -392,7 +392,7 @@
|
||||
|
||||
(defn- add-new-pages-from-refs
|
||||
[pages-and-blocks]
|
||||
(let [existing-pages (->> pages-and-blocks (keep #(get-in % [:page :block/original-name])) set)
|
||||
(let [existing-pages (->> pages-and-blocks (keep #(get-in % [:page :block/title])) set)
|
||||
new-pages-from-refs
|
||||
(->> pages-and-blocks
|
||||
(mapcat
|
||||
@@ -401,15 +401,15 @@
|
||||
(mapcat #(extract-content-refs (:block/content %)))
|
||||
(remove existing-pages))))
|
||||
distinct
|
||||
(map #(hash-map :page {:block/original-name %})))]
|
||||
(map #(hash-map :page {:block/title %})))]
|
||||
(when (seq new-pages-from-refs)
|
||||
(println "Building additional pages from content refs:" (pr-str (mapv #(get-in % [:page :block/original-name]) new-pages-from-refs))))
|
||||
(println "Building additional pages from content refs:" (pr-str (mapv #(get-in % [:page :block/title]) new-pages-from-refs))))
|
||||
(concat pages-and-blocks new-pages-from-refs)))
|
||||
|
||||
(defn- add-new-pages-from-properties
|
||||
[properties pages-and-blocks]
|
||||
(let [used-properties (get-used-properties-from-options {:pages-and-blocks pages-and-blocks :properties properties})
|
||||
existing-pages (->> pages-and-blocks (keep #(get-in % [:page :block/original-name])) set)
|
||||
existing-pages (->> pages-and-blocks (keep #(get-in % [:page :block/title])) set)
|
||||
new-pages (->> (mapcat val used-properties)
|
||||
(mapcat (fn [val-or-vals]
|
||||
(if (coll? val-or-vals)
|
||||
@@ -417,9 +417,9 @@
|
||||
(when (page-prop-value? val-or-vals) (second val-or-vals)))))
|
||||
distinct
|
||||
(remove existing-pages)
|
||||
(map #(hash-map :page {:block/original-name %})))]
|
||||
(map #(hash-map :page {:block/title %})))]
|
||||
(when (seq new-pages)
|
||||
(println "Building additional pages from property values:" (pr-str (mapv #(get-in % [:page :block/original-name]) new-pages))))
|
||||
(println "Building additional pages from property values:" (pr-str (mapv #(get-in % [:page :block/title]) new-pages))))
|
||||
(concat pages-and-blocks new-pages)))
|
||||
|
||||
(defn- expand-build-children
|
||||
@@ -460,7 +460,7 @@
|
||||
(let [page-name (date-time-util/int->journal-title date-int "MMM do, yyyy")]
|
||||
(-> (dissoc page :build/journal)
|
||||
(merge {:block/journal-day date-int
|
||||
:block/original-name page-name
|
||||
:block/title page-name
|
||||
:block/uuid (common-uuid/gen-uuid date-int)
|
||||
:block/type #{"journal" "page"}})))))
|
||||
m))]
|
||||
@@ -552,8 +552,8 @@
|
||||
* :pages-and-blocks - This is a vector of maps containing a :page key and optionally a :blocks
|
||||
key when defining a page's blocks. More about each key:
|
||||
* :page - This is a datascript attribute map for pages with
|
||||
:block/original-name required e.g. `{:block/original/name \"foo\"}`. Additional keys available:
|
||||
* :build/journal - Define a journal pages as an integer e.g. 20240101 is Jan 1, 2024. :block/original-name
|
||||
:block/title required e.g. `{:block/original/name \"foo\"}`. Additional keys available:
|
||||
* :build/journal - Define a journal pages as an integer e.g. 20240101 is Jan 1, 2024. :block/title
|
||||
is not required if using this since it generates one
|
||||
* :build/properties - Defines properties on a page
|
||||
* :blocks - This is a vec of datascript attribute maps for blocks with
|
||||
@@ -568,7 +568,7 @@
|
||||
* :build/closed-values - Define closed values with a vec of maps. A map contains keys :uuid, :value and :icon.
|
||||
* :build/schema-classes - Vec of class name keywords. Defines a property's range classes
|
||||
* :classes - This is a map to configure classes where the keys are class name keywords
|
||||
and the values are maps of datascript attributes e.g. `{:block/original-name \"Foo\"}`.
|
||||
and the values are maps of datascript attributes e.g. `{:block/title \"Foo\"}`.
|
||||
Additional keys available:
|
||||
* :build/properties - Define properties on a class page
|
||||
* :build/class-parent - Add a class parent by its keyword name
|
||||
@@ -598,4 +598,4 @@
|
||||
{:keys [init-tx block-props-tx]} (build-blocks-tx options')]
|
||||
(d/transact! conn init-tx)
|
||||
(when (seq block-props-tx)
|
||||
(d/transact! conn block-props-tx))))
|
||||
(d/transact! conn block-props-tx))))
|
||||
|
||||
6
deps/db/src/logseq/db/sqlite/common_db.cljs
vendored
6
deps/db/src/logseq/db/sqlite/common_db.cljs
vendored
@@ -21,12 +21,12 @@
|
||||
(when (and db (string? page-name))
|
||||
(first (sort (map :e (get-pages-by-name db page-name))))))
|
||||
|
||||
(defn get-first-page-by-original-name
|
||||
"Return the oldest page's db id for :block/original-name"
|
||||
(defn get-first-page-by-title
|
||||
"Return the oldest page's db id for :block/title"
|
||||
[db page-name]
|
||||
{:pre [(string? page-name)]}
|
||||
(first (sort (map :e
|
||||
(d/datoms db :avet :block/original-name page-name)))))
|
||||
(d/datoms db :avet :block/title page-name)))))
|
||||
|
||||
(comment
|
||||
(defn- get-built-in-files
|
||||
|
||||
16
deps/db/src/logseq/db/sqlite/create_graph.cljs
vendored
16
deps/db/src/logseq/db/sqlite/create_graph.cljs
vendored
@@ -14,8 +14,8 @@
|
||||
(defn build-initial-properties*
|
||||
[built-in-properties]
|
||||
(mapcat
|
||||
(fn [[db-ident {:keys [schema original-name closed-values] :as m}]]
|
||||
(let [prop-name (or original-name (name (:name m)))
|
||||
(fn [[db-ident {:keys [schema title closed-values] :as m}]]
|
||||
(let [prop-name (or title (name (:name m)))
|
||||
blocks (if closed-values
|
||||
(db-property-build/build-closed-values
|
||||
db-ident
|
||||
@@ -25,7 +25,7 @@
|
||||
[(sqlite-util/build-new-property
|
||||
db-ident
|
||||
schema
|
||||
{:original-name prop-name})])]
|
||||
{:title prop-name})])]
|
||||
blocks))
|
||||
(dissoc built-in-properties :logseq.property/built-in?)))
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
built-in-property (sqlite-util/build-new-property
|
||||
:logseq.property/built-in?
|
||||
built-in-property-schema
|
||||
{:original-name (name :logseq.property/built-in?)})
|
||||
{:title (name :logseq.property/built-in?)})
|
||||
built-in-prop-value (db-property-build/build-property-value-block
|
||||
{:db/id [:block/uuid (:block/uuid built-in-property)]}
|
||||
{:db/ident :logseq.property/built-in?
|
||||
@@ -84,8 +84,8 @@
|
||||
|
||||
(defn- build-initial-classes [db-ident->properties built-in-prop-value]
|
||||
(map
|
||||
(fn [[db-ident {:keys [schema original-name]}]]
|
||||
(let [original-name' (or original-name (name db-ident))]
|
||||
(fn [[db-ident {:keys [schema title]}]]
|
||||
(let [title' (or title (name db-ident))]
|
||||
(mark-block-as-built-in
|
||||
(sqlite-util/build-new-class
|
||||
(let [properties (mapv
|
||||
@@ -95,8 +95,8 @@
|
||||
db-ident))
|
||||
(:properties schema))]
|
||||
(cond->
|
||||
{:block/original-name original-name'
|
||||
:block/name (common-util/page-name-sanity-lc original-name')
|
||||
{:block/title title'
|
||||
:block/name (common-util/page-name-sanity-lc title')
|
||||
:db/ident db-ident
|
||||
:block/uuid (d/squuid)}
|
||||
(seq properties)
|
||||
|
||||
10
deps/db/src/logseq/db/sqlite/util.cljs
vendored
10
deps/db/src/logseq/db/sqlite/util.cljs
vendored
@@ -75,15 +75,15 @@
|
||||
(defn build-new-property
|
||||
"Build a standard new property so that it is is consistent across contexts. Takes
|
||||
an optional map with following keys:
|
||||
* :original-name - Case sensitive property name. Defaults to deriving this from db-ident
|
||||
* :title - Case sensitive property name. Defaults to deriving this from db-ident
|
||||
* :block-uuid - :block/uuid for property"
|
||||
([db-ident prop-schema] (build-new-property db-ident prop-schema {}))
|
||||
([db-ident prop-schema {:keys [original-name block-uuid ref-type?]}]
|
||||
([db-ident prop-schema {:keys [title block-uuid ref-type?]}]
|
||||
(assert (keyword? db-ident))
|
||||
(let [db-ident' (if (qualified-keyword? db-ident)
|
||||
db-ident
|
||||
(db-property/create-user-property-ident-from-name (name db-ident)))
|
||||
prop-name (or original-name (name db-ident'))
|
||||
prop-name (or title (name db-ident'))
|
||||
classes (:classes prop-schema)
|
||||
prop-schema (assoc prop-schema :type (get prop-schema :type :default))]
|
||||
(block-with-timestamps
|
||||
@@ -94,7 +94,7 @@
|
||||
:block/schema (merge {:type :default} (dissoc prop-schema :classes :cardinality))
|
||||
:block/name (common-util/page-name-sanity-lc (name prop-name))
|
||||
:block/uuid (or block-uuid (d/squuid))
|
||||
:block/original-name (name prop-name)
|
||||
:block/title (name prop-name)
|
||||
:db/index true
|
||||
:db/cardinality (if (= :many (:cardinality prop-schema))
|
||||
:db.cardinality/many
|
||||
@@ -121,7 +121,7 @@
|
||||
[page-name]
|
||||
(block-with-timestamps
|
||||
{:block/name (common-util/page-name-sanity-lc page-name)
|
||||
:block/original-name page-name
|
||||
:block/title page-name
|
||||
:block/uuid (d/squuid)
|
||||
:block/format :markdown
|
||||
:block/type #{"page"}}))
|
||||
|
||||
@@ -7,5 +7,5 @@
|
||||
(is (= "string [[~^foo]] string2 [[~^foo-bar]]"
|
||||
(db-content/replace-tags-with-page-refs
|
||||
"string #foo string2 #foo-bar"
|
||||
[{:block/original-name "foo" :block/uuid "foo"}
|
||||
{:block/original-name "foo-bar" :block/uuid "foo-bar"}])))))
|
||||
[{:block/title "foo" :block/uuid "foo"}
|
||||
{:block/title "foo-bar" :block/uuid "foo-bar"}])))))
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
(let [conn (d/create-conn db-schema/schema-for-db-based-graph)
|
||||
_ (sqlite-build/create-blocks
|
||||
conn
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "parent"
|
||||
:build/children
|
||||
[{:block/content "child 1"}
|
||||
@@ -221,4 +221,4 @@
|
||||
":+1d and today resolve to correct journal range")
|
||||
|
||||
(is (= ["+1d" "now"] (blocks-journaled-between-inputs db :today :today/+1d))
|
||||
":today/+1d and today resolve to correct journal range"))))
|
||||
":today/+1d and today resolve to correct journal range"))))
|
||||
|
||||
56
deps/db/test/logseq/db/frontend/rules_test.cljs
vendored
56
deps/db/test/logseq/db/frontend/rules_test.cljs
vendored
@@ -24,22 +24,22 @@
|
||||
{:properties {:foo {:block/schema {:type :default}}
|
||||
:foo2 {:block/schema {:type :default}}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "Page"
|
||||
[{:page {:block/title "Page"
|
||||
:build/properties {:foo "bar"}}}]})]
|
||||
|
||||
|
||||
(is (= ["Page"]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (has-page-property ?b :user.property/foo)]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (has-page-property ?b :user.property/foo)]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"has-page-property returns result when page has property")
|
||||
(is (= []
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (has-page-property ?b :user.property/foo2)]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (has-page-property ?b :user.property/foo2)]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"has-page-property returns no result when page doesn't have property")
|
||||
(is (= [:user.property/foo]
|
||||
(q-with-rules '[:find [?p ...]
|
||||
:where (has-page-property ?b ?p) [?b :block/original-name "Page"]]
|
||||
:where (has-page-property ?b ?p) [?b :block/title "Page"]]
|
||||
@conn))
|
||||
"has-page-property can bind to property arg")))
|
||||
|
||||
@@ -52,42 +52,42 @@
|
||||
:number-many {:block/schema {:type :number :cardinality :many}}
|
||||
:page-many {:block/schema {:type :page :cardinality :many}}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "Page"
|
||||
[{:page {:block/title "Page"
|
||||
:build/properties {:foo "bar" :number-many #{5 10} :page-many #{[:page "Page A"]}}}}
|
||||
{:page {:block/original-name "Page A"
|
||||
{:page {:block/title "Page A"
|
||||
:build/properties {:foo "bar A"}}}]})]
|
||||
(testing "cardinality :one property"
|
||||
(is (= ["Page"]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (page-property ?b :user.property/foo "bar")]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (page-property ?b :user.property/foo "bar")]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns result when page has property")
|
||||
(is (= []
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (page-property ?b :user.property/foo "baz")]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (page-property ?b :user.property/foo "baz")]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns no result when page doesn't have property value")
|
||||
(is (= #{:user.property/foo}
|
||||
(->> (q-with-rules '[:find [?p ...]
|
||||
:where (page-property ?b ?p "bar") [?b :block/original-name "Page"]]
|
||||
:where (page-property ?b ?p "bar") [?b :block/title "Page"]]
|
||||
@conn)
|
||||
set))
|
||||
"page-property can bind to property arg with bound property value"))
|
||||
|
||||
(testing "cardinality :many property"
|
||||
(is (= ["Page"]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (page-property ?b :user.property/number-many 5)]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (page-property ?b :user.property/number-many 5)]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns result when page has property")
|
||||
(is (= []
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name]) :where (page-property ?b :user.property/number-many 20)]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title]) :where (page-property ?b :user.property/number-many 20)]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns no result when page doesn't have property value")
|
||||
(is (= #{:user.property/number-many}
|
||||
(->> (q-with-rules '[:find [?p ...]
|
||||
:where (page-property ?b ?p 5) [?b :block/original-name "Page"]]
|
||||
:where (page-property ?b ?p 5) [?b :block/title "Page"]]
|
||||
@conn)
|
||||
set))
|
||||
"page-property can bind to property arg with bound property value"))
|
||||
@@ -95,22 +95,22 @@
|
||||
;; NOTE: Querying a ref's name is different than before and requires more than just the rule
|
||||
(testing ":ref property"
|
||||
(is (= ["Page"]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name])
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title])
|
||||
:where (page-property ?b :user.property/page-many "Page A")]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns result when page has property")
|
||||
(is (= []
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name])
|
||||
:where [?b :user.property/page-many ?pv] [?pv :block/original-name "Page B"]]
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title])
|
||||
:where [?b :user.property/page-many ?pv] [?pv :block/title "Page B"]]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))))
|
||||
(map (comp :block/title first))))
|
||||
"page-property returns no result when page doesn't have property value"))
|
||||
|
||||
(testing "bindings with property value"
|
||||
(is (= #{:user.property/foo :user.property/number-many :user.property/page-many}
|
||||
(->> (q-with-rules '[:find [?p ...]
|
||||
:where (page-property ?b ?p _) [?b :block/original-name "Page"]]
|
||||
:where (page-property ?b ?p _) [?b :block/title "Page"]]
|
||||
@conn)
|
||||
set))
|
||||
"page-property can bind to property arg with unbound property value")
|
||||
@@ -119,16 +119,16 @@
|
||||
[:user.property/foo "bar"]
|
||||
[:user.property/page-many "Page A"]}
|
||||
(->> (q-with-rules '[:find ?p ?v
|
||||
:where (page-property ?b ?p ?v) [?b :block/original-name "Page"]]
|
||||
:where (page-property ?b ?p ?v) [?b :block/title "Page"]]
|
||||
@conn)
|
||||
set))
|
||||
"page-property can bind to property and property value args")
|
||||
(is (= #{"Page"}
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/original-name])
|
||||
(->> (q-with-rules '[:find (pull ?b [:block/title])
|
||||
:where
|
||||
[?b :user.property/page-many ?pv]
|
||||
(page-property ?pv :user.property/foo "bar A")]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))
|
||||
(map (comp :block/title first))
|
||||
set))
|
||||
"page-property can be used multiple times to query a property value's property"))))
|
||||
|
||||
26
deps/db/test/logseq/db/sqlite/build_test.cljs
vendored
26
deps/db/test/logseq/db/sqlite/build_test.cljs
vendored
@@ -11,18 +11,18 @@
|
||||
_ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
|
||||
_ (sqlite-build/create-blocks
|
||||
conn
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "Jrue Holiday" :build/tags [:Person]}]}
|
||||
{:page {:block/original-name "Jayson Tatum" :build/tags [:Person]}}])]
|
||||
(is (= {:block/tags [{:block/original-name "Person", :block/type ["class" "page"]}]}
|
||||
(first (d/q '[:find [(pull ?b [{:block/tags [:block/original-name :block/type]}]) ...]
|
||||
{:page {:block/title "Jayson Tatum" :build/tags [:Person]}}])]
|
||||
(is (= {:block/tags [{:block/title "Person", :block/type ["class" "page"]}]}
|
||||
(first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
|
||||
:where [?b :block/content "Jrue Holiday"]]
|
||||
@conn)))
|
||||
"Person class is created and correctly associated to a block")
|
||||
|
||||
(is (= {:block/tags [{:block/original-name "Person", :block/type ["class" "page"]}]}
|
||||
(first (d/q '[:find [(pull ?b [{:block/tags [:block/original-name :block/type]}]) ...]
|
||||
:where [?b :block/original-name "Jayson Tatum"]]
|
||||
(is (= {:block/tags [{:block/title "Person", :block/type ["class" "page"]}]}
|
||||
(first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
|
||||
:where [?b :block/title "Jayson Tatum"]]
|
||||
@conn)))
|
||||
"Person class is created and correctly associated to a page")))
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
_ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
|
||||
_ (sqlite-build/create-blocks
|
||||
conn
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "Jrue Holiday" :build/properties {:description "Clutch defense"}}]}
|
||||
{:page {:block/original-name "Jayson Tatum" :build/properties {:description "Awesome selfless basketball"}}}])]
|
||||
{:page {:block/title "Jayson Tatum" :build/properties {:description "Awesome selfless basketball"}}}])]
|
||||
(is (= "Clutch defense"
|
||||
(->> @conn
|
||||
(d/q '[:find [(pull ?b [*]) ...]
|
||||
@@ -46,18 +46,18 @@
|
||||
(is (= "Awesome selfless basketball"
|
||||
(->> @conn
|
||||
(d/q '[:find [(pull ?b [*]) ...]
|
||||
:where [?b :block/original-name "Jayson Tatum"]])
|
||||
:where [?b :block/title "Jayson Tatum"]])
|
||||
first
|
||||
:user.property/description
|
||||
(db-property/ref->property-value-contents @conn)))
|
||||
"description property is created and correctly associated to a page")))
|
||||
|
||||
|
||||
(deftest build-properties-built-in
|
||||
(let [conn (d/create-conn db-schema/schema-for-db-based-graph)
|
||||
_ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
|
||||
_ (sqlite-build/create-blocks
|
||||
conn
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "some todo"
|
||||
:build/properties {:logseq.task/status :logseq.task/status.doing}}
|
||||
{:block/content "some slide"
|
||||
@@ -78,4 +78,4 @@
|
||||
first
|
||||
:logseq.property/background-image
|
||||
(db-property/ref->property-value-contents @conn)))
|
||||
"built-in :default property is created and correctly associated to a block")))
|
||||
"built-in :default property is created and correctly associated to a block")))
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
:block/uuid page-uuid
|
||||
:block/journal-day date-int
|
||||
:block/name (string/lower-case date-title)
|
||||
:block/original-name date-title
|
||||
:block/title date-title
|
||||
:block/created-at created-at
|
||||
:block/updated-at created-at}
|
||||
{:db/id 100002
|
||||
|
||||
@@ -89,10 +89,10 @@
|
||||
conn
|
||||
{:properties {:url {:block/schema {:type :url}}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:url "https://logseq.com"}}
|
||||
;; :url macros are used for consistently building urls with the same hostname e.g. docs graph
|
||||
{:block/content "b2" :build/properties {:url "{{docs-base-url test}}"}}]}]})
|
||||
|
||||
(is (empty? (map :entity (:errors (db-validate/validate-db! @conn))))
|
||||
"Graph with different :url blocks has no validation errors"))))
|
||||
"Graph with different :url blocks has no validation errors"))))
|
||||
|
||||
@@ -318,10 +318,10 @@
|
||||
(if class?
|
||||
(ldb/get-case-page db original-page-name)
|
||||
(ldb/get-page db original-page-name)))
|
||||
original-page-name (or from-page (:block/original-name page-entity) original-page-name)]
|
||||
original-page-name (or from-page (:block/title page-entity) original-page-name)]
|
||||
(merge
|
||||
{:block/name page-name
|
||||
:block/original-name original-page-name}
|
||||
:block/title original-page-name}
|
||||
(let [new-uuid* (if (uuid? page-uuid)
|
||||
page-uuid
|
||||
(if journal-day (common-uuid/gen-uuid journal-day) (common-uuid/gen-uuid)))
|
||||
@@ -391,7 +391,7 @@
|
||||
children-pages (when-not db-based?
|
||||
(->> (mapcat (fn [p]
|
||||
(let [p (if (map? p)
|
||||
(:block/original-name p)
|
||||
(:block/title p)
|
||||
p)]
|
||||
(when (string? p)
|
||||
(let [p (or (text/get-nested-page-name p) p)]
|
||||
@@ -520,7 +520,7 @@
|
||||
property-refs (->> (get-page-refs-from-properties
|
||||
properties db date-formatter
|
||||
user-config)
|
||||
(map :block/original-name))
|
||||
(map :block/title))
|
||||
pre-block? (if (:heading properties) false true)
|
||||
block {:block/uuid id
|
||||
:block/content content
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
(defn- page-title->block
|
||||
[title]
|
||||
{:block/name (string/lower-case title)
|
||||
:block/original-name title
|
||||
:block/title title
|
||||
:block/uuid (random-uuid)})
|
||||
|
||||
(def built-in-pages
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
(if-let [new-class (:block.temp/new-class tag-block)]
|
||||
(merge (db-class/build-new-class
|
||||
db
|
||||
{:block/original-name new-class
|
||||
{:block/title new-class
|
||||
:block/name (common-util/page-name-sanity-lc new-class)})
|
||||
(when-let [existing-tag-uuid (get page-names-to-uuids (common-util/page-name-sanity-lc new-class))]
|
||||
{:block/uuid existing-tag-uuid}))
|
||||
@@ -115,7 +115,7 @@
|
||||
content-without-tags-ignore-case
|
||||
(->> original-tags
|
||||
(filter #(tag-classes (:block/name %)))
|
||||
(map :block/original-name)))
|
||||
(map :block/title)))
|
||||
(update :block/content
|
||||
db-content/replace-tags-with-page-refs
|
||||
(->> original-tags
|
||||
@@ -149,10 +149,10 @@
|
||||
(update :block/content string/replace-first (re-pattern (str marker "\\s*")) "")
|
||||
(update :block/tags (fnil conj []) :logseq.class/task)
|
||||
(update :block/refs (fn [refs]
|
||||
(into (remove #(= marker (:block/original-name %)) refs)
|
||||
(into (remove #(= marker (:block/title %)) refs)
|
||||
[:logseq.class/task :logseq.task/status status-ident])))
|
||||
(update :block/path-refs (fn [refs]
|
||||
(into (remove #(= marker (:block/original-name %)) refs)
|
||||
(into (remove #(= marker (:block/title %)) refs)
|
||||
[:logseq.class/task :logseq.task/status status-ident])))
|
||||
(dissoc :block/marker)))
|
||||
block))
|
||||
@@ -171,10 +171,10 @@
|
||||
(assoc :logseq.task/priority priority-value)
|
||||
(update :block/content string/replace-first (re-pattern (str "\\[#" priority "\\]" "\\s*")) "")
|
||||
(update :block/refs (fn [refs]
|
||||
(into (remove #(= priority (:block/original-name %)) refs)
|
||||
(into (remove #(= priority (:block/title %)) refs)
|
||||
[:logseq.task/priority priority-value])))
|
||||
(update :block/path-refs (fn [refs]
|
||||
(into (remove #(= priority (:block/original-name %)) refs)
|
||||
(into (remove #(= priority (:block/title %)) refs)
|
||||
[:logseq.task/priority priority-value])))
|
||||
(dissoc :block/priority)))
|
||||
block))
|
||||
@@ -252,7 +252,7 @@
|
||||
(seq prop-val)
|
||||
(set/subset? prop-val
|
||||
(set (keep #(when (contains? (:block/type %) "journal")
|
||||
(:block/original-name %)) refs))))
|
||||
(:block/title %)) refs))))
|
||||
:date
|
||||
(and (coll? prop-val) (seq prop-val) (text-with-refs? prop-val prop-val-text))
|
||||
:default
|
||||
@@ -543,7 +543,7 @@
|
||||
(when (> (count parent-classes-from-properties) 1)
|
||||
(log-fn :skipped-parent-classes "Only one parent class is allowed so skipped ones after the first one" :classes parent-classes-from-properties))
|
||||
(sqlite-util/build-new-class
|
||||
{:block/original-name new-class
|
||||
{:block/title new-class
|
||||
:block/uuid (or (get-pid db new-class) (d/squuid))
|
||||
:block/name (common-util/page-name-sanity-lc new-class)})))))
|
||||
(dissoc block* :block/properties))]
|
||||
@@ -637,10 +637,10 @@
|
||||
(defn- build-new-page
|
||||
[m db tag-classes page-names-to-uuids]
|
||||
(-> m
|
||||
;; Fix pages missing :block/original-name. Shouldn't happen
|
||||
;; Fix pages missing :block/title. Shouldn't happen
|
||||
((fn [m']
|
||||
(if-not (:block/original-name m')
|
||||
(assoc m' :block/original-name (:block/name m'))
|
||||
(if-not (:block/title m')
|
||||
(assoc m' :block/title (:block/name m'))
|
||||
m')))
|
||||
add-missing-timestamps
|
||||
;; TODO: org-mode content needs to be handled
|
||||
@@ -670,14 +670,14 @@
|
||||
pages-tx (keep (fn [m]
|
||||
(if-let [page-uuid (existing-page-names-to-uuids (:block/name m))]
|
||||
(let [;; These attributes are not allowed to be transacted because they must not change across files
|
||||
disallowed-attributes [:block/name :block/uuid :block/format :block/original-name :block/journal-day
|
||||
disallowed-attributes [:block/name :block/uuid :block/format :block/title :block/journal-day
|
||||
:block/created-at :block/updated-at]
|
||||
allowed-attributes (into [:block/tags :block/alias :class/parent :block/type :block/namespace]
|
||||
(keep #(when (db-malli-schema/user-property? (key %)) (key %))
|
||||
m))
|
||||
block-changes (select-keys m allowed-attributes)]
|
||||
(when-let [ignored-attrs (not-empty (apply dissoc m (into disallowed-attributes allowed-attributes)))]
|
||||
(notify-user {:msg (str "Import ignored the following attributes on page " (pr-str (:block/original-name m)) ": "
|
||||
(notify-user {:msg (str "Import ignored the following attributes on page " (pr-str (:block/title m)) ": "
|
||||
ignored-attrs)}))
|
||||
(when (seq block-changes)
|
||||
(cond-> (merge block-changes {:block/uuid page-uuid})
|
||||
@@ -802,11 +802,11 @@
|
||||
_ (when (seq new-properties) (prn :new-properties new-properties))
|
||||
[properties-tx pages-tx'] ((juxt filter remove)
|
||||
#(contains? new-properties (keyword (:block/name %))) pages-tx)
|
||||
property-pages-tx (map (fn [{:block/keys [original-name uuid]}]
|
||||
(let [db-ident (get @(:all-idents import-state) (keyword original-name))]
|
||||
property-pages-tx (map (fn [{:block/keys [title uuid]}]
|
||||
(let [db-ident (get @(:all-idents import-state) (keyword title))]
|
||||
(sqlite-util/build-new-property db-ident
|
||||
(get @(:property-schemas import-state) (keyword original-name))
|
||||
{:original-name original-name :block-uuid uuid})))
|
||||
(get @(:property-schemas import-state) (keyword title))
|
||||
{:title title :block-uuid uuid})))
|
||||
properties-tx)
|
||||
converted-property-pages-tx
|
||||
(map (fn [kw-name]
|
||||
@@ -814,7 +814,7 @@
|
||||
db-ident (get @(:all-idents import-state) kw-name)
|
||||
new-prop (sqlite-util/build-new-property db-ident
|
||||
(get @(:property-schemas import-state) kw-name)
|
||||
{:original-name (name kw-name)})]
|
||||
{:title (name kw-name)})]
|
||||
(assert existing-page-uuid)
|
||||
(merge (select-keys new-prop [:block/type :block/schema :db/ident :db/index :db/cardinality :db/valueType])
|
||||
{:block/uuid existing-page-uuid})))
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
(fn [alias]
|
||||
(let [page-name (common-util/page-name-sanity-lc alias)]
|
||||
{:block/name page-name
|
||||
:block/original-name alias}))
|
||||
:block/title alias}))
|
||||
aliases)
|
||||
result (cond-> page-m
|
||||
(seq aliases')
|
||||
@@ -146,7 +146,7 @@
|
||||
tags (if (coll? tags) tags [(str tags)])
|
||||
tags (remove string/blank? tags)]
|
||||
(map (fn [tag] {:block/name (common-util/page-name-sanity-lc tag)
|
||||
:block/original-name tag})
|
||||
:block/title tag})
|
||||
tags))))]
|
||||
(update result :block/properties #(apply dissoc % gp-property/editable-linkable-built-in-properties))))
|
||||
|
||||
@@ -239,7 +239,7 @@
|
||||
[properties [] {}])
|
||||
page-map (build-page-map properties invalid-properties properties-text-values file page page-name (assoc options' :from-page page))
|
||||
namespace-pages (when-not db-based?
|
||||
(let [page (:block/original-name page-map)]
|
||||
(let [page (:block/title page-map)]
|
||||
(when (text/namespace-page? page)
|
||||
(->> (common-util/split-namespace-pages page)
|
||||
(map (fn [page]
|
||||
@@ -261,7 +261,7 @@
|
||||
(assoc page :block/uuid page-id)))
|
||||
pages)
|
||||
blocks (->> (remove nil? blocks)
|
||||
(map (fn [b] (dissoc b :block/title :block/body :block/level :block/children :block/meta))))]
|
||||
(map (fn [b] (dissoc b :block/body :block/level :block/children :block/meta))))]
|
||||
[pages blocks])
|
||||
(catch :default e
|
||||
(log/error :exception e))))
|
||||
@@ -314,14 +314,14 @@
|
||||
(common-util/dissoc-in [:block/left :block/name])))
|
||||
blocks)
|
||||
serialized-page (first pages)
|
||||
;; whiteboard edn file should normally have valid :block/original-name, :block/name, :block/uuid
|
||||
;; whiteboard edn file should normally have valid :block/title, :block/name, :block/uuid
|
||||
page-name (-> (or (:block/name serialized-page)
|
||||
(filepath->page-name file))
|
||||
(common-util/page-name-sanity-lc))
|
||||
original-name (or (:block/original-name serialized-page)
|
||||
title (or (:block/title serialized-page)
|
||||
page-name)
|
||||
page-block (merge {:block/name page-name
|
||||
:block/original-name original-name
|
||||
:block/title title
|
||||
:block/type #{"whiteboard" "page"}
|
||||
:block/file {:file/path (common-util/path-normalize file)}}
|
||||
serialized-page)
|
||||
|
||||
@@ -136,10 +136,10 @@
|
||||
|
||||
(let [no-name (->> (d/q '[:find (pull ?n [*]) :where [?b :block/namespace ?n]] db)
|
||||
(filter (fn [x]
|
||||
(when-not (:block/original-name (first x))
|
||||
(when-not (:block/title (first x))
|
||||
x))))
|
||||
all-namespaces (->> (d/q '[:find (pull ?n [*]) :where [?b :block/namespace ?n]] db)
|
||||
(map (comp :block/original-name first))
|
||||
(map (comp :block/title first))
|
||||
set)]
|
||||
(is (= #{"term" "setting" "book" "templates" "Query table" "page"
|
||||
"Whiteboard" "Whiteboard/Tool" "Whiteboard/Tool/Shape" "Whiteboard/Object"
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
(into [(merge page
|
||||
{:db/id page-id
|
||||
:block/uuid page-uuid
|
||||
:block/original-name (string/capitalize (:block/name page))
|
||||
:block/title (string/capitalize (:block/name page))
|
||||
:block/created-at created-at
|
||||
:block/updated-at created-at})]
|
||||
(mapv #(merge %
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
(->> name
|
||||
(d/q '[:find [(pull ?b [*]) ...]
|
||||
:in $ ?name
|
||||
:where [?b :block/original-name ?name]]
|
||||
:where [?b :block/title ?name]]
|
||||
db)
|
||||
first))
|
||||
|
||||
@@ -145,8 +145,8 @@
|
||||
|
||||
;; Don't count pages like url.md that have properties but no content
|
||||
(is (= 5
|
||||
(count (->> (d/q '[:find [(pull ?b [:block/original-name :block/type]) ...]
|
||||
:where [?b :block/original-name] [_ :block/page ?b]] @conn)
|
||||
(count (->> (d/q '[:find [(pull ?b [:block/title :block/type]) ...]
|
||||
:where [?b :block/title] [_ :block/page ?b]] @conn)
|
||||
(filter #(= ["page"] (:block/type %))))))
|
||||
"Correct number of pages with block content")
|
||||
(is (= 2 (count @(:ignored-properties import-state)))
|
||||
@@ -164,8 +164,8 @@
|
||||
(->>
|
||||
(ldb/get-page-blocks @conn
|
||||
(:db/id (ldb/get-page @conn common-config/favorites-page-name))
|
||||
{:pull-keys '[* {:block/link [:block/original-name]}]})
|
||||
(map #(get-in % [:block/link :block/original-name]))
|
||||
{:pull-keys '[* {:block/link [:block/title]}]})
|
||||
(map #(get-in % [:block/link :block/title]))
|
||||
set))))
|
||||
|
||||
(testing "user properties"
|
||||
@@ -205,7 +205,7 @@
|
||||
(is (= #{"prop-num" "prop-string" "prop-bool"}
|
||||
(->> (d/entity @conn (:db/id (find-block-by-content @conn "b1")))
|
||||
:block/refs
|
||||
(map :block/original-name)
|
||||
(map :block/title)
|
||||
set))
|
||||
"Block with properties has correct refs")
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@
|
||||
:block/format :markdown}),
|
||||
:pages
|
||||
({:block/format :markdown,
|
||||
:block/original-name "Foo"
|
||||
:block/title "Foo"
|
||||
:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"
|
||||
:block/properties {:title "my whiteboard foo"}})})
|
||||
|
||||
@@ -145,5 +145,5 @@
|
||||
(is (= (get-in page [:block/file :file/path]) "/whiteboards/foo.edn"))
|
||||
(is (= (:block/name page) "foo"))
|
||||
(is (= (:block/type page) #{"whiteboard" "page"}))
|
||||
(is (= (:block/original-name page) "Foo"))
|
||||
(is (= (:block/title page) "Foo"))
|
||||
(is (every? #(= (:block/parent %) [:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"]) blocks))))
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
:pages
|
||||
({:block/format :markdown,
|
||||
:block/name "foo"
|
||||
:block/original-name "Foo"
|
||||
:block/title "Foo"
|
||||
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"
|
||||
:block/properties {:title "my whiteboard foo"}})})
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
:pages
|
||||
({:block/format :markdown,
|
||||
:block/name "foo conflicted"
|
||||
:block/original-name "Foo conflicted"
|
||||
:block/title "Foo conflicted"
|
||||
:block/uuid #uuid "16c90195-6a03-4b3f-839d-095a496d9acd"})})
|
||||
|
||||
(def bar-edn
|
||||
@@ -51,7 +51,7 @@
|
||||
:pages
|
||||
({:block/format :markdown,
|
||||
:block/name "bar"
|
||||
:block/original-name "Bar"
|
||||
:block/title "Bar"
|
||||
:block/uuid #uuid "71515b7d-b5fc-496b-b6bf-c58004a34ee3"})})
|
||||
|
||||
(defn- parse-file
|
||||
@@ -89,7 +89,7 @@
|
||||
(parse-file conn "/whiteboards/foo.edn" (pr-str foo-edn))
|
||||
(let [blocks (d/q '[:find (pull ?b [* {:block/page
|
||||
[:block/name
|
||||
:block/original-name
|
||||
:block/title
|
||||
:block/type
|
||||
{:block/file
|
||||
[:file/path]}]}])
|
||||
@@ -98,7 +98,7 @@
|
||||
@conn)
|
||||
parent (:block/page (ffirst blocks))]
|
||||
(is (= {:block/name "foo"
|
||||
:block/original-name "Foo"
|
||||
:block/title "Foo"
|
||||
:block/type ["page" "whiteboard"]
|
||||
:block/file {:file/path "/whiteboards/foo.edn"}}
|
||||
parent)
|
||||
@@ -168,7 +168,7 @@
|
||||
(:block/properties block))
|
||||
"Quoted value is unparsed")
|
||||
(is (= ["desc"]
|
||||
(map :block/original-name (:block/refs block)))
|
||||
(map :block/title (:block/refs block)))
|
||||
"No refs from property value")))
|
||||
|
||||
(deftest non-string-property-values
|
||||
@@ -242,12 +242,12 @@
|
||||
blocks (->> (d/q '[:find (pull ?b [:block/pre-block?
|
||||
:block/properties
|
||||
:block/properties-text-values
|
||||
{:block/refs [:block/original-name]}])
|
||||
{:block/refs [:block/title]}])
|
||||
:in $
|
||||
:where [?b :block/properties] [(missing? $ ?b :block/name)]]
|
||||
@conn)
|
||||
(map first)
|
||||
(map (fn [m] (update m :block/refs #(map :block/original-name %)))))
|
||||
(map (fn [m] (update m :block/refs #(map :block/title %)))))
|
||||
block-db-properties (block-property-transform db-properties)]
|
||||
|
||||
(testing "Page properties"
|
||||
@@ -356,7 +356,7 @@
|
||||
:in $
|
||||
:where [?b :block/name]]
|
||||
@conn)
|
||||
(map (comp :block/original-name first))
|
||||
(map (comp :block/title first))
|
||||
(remove built-in-pages)
|
||||
set))))))
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@
|
||||
(cond-> {}
|
||||
(not= schema (:block/schema property))
|
||||
(assoc :block/schema schema)
|
||||
(and (some? property-name) (not= property-name (:block/original-name property)))
|
||||
(assoc :block/original-name property-name))
|
||||
(and (some? property-name) (not= property-name (:block/title property)))
|
||||
(assoc :block/title property-name))
|
||||
property-tx-data
|
||||
(cond-> []
|
||||
(seq changed-property-attrs)
|
||||
@@ -143,7 +143,7 @@
|
||||
(assert (some? k-name)
|
||||
(prn "property-id: " property-id ", property-name: " property-name))
|
||||
(ldb/transact! conn
|
||||
[(sqlite-util/build-new-property db-ident' schema {:original-name k-name})]
|
||||
[(sqlite-util/build-new-property db-ident' schema {:title k-name})]
|
||||
{:outliner-op :new-property})
|
||||
(d/entity @conn db-ident')))))
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
(defn- raw-set-block-property!
|
||||
"Adds the raw property pair (value not modified) to the given block if the property value is valid"
|
||||
[conn block property property-type new-value]
|
||||
(let [k-name (:block/original-name property)
|
||||
(let [k-name (:block/title property)
|
||||
property-id (:db/ident property)
|
||||
schema (get-property-value-schema @conn property-type property)]
|
||||
(if-let [msg (and
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
_ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
|
||||
_ (sqlite-build/create-blocks
|
||||
conn
|
||||
[{:page {:block/original-name "bar"}}
|
||||
{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "bar"}}
|
||||
{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "parent [[foo]]"
|
||||
:build/children
|
||||
[{:block/content "child [[baz]]"
|
||||
@@ -32,7 +32,7 @@
|
||||
[{:block/content "grandchild [[bing]]"}]}]}]}])
|
||||
blocks (get-blocks @conn)
|
||||
;; Update parent block to replace 'foo' with 'bar' ref
|
||||
new-tag-id (ffirst (d/q '[:find ?b :where [?b :block/original-name "bar"]] @conn))
|
||||
new-tag-id (ffirst (d/q '[:find ?b :where [?b :block/title "bar"]] @conn))
|
||||
modified-blocks (map #(if (string/starts-with? (:block/content %) "parent")
|
||||
(assoc %
|
||||
:block/refs [{:db/id new-tag-id}]
|
||||
@@ -52,4 +52,3 @@
|
||||
{:block/content "grandchild"
|
||||
:path-ref-names #{"page1" "bar" "baz" "bing"}}]
|
||||
updated-blocks)))))
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@
|
||||
(outliner-property/upsert-property! conn nil {} {:property-name ":p1"})
|
||||
(outliner-property/upsert-property! conn nil {} {:property-name "1p1"})
|
||||
|
||||
(is (= {:block/name "p1" :block/original-name "p1" :block/schema {:type :default}}
|
||||
(select-keys (d/entity @conn :user.property/p1) [:block/name :block/original-name :block/schema]))
|
||||
(is (= {:block/name "p1" :block/title "p1" :block/schema {:type :default}}
|
||||
(select-keys (d/entity @conn :user.property/p1) [:block/name :block/title :block/schema]))
|
||||
"Existing db/ident does not get modified")
|
||||
(is (= ":p1"
|
||||
(:block/original-name (d/entity @conn :user.property/p1-1)))
|
||||
(:block/title (d/entity @conn :user.property/p1-1)))
|
||||
"2nd property gets unique ident")
|
||||
(is (= "1p1"
|
||||
(:block/original-name (d/entity @conn :user.property/p1-2)))
|
||||
(:block/title (d/entity @conn :user.property/p1-2)))
|
||||
"3rd property gets unique ident"))))
|
||||
|
||||
(deftest convert-property-input-string
|
||||
@@ -66,7 +66,7 @@
|
||||
(deftest create-property-text-block!
|
||||
(testing "Create a new :default property value"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:default "foo"}}
|
||||
{:block/content "b2"}]}])
|
||||
block (find-block-by-content conn "b2")
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
(testing "Create cases for a new :one :number property value"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:num 2}}
|
||||
{:block/content "b2"}]}])
|
||||
block (find-block-by-content conn "b2")
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
(testing "Create new :many :number property values"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:num-many #{2}}}
|
||||
{:block/content "b2"}]}])
|
||||
block (find-block-by-content conn "b2")
|
||||
@@ -123,7 +123,7 @@
|
||||
(deftest set-block-property-basic-cases
|
||||
(testing "Set a :number value with existing value"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:num 2}}
|
||||
{:block/content "b2"}]}])
|
||||
property-value (:user.property/num (find-block-by-content conn "b1"))
|
||||
@@ -136,7 +136,7 @@
|
||||
|
||||
(testing "Update a :number value with existing value"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:num 2}}
|
||||
{:block/content "b2" :build/properties {:num 3}}]}])
|
||||
property-value (:user.property/num (find-block-by-content conn "b1"))
|
||||
@@ -150,7 +150,7 @@
|
||||
(deftest set-block-property-with-non-ref-values
|
||||
(testing "Setting :default with same property value reuses existing entity"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:logseq.property/order-list-type "number"}}
|
||||
{:block/content "b2"}]}])
|
||||
property-value (:logseq.property/order-list-type (find-block-by-content conn "b1"))
|
||||
@@ -164,7 +164,7 @@
|
||||
|
||||
(testing "Setting :checkbox with same property value reuses existing entity"
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:checkbox true}}
|
||||
{:block/content "b2"}]}])
|
||||
property-value (:user.property/checkbox (find-block-by-content conn "b1"))
|
||||
@@ -178,7 +178,7 @@
|
||||
|
||||
(deftest remove-block-property!
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:default "foo"}}]}])
|
||||
block (find-block-by-content conn "b1")
|
||||
_ (assert (:user.property/default block))
|
||||
@@ -190,7 +190,7 @@
|
||||
|
||||
(deftest batch-set-property!
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "item 1"}
|
||||
{:block/content "item 2"}]}])
|
||||
block-ids (map #(-> (find-block-by-content conn %) :block/uuid) ["item 1" "item 2"])
|
||||
@@ -203,7 +203,7 @@
|
||||
|
||||
(deftest batch-remove-property!
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "item 1" :build/properties {:logseq.property/order-list-type "number"}}
|
||||
{:block/content "item 2" :build/properties {:logseq.property/order-list-type "number"}}]}])
|
||||
block-ids (map #(-> (find-block-by-content conn %) :block/uuid) ["item 1" "item 2"])
|
||||
@@ -215,7 +215,7 @@
|
||||
|
||||
(deftest add-existing-values-to-closed-values!
|
||||
(let [conn (create-conn-with-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :build/properties {:num 1}}
|
||||
{:block/content "b2" :build/properties {:num 2}}]}])
|
||||
values (map (fn [d] (:block/uuid (d/entity @conn (:v d)))) (d/datoms @conn :avet :user.property/num))
|
||||
@@ -266,7 +266,7 @@
|
||||
{:uuid used-closed-value-uuid :value "bar"}]
|
||||
:block/schema {:type :default}}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1" :user.property/default [:block/uuid used-closed-value-uuid]}]}]})
|
||||
_ (assert (:user.property/default (find-block-by-content conn "b1")))
|
||||
property-uuid (:block/uuid (d/entity @conn :user.property-default))
|
||||
@@ -299,9 +299,9 @@
|
||||
{:classes {:c1 {:build/schema-properties [:p1]}
|
||||
:c2 {:build/schema-properties [:p2 :p3]}}
|
||||
:pages-and-blocks
|
||||
[{:page {:block/original-name "p1"}
|
||||
[{:page {:block/title "p1"}
|
||||
:blocks [{:block/content "o1"
|
||||
:build/tags [:c1 :c2]}]}]})
|
||||
block (find-block-by-content conn "o1")]
|
||||
(is (= [:user.property/p1 :user.property/p2 :user.property/p3]
|
||||
(:classes-properties (outliner-property/get-block-classes-properties @conn (:db/id block)))))))
|
||||
(:classes-properties (outliner-property/get-block-classes-properties @conn (:db/id block)))))))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#(get %1 (keyword (name %2))))]
|
||||
(when-some [uuid (:block/uuid block)]
|
||||
(when-some [stamp (prop-lookup-fn props :logseq.property.pdf/hl-stamp)]
|
||||
(let [group-key (string/replace-first (:block/original-name page) #"^hls__" "")
|
||||
(let [group-key (string/replace-first (:block/title page) #"^hls__" "")
|
||||
hl-page (prop-lookup-fn props :logseq.property.pdf/hl-page)
|
||||
encoded-chars? (boolean (re-find #"(?i)%[0-9a-f]{2}" group-key))
|
||||
group-key (if encoded-chars? (js/encodeURI group-key) group-key)]
|
||||
|
||||
@@ -2335,4 +2335,4 @@
|
||||
:block/created-at 1668430322981
|
||||
:block/type "whiteboard"
|
||||
:block/name "637239f2-9680-4c82-802c-8858d9835c80"
|
||||
:block/original-name "637239f2-9680-4c82-802c-8858d9835c80"})}
|
||||
:block/title "637239f2-9680-4c82-802c-8858d9835c80"})}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
(map-indexed
|
||||
(fn [idx id]
|
||||
{:block/uuid id
|
||||
:block/original-name (str "Page-" (+ start-idx idx))})
|
||||
:block/title (str "Page-" (+ start-idx idx))})
|
||||
ids)))
|
||||
|
||||
(defn build-blocks
|
||||
@@ -69,7 +69,7 @@
|
||||
conn (outliner-cli/init-conn dir db-name {:classpath (cp/get-classpath)})
|
||||
_ (println "Building tx ...")
|
||||
{:keys [init-tx]} (outliner-cli/build-blocks-tx (create-init-data options))]
|
||||
(println "Built" (count init-tx) "tx," (count (filter :block/original-name init-tx)) "pages and"
|
||||
(println "Built" (count init-tx) "tx," (count (filter :block/title init-tx)) "pages and"
|
||||
(count (filter :block/content init-tx)) "blocks ...")
|
||||
;; Vary the chunking with page size up to a max to avoid OOM
|
||||
(let [tx-chunks (partition-all (min (:pages options) 30000) init-tx)]
|
||||
@@ -77,7 +77,7 @@
|
||||
chunk-num 1]
|
||||
(when-let [chunk (first chunks)]
|
||||
(println "Transacting chunk" chunk-num "of" (count tx-chunks)
|
||||
"starting with block:" (pr-str (select-keys (first chunk) [:block/content :block/original-name])))
|
||||
"starting with block:" (pr-str (select-keys (first chunk) [:block/content :block/title])))
|
||||
(d/transact! conn chunk)
|
||||
(recur (rest chunks) (inc chunk-num)))))
|
||||
#_(d/transact! conn blocks-tx)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
two-days-ago (subtract-days today 2)
|
||||
closed-values-config (build-closed-values-config {:dates [today yesterday two-days-ago]})
|
||||
page-values-tx (mapv #(hash-map :page
|
||||
{:block/uuid (:uuid %) :block/original-name (:value %)})
|
||||
{:block/uuid (:uuid %) :block/title (:value %)})
|
||||
(:page-closed closed-values-config))
|
||||
;; Stores random closed values for use with queries
|
||||
closed-values (atom {})
|
||||
@@ -69,9 +69,9 @@
|
||||
page-values-tx
|
||||
|
||||
;; Objects
|
||||
[{:page {:block/original-name "Page object"
|
||||
[{:page {:block/title "Page object"
|
||||
:build/tags [:TestClass]}}
|
||||
{:page {:block/original-name "Blocks"}
|
||||
{:page {:block/title "Blocks"}
|
||||
:blocks
|
||||
[{:block/content "block object"
|
||||
:block/uuid object-uuid
|
||||
@@ -88,7 +88,7 @@
|
||||
{:page {:build/journal (date-time-util/date->int two-days-ago)}}
|
||||
|
||||
;; Block property blocks and queries
|
||||
{:page {:block/original-name "Block Properties"}
|
||||
{:page {:block/title "Block Properties"}
|
||||
:blocks
|
||||
[{:block/content "default property block" :build/properties {:default "haha"}}
|
||||
{:block/content "default property block" :build/properties {:default-many #{"yee" "haw" "sir"}}}
|
||||
@@ -110,7 +110,7 @@
|
||||
{:block/content "date-many property block" :build/properties {:date-many #{[:page (date-journal-title today)]
|
||||
[:page (date-journal-title yesterday)]}}}
|
||||
#_{:block/content "date-closed property block" :build/properties {:date-closed (random-closed-value :date-closed)}}]}
|
||||
{:page {:block/original-name "Block Property Queries"}
|
||||
{:page {:block/title "Block Property Queries"}
|
||||
:blocks
|
||||
[{:block/content "{{query (property :default \"haha\")}}"}
|
||||
{:block/content "{{query (property :default-many \"haw\")}}"}
|
||||
@@ -132,26 +132,26 @@
|
||||
#_{:block/content (str "{{query (property :date-closed " (page-ref/->page-ref (string/capitalize (get-closed-value :date-closed))) ")}}")}]}
|
||||
|
||||
;; Page property pages and queries
|
||||
{:page {:block/original-name "default page" :build/properties {:default "yolo"}}}
|
||||
{:page {:block/original-name "default-many page" :build/properties {:default-many #{"yee" "haw" "sir"}}}}
|
||||
{:page {:block/original-name "default-closed page" :build/properties {:default-closed (random-closed-value :default-closed)}}}
|
||||
{:page {:block/original-name "url page" :build/properties {:url "https://logseq.com"}}}
|
||||
{:page {:block/original-name "url-many page" :build/properties {:url-many #{"https://logseq.com" "https://docs.logseq.com"}}}}
|
||||
{:page {:block/original-name "url-closed page" :build/properties {:url-closed (random-closed-value :url-closed)}}}
|
||||
{:page {:block/original-name "checkbox page" :build/properties {:checkbox true}}}
|
||||
{:page {:block/original-name "number page" :build/properties {:number 5}}}
|
||||
{:page {:block/original-name "number-many page" :build/properties {:number-many #{5 10}}}}
|
||||
{:page {:block/original-name "number-closed page" :build/properties {:number-closed (random-closed-value :number-closed)}}}
|
||||
{:page {:block/original-name "object page" :build/properties {:object [:block/uuid object-uuid]}}}
|
||||
{:page {:block/original-name "object-many page" :build/properties {:object-many #{[:block/uuid object-uuid] [:page "Page object"]}}}}
|
||||
{:page {:block/original-name "page page" :build/properties {:page [:page "Page 1"]}}}
|
||||
{:page {:block/original-name "page-many page" :build/properties {:page-many #{[:page "Page 1"] [:page "Page 2"]}}}}
|
||||
;; #_{:page {:block/original-name "page-closed page" :build/properties {:page-closed (random-closed-value :page-closed)}}}
|
||||
{:page {:block/original-name "date page" :build/properties {:date [:page (date-journal-title today)]}}}
|
||||
{:page {:block/original-name "date-many page" :build/properties {:date-many #{[:page (date-journal-title today)]
|
||||
{:page {:block/title "default page" :build/properties {:default "yolo"}}}
|
||||
{:page {:block/title "default-many page" :build/properties {:default-many #{"yee" "haw" "sir"}}}}
|
||||
{:page {:block/title "default-closed page" :build/properties {:default-closed (random-closed-value :default-closed)}}}
|
||||
{:page {:block/title "url page" :build/properties {:url "https://logseq.com"}}}
|
||||
{:page {:block/title "url-many page" :build/properties {:url-many #{"https://logseq.com" "https://docs.logseq.com"}}}}
|
||||
{:page {:block/title "url-closed page" :build/properties {:url-closed (random-closed-value :url-closed)}}}
|
||||
{:page {:block/title "checkbox page" :build/properties {:checkbox true}}}
|
||||
{:page {:block/title "number page" :build/properties {:number 5}}}
|
||||
{:page {:block/title "number-many page" :build/properties {:number-many #{5 10}}}}
|
||||
{:page {:block/title "number-closed page" :build/properties {:number-closed (random-closed-value :number-closed)}}}
|
||||
{:page {:block/title "object page" :build/properties {:object [:block/uuid object-uuid]}}}
|
||||
{:page {:block/title "object-many page" :build/properties {:object-many #{[:block/uuid object-uuid] [:page "Page object"]}}}}
|
||||
{:page {:block/title "page page" :build/properties {:page [:page "Page 1"]}}}
|
||||
{:page {:block/title "page-many page" :build/properties {:page-many #{[:page "Page 1"] [:page "Page 2"]}}}}
|
||||
;; #_{:page {:block/title "page-closed page" :build/properties {:page-closed (random-closed-value :page-closed)}}}
|
||||
{:page {:block/title "date page" :build/properties {:date [:page (date-journal-title today)]}}}
|
||||
{:page {:block/title "date-many page" :build/properties {:date-many #{[:page (date-journal-title today)]
|
||||
[:page (date-journal-title yesterday)]}}}}
|
||||
#_{:page {:block/original-name "date-closed page" :build/properties {:date-closed (random-closed-value :date-closed)}}}
|
||||
{:page {:block/original-name "Page Property Queries"}
|
||||
#_{:page {:block/title "date-closed page" :build/properties {:date-closed (random-closed-value :date-closed)}}}
|
||||
{:page {:block/title "Page Property Queries"}
|
||||
:blocks
|
||||
[{:block/content "{{query (page-property :default \"yolo\")}}"}
|
||||
{:block/content "{{query (page-property :default-many \"haw\")}}"}
|
||||
@@ -212,8 +212,8 @@
|
||||
conn (outliner-cli/init-conn dir db-name {:additional-config (:config options)
|
||||
:classpath (cp/get-classpath)})
|
||||
{:keys [init-tx block-props-tx]} (outliner-cli/build-blocks-tx (create-init-data))
|
||||
existing-names (set (map :v (d/datoms @conn :avet :block/original-name)))
|
||||
conflicting-names (set/intersection existing-names (set (keep :block/original-name init-tx)))]
|
||||
existing-names (set (map :v (d/datoms @conn :avet :block/title)))
|
||||
conflicting-names (set/intersection existing-names (set (keep :block/title init-tx)))]
|
||||
(when (seq conflicting-names)
|
||||
(println "Error: Following names conflict -" (string/join "," conflicting-names))
|
||||
(js/process.exit 1))
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
inverted-renamed-classes (set/map-invert renamed-classes)
|
||||
class-name (strip-schema-prefix (class-m "@id"))
|
||||
url (str "https://schema.org/" (get inverted-renamed-classes class-name class-name))]
|
||||
(cond-> {:block/original-name class-name
|
||||
(cond-> {:block/title class-name
|
||||
:build/properties (cond-> {:url url}
|
||||
(class-m "rdfs:comment")
|
||||
(assoc :description (get-comment-string (class-m "rdfs:comment") renamed-pages)))}
|
||||
@@ -241,7 +241,7 @@
|
||||
(->class-page % class-to-properties options)))
|
||||
(into {}))]
|
||||
(assert (= ["Thing"] (keep #(when-not (:build/class-parent %)
|
||||
(:block/original-name %))
|
||||
(:block/title %))
|
||||
(vals classes)))
|
||||
"Thing is the only class that doesn't have a schema.org parent class")
|
||||
classes))
|
||||
@@ -355,10 +355,10 @@
|
||||
(defn- write-debug-file [db]
|
||||
(let [ents (remove #(db-malli-schema/internal-ident? (:db/ident %))
|
||||
(d/q '[:find [(pull ?b [*
|
||||
{:class/schema.properties [:block/original-name]}
|
||||
{:property/schema.classes [:block/original-name]}
|
||||
{:class/parent [:block/original-name]}
|
||||
{:block/refs [:block/original-name]}]) ...]
|
||||
{:class/schema.properties [:block/title]}
|
||||
{:property/schema.classes [:block/title]}
|
||||
{:class/parent [:block/title]}
|
||||
{:block/refs [:block/title]}]) ...]
|
||||
:in $
|
||||
:where [?b :db/ident ?ident]]
|
||||
db))]
|
||||
@@ -367,7 +367,7 @@
|
||||
(->> ents
|
||||
(map (fn [m]
|
||||
(let [props (db-property/properties m)]
|
||||
(cond-> (select-keys m [:block/name :block/type :block/original-name :block/schema :db/ident
|
||||
(cond-> (select-keys m [:block/name :block/type :block/title :block/schema :db/ident
|
||||
:class/schema.properties :class/parent
|
||||
:db/cardinality :property/schema.classes :block/refs])
|
||||
(seq props)
|
||||
@@ -377,13 +377,13 @@
|
||||
(db-property/property-value-content (d/entity db (:db/id v)))
|
||||
v)))))
|
||||
(seq (:class/schema.properties m))
|
||||
(update :class/schema.properties #(set (map :block/original-name %)))
|
||||
(update :class/schema.properties #(set (map :block/title %)))
|
||||
(some? (:class/parent m))
|
||||
(update :class/parent :block/original-name)
|
||||
(update :class/parent :block/title)
|
||||
(seq (:property/schema.classes m))
|
||||
(update :property/schema.classes #(set (map :block/original-name %)))
|
||||
(update :property/schema.classes #(set (map :block/title %)))
|
||||
(seq (:block/refs m))
|
||||
(update :block/refs #(set (map :block/original-name %)))))))
|
||||
(update :block/refs #(set (map :block/title %)))))))
|
||||
set)))))
|
||||
|
||||
(defn -main [args]
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
(safe-api-call "redirectWhenExists"
|
||||
;; Redirect to the given page or block when the provided page or block exists.
|
||||
;; Either :page-name or :block-id is required.
|
||||
;; :page-name : the original-name of the page.
|
||||
;; :page-name : the title of the page.
|
||||
;; :block-id : uuid.
|
||||
(fn [data]
|
||||
(let [{:keys [page-name block-id file]} (bean/->clj data)]
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"block name, lowercase, only page-blocks have this attr"
|
||||
:string)
|
||||
|
||||
(sr/defkeyword :block/original-name
|
||||
(sr/defkeyword :block/title
|
||||
"like `:block/name`, but not unified into lowercase"
|
||||
:string)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
(defn- columns
|
||||
[db]
|
||||
(let [db-based? (ldb/db-based-graph? db)]
|
||||
(->> [{:id :block/original-name
|
||||
(->> [{:id :block/title
|
||||
:name (t :block/name)
|
||||
:cell (fn [_table row _column]
|
||||
(component-block/page-cp {} row))
|
||||
|
||||
@@ -559,7 +559,7 @@
|
||||
page-name (:block/name page-entity)
|
||||
breadcrumb? (:breadcrumb? config)
|
||||
config (assoc config :whiteboard-page? whiteboard-page?)
|
||||
untitled? (when page-name (model/untitled-page? (:block/original-name page-entity)))
|
||||
untitled? (when page-name (model/untitled-page? (:block/title page-entity)))
|
||||
display-close-button? (and (not (:hide-close-button? config))
|
||||
(not config/publishing?))
|
||||
hide-icon? (:hide-icon? config)]
|
||||
@@ -621,7 +621,7 @@
|
||||
(->elem :span (map-inline config label))
|
||||
|
||||
:else
|
||||
(let [original-name (:block/original-name page-entity)
|
||||
(let [title (:block/title page-entity)
|
||||
s (cond untitled?
|
||||
(t :untitled)
|
||||
|
||||
@@ -629,11 +629,11 @@
|
||||
(pdf-utils/hls-file? page-name)
|
||||
(pdf-utils/fix-local-asset-pagename page-name)
|
||||
|
||||
(not= (util/safe-page-name-sanity-lc original-name) page-name)
|
||||
(not= (util/safe-page-name-sanity-lc title) page-name)
|
||||
page-name ;; page-name-in-block might be overridden (legacy))
|
||||
|
||||
original-name
|
||||
(util/trim-safe original-name)
|
||||
title
|
||||
(util/trim-safe title)
|
||||
|
||||
:else
|
||||
(util/trim-safe page-name))
|
||||
@@ -1511,7 +1511,7 @@
|
||||
[:ul
|
||||
(for [child children]
|
||||
[:li {:key (str "namespace-" namespace "-" (:db/id child))}
|
||||
(let [shorten-name (some-> (or (:block/original-name child) (:block/name child))
|
||||
(let [shorten-name (some-> (or (:block/title child) (:block/name child))
|
||||
(string/split "/")
|
||||
last)]
|
||||
(page-cp {:label shorten-name} child))
|
||||
@@ -2228,7 +2228,7 @@
|
||||
util/caret-range)
|
||||
{:block/keys [content format]} block
|
||||
content (if (config/db-based-graph? (state/get-current-repo))
|
||||
(or (:block/original-name block) content)
|
||||
(or (:block/title block) content)
|
||||
(->> content
|
||||
(property-file/remove-built-in-properties-when-file-based
|
||||
(state/get-current-repo) format)
|
||||
@@ -2328,7 +2328,7 @@
|
||||
(rum/defc ^:large-vars/cleanup-todo block-content < rum/reactive
|
||||
[config {:block/keys [uuid content properties scheduled deadline format pre-block?] :as block} edit-input-id block-id slide?]
|
||||
(let [repo (state/get-current-repo)
|
||||
content (or (:block/original-name block)
|
||||
content (or (:block/title block)
|
||||
(if (config/db-based-graph? (state/get-current-repo))
|
||||
(:block/content block)
|
||||
(property-util/remove-built-in-properties format content)))
|
||||
@@ -2508,7 +2508,7 @@
|
||||
(ui/block-error "Block Render Error:"
|
||||
{:content (:block/content block)
|
||||
:section-attrs
|
||||
{:on-click #(let [content (or (:block/original-name block)
|
||||
{:on-click #(let [content (or (:block/title block)
|
||||
(:block/content block))]
|
||||
(editor-handler/clear-selection!)
|
||||
(editor-handler/unhighlight-blocks!)
|
||||
@@ -2630,7 +2630,7 @@
|
||||
page (or (db/get-block-page repo block-id) ;; only return for block uuid
|
||||
(model/query-block-by-uuid block-id)) ;; return page entity when received page uuid
|
||||
page-name (:block/name page)
|
||||
page-original-name (:block/original-name page)
|
||||
page-title (:block/title page)
|
||||
show? (or (seq parents) show-page? page-name)
|
||||
parents (if (= page-name (:block/name (first parents)))
|
||||
(rest parents)
|
||||
@@ -2642,7 +2642,7 @@
|
||||
(let [page-name-props (when show-page?
|
||||
[page
|
||||
(page-cp (dissoc config :breadcrumb? true) page)
|
||||
{:block/name (or page-original-name page-name)}])
|
||||
{:block/name (or page-title page-name)}])
|
||||
parents-props (doall
|
||||
(for [{:block/keys [uuid name content] :as block} parents]
|
||||
(if name
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
(if-let [parent-class (some-> (:db/id (:class/parent page))
|
||||
db/entity)]
|
||||
[:a {:on-click #(route-handler/redirect-to-page! (:block/uuid parent-class))}
|
||||
(:block/original-name parent-class)]
|
||||
(:block/title parent-class)]
|
||||
"None")]
|
||||
[:div.col-span-3
|
||||
(let [parent (some-> (:db/id (:class/parent page))
|
||||
@@ -95,8 +95,8 @@
|
||||
[:div.col-span-2 "Ancestor classes:"]
|
||||
[:div.col-span-3
|
||||
(interpose [:span.opacity-50.text-sm " > "]
|
||||
(map (fn [{class-name :block/original-name :as ancestor}]
|
||||
(if (= class-name (:block/original-name page))
|
||||
(map (fn [{class-name :block/title :as ancestor}]
|
||||
(if (= class-name (:block/title page))
|
||||
[:span class-name]
|
||||
[:a {:on-click #(route-handler/redirect-to-page! (:block/uuid ancestor))} class-name]))
|
||||
class-ancestors))]])))])))
|
||||
@@ -106,8 +106,8 @@
|
||||
(let [children (:class/_parent class)]
|
||||
(when (seq children)
|
||||
[:ul
|
||||
(for [child (sort-by :block/original-name children)]
|
||||
(let [title [:li.ml-2 (block/page-reference false (:block/original-name child) {:show-brackets? false} nil)]]
|
||||
(for [child (sort-by :block/title children)]
|
||||
(let [title [:li.ml-2 (block/page-reference false (:block/title child) {:show-brackets? false} nil)]]
|
||||
(if (seq (:class/_parent child))
|
||||
(ui/foldable
|
||||
title
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
:icon-theme :gray
|
||||
:text (:title page)
|
||||
:source-page (if source-page
|
||||
(:block/original-name source-page)
|
||||
(:block/title source-page)
|
||||
(:title page)))))))]
|
||||
(swap! !results update group merge {:status :success :items items}))))
|
||||
|
||||
@@ -233,7 +233,7 @@
|
||||
!results (::results state)]
|
||||
(swap! !results assoc-in [group :status] :loading)
|
||||
(p/let [whiteboards (->> (model/get-all-whiteboards (state/get-current-repo))
|
||||
(map :block/original-name))
|
||||
(map :block/title))
|
||||
pages (search/fuzzy-search whiteboards @!input {:limit 100})
|
||||
items (->> pages
|
||||
(remove nil?)
|
||||
|
||||
@@ -76,9 +76,9 @@
|
||||
[page icon recent?]
|
||||
(let [repo (state/get-current-repo)
|
||||
page (or (db/get-alias-source-page repo (:db/id page)) page)
|
||||
original-name (:block/original-name page)
|
||||
title (:block/title page)
|
||||
whiteboard-page? (db-model/whiteboard-page? page)
|
||||
untitled? (db-model/untitled-page? original-name)
|
||||
untitled? (db-model/untitled-page? title)
|
||||
name (:block/name page)
|
||||
file-rpath (when (util/electron?) (page-util/get-page-file-rpath name))
|
||||
ctx-icon #(shui/tabler-icon %1 {:class "scale-90 pr-1 opacity-80"})
|
||||
@@ -92,7 +92,7 @@
|
||||
[:<>
|
||||
(when-not recent?
|
||||
(x-menu-item
|
||||
{:on-click #(page-handler/<unfavorite-page! original-name)}
|
||||
{:on-click #(page-handler/<unfavorite-page! title)}
|
||||
(ctx-icon "star-off")
|
||||
(t :page/unfavorite)
|
||||
(x-menu-shortcut (when-let [binding (shortcut-dh/shortcut-binding :command/toggle-favorite)]
|
||||
@@ -133,7 +133,7 @@
|
||||
[:span.page-icon.ml-3.justify-center (if whiteboard-page? (ui/icon "whiteboard" {:extension? true}) icon)]
|
||||
[:span.page-title {:class (when untitled? "opacity-50")}
|
||||
(if untitled? (t :untitled)
|
||||
(pdf-utils/fix-local-asset-pagename original-name))]
|
||||
(pdf-utils/fix-local-asset-pagename title))]
|
||||
|
||||
;; dots trigger
|
||||
(shui/button
|
||||
@@ -194,7 +194,7 @@
|
||||
(for [page pages]
|
||||
[:li.recent-item.select-none
|
||||
{:key (str "recent-" (:db/id page))
|
||||
:title (:block/original-name page)
|
||||
:title (:block/title page)
|
||||
:draggable true
|
||||
:on-drag-start (fn [event] (editor-handler/block->data-transfer! (:block/name page) event true))
|
||||
:data-ref name}
|
||||
|
||||
@@ -293,6 +293,6 @@
|
||||
(ui/button (t :export-save-to-file)
|
||||
:on-click #(let [file-name (if (uuid? root-block-uuids-or-page-uuid)
|
||||
(-> (db/get-page root-block-uuids-or-page-uuid)
|
||||
(util/get-page-original-name))
|
||||
(util/get-page-title))
|
||||
(t/now))]
|
||||
(utils/saveToFile (js/Blob. [@*content]) (str "logseq_" file-name) (if (= tp :text) "txt" (name tp)))))])]]))
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
(let [repo-dir (config/get-repo-dir (state/get-current-repo))
|
||||
rel-path (when (string/starts-with? path repo-dir)
|
||||
(path/trim-dir-prefix repo-dir path))
|
||||
original-name (db/get-file-page (or path rel-path))
|
||||
title (db/get-file-page (or path rel-path))
|
||||
in-db? (when-not (path/absolute? path)
|
||||
(boolean (db/get-file (or path rel-path))))
|
||||
file-path (cond
|
||||
@@ -120,22 +120,22 @@
|
||||
[:div.file {:id (str "file-edit-wrapper-" random-id)
|
||||
:key path}
|
||||
[:h1.title
|
||||
[:bdi (or original-name rel-path path)]]
|
||||
(when original-name
|
||||
[:bdi (or title rel-path path)]]
|
||||
(when title
|
||||
[:div.text-sm.mb-4.ml-1 "Page: "
|
||||
[:a.bg-base-2.p-1.ml-1 {:style {:border-radius 4}
|
||||
:href (rfe/href :page {:name original-name})
|
||||
:href (rfe/href :page {:name title})
|
||||
:on-click (fn [e]
|
||||
(when (gobj/get e "shiftKey")
|
||||
(when-let [page (db/get-page original-name)]
|
||||
(when-let [page (db/get-page title)]
|
||||
(state/sidebar-add-block!
|
||||
(state/get-current-repo)
|
||||
(:db/id page)
|
||||
:page))
|
||||
(util/stop e)))}
|
||||
original-name]])
|
||||
title]])
|
||||
|
||||
(when (and original-name (not (string/starts-with? original-name "logseq/")))
|
||||
(when (and title (not (string/starts-with? title "logseq/")))
|
||||
[:p.text-sm.ml-1.mb-4
|
||||
(svg/warning {:style {:width "1em"
|
||||
:display "inline-block"}})
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
(distinct)
|
||||
(sort-by :block/name)
|
||||
(map (fn [page]
|
||||
(or (:block/original-name page) (:block/name page))))
|
||||
(or (:block/title page) (:block/name page))))
|
||||
(map #(string/split % "/")))
|
||||
page-namespace (db-model/get-page-namespace repo page)
|
||||
page-namespace (util/get-page-original-name page-namespace)]
|
||||
page-namespace (util/get-page-title page-namespace)]
|
||||
(cond
|
||||
(seq pages)
|
||||
{:namespaces pages
|
||||
|
||||
@@ -632,7 +632,7 @@
|
||||
[list-ready? set-list-ready?] (rum/use-state false)
|
||||
[content-ready? set-content-ready?] (rum/use-state false)
|
||||
*ref-contents (rum/use-ref (atom {}))
|
||||
original-page-name (or (:block/original-name page-entity) page-name)]
|
||||
original-page-name (or (:block/title page-entity) page-name)]
|
||||
|
||||
(rum/use-effect!
|
||||
#(when selected-page
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
(str repo "-custom-query-" (:query query))))]))))
|
||||
|
||||
(rum/defc tagged-pages
|
||||
[repo tag tag-original-name]
|
||||
[repo tag tag-title]
|
||||
(let [[pages set-pages!] (rum/use-state nil)]
|
||||
(rum/use-effect!
|
||||
(fn []
|
||||
@@ -240,9 +240,9 @@
|
||||
[:div.references.page-tags.mt-6.flex-1.flex-row
|
||||
[:div.content
|
||||
(ui/foldable
|
||||
[:h2.font-bold.opacity-50 (util/format "Pages tagged with \"%s\"" tag-original-name)]
|
||||
[:h2.font-bold.opacity-50 (util/format "Pages tagged with \"%s\"" tag-title)]
|
||||
[:ul.mt-2
|
||||
(for [page (sort-by :block/original-name pages)]
|
||||
(for [page (sort-by :block/title pages)]
|
||||
[:li {:key (str "tagged-page-" (:db/id page))}
|
||||
(component-block/page-cp {} page)])]
|
||||
{:default-collapsed? false})]])))
|
||||
@@ -318,18 +318,18 @@
|
||||
:on-click #(swap! *show-page-info? not)}
|
||||
"Configure")])
|
||||
|
||||
(rum/defcs ^:large-vars/cleanup-todo page-title < rum/reactive
|
||||
(rum/defcs ^:large-vars/cleanup-todo page-title-cp < rum/reactive
|
||||
(rum/local false ::edit?)
|
||||
(rum/local "" ::input-value)
|
||||
{:init (fn [state]
|
||||
(let [page (first (:rum/args state))
|
||||
original-name (:block/original-name page)
|
||||
*title-value (atom original-name)]
|
||||
title (:block/title page)
|
||||
*title-value (atom title)]
|
||||
(assoc state ::title-value *title-value)))}
|
||||
[state page {:keys [fmt-journal? preview? *hover? *show-page-info?]}]
|
||||
(when page
|
||||
(let [page (db/sub-block (:db/id page))
|
||||
title (:block/original-name page)]
|
||||
title (:block/title page)]
|
||||
(when title
|
||||
(let [journal? (ldb/journal-page? page)
|
||||
icon (get page (pu/get-pid :logseq.property/icon))
|
||||
@@ -366,7 +366,7 @@
|
||||
{:class (when-not whiteboard-page? "title")
|
||||
:on-pointer-down (fn [e]
|
||||
(when (util/right-click? e)
|
||||
(state/set-state! :page-title/context {:page (:block/original-name page)
|
||||
(state/set-state! :page-title/context {:page (:block/title page)
|
||||
:page-entity page})))
|
||||
:on-click (fn [e]
|
||||
(when-not (= (.-nodeName (.-target e)) "INPUT")
|
||||
@@ -388,7 +388,7 @@
|
||||
(page-title-editor page {:*title-value *title-value
|
||||
:*edit? *edit?
|
||||
:*input-value *input-value
|
||||
:page-name (:block/original-name page)
|
||||
:page-name (:block/title page)
|
||||
:old-name old-name
|
||||
:untitled? untitled?
|
||||
:whiteboard-page? whiteboard-page?
|
||||
@@ -398,7 +398,7 @@
|
||||
(when (and (state/home?) (not preview?))
|
||||
(route-handler/redirect-to-page! (:block/uuid page))))
|
||||
:data-value @*input-value
|
||||
:data-ref (:block/original-name page)
|
||||
:data-ref (:block/title page)
|
||||
:style {:opacity (when @*edit? 0)}}
|
||||
(let [nested? (and (string/includes? title page-ref/left-brackets)
|
||||
(string/includes? title page-ref/right-brackets))]
|
||||
@@ -494,8 +494,8 @@
|
||||
whiteboard-page? (model/whiteboard-page? page) ;; is this page a whiteboard?
|
||||
route-page-name path-page-name
|
||||
page-name (:block/name page)
|
||||
page-original-name (:block/original-name page)
|
||||
title (or page-original-name page-name)
|
||||
page-title (:block/title page)
|
||||
title (or page-title page-name)
|
||||
today? (and
|
||||
journal?
|
||||
(= page-name (util/page-name-sanity-lc (date/journal-name))))
|
||||
@@ -506,7 +506,7 @@
|
||||
(when (or page-name block-or-whiteboard?)
|
||||
[:div.flex-1.page.relative
|
||||
(merge (if (seq (:block/tags page))
|
||||
(let [page-names (map :block/original-name (:block/tags page))]
|
||||
(let [page-names (map :block/title (:block/tags page))]
|
||||
(when (seq page-names)
|
||||
{:data-page-tags (text-util/build-data-value page-names)}))
|
||||
{})
|
||||
@@ -528,11 +528,11 @@
|
||||
(page-mouse-leave e *control-show?))}
|
||||
(page-blocks-collapse-control title *control-show? *all-collapsed?)])
|
||||
(when (and (not whiteboard?) (ldb/page? page))
|
||||
(page-title page {:journal? journal?
|
||||
:fmt-journal? fmt-journal?
|
||||
:preview? preview?
|
||||
:*hover? (::hover-title? state)
|
||||
:*show-page-info? (::show-page-info? state)}))
|
||||
(page-title-cp page {:journal? journal?
|
||||
:fmt-journal? fmt-journal?
|
||||
:preview? preview?
|
||||
:*hover? (::hover-title? state)
|
||||
:*show-page-info? (::show-page-info? state)}))
|
||||
(when (not config/publishing?)
|
||||
(when config/lsp-enabled?
|
||||
[:div.flex.flex-row
|
||||
@@ -555,15 +555,15 @@
|
||||
|
||||
(when-not (and db-based? (ldb/class? page))
|
||||
[:div
|
||||
(when (and block? (not sidebar?) (not whiteboard?))
|
||||
(let [config (merge config {:id "block-parent"
|
||||
:block? true})]
|
||||
[:div.mb-4
|
||||
(component-block/breadcrumb config repo block-id {:level-limit 3})]))
|
||||
(when (and block? (not sidebar?) (not whiteboard?))
|
||||
(let [config (merge config {:id "block-parent"
|
||||
:block? true})]
|
||||
[:div.mb-4
|
||||
(component-block/breadcrumb config repo block-id {:level-limit 3})]))
|
||||
|
||||
;; blocks
|
||||
(page-blocks-cp repo page (merge option {:sidebar? sidebar?
|
||||
:whiteboard? whiteboard?}))])])
|
||||
(page-blocks-cp repo page (merge option {:sidebar? sidebar?
|
||||
:whiteboard? whiteboard?}))])])
|
||||
|
||||
(when @(::main-ready? state)
|
||||
[:div {:style {:padding-left 9}}
|
||||
@@ -574,7 +574,7 @@
|
||||
(scheduled/scheduled-and-deadlines page-name))
|
||||
|
||||
(when (and (not block?) (not db-based?))
|
||||
(tagged-pages repo page page-original-name))
|
||||
(tagged-pages repo page page-title))
|
||||
|
||||
(when (contains? (:block/type page) "class")
|
||||
(class-component/class-children page))
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
[page]
|
||||
(page-handler/<delete! (:block/uuid page)
|
||||
(fn []
|
||||
(notification/show! (str "Page " (:block/original-name page) " was deleted successfully!")
|
||||
(notification/show! (str "Page " (:block/title page) " was deleted successfully!")
|
||||
:success))
|
||||
{:error-handler (fn [{:keys [msg]}]
|
||||
(notification/show! msg :warning))}))
|
||||
@@ -40,7 +40,7 @@
|
||||
(if (config/db-based-graph? (state/get-current-repo))
|
||||
(t :page/db-delete-confirmation)
|
||||
(t :page/delete-confirmation))]
|
||||
:content [:p.opacity-60 (str "- " (:block/original-name page))]
|
||||
:content [:p.opacity-60 (str "- " (:block/title page))]
|
||||
:outside-cancel? true})
|
||||
(p/then #(delete-page! page))
|
||||
(p/catch #()))))
|
||||
@@ -49,7 +49,7 @@
|
||||
[page]
|
||||
(when-let [page-name (and page (db/page? page) (:block/name page))]
|
||||
(let [repo (state/sub :git/current-repo)
|
||||
page-original-name (:block/original-name page)
|
||||
page-title (:block/title page)
|
||||
whiteboard? (contains? (set (:block/type page)) "whiteboard")
|
||||
block? (and page (util/uuid-string? page-name) (not whiteboard?))
|
||||
contents? (= page-name "contents")
|
||||
@@ -74,8 +74,8 @@
|
||||
:options {:on-click
|
||||
(fn []
|
||||
(if favorited?
|
||||
(page-handler/<unfavorite-page! page-original-name)
|
||||
(page-handler/<favorite-page! page-original-name)))}})
|
||||
(page-handler/<unfavorite-page! page-title)
|
||||
(page-handler/<favorite-page! page-title)))}})
|
||||
|
||||
(when (or (util/electron?) file-sync-graph-uuid)
|
||||
{:title (t :page/version-history)
|
||||
@@ -95,7 +95,7 @@
|
||||
(when (or (util/electron?)
|
||||
(mobile-util/native-platform?))
|
||||
{:title (t :page/copy-page-url)
|
||||
:options {:on-click #(page-handler/copy-page-url page-original-name)}})
|
||||
:options {:on-click #(page-handler/copy-page-url page-title)}})
|
||||
|
||||
(when-not (or contents?
|
||||
config/publishing?
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
(if (seq schema-classes)
|
||||
[:div.flex.flex-1.flex-row.items-center.flex-wrap.gap-2
|
||||
(for [class schema-classes]
|
||||
[:a.text-sm (str "#" (:block/original-name class))])]
|
||||
[:a.text-sm (str "#" (:block/title class))])]
|
||||
(pv/property-empty-btn-value))])])))
|
||||
|
||||
(defn- property-type-label
|
||||
@@ -160,7 +160,7 @@
|
||||
*show-class-select?
|
||||
default-open? page-configure? class-schema?]
|
||||
:as opts}]
|
||||
(let [property-name (or (and *property-name @*property-name) (:block/original-name property))
|
||||
(let [property-name (or (and *property-name @*property-name) (:block/title property))
|
||||
property-schema (or (and *property-schema @*property-schema) (:block/schema property))
|
||||
schema-types (->> (concat db-property-type/user-built-in-property-types
|
||||
(when built-in?
|
||||
@@ -245,7 +245,7 @@
|
||||
(assoc state ::values *values)))
|
||||
:will-mount (fn [state]
|
||||
(let [[property _opts] (:rum/args state)]
|
||||
(reset! (::property-name state) (:block/original-name property))
|
||||
(reset! (::property-name state) (:block/title property))
|
||||
(reset! (::property-schema state) (:block/schema property))
|
||||
(state/set-state! :editor/property-configure? true)
|
||||
state))
|
||||
@@ -412,14 +412,14 @@
|
||||
(set-properties! (remove exclude-properties properties))
|
||||
(set-excluded-properties! (->> properties
|
||||
(filter exclude-properties)
|
||||
(map :block/original-name)
|
||||
(map :block/title)
|
||||
set))))
|
||||
[])
|
||||
[:div.ls-property-add.flex.flex-row.items-center.property-key
|
||||
[:div.ls-property-key
|
||||
(select/select (merge
|
||||
{:items (map (fn [x]
|
||||
{:label (:block/original-name x)
|
||||
{:label (:block/title x)
|
||||
:value (:block/uuid x)}) properties)
|
||||
:extract-fn :label
|
||||
:dropdown? false
|
||||
@@ -523,10 +523,10 @@
|
||||
*property-schema (::property-schema state)
|
||||
existing-tag-alias (->> db-property/db-attribute-properties
|
||||
(map db-property/built-in-properties)
|
||||
(keep #(when (get block (:attribute %)) (:original-name %)))
|
||||
(keep #(when (get block (:attribute %)) (:title %)))
|
||||
set)
|
||||
exclude-properties (fn [m]
|
||||
(or (and (not page?) (contains? existing-tag-alias (:block/original-name m)))
|
||||
(or (and (not page?) (contains? existing-tag-alias (:block/title m)))
|
||||
;; Filters out properties from being in wrong :view-context
|
||||
(and (not page?) (= :page (get-in m [:block/schema :view-context])))
|
||||
(and page? (= :block (get-in m [:block/schema :view-context])))))
|
||||
@@ -589,7 +589,7 @@
|
||||
[state block property {:keys [class-schema? page-cp inline-text other-position?]}]
|
||||
(let [*hover? (::hover? state)
|
||||
icon (:logseq.property/icon property)
|
||||
property-name (:block/original-name property)]
|
||||
property-name (:block/title property)]
|
||||
[:div.flex.flex-row.items-center.gap-1
|
||||
{:on-mouse-over #(reset! *hover? true)
|
||||
:on-mouse-leave #(reset! *hover? false)
|
||||
@@ -635,11 +635,11 @@
|
||||
(if config/publishing?
|
||||
[:a.property-k.flex.select-none.jtrigger
|
||||
{:on-click #(route-handler/redirect-to-page! (:block/uuid property))}
|
||||
(:block/original-name property)]
|
||||
(:block/title property)]
|
||||
|
||||
(shui/trigger-as :a
|
||||
{:tabIndex 0
|
||||
:title (str "Configure property: " (:block/original-name property))
|
||||
:title (str "Configure property: " (:block/title property))
|
||||
:class "property-k flex select-none jtrigger w-full"
|
||||
:on-pointer-down (fn [^js e]
|
||||
(when (util/meta-key? e)
|
||||
@@ -666,7 +666,7 @@
|
||||
:align "start"
|
||||
:auto-side? true
|
||||
:auto-focus? true}))}
|
||||
(:block/original-name property)))]))
|
||||
(:block/title property)))]))
|
||||
|
||||
(defn- resolve-linked-block-if-exists
|
||||
"Properties will be updated for the linked page instead of the refed block.
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
[state item {:keys [toggle-fn delete-choice update-icon]} parent-opts]
|
||||
(let [*hover? (::hover? state)
|
||||
value (db-property/closed-value-content item)
|
||||
page? (:block/original-name item)
|
||||
page? (:block/title item)
|
||||
property-block? (db-property/property-created-block? item)]
|
||||
[:div.flex.flex-1.flex-row.items-center.gap-2.justify-between
|
||||
{:on-mouse-over #(reset! *hover? true)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
(defn update-property!
|
||||
[property property-name property-schema]
|
||||
(when (or (not= (:block/original-name property) property-name)
|
||||
(when (or (not= (:block/title property) property-name)
|
||||
(not= (:block/schema property) property-schema))
|
||||
(db-property-handler/upsert-property!
|
||||
(:db/ident property)
|
||||
|
||||
@@ -188,7 +188,7 @@
|
||||
[value {:keys [on-change editing? multiple-values? other-position?]}]
|
||||
(let [*trigger-ref (rum/use-ref nil)
|
||||
page value
|
||||
title (when page (:block/original-name page))
|
||||
title (when page (:block/title page))
|
||||
value' (when title
|
||||
(js/Date. (date/journal-title->long title)))
|
||||
content-fn (fn [{:keys [id]}] (calendar-inner id on-change value'))
|
||||
@@ -276,7 +276,7 @@
|
||||
(let [selected-choices (->> selected-choices
|
||||
(remove nil?)
|
||||
(remove #(= :logseq.property/empty-placeholder %)))
|
||||
clear-value (str "No " (:block/original-name property))
|
||||
clear-value (str "No " (:block/title property))
|
||||
clear-value-label [:div.flex.flex-row.items-center.gap-2
|
||||
(ui/icon "x")
|
||||
[:div clear-value]]
|
||||
@@ -309,7 +309,7 @@
|
||||
|
||||
(defn- get-title
|
||||
[e]
|
||||
(or (:block/original-name e)
|
||||
(or (:block/title e)
|
||||
(:block/content e)))
|
||||
|
||||
(rum/defc select-page < rum/reactive db-mixins/query
|
||||
@@ -391,10 +391,10 @@
|
||||
(mapcat #(model/get-class-children repo (:db/id %)))
|
||||
(map #(db/entity repo %)))]
|
||||
(->> (concat classes' descendent-classes)
|
||||
(filter #(string/includes? (:block/original-name %) class-input))
|
||||
(filter #(string/includes? (:block/title %) class-input))
|
||||
(mapv (fn [p]
|
||||
{:value (str new-page "#" (:block/original-name p))
|
||||
:label (str new-page "#" (:block/original-name p))}))))
|
||||
{:value (str new-page "#" (:block/title p))
|
||||
:label (str new-page "#" (:block/title p))}))))
|
||||
results))))]
|
||||
(select-aux block property opts')))
|
||||
|
||||
@@ -464,7 +464,7 @@
|
||||
:value value})))
|
||||
(distinct)))
|
||||
items (->> (if (= :date type)
|
||||
(map (fn [m] (let [label (:block/original-name (db/entity (:value m)))]
|
||||
(map (fn [m] (let [label (:block/title (db/entity (:value m)))]
|
||||
(when label
|
||||
(assoc m :label label)))) items)
|
||||
items)
|
||||
@@ -848,5 +848,5 @@
|
||||
(shui/tooltip-trigger
|
||||
{:onFocusCapture #(util/stop-propagation %)} value-cp)
|
||||
(shui/tooltip-content
|
||||
(str "Change " (:block/original-name property)))))
|
||||
(str "Change " (:block/title property)))))
|
||||
value-cp))))
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
(set-properties! properties)))
|
||||
[])
|
||||
(select (map #(hash-map :db/ident (:db/ident %)
|
||||
:value (:block/original-name %))
|
||||
:value (:block/title %))
|
||||
properties)
|
||||
(fn [{value :value db-ident :db/ident}]
|
||||
(reset! *mode "property-value")
|
||||
@@ -191,7 +191,7 @@
|
||||
(set-values! result)))
|
||||
[])
|
||||
(let [items (->> values
|
||||
(map :block/original-name)
|
||||
(map :block/title)
|
||||
sort)]
|
||||
(select items
|
||||
(fn [{:keys [value]}]
|
||||
@@ -256,13 +256,13 @@
|
||||
(append-tree! *tree opts loc (vec (cons :priority choices)))))})
|
||||
|
||||
"page"
|
||||
(let [pages (sort (db-model/get-all-page-original-names repo))]
|
||||
(let [pages (sort (db-model/get-all-page-titles repo))]
|
||||
(select pages
|
||||
(fn [{:keys [value]}]
|
||||
(append-tree! *tree opts loc [:page value]))))
|
||||
|
||||
"page reference"
|
||||
(let [pages (sort (db-model/get-all-page-original-names repo))]
|
||||
(let [pages (sort (db-model/get-all-page-titles repo))]
|
||||
(select pages
|
||||
(fn [{:keys [value]}]
|
||||
(append-tree! *tree opts loc [:page-ref value]))
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
result)
|
||||
result)
|
||||
sort-by-column' (if (and db-graph? (qualified-keyword? sort-by-column))
|
||||
(:block/original-name (db-utils/entity repo sort-by-column))
|
||||
(:block/title (db-utils/entity repo sort-by-column))
|
||||
sort-by-column)]
|
||||
(sort-by (fn [item]
|
||||
(block/normalize-block (sort-by-fn sort-by-column' item {:page? page? :db-graph? db-graph?})
|
||||
@@ -157,9 +157,9 @@
|
||||
(case column
|
||||
:page
|
||||
[:string (if page?
|
||||
(or (:block/original-name row)
|
||||
(or (:block/title row)
|
||||
(:block/name row))
|
||||
(or (get-in row [:block/page :block/original-name])
|
||||
(or (get-in row [:block/page :block/title])
|
||||
(get-in row [:block/page :block/name])))]
|
||||
|
||||
:block ; block title
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
filtered-ref-blocks' (map first result)
|
||||
ref-pages (->>
|
||||
(mapcat second result)
|
||||
(map :block/original-name)
|
||||
(map :block/title)
|
||||
frequencies)]
|
||||
(reset! *ref-pages ref-pages)
|
||||
(when (or (seq (:included filters)) (seq (:excluded filters)) (> filter-n 0))
|
||||
@@ -207,7 +207,7 @@
|
||||
(when (seq ref-blocks)
|
||||
[:div.references-blocks
|
||||
(let [ref-hiccup (block/->hiccup ref-blocks
|
||||
{:id (str (:block/original-name page) "-unlinked-")
|
||||
{:id (str (:block/title page) "-unlinked-")
|
||||
:ref? true
|
||||
:group-by-page? true
|
||||
:editor-box editor/box}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
[page filters filtered-references*]
|
||||
[:div.flex.gap-2.flex-wrap.items-center
|
||||
(let [filtered-references (if (de/entity? (first filtered-references*))
|
||||
(map (fn [e] [(:block/original-name e)]) filtered-references*)
|
||||
(map (fn [e] [(:block/title e)]) filtered-references*)
|
||||
filtered-references*)] <
|
||||
(for [[ref-name ref-count] filtered-references]
|
||||
(when ref-name
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
(if-let [icon (pu/get-block-property-value page :logseq.property/icon)]
|
||||
[:.text-md.mr-2 icon]
|
||||
(ui/icon (if (contains? (:block/type page) "whiteboard") "whiteboard" "page") {:class "text-md mr-2"}))
|
||||
[:span.overflow-hidden.text-ellipsis (:block/original-name page)]]
|
||||
[:span.overflow-hidden.text-ellipsis (:block/title page)]]
|
||||
(page-cp repo page-name)])
|
||||
|
||||
:search
|
||||
@@ -124,7 +124,7 @@
|
||||
:page-slide-view
|
||||
(let [page (db/entity db-id)]
|
||||
[[:a.page-title {:href (rfe/href :page {:name (str (:block/uuid page))})}
|
||||
(:block/original-name page)]
|
||||
(:block/title page)]
|
||||
[:div.ml-2.slide.mt-2
|
||||
(slide/slide page)]])
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@
|
||||
(or (db/entity ident) property))]
|
||||
{:id ident
|
||||
:name (or (:name property)
|
||||
(:block/original-name property))
|
||||
(:block/title property))
|
||||
:header (or (:header property)
|
||||
header-cp)
|
||||
:cell (or (:cell property)
|
||||
@@ -226,7 +226,7 @@
|
||||
(case (:id column)
|
||||
:select 32
|
||||
:add-property 160
|
||||
(:object/name :block/original-name :block/name :block/content) 360
|
||||
(:object/name :block/title :block/name :block/content) 360
|
||||
(:block/created-at :block/updated-at) 160
|
||||
180))
|
||||
|
||||
@@ -429,7 +429,7 @@
|
||||
(let [id (:id column)
|
||||
property (db/entity id)
|
||||
internal-property {:db/ident (:id column)
|
||||
:block/original-name (:name column)
|
||||
:block/title (:name column)
|
||||
:block/schema {:type (:type column)}}]
|
||||
(if (or property
|
||||
(= :db.cardinality/many (:db/cardinality (get schema id)))
|
||||
@@ -447,7 +447,7 @@
|
||||
timestamp?
|
||||
(merge option
|
||||
{:items timestamp-options
|
||||
:input-default-placeholder (if property (:block/original-name property) "Select")
|
||||
:input-default-placeholder (if property (:block/title property) "Select")
|
||||
:on-chosen (fn [value]
|
||||
(shui/popup-hide!)
|
||||
(let [filters' (conj filters [(:db/ident property) :after value])]
|
||||
@@ -458,14 +458,14 @@
|
||||
{:value false :label "false"}]]
|
||||
(merge option
|
||||
{:items items
|
||||
:input-default-placeholder (if property (:block/original-name property) "Select")
|
||||
:input-default-placeholder (if property (:block/title property) "Select")
|
||||
:on-chosen (fn [value]
|
||||
(let [filters' (conj filters [(:db/ident property) :is value])]
|
||||
(set-filters! filters')))}))
|
||||
(let [items (get-property-values (:data table) property)]
|
||||
(merge option
|
||||
{:items items
|
||||
:input-default-placeholder (if property (:block/original-name property) "Select")
|
||||
:input-default-placeholder (if property (:block/title property) "Select")
|
||||
:multiple-choices? true
|
||||
:on-chosen (fn [_value _selected? selected]
|
||||
(let [selected-value (if (de/entity? (first selected))
|
||||
@@ -627,7 +627,7 @@
|
||||
false
|
||||
true)
|
||||
option (cond->
|
||||
{:input-default-placeholder (:block/original-name property)
|
||||
{:input-default-placeholder (:block/title property)
|
||||
:input-opts {:class "!px-3 !py-1"}
|
||||
:items items
|
||||
:extract-fn :label
|
||||
@@ -715,18 +715,18 @@
|
||||
(let [[property-ident operator value] filter
|
||||
property (if (= property-ident :object/name)
|
||||
{:db/ident property-ident
|
||||
:block/original-name "Name"}
|
||||
:block/title "Name"}
|
||||
(or (db/entity property-ident)
|
||||
(some (fn [column] (when (= (:id column) property-ident)
|
||||
{:db/ident (:id column)
|
||||
:block/original-name (:name column)})) columns)))]
|
||||
:block/title (:name column)})) columns)))]
|
||||
[:div.flex.flex-row.items-center.border.rounded
|
||||
(shui/button
|
||||
{:class "!px-2 rounded-none border-r"
|
||||
:variant "ghost"
|
||||
:size :sm
|
||||
:disabled true}
|
||||
[:span.text-xs (:block/original-name property)])
|
||||
[:span.text-xs (:block/title property)])
|
||||
(filter-operator property operator filters set-filters! idx)
|
||||
(filter-value table property operator value filters set-filters! idx)
|
||||
(shui/button
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
[:div.dashboard-card-title-name.font-bold
|
||||
(if (common-util/uuid-string? (:block/name whiteboard))
|
||||
[:span.opacity-50 (t :untitled)]
|
||||
(:block/original-name whiteboard))]
|
||||
(:block/title whiteboard))]
|
||||
[:div.flex-1]
|
||||
[:div.dashboard-card-checkbox
|
||||
{:tab-index -1
|
||||
@@ -208,7 +208,7 @@
|
||||
[:div.whiteboard-page-title
|
||||
{:style {:color "var(--ls-primary-text-color)"
|
||||
:user-select "none"}}
|
||||
(page/page-title page {:*hover? (atom false)})]
|
||||
(page/page-title-cp page {:*hover? (atom false)})]
|
||||
|
||||
(references-count (:block/uuid page) "text-md cursor-pointer" {})]
|
||||
(tldraw-app page-uuid block-id)]))
|
||||
|
||||
@@ -54,10 +54,10 @@
|
||||
[graph]
|
||||
(p/let [result (<q graph
|
||||
{:transact-db? false}
|
||||
'[:find [(pull ?e [:block/uuid :db/ident :block/original-name :block/schema]) ...]
|
||||
'[:find [(pull ?e [:block/uuid :db/ident :block/title :block/schema]) ...]
|
||||
:where
|
||||
[?e :block/type "property"]
|
||||
[?e :block/original-name]])]
|
||||
[?e :block/title]])]
|
||||
(->> result
|
||||
;; remove private built-in properties
|
||||
(remove #(and (:db/ident %)
|
||||
@@ -66,15 +66,15 @@
|
||||
|
||||
(defn <get-all-properties
|
||||
"Returns all public properties as property maps including their
|
||||
:block/original-name and :db/ident. For file graphs the map only contains
|
||||
:block/original-name"
|
||||
:block/title and :db/ident. For file graphs the map only contains
|
||||
:block/title"
|
||||
[]
|
||||
(when-let [graph (state/get-current-repo)]
|
||||
(if (config/db-based-graph? graph)
|
||||
(<db-based-get-all-properties graph)
|
||||
(p/let [properties (file-async/<file-based-get-all-properties graph)
|
||||
hidden-properties (set (map name (property-util/hidden-properties)))]
|
||||
(remove #(hidden-properties (:block/original-name %)) properties)))))
|
||||
(remove #(hidden-properties (:block/title %)) properties)))))
|
||||
|
||||
(defn <file-get-property-values
|
||||
"For file graphs, returns property value names for given property name"
|
||||
@@ -106,9 +106,8 @@
|
||||
[?b ?property-id ?vid]
|
||||
[(not= ?vid :logseq.property/empty-placeholder)]
|
||||
(or
|
||||
[?vid :block/content ?value]
|
||||
[?vid :property.value/content ?value]
|
||||
[?vid :block/original-name ?value])]
|
||||
[?vid :block/title ?value])]
|
||||
property-id
|
||||
value)]
|
||||
(db/entity (:db/id (first result))))))
|
||||
@@ -235,7 +234,7 @@
|
||||
(defn <get-tag-pages
|
||||
[graph tag-id]
|
||||
(<q graph {:transact-db? true}
|
||||
'[:find [(pull ?page [:db/id :block/uuid :block/name :block/original-name :block/created-at :block/updated-at])]
|
||||
'[:find [(pull ?page [:db/id :block/uuid :block/name :block/title :block/created-at :block/updated-at])]
|
||||
:in $ ?tag-id
|
||||
:where
|
||||
[?page :block/tags ?tag-id]
|
||||
@@ -266,7 +265,7 @@
|
||||
(defn <get-tags
|
||||
[graph]
|
||||
(<q graph {:transact-db? false}
|
||||
'[:find [(pull ?tag [:db/id :block/original-name])]
|
||||
'[:find [(pull ?tag [:db/id :block/title])]
|
||||
:where
|
||||
[?tag :block/type "class"]]))
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
distinct
|
||||
sort
|
||||
(map name)
|
||||
(map #(hash-map :block/original-name %)))))
|
||||
(map #(hash-map :block/title %)))))
|
||||
|
||||
(defn- property-value-for-refs-and-text
|
||||
"Given a property value's refs and full text, determines the value to
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
(d/q '[:find ?page-name ?tag
|
||||
:where
|
||||
[?page :block/tags ?e]
|
||||
[?e :block/original-name ?tag]
|
||||
[?e :block/title ?tag]
|
||||
[?page :block/name ?page-name]]
|
||||
(conn/get-db repo)))
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
(let [db (conn/get-db repo)]
|
||||
(ldb/get-all-pages db)))
|
||||
|
||||
(defn get-all-page-original-names
|
||||
(defn get-all-page-titles
|
||||
[repo]
|
||||
(->> (get-all-pages repo)
|
||||
(map :block/original-name)))
|
||||
(map :block/title)))
|
||||
|
||||
(defn get-page-alias
|
||||
[repo page-name]
|
||||
@@ -210,14 +210,14 @@ independent of format as format specific heading characters are stripped"
|
||||
alias-ids (->> (page-alias-set repo page-id)
|
||||
(remove #{page-id}))]
|
||||
(when (seq alias-ids)
|
||||
(map (fn [id] (:block/original-name (db-utils/entity id))) alias-ids))))
|
||||
(map (fn [id] (:block/title (db-utils/entity id))) alias-ids))))
|
||||
|
||||
(defn with-pages
|
||||
[blocks]
|
||||
(let [pages-ids (->> (map (comp :db/id :block/page) blocks)
|
||||
(remove nil?))
|
||||
pages (when (seq pages-ids)
|
||||
(db-utils/pull-many '[:db/id :block/name :block/original-name :block/journal-day] pages-ids))
|
||||
(db-utils/pull-many '[:db/id :block/name :block/title :block/journal-day] pages-ids))
|
||||
pages-map (reduce (fn [acc p] (assoc acc (:db/id p) p)) {} pages)
|
||||
blocks (map
|
||||
(fn [block]
|
||||
@@ -416,18 +416,18 @@ independent of format as format specific heading characters are stripped"
|
||||
(defn get-file-page
|
||||
([file-path]
|
||||
(get-file-page file-path true))
|
||||
([file-path original-name?]
|
||||
([file-path title?]
|
||||
(when-let [repo (state/get-current-repo)]
|
||||
(when-let [db (conn/get-db repo)]
|
||||
(some->
|
||||
(d/q
|
||||
(if original-name?
|
||||
(if title?
|
||||
'[:find ?page-name
|
||||
:in $ ?path
|
||||
:where
|
||||
[?file :file/path ?path]
|
||||
[?page :block/file ?file]
|
||||
[?page :block/original-name ?page-name]]
|
||||
[?page :block/title ?page-name]]
|
||||
'[:find ?page-name
|
||||
:in $ ?path
|
||||
:where
|
||||
@@ -736,7 +736,7 @@ independent of format as format specific heading characters are stripped"
|
||||
'[:find [(pull ?page [:db/id
|
||||
:block/uuid
|
||||
:block/name
|
||||
:block/original-name
|
||||
:block/title
|
||||
:block/created-at
|
||||
:block/updated-at]) ...]
|
||||
:where
|
||||
@@ -765,7 +765,7 @@ independent of format as format specific heading characters are stripped"
|
||||
'[:find ?name ?id
|
||||
:where
|
||||
[?page :block/type "class"]
|
||||
[?page :block/original-name ?name]
|
||||
[?page :block/title ?name]
|
||||
[?page :block/uuid ?id]]
|
||||
(conn/get-db repo)))
|
||||
|
||||
@@ -808,7 +808,7 @@ independent of format as format specific heading characters are stripped"
|
||||
:where
|
||||
[?page :block/name ?page-name]
|
||||
[?page :block/namespace ?e]
|
||||
[?e :block/original-name ?parent]]
|
||||
[?e :block/title ?parent]]
|
||||
(conn/get-db repo)))
|
||||
|
||||
(defn get-all-namespace-parents
|
||||
@@ -929,7 +929,7 @@ independent of format as format specific heading characters are stripped"
|
||||
(map :e)))]
|
||||
(when (seq ids)
|
||||
(db-utils/pull-many repo
|
||||
'[:db/id :block/name :block/original-name
|
||||
'[:db/id :block/name :block/title
|
||||
{:block/file [:db/id :file/path]}]
|
||||
ids))))))
|
||||
|
||||
|
||||
@@ -652,7 +652,7 @@ Some bindings in this fn:
|
||||
"Like ldb/block-attrs but for query dsl an db graphs"
|
||||
;; '*' needed as we need to pull user properties and don't know their names in advance
|
||||
'[*
|
||||
{:block/page [:db/id :block/name :block/original-name :block/journal-day]}
|
||||
{:block/page [:db/id :block/name :block/title :block/journal-day]}
|
||||
{:block/_parent ...}])
|
||||
|
||||
(defn query
|
||||
|
||||
@@ -245,7 +245,7 @@
|
||||
[block]
|
||||
(let [id (:block/uuid block)
|
||||
page (db/entity (:db/id (:block/page block)))
|
||||
page-name (:block/original-name page)
|
||||
page-name (:block/title page)
|
||||
file-path (pu/get-block-property-value block :logseq.property.pdf/file-path)
|
||||
hl-page (pu/get-block-property-value block :logseq.property.pdf/hl-page)
|
||||
db-base? (config/db-based-graph? (state/get-current-repo))]
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
(render!)))))
|
||||
state)}
|
||||
[page]
|
||||
(let [page-name (:block/original-name page)
|
||||
(let [page-name (:block/title page)
|
||||
loading? (rum/react *loading?)
|
||||
journal? (ldb/journal-page? page)
|
||||
repo (state/get-current-repo)
|
||||
|
||||
2
src/main/frontend/external/roam_export.cljs
vendored
2
src/main/frontend/external/roam_export.cljs
vendored
@@ -77,7 +77,7 @@
|
||||
|
||||
(update-todo)
|
||||
|
||||
(s/rename-keys {:block/original-name :page/title
|
||||
(s/rename-keys {:block/title :page/title
|
||||
:block/content :block/string})
|
||||
|
||||
(select-keys keyseq))
|
||||
|
||||
@@ -80,7 +80,7 @@ and handles unexpected failure."
|
||||
(merge block new-block)
|
||||
(> (count blocks) 1)
|
||||
(assoc :block/warning :multiple-blocks))
|
||||
block (dissoc block :block/title :block/body :block/level)]
|
||||
block (dissoc block :block/body :block/level)]
|
||||
(if uuid (assoc block :block/uuid uuid) block))))
|
||||
|
||||
(defn parse-title-and-body
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
(when (:block/name ref)
|
||||
{:db/id (:db/id ref)
|
||||
:block/name (:block/name ref)
|
||||
:block/original-name (:block/original-name ref)})) refs)))
|
||||
:block/title (:block/title ref)})) refs)))
|
||||
|
||||
(defn filter-blocks
|
||||
[ref-blocks filters]
|
||||
@@ -199,7 +199,7 @@
|
||||
db-graph? (config/db-based-graph? repo)
|
||||
block (or (db/entity [:block/uuid block-id]) block)
|
||||
content (if (and db-graph? (:block/name block))
|
||||
(:block/original-name block)
|
||||
(:block/title block)
|
||||
(or custom-content (:block/content block) ""))
|
||||
content-length (count content)
|
||||
text-range (cond
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
(into {})))
|
||||
(seq (:block/refs result*))
|
||||
(assoc :block.debug/refs
|
||||
(mapv #(or (:block/original-name (db/entity (:db/id %))) %) (:block/refs result*))))
|
||||
(mapv #(or (:block/title (db/entity (:db/id %))) %) (:block/refs result*))))
|
||||
pull-data (with-out-str (pprint/pprint result))]
|
||||
(println pull-data)
|
||||
(notification/show!
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
(let [content (:block/content block)
|
||||
content' (if (some :block/name (:block/refs block))
|
||||
(reduce
|
||||
(fn [content {:block/keys [original-name uuid]}]
|
||||
(replace-page-ref-with-id content original-name uuid))
|
||||
(fn [content {:block/keys [title uuid]}]
|
||||
(replace-page-ref-with-id content title uuid))
|
||||
content
|
||||
(filter :block/name (:block/refs block)))
|
||||
content)]
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
(defn get-property-name
|
||||
"Get a property's name given its id"
|
||||
[id]
|
||||
(:block/original-name (db-utils/entity id)))
|
||||
(:block/title (db-utils/entity id)))
|
||||
|
||||
(defn get-property-value
|
||||
"Get a property's name given its id"
|
||||
@@ -38,7 +38,7 @@
|
||||
(->> properties
|
||||
(map (fn [[k v]]
|
||||
(let [prop-ent (db-utils/entity k)]
|
||||
[(if original-key? k (-> prop-ent :block/original-name keyword))
|
||||
[(if original-key? k (-> prop-ent :block/title keyword))
|
||||
(cond
|
||||
(set? v)
|
||||
(set (map db-property/property-value-content v))
|
||||
@@ -57,4 +57,4 @@
|
||||
[property-id]
|
||||
(let [repo (state/get-current-repo)
|
||||
db (conn/get-db repo)]
|
||||
(db-property/get-closed-property-values db property-id)))
|
||||
(db-property/get-closed-property-values db property-id)))
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
(when-let [sibling-entity (db/entity [:block/uuid (uuid sibling-block-id)])]
|
||||
(if (:block/name sibling-entity)
|
||||
{:prev-block sibling-entity
|
||||
:new-value (:block/original-name sibling-entity)
|
||||
:new-value (:block/title sibling-entity)
|
||||
:edit-block-f #(edit-block! sibling-entity :max)}
|
||||
(let [db? (config/db-based-graph? repo)
|
||||
original-content (if (= (:db/id sibling-entity) (:db/id (state/get-edit-block)))
|
||||
@@ -1304,7 +1304,7 @@
|
||||
(let [value (string/trim value)]
|
||||
;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever
|
||||
;; maybe we shouldn't save the block/file in "will-unmount" event?
|
||||
(if (:block/original-name entity)
|
||||
(if (:block/title entity)
|
||||
(let [existing-tags (:block/tags block)
|
||||
tags (mldoc/extract-tags value)]
|
||||
(when (seq tags)
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
(and (map? x) (contains? x :block/uuid))
|
||||
(-> x
|
||||
(s/rename-keys {:block/uuid :block/id
|
||||
:block/original-name :block/page-name})
|
||||
:block/title :block/page-name})
|
||||
(dissoc-properties [:id])
|
||||
(select-keys keyseq))
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@
|
||||
(common/get-page-content root-block-uuids-or-page-uuid)
|
||||
(common/root-block-uuids->content repo root-block-uuids-or-page-uuid))
|
||||
title (if (uuid? root-block-uuids-or-page-uuid)
|
||||
(:block/original-name (db/entity [:block/uuid root-block-uuids-or-page-uuid]))
|
||||
(:block/title (db/entity [:block/uuid root-block-uuids-or-page-uuid]))
|
||||
"untitled")
|
||||
first-block (and (coll? root-block-uuids-or-page-uuid)
|
||||
(db/entity [:block/uuid (first root-block-uuids-or-page-uuid)]))
|
||||
|
||||
@@ -220,7 +220,7 @@
|
||||
result (parse-and-load-file! repo-url file opts')
|
||||
page-name (when (coll? result) ; result could be a promise
|
||||
(some (fn [x] (when (and (map? x)
|
||||
(:block/original-name x)
|
||||
(:block/title x)
|
||||
(= (:file/path file) (:file/path (:block/file x))))
|
||||
(:block/name x)))
|
||||
result))
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
nodes))
|
||||
|
||||
(defn- normalize-page-name
|
||||
[{:keys [nodes links page-name->original-name]}]
|
||||
[{:keys [nodes links page-name->title]}]
|
||||
(let [links (->>
|
||||
(map
|
||||
(fn [{:keys [source target]}]
|
||||
(let [source (get page-name->original-name source)
|
||||
target (get page-name->original-name target)]
|
||||
(let [source (get page-name->title source)
|
||||
target (get page-name->title target)]
|
||||
(when (and source target)
|
||||
{:source source :target target})))
|
||||
links)
|
||||
@@ -81,8 +81,8 @@
|
||||
nodes (->> (remove-uuids-and-files! nodes)
|
||||
(util/distinct-by (fn [node] (:id node)))
|
||||
(map (fn [node]
|
||||
(if-let [original-name (get page-name->original-name (:id node))]
|
||||
(assoc node :id original-name :label original-name)
|
||||
(if-let [title (get page-name->title (:id node))]
|
||||
(assoc node :id title :label title)
|
||||
nil)))
|
||||
(remove nil?))]
|
||||
{:nodes nodes
|
||||
@@ -99,8 +99,8 @@
|
||||
tags (set (map second tagged-pages))
|
||||
full-pages (db/get-all-pages repo)
|
||||
full-pages-map (into {} (map (juxt :block/name identity) full-pages))
|
||||
all-pages (map common-util/get-page-original-name full-pages)
|
||||
page-name->original-name (zipmap (map :block/name full-pages) all-pages)
|
||||
all-pages (map common-util/get-page-title full-pages)
|
||||
page-name->title (zipmap (map :block/name full-pages) all-pages)
|
||||
created-ats (map :block/created-at full-pages)
|
||||
|
||||
;; build up nodes
|
||||
@@ -131,7 +131,7 @@
|
||||
nodes (build-nodes dark? (string/lower-case current-page) page-links tags nodes namespaces)]
|
||||
(-> {:nodes (map #(assoc % :block/created-at (get-in full-pages-map [(:id %) :block/created-at])) nodes)
|
||||
:links links
|
||||
:page-name->original-name page-name->original-name}
|
||||
:page-name->title page-name->title}
|
||||
normalize-page-name
|
||||
(assoc :all-pages
|
||||
{:created-at-min (apply min created-ats)
|
||||
@@ -190,12 +190,12 @@
|
||||
(distinct))
|
||||
nodes (build-nodes dark? page links (set tags) nodes namespaces)
|
||||
full-pages (db/get-all-pages repo)
|
||||
all-pages (map common-util/get-page-original-name full-pages)
|
||||
page-name->original-name (zipmap (map :block/name full-pages) all-pages)]
|
||||
all-pages (map common-util/get-page-title full-pages)
|
||||
page-name->title (zipmap (map :block/name full-pages) all-pages)]
|
||||
(normalize-page-name
|
||||
{:nodes nodes
|
||||
:links links
|
||||
:page-name->original-name page-name->original-name})))))
|
||||
:page-name->title page-name->title})))))
|
||||
|
||||
(defn build-block-graph
|
||||
"Builds a citation/reference graph for a given block uuid."
|
||||
@@ -269,4 +269,4 @@
|
||||
(defn get-metadata-local
|
||||
[]
|
||||
(let [k :ls-graphs-metadata]
|
||||
(storage/get k)))
|
||||
(storage/get k)))
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
(if (> (count content) 48)
|
||||
(str (subs content 0 48) "...")
|
||||
content))))
|
||||
block-name (:block/original-name page)
|
||||
block-name (:block/title page)
|
||||
block-name' (when block-name
|
||||
(if (common-util/uuid-string? block-name)
|
||||
"Untitled"
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
(if-let [page-id (:pageId shape)]
|
||||
(let [page (db/get-page page-id)]
|
||||
;; Used in page preview
|
||||
(assoc shape :pageName (:block/original-name page)))
|
||||
(assoc shape :pageName (:block/title page)))
|
||||
shape))))))
|
||||
|
||||
(defn- whiteboard-clj->tldr [page-block blocks]
|
||||
@@ -67,7 +67,7 @@
|
||||
:nonce (get-k "nonce")
|
||||
:assets (js->clj-keywordize assets)}]
|
||||
{:db/id (:db/id page-entity)
|
||||
:block/original-name page-name
|
||||
:block/title page-name
|
||||
:block/name (util/page-name-sanity-lc page-name)
|
||||
:block/type #{"page" "whiteboard"}
|
||||
:block/format :markdown
|
||||
@@ -80,7 +80,7 @@
|
||||
(defn file-build-page-block
|
||||
[page-entity page-name tldraw-page assets]
|
||||
(let [get-k #(gobj/get tldraw-page %)]
|
||||
{:block/original-name page-name
|
||||
{:block/title page-name
|
||||
:block/name (util/page-name-sanity-lc page-name)
|
||||
:block/type #{"page" "whiteboard"}
|
||||
:block/properties {(pu/get-pid :logseq.property/ls-type)
|
||||
@@ -137,7 +137,7 @@
|
||||
(if-let [new-order (when new-id->order (get new-id->order (str (:block/uuid block))))]
|
||||
(assoc block :block/order new-order)
|
||||
block))))
|
||||
page-name (or (:block/original-name page-entity) (str page-uuid))
|
||||
page-name (or (:block/title page-entity) (str page-uuid))
|
||||
page-block (build-page-block page-entity page-name tl-page assets)]
|
||||
(when (or (seq upserted-blocks)
|
||||
(seq deleted-shapes-tx)
|
||||
@@ -252,7 +252,7 @@
|
||||
(pu/get-pid :logseq.property.tldraw/page) tldraw-page}
|
||||
m #:block{:uuid id
|
||||
:name (util/page-name-sanity-lc page-name),
|
||||
:original-name page-name
|
||||
:title page-name
|
||||
:type #{"whiteboard" "page"},
|
||||
:format :markdown
|
||||
:updated-at (util/time-ms),
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
(when q
|
||||
(p/let [q (fuzzy/clean-str q)
|
||||
properties* (db-async/<get-all-properties)
|
||||
properties (map :block/original-name properties*)]
|
||||
properties (map :block/title properties*)]
|
||||
(when (seq properties)
|
||||
(if (string/blank? q)
|
||||
properties
|
||||
@@ -128,7 +128,7 @@
|
||||
(p/let [page (db/entity page-id)
|
||||
alias-names (conj (set (map util/safe-page-name-sanity-lc
|
||||
(db/get-page-alias-names repo page-id)))
|
||||
(:block/original-name page))
|
||||
(:block/title page))
|
||||
q (string/join " " alias-names)
|
||||
result (block-search repo q {:limit 100})
|
||||
eids (map (fn [b] [:block/uuid (:block/uuid b)]) result)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
page (if block-uuid
|
||||
(:block/page (db-utils/entity [:block/uuid block-uuid]))
|
||||
(ldb/get-page (conn/get-db) current-page))
|
||||
current-page' (:block/original-name page)]
|
||||
current-page' (:block/title page)]
|
||||
(page-ref/->page-ref current-page')))})
|
||||
|
||||
;; TODO: programmable
|
||||
|
||||
@@ -1018,7 +1018,7 @@
|
||||
(def safe-page-name-sanity-lc common-util/safe-page-name-sanity-lc))
|
||||
|
||||
#?(:cljs
|
||||
(def get-page-original-name common-util/get-page-original-name))
|
||||
(def get-page-title common-util/get-page-title))
|
||||
|
||||
#?(:cljs
|
||||
(defn add-style!
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
(defn get-current-page-name
|
||||
"Fetch the current page's original name with same approach as get-current-page-id"
|
||||
[]
|
||||
(or (:block/original-name (db/get-page (state/get-current-page)))
|
||||
(get-in (first (state/get-editor-args)) [:block :block/page :block/original-name])))
|
||||
(or (:block/title (db/get-page (state/get-current-page)))
|
||||
(get-in (first (state/get-editor-args)) [:block :block/page :block/title])))
|
||||
|
||||
(defn get-current-page-id
|
||||
"Fetches the current page id. Looks up page based on latest route and if
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
(->> (d/q '[:find (pull ?b [*])
|
||||
:in $
|
||||
:where
|
||||
[?b :block/original-name]
|
||||
[?b :block/title]
|
||||
[?b :block/name]] db)
|
||||
|
||||
(map (fn [[page]]
|
||||
@@ -61,5 +61,5 @@
|
||||
(->> (d/datoms db :avet :block/name)
|
||||
(map (fn [d]
|
||||
(let [e (d/entity db (:e d))]
|
||||
[(:block/original-name e)
|
||||
[(:block/title e)
|
||||
(block->content repo db (:block/uuid e) {} {})])))))
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
journal-page? (and journal-page? (not (string/blank? journal-title)))
|
||||
filename (if journal-page?
|
||||
(worker-date/date->file-name journal-title (:journal-file-name-format context))
|
||||
(-> (or (:block/original-name page-block) (:block/name page-block))
|
||||
(-> (or (:block/title page-block) (:block/name page-block))
|
||||
wfu/file-name-sanity))
|
||||
sub-dir (cond
|
||||
journal-page? (:journals-directory context)
|
||||
|
||||
@@ -10,46 +10,46 @@
|
||||
;; FIXME: bring it back, decouple this from page renaming though
|
||||
(comment
|
||||
(defn merge-pages!
|
||||
[repo conn config from-page to-page]
|
||||
(let [from-page-name (:block/original-name from-page)
|
||||
to-page-name (:block/original-name to-page)]
|
||||
(when (and from-page to-page
|
||||
(not= from-page-name to-page-name))
|
||||
(let [db @conn
|
||||
to-id (:db/id to-page)
|
||||
from-id (:db/id from-page)
|
||||
datoms (d/datoms @conn :avet :block/page from-id)
|
||||
block-eids (mapv :e datoms)
|
||||
blocks (d/pull-many db '[:db/id :block/page :block/refs :block/path-refs :block/parent] block-eids)
|
||||
blocks-tx-data (map (fn [block]
|
||||
(let [id (:db/id block)]
|
||||
(cond->
|
||||
{:db/id id
|
||||
:block/page {:db/id to-id}
|
||||
:block/refs (rename-update-block-refs! (:block/refs block) from-id to-id)
|
||||
:block/order (db-order/gen-key nil)}
|
||||
[repo conn config from-page to-page]
|
||||
(let [from-page-name (:block/title from-page)
|
||||
to-page-name (:block/title to-page)]
|
||||
(when (and from-page to-page
|
||||
(not= from-page-name to-page-name))
|
||||
(let [db @conn
|
||||
to-id (:db/id to-page)
|
||||
from-id (:db/id from-page)
|
||||
datoms (d/datoms @conn :avet :block/page from-id)
|
||||
block-eids (mapv :e datoms)
|
||||
blocks (d/pull-many db '[:db/id :block/page :block/refs :block/path-refs :block/parent] block-eids)
|
||||
blocks-tx-data (map (fn [block]
|
||||
(let [id (:db/id block)]
|
||||
(cond->
|
||||
{:db/id id
|
||||
:block/page {:db/id to-id}
|
||||
:block/refs (rename-update-block-refs! (:block/refs block) from-id to-id)
|
||||
:block/order (db-order/gen-key nil)}
|
||||
|
||||
(= (:block/parent block) {:db/id from-id})
|
||||
(assoc :block/parent {:db/id to-id})))) blocks)
|
||||
replace-ref-tx-data (replace-page-ref from-page to-page)
|
||||
tx-data (concat blocks-tx-data replace-ref-tx-data)]
|
||||
(= (:block/parent block) {:db/id from-id})
|
||||
(assoc :block/parent {:db/id to-id})))) blocks)
|
||||
replace-ref-tx-data (replace-page-ref from-page to-page)
|
||||
tx-data (concat blocks-tx-data replace-ref-tx-data)]
|
||||
|
||||
(rename-page-aux repo conn config from-page-name to-page-name
|
||||
:merge? true
|
||||
:other-tx tx-data)
|
||||
(rename-page-aux repo conn config from-page-name to-page-name
|
||||
:merge? true
|
||||
:other-tx tx-data)
|
||||
|
||||
(worker-page/delete! repo conn (:block/uuid from-page) {:rename? true}))))))
|
||||
(worker-page/delete! repo conn (:block/uuid from-page) {:rename? true}))))))
|
||||
|
||||
(defn- rename-page-aux
|
||||
"Only accepts unsanitized page names"
|
||||
[repo conn page new-name & {:keys [merge? other-tx]}]
|
||||
(let [old-page-name (:block/original-name page)
|
||||
(let [old-page-name (:block/title page)
|
||||
new-page-name (common-util/page-name-sanity-lc new-name)]
|
||||
(when (and repo page)
|
||||
(let [page-txs (when-not merge?
|
||||
[{:db/id (:db/id page)
|
||||
:block/name new-page-name
|
||||
:block/original-name new-name}])
|
||||
:block/title new-name}])
|
||||
txs (concat page-txs other-tx)]
|
||||
(ldb/transact! conn txs {:outliner-op :rename-page
|
||||
:data (cond->
|
||||
@@ -61,14 +61,14 @@
|
||||
"Original names (unsanitized only)"
|
||||
[repo conn page new-name]
|
||||
(rename-page-aux repo conn page new-name)
|
||||
(println "Renamed " (:block/original-name page) " to " new-name))
|
||||
(println "Renamed " (:block/title page) " to " new-name))
|
||||
|
||||
(defn rename!
|
||||
[repo conn _config page-uuid new-name & {:keys [persist-op?]
|
||||
:or {persist-op? true}}]
|
||||
(let [db @conn]
|
||||
(when-let [page-e (d/entity db [:block/uuid page-uuid])]
|
||||
(let [old-name (:block/original-name page-e)
|
||||
(let [old-name (:block/title page-e)
|
||||
new-name (string/trim new-name)
|
||||
old-page-name (common-util/page-name-sanity-lc old-name)
|
||||
new-page-name (common-util/page-name-sanity-lc new-name)
|
||||
@@ -89,7 +89,7 @@
|
||||
(if (= old-page-name new-page-name) ; case changed
|
||||
(ldb/transact! conn
|
||||
[{:db/id (:db/id page-e)
|
||||
:block/original-name new-name}]
|
||||
:block/title new-name}]
|
||||
{:persist-op? persist-op?
|
||||
:outliner-op :rename-page})
|
||||
(rename-page! repo conn page-e new-name)))))))
|
||||
|
||||
@@ -114,13 +114,13 @@
|
||||
[db config page new-name]
|
||||
;; update all pages which have references to this page
|
||||
(let [to-page (ldb/get-page db new-name)
|
||||
old-original-name (:block/original-name page)
|
||||
old-title (:block/title page)
|
||||
blocks (:block/_refs (d/entity db (:db/id page)))
|
||||
tx (->> (map (fn [{:block/keys [uuid content properties format] :as block}]
|
||||
(let [content (let [content' (replace-old-page! config content old-original-name new-name format)]
|
||||
(let [content (let [content' (replace-old-page! config content old-title new-name format)]
|
||||
(when-not (= content' content)
|
||||
content'))
|
||||
properties (let [properties' (walk-replace-old-page! config properties old-original-name new-name format)]
|
||||
properties (let [properties' (walk-replace-old-page! config properties old-title new-name format)]
|
||||
(when-not (= properties' properties)
|
||||
properties'))]
|
||||
(when (or content properties)
|
||||
@@ -138,8 +138,8 @@
|
||||
|
||||
(defn rename-update-namespace!
|
||||
"update :block/namespace of the renamed block"
|
||||
[repo conn config page old-original-name new-name]
|
||||
(let [old-namespace? (text/namespace-page? old-original-name)
|
||||
[repo conn config page old-title new-name]
|
||||
(let [old-namespace? (text/namespace-page? old-title)
|
||||
new-namespace? (text/namespace-page? new-name)]
|
||||
(cond
|
||||
new-namespace?
|
||||
@@ -224,12 +224,12 @@
|
||||
new-page-name (common-util/page-name-sanity-lc new-name)
|
||||
page (d/pull @conn '[*] [:block/name old-page-name])]
|
||||
(when (and repo page)
|
||||
(let [old-original-name (:block/original-name page)
|
||||
(let [old-title (:block/title page)
|
||||
page-txs (when-not merge?
|
||||
[{:db/id (:db/id page)
|
||||
:block/uuid (:block/uuid page)
|
||||
:block/name new-page-name
|
||||
:block/original-name new-name}])
|
||||
:block/title new-name}])
|
||||
{:keys [old-path new-path tx-data]} (update-file-tx db old-page-name new-name)
|
||||
txs (concat page-txs
|
||||
other-tx
|
||||
@@ -250,7 +250,7 @@
|
||||
(merge {:old-path old-path
|
||||
:new-path new-path}))})
|
||||
|
||||
(rename-update-namespace! repo conn config page old-original-name new-name)))))
|
||||
(rename-update-namespace! repo conn config page old-title new-name)))))
|
||||
|
||||
(defn- rename-namespace-pages!
|
||||
"Original names (unsanitized only)"
|
||||
@@ -258,8 +258,8 @@
|
||||
(let [pages (ldb/get-namespace-pages @conn old-name {})
|
||||
page (d/pull @conn '[*] [:block/name (common-util/page-name-sanity-lc old-name)])
|
||||
pages (cons page pages)]
|
||||
(doseq [{:block/keys [name original-name]} pages]
|
||||
(let [old-page-title (or original-name name)
|
||||
(doseq [{:block/keys [name title]} pages]
|
||||
(let [old-page-title (or title name)
|
||||
;; only replace one time, for the case that the namespace is a sub-string of the sub-namespace page name
|
||||
;; Example: has pages [[work]] [[work/worklog]],
|
||||
;; we want to rename [[work/worklog]] to [[work1/worklog]] when rename [[work]] to [[work1]],
|
||||
@@ -279,8 +279,8 @@
|
||||
nested-pages-ns (ldb/get-pages-by-name-partition @conn ns-prefix)]
|
||||
(when nested-pages
|
||||
;; rename page "[[obsidian]] is a tool" to "[[logseq]] is a tool"
|
||||
(doseq [{:block/keys [name original-name]} nested-pages]
|
||||
(let [old-page-title (or original-name name)
|
||||
(doseq [{:block/keys [name title]} nested-pages]
|
||||
(let [old-page-title (or title name)
|
||||
new-page-title (string/replace
|
||||
old-page-title
|
||||
(page-ref/->page-ref old-ns-name)
|
||||
@@ -290,8 +290,8 @@
|
||||
(println "Renamed " old-page-title " to " new-page-title)))))
|
||||
(when nested-pages-ns
|
||||
;; rename page "[[obsidian/page1]] is a tool" to "[[logseq/page1]] is a tool"
|
||||
(doseq [{:block/keys [name original-name]} nested-pages-ns]
|
||||
(let [old-page-title (or original-name name)
|
||||
(doseq [{:block/keys [name title]} nested-pages-ns]
|
||||
(let [old-page-title (or title name)
|
||||
new-page-title (string/replace
|
||||
old-page-title
|
||||
(common-util/format ns-prefix-format-str old-ns-name)
|
||||
@@ -305,7 +305,7 @@
|
||||
:or {persist-op? true}}]
|
||||
(let [db @conn
|
||||
page-e (d/entity db [:block/uuid page-uuid])
|
||||
old-name (:block/original-name page-e)
|
||||
old-name (:block/title page-e)
|
||||
new-name (string/trim new-name)
|
||||
old-page-name (common-util/page-name-sanity-lc old-name)
|
||||
new-page-name (common-util/page-name-sanity-lc new-name)
|
||||
@@ -329,7 +329,7 @@
|
||||
(= old-page-name new-page-name) ; case changed
|
||||
(ldb/transact! conn
|
||||
[{:db/id (:db/id page-e)
|
||||
:block/original-name new-name}]
|
||||
:block/title new-name}]
|
||||
{:persist-op? persist-op?
|
||||
:outliner-op :rename-page})
|
||||
|
||||
|
||||
@@ -169,12 +169,12 @@
|
||||
|
||||
(defmethod local-block-ops->remote-ops-aux :update-page-op
|
||||
[_ & {:keys [db block-uuid *remote-ops]}]
|
||||
(when-let [{page-name :block/name original-name :block/original-name}
|
||||
(when-let [{page-name :block/name title :block/title}
|
||||
(d/entity db [:block/uuid block-uuid])]
|
||||
(swap! *remote-ops conj
|
||||
[:update-page {:block-uuid block-uuid
|
||||
:page-name page-name
|
||||
:original-name (or original-name page-name)}])))
|
||||
:title (or title page-name)}])))
|
||||
|
||||
(defmethod local-block-ops->remote-ops-aux :remove-op
|
||||
[_ & {:keys [db remove-op *remote-ops]}]
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
[:map
|
||||
[:block-uuid :uuid]
|
||||
[:page-name :string]
|
||||
[:original-name :string]]]]
|
||||
[:title :string]]]]
|
||||
[:remove-page
|
||||
[:cat :keyword
|
||||
[:map
|
||||
@@ -128,8 +128,7 @@
|
||||
[:map
|
||||
[:op :keyword]
|
||||
[:self :uuid]
|
||||
[:page-name :string]
|
||||
[:block/original-name :string]
|
||||
[:block/title :string]
|
||||
[:db/ident {:optional true} :keyword]
|
||||
[:block/order {:optional true} db-malli-schema/block-order]
|
||||
[::m/default extra-attr-map-schema]]]
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
block-uuid (:block/uuid (d/entity db-after e))
|
||||
a->add?->v->t (e->a->add?->v->t e)
|
||||
{add?->block-name->t :block/name
|
||||
add?->block-original-name->t :block/original-name
|
||||
add?->block-title->t :block/title
|
||||
add?->block-uuid->t :block/uuid
|
||||
add?->block-parent->t :block/parent
|
||||
add?->block-order->t :block/order}
|
||||
@@ -87,7 +87,7 @@
|
||||
[retract-block-uuid t1] (some-> add?->block-uuid->t (get false) first)
|
||||
[retract-block-name _] (some-> add?->block-name->t (get false) first)
|
||||
[add-block-name t2] (some-> add?->block-name->t latest-add?->v->t (get-first-vt true))
|
||||
[add-block-original-name t3] (some-> add?->block-original-name->t
|
||||
[add-block-title t3] (some-> add?->block-title->t
|
||||
latest-add?->v->t
|
||||
(get-first-vt true))
|
||||
[add-block-parent t4] (some-> add?->block-parent->t latest-add?->v->t (get-first-vt true))
|
||||
@@ -105,7 +105,7 @@
|
||||
(or add-block-parent add-block-order)
|
||||
(conj [:move (or t4 t5) {:block-uuid block-uuid}])
|
||||
|
||||
(or add-block-name add-block-original-name)
|
||||
(or add-block-name add-block-title)
|
||||
(conj [:update-page (or t2 t3) {:block-uuid block-uuid}]))
|
||||
update-op (when-let [av-coll (not-empty (update-op-av-coll db-before db-after a->add?->v->t*))]
|
||||
(let [t (max-t a->add?->v->t*)]
|
||||
|
||||
@@ -497,10 +497,10 @@
|
||||
[repo conn update-page-ops]
|
||||
(let [config (worker-state/get-config repo)]
|
||||
(doseq [{:keys [self _page-name]
|
||||
original-name :block/original-name
|
||||
title :block/title
|
||||
:as op-value} update-page-ops]
|
||||
(let [create-opts {:uuid self}
|
||||
[_ page-name page-uuid] (worker-page/rtc-create-page! conn config (ldb/read-transit-str original-name) create-opts)]
|
||||
[_ page-name page-uuid] (worker-page/rtc-create-page! conn config (ldb/read-transit-str title) create-opts)]
|
||||
;; TODO: current page-create fn is buggy, even provide :uuid option, it will create-page with different uuid,
|
||||
;; if there's already existing same name page
|
||||
(assert (= page-uuid self) {:page-name page-name :page-uuid page-uuid :should-be self})
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
;; closed value
|
||||
(property-value-when-closed e)
|
||||
;; :page or :date properties
|
||||
(:block/original-name e)
|
||||
(:block/title e)
|
||||
;; block generated by template
|
||||
(and
|
||||
(:logseq.property/created-from-template e)
|
||||
@@ -220,7 +220,7 @@
|
||||
(remove string/blank?))
|
||||
hide? (get-in property [:block/schema :hide?])]
|
||||
(when (and (not hide?) (seq values))
|
||||
(str (:block/original-name property)
|
||||
(str (:block/title property)
|
||||
": "
|
||||
(string/join "; " values))))))
|
||||
(string/join ", "))))
|
||||
@@ -265,7 +265,7 @@
|
||||
{:id (str (:block/uuid p))
|
||||
:name (:block/name p)
|
||||
:built-in? (boolean (db-property/property-value-content (:logseq.property/built-in? p)))
|
||||
:original-name (:block/original-name p)}))
|
||||
:title (:block/title p)}))
|
||||
|
||||
(defn- hidden-page?
|
||||
[page]
|
||||
@@ -290,7 +290,7 @@
|
||||
(map original-page-name->index)
|
||||
(bean/->js))
|
||||
indice (fuse. pages
|
||||
(clj->js {:keys ["original-name"]
|
||||
(clj->js {:keys ["title"]
|
||||
:shouldSort true
|
||||
:tokenize true
|
||||
:distance 1024
|
||||
@@ -328,7 +328,7 @@
|
||||
datoms (filter
|
||||
(fn [datom]
|
||||
;; Capture any direct change on page display title, page ref or block content
|
||||
(contains? #{:block/uuid :block/name :block/original-name :block/content :block/properties :block/schema} (:a datom)))
|
||||
(contains? #{:block/uuid :block/name :block/title :block/content :block/properties :block/schema} (:a datom)))
|
||||
data)]
|
||||
(when (seq datoms)
|
||||
(get-blocks-from-datoms-impl repo tx-report datoms))))
|
||||
@@ -396,7 +396,7 @@
|
||||
(keep
|
||||
(fn [{:keys [item]}]
|
||||
{:id (:id item)
|
||||
:title (:original-name item)}))
|
||||
:title (:title item)}))
|
||||
(distinct)
|
||||
(filter (fn [{:keys [title]}]
|
||||
(exact-matched? q title)))
|
||||
|
||||
@@ -832,7 +832,7 @@
|
||||
;; FIXME: This ns should not be creating idents. This allows for ident conflicts
|
||||
;; and assumes that names directly map to idents which is incorrect and breaks for multiple
|
||||
;; cases e.g. a property that has been renamed or sanitized. Instead it should
|
||||
;; find a property's ident by looking up the property in the db by its original-name
|
||||
;; find a property's ident by looking up the property in the db by its title
|
||||
(defn get-db-ident-for-property-name
|
||||
"Finds a property :db/ident for a given property name"
|
||||
[property-name]
|
||||
|
||||
@@ -150,16 +150,16 @@ prop-d:: [[nada]]"}])
|
||||
(test-helper/with-config {}
|
||||
(block-property-queries-test))))
|
||||
|
||||
|
||||
|
||||
(when js/process.env.DB_GRAPH
|
||||
(deftest db-only-block-property-queries
|
||||
(load-test-files-for-db-graph
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "b1"
|
||||
:build/properties {:Foo "bar"}}
|
||||
{:block/content "b2"
|
||||
:build/properties {:foo "bar"}}]}])
|
||||
|
||||
|
||||
(is (= ["b1"]
|
||||
(map :block/content (dsl-query "(property Foo)")))
|
||||
"filter is case sensitive")
|
||||
@@ -237,7 +237,7 @@ prop-d:: [[nada]]"}])
|
||||
:block/name
|
||||
(dsl-query "(and (not (page-property foo bar)) (page-property parent [[child page 2]]))")))
|
||||
"Page property queries nested NOT in first clause")
|
||||
|
||||
|
||||
(testing "boolean values"
|
||||
(is (= ["page1"]
|
||||
(map :block/name (dsl-query "(page-property interesting true)")))
|
||||
@@ -311,7 +311,7 @@ prop-d:: [[nada]]"}])
|
||||
|
||||
(deftest priority-queries
|
||||
(load-test-files (if js/process.env.DB_GRAPH
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "[#A] b1"
|
||||
:build/properties {:logseq.task/priority :logseq.task/priority.high}}
|
||||
{:block/content "[#B] b2"
|
||||
@@ -507,7 +507,7 @@ prop-d:: [[nada]]"}])
|
||||
|
||||
(deftest nested-page-ref-queries
|
||||
(load-test-files (if js/process.env.DB_GRAPH
|
||||
[{:page {:block/original-name "page1"}
|
||||
[{:page {:block/title "page1"}
|
||||
:blocks [{:block/content "p1 [[Parent page]]"
|
||||
:build/children [{:block/content "[[Child page]]"}]}
|
||||
{:block/content "p2 [[Parent page]]"
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
(doseq [page pages]
|
||||
(test-helper/create-page! page {:redirect? false :create-first-block? false :class? true})
|
||||
(db-recent-handler/add-page-to-recent! (:db/id (db/get-page page)) false))
|
||||
(is (= (map :block/original-name (db-recent-handler/get-recent-pages)) (reverse pages)))
|
||||
(is (= (map :block/title (db-recent-handler/get-recent-pages)) (reverse pages)))
|
||||
(testing "Click existing recent item shouldn't update its position"
|
||||
(db-recent-handler/add-page-to-recent! (:db/id (db/get-page "Page 10")) true)
|
||||
(is (= (map :block/original-name (db-recent-handler/get-recent-pages)) (reverse pages)))))))
|
||||
(is (= (map :block/title (db-recent-handler/get-recent-pages)) (reverse pages)))))))
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
(string/trim "
|
||||
- 1
|
||||
id:: 61506710-484c-46d5-9983-3d1651ec02c8
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- ((61506712-3007-407e-b6d3-d008a8dfa88b))
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- ((61506712-3007-407e-b6d3-d008a8dfa88b))
|
||||
- 4
|
||||
id:: 61506712-b8a7-491d-ad84-b71651c3fdab")}
|
||||
{:file/path "pages/page2.md"
|
||||
@@ -24,7 +24,7 @@
|
||||
(string/trim "
|
||||
- 3
|
||||
id:: 97a00e55-48c3-48d8-b9ca-417b16e3a616
|
||||
- {{embed [[page1]]}}")}])
|
||||
- {{embed [[page1]]}}")}])
|
||||
|
||||
(use-fixtures :once
|
||||
{:before (fn []
|
||||
@@ -41,18 +41,18 @@
|
||||
{:remove-options #{:property}})))
|
||||
(string/trim "
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 3")
|
||||
- 2
|
||||
- 3
|
||||
- 3")
|
||||
"61506710-484c-46d5-9983-3d1651ec02c8"
|
||||
|
||||
(string/trim "
|
||||
- 3
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 3
|
||||
- 4")
|
||||
- 1
|
||||
- 2
|
||||
- 3
|
||||
- 3
|
||||
- 4")
|
||||
"97a00e55-48c3-48d8-b9ca-417b16e3a616"))
|
||||
|
||||
|
||||
@@ -62,25 +62,25 @@
|
||||
(string/trim "
|
||||
- 1
|
||||
id:: 61506710-484c-46d5-9983-3d1651ec02c8
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- 3")
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- 3")
|
||||
"61506710-484c-46d5-9983-3d1651ec02c8"
|
||||
|
||||
(string/trim "
|
||||
- 3
|
||||
id:: 97a00e55-48c3-48d8-b9ca-417b16e3a616
|
||||
- 1
|
||||
id:: 61506710-484c-46d5-9983-3d1651ec02c8
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- 3
|
||||
- 4
|
||||
id:: 61506712-b8a7-491d-ad84-b71651c3fdab")
|
||||
- 1
|
||||
id:: 61506710-484c-46d5-9983-3d1651ec02c8
|
||||
- 2
|
||||
id:: 61506711-5638-4899-ad78-187bdc2eaffc
|
||||
- 3
|
||||
id:: 61506712-3007-407e-b6d3-d008a8dfa88b
|
||||
- 3
|
||||
- 4
|
||||
id:: 61506712-b8a7-491d-ad84-b71651c3fdab")
|
||||
"97a00e55-48c3-48d8-b9ca-417b16e3a616"))
|
||||
|
||||
(deftest export-blocks-as-markdown-level<N
|
||||
@@ -90,13 +90,13 @@
|
||||
:other-options {:keep-only-level<=N 2}})))
|
||||
(string/trim "
|
||||
- 1
|
||||
- 2")
|
||||
- 2")
|
||||
"61506710-484c-46d5-9983-3d1651ec02c8"
|
||||
|
||||
(string/trim "
|
||||
- 3
|
||||
- 1
|
||||
- 4")
|
||||
- 1
|
||||
- 4")
|
||||
"97a00e55-48c3-48d8-b9ca-417b16e3a616"))
|
||||
|
||||
(deftest export-blocks-as-markdown-newline-after-block
|
||||
@@ -107,24 +107,24 @@
|
||||
(string/trim "
|
||||
- 1
|
||||
|
||||
- 2
|
||||
- 2
|
||||
|
||||
- 3
|
||||
- 3
|
||||
|
||||
- 3")
|
||||
- 3")
|
||||
"61506710-484c-46d5-9983-3d1651ec02c8"
|
||||
(string/trim "
|
||||
- 3
|
||||
|
||||
- 1
|
||||
- 1
|
||||
|
||||
- 2
|
||||
- 2
|
||||
|
||||
- 3
|
||||
- 3
|
||||
|
||||
- 3
|
||||
- 3
|
||||
|
||||
- 4")
|
||||
- 4")
|
||||
"97a00e55-48c3-48d8-b9ca-417b16e3a616"))
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
edn-output (edn/read-string result)]
|
||||
(is (= #{:version :blocks} (set (keys edn-output)))
|
||||
"Correct top-level keys")
|
||||
(is (= (sort (concat (map :block/original-name gp-db/built-in-pages)
|
||||
(is (= (sort (concat (map :block/title gp-db/built-in-pages)
|
||||
["page1" "page2"]))
|
||||
(sort (map :block/page-name (:blocks edn-output))))
|
||||
"Correct pages")))
|
||||
|
||||
@@ -138,7 +138,7 @@
|
||||
(string/replace "_" "")
|
||||
parse-double)
|
||||
(throw (ex-info (str "Can't detect page name of file: " (pr-str path)) {})))}
|
||||
{:block/original-name
|
||||
{:block/title
|
||||
(or (second (re-find #"/([^/]+)\." path))
|
||||
(throw (ex-info (str "Can't detect page name of file: " (pr-str path)) {})))})]
|
||||
{:page (cond-> unique-page-attrs
|
||||
@@ -183,7 +183,7 @@ This can be called in synchronous contexts as no async fns should be invoked"
|
||||
[;; page
|
||||
{:block/uuid page-uuid
|
||||
:block/name "test"
|
||||
:block/original-name "Test"}
|
||||
:block/title "Test"}
|
||||
;; first block
|
||||
{:block/uuid first-block-uuid
|
||||
:block/page page-id
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user