|
@@ -383,10 +383,10 @@ independent of format as format specific heading characters are stripped"
|
|
|
|
|
|
|
|
(defn page-exists?
|
|
(defn page-exists?
|
|
|
"Whether a page exists."
|
|
"Whether a page exists."
|
|
|
- [page-name type]
|
|
|
|
|
|
|
+ [page-name tags]
|
|
|
(let [repo (state/get-current-repo)]
|
|
(let [repo (state/get-current-repo)]
|
|
|
(when-let [db (conn/get-db repo)]
|
|
(when-let [db (conn/get-db repo)]
|
|
|
- (ldb/page-exists? db page-name type))))
|
|
|
|
|
|
|
+ (ldb/page-exists? db page-name tags))))
|
|
|
|
|
|
|
|
(defn page-empty?
|
|
(defn page-empty?
|
|
|
"Whether a page is empty. Does it has a non-page block?
|
|
"Whether a page is empty. Does it has a non-page block?
|
|
@@ -531,14 +531,23 @@ independent of format as format specific heading characters are stripped"
|
|
|
(defn get-journals-length
|
|
(defn get-journals-length
|
|
|
[]
|
|
[]
|
|
|
(let [today (date-time-util/date->int (js/Date.))]
|
|
(let [today (date-time-util/date->int (js/Date.))]
|
|
|
- (d/q '[:find (count ?page) .
|
|
|
|
|
- :in $ ?today
|
|
|
|
|
- :where
|
|
|
|
|
- [?page :block/type "journal"]
|
|
|
|
|
- [?page :block/journal-day ?journal-day]
|
|
|
|
|
- [(<= ?journal-day ?today)]]
|
|
|
|
|
- (conn/get-db (state/get-current-repo))
|
|
|
|
|
- today)))
|
|
|
|
|
|
|
+ (if (config/db-based-graph?)
|
|
|
|
|
+ (d/q '[:find (count ?page) .
|
|
|
|
|
+ :in $ ?today
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?page :block/tags :logseq.class/Journal]
|
|
|
|
|
+ [?page :block/journal-day ?journal-day]
|
|
|
|
|
+ [(<= ?journal-day ?today)]]
|
|
|
|
|
+ (conn/get-db (state/get-current-repo))
|
|
|
|
|
+ today)
|
|
|
|
|
+ (d/q '[:find (count ?page) .
|
|
|
|
|
+ :in $ ?today
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?page :block/type "journal"]
|
|
|
|
|
+ [?page :block/journal-day ?journal-day]
|
|
|
|
|
+ [(<= ?journal-day ?today)]]
|
|
|
|
|
+ (conn/get-db (state/get-current-repo))
|
|
|
|
|
+ today))))
|
|
|
|
|
|
|
|
(defn get-latest-journals
|
|
(defn get-latest-journals
|
|
|
([n]
|
|
([n]
|
|
@@ -749,17 +758,29 @@ independent of format as format specific heading characters are stripped"
|
|
|
|
|
|
|
|
(defn get-all-whiteboards
|
|
(defn get-all-whiteboards
|
|
|
[repo]
|
|
[repo]
|
|
|
- (d/q
|
|
|
|
|
- '[:find [(pull ?page [:db/id
|
|
|
|
|
- :block/uuid
|
|
|
|
|
- :block/name
|
|
|
|
|
- :block/title
|
|
|
|
|
- :block/created-at
|
|
|
|
|
- :block/updated-at]) ...]
|
|
|
|
|
- :where
|
|
|
|
|
- [?page :block/name]
|
|
|
|
|
- [?page :block/type "whiteboard"]]
|
|
|
|
|
- (conn/get-db repo)))
|
|
|
|
|
|
|
+ (if (config/db-based-graph?)
|
|
|
|
|
+ (d/q
|
|
|
|
|
+ '[:find [(pull ?page [:db/id
|
|
|
|
|
+ :block/uuid
|
|
|
|
|
+ :block/name
|
|
|
|
|
+ :block/title
|
|
|
|
|
+ :block/created-at
|
|
|
|
|
+ :block/updated-at]) ...]
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?page :block/name]
|
|
|
|
|
+ [?page :block/tags :logseq.class/Whiteboard]]
|
|
|
|
|
+ (conn/get-db repo))
|
|
|
|
|
+ (d/q
|
|
|
|
|
+ '[:find [(pull ?page [:db/id
|
|
|
|
|
+ :block/uuid
|
|
|
|
|
+ :block/name
|
|
|
|
|
+ :block/title
|
|
|
|
|
+ :block/created-at
|
|
|
|
|
+ :block/updated-at]) ...]
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?page :block/name]
|
|
|
|
|
+ [?page :block/type "whiteboard"]]
|
|
|
|
|
+ (conn/get-db repo))))
|
|
|
|
|
|
|
|
(defn get-whiteboard-id-nonces
|
|
(defn get-whiteboard-id-nonces
|
|
|
[repo page-id]
|
|
[repo page-id]
|
|
@@ -780,7 +801,7 @@ independent of format as format specific heading characters are stripped"
|
|
|
[repo & {:keys [except-root-class?]
|
|
[repo & {:keys [except-root-class?]
|
|
|
:or {except-root-class? false}}]
|
|
:or {except-root-class? false}}]
|
|
|
(let [db (conn/get-db repo)
|
|
(let [db (conn/get-db repo)
|
|
|
- classes (->> (d/datoms db :avet :block/type "class")
|
|
|
|
|
|
|
+ classes (->> (d/datoms db :avet :block/tags :logseq.class/Class)
|
|
|
(map (fn [d]
|
|
(map (fn [d]
|
|
|
(db-utils/entity db (:e d)))))]
|
|
(db-utils/entity db (:e d)))))]
|
|
|
(if except-root-class?
|
|
(if except-root-class?
|
|
@@ -849,18 +870,30 @@ independent of format as format specific heading characters are stripped"
|
|
|
(defn get-pages-relation
|
|
(defn get-pages-relation
|
|
|
[repo with-journal?]
|
|
[repo with-journal?]
|
|
|
(when-let [db (conn/get-db repo)]
|
|
(when-let [db (conn/get-db repo)]
|
|
|
- (let [q (if with-journal?
|
|
|
|
|
- '[:find ?p ?ref-page
|
|
|
|
|
- :where
|
|
|
|
|
- [?block :block/page ?p]
|
|
|
|
|
- [?block :block/refs ?ref-page]]
|
|
|
|
|
- '[:find ?p ?ref-page
|
|
|
|
|
- :where
|
|
|
|
|
- [?block :block/page ?p]
|
|
|
|
|
- [(get-else $ ?p :block/type "N/A") ?type]
|
|
|
|
|
- [(not= ?type "journal")]
|
|
|
|
|
- [?block :block/refs ?ref-page]])]
|
|
|
|
|
- (d/q q db))))
|
|
|
|
|
|
|
+ (if (config/db-based-graph?)
|
|
|
|
|
+ (let [q (if with-journal?
|
|
|
|
|
+ '[:find ?p ?ref-page
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?block :block/page ?p]
|
|
|
|
|
+ [?block :block/refs ?ref-page]]
|
|
|
|
|
+ '[:find ?p ?ref-page
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?block :block/page ?p]
|
|
|
|
|
+ [?p :block/tags]
|
|
|
|
|
+ (not [?p :block/tags :logseq.class/Journal])
|
|
|
|
|
+ [?block :block/refs ?ref-page]])]
|
|
|
|
|
+ (d/q q db))
|
|
|
|
|
+ (let [q (if with-journal?
|
|
|
|
|
+ '[:find ?p ?ref-page
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?block :block/page ?p]
|
|
|
|
|
+ [?block :block/refs ?ref-page]]
|
|
|
|
|
+ '[:find ?p ?ref-page
|
|
|
|
|
+ :where
|
|
|
|
|
+ [?block :block/page ?p]
|
|
|
|
|
+ (not [?p :block/type "journal"])
|
|
|
|
|
+ [?block :block/refs ?ref-page]])]
|
|
|
|
|
+ (d/q q db)))))
|
|
|
|
|
|
|
|
(defn get-namespace-pages
|
|
(defn get-namespace-pages
|
|
|
"Accepts both sanitized and unsanitized namespaces"
|
|
"Accepts both sanitized and unsanitized namespaces"
|