mirror of
https://github.com/logseq/logseq.git
synced 2026-04-24 22:25:01 +00:00
fix: current page not triggering and translating to current page
For logseq/db-test#28
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
[clojure.string :as string]
|
||||
[promesa.core :as p]
|
||||
[rum.core :as rum]
|
||||
[frontend.modules.outliner.tree :as tree]))
|
||||
[frontend.modules.outliner.tree :as tree]
|
||||
[frontend.template :as template]))
|
||||
|
||||
(defn trigger-custom-query!
|
||||
[config query *query-error *fulltext-query-result]
|
||||
@@ -26,7 +27,9 @@
|
||||
(let [q (:query query)
|
||||
form (common-util/safe-read-string q)]
|
||||
(cond
|
||||
(symbol? form)
|
||||
(and (symbol? form)
|
||||
;; Queries only containgin template should trigger a query
|
||||
(not (re-matches template/template-re (string/trim q))))
|
||||
(atom nil)
|
||||
|
||||
(re-matches #"\".*\"" q) ; full-text search
|
||||
|
||||
@@ -19,27 +19,29 @@
|
||||
(date/today))]
|
||||
(let [block-uuid (parse-uuid current-page)
|
||||
page (if block-uuid
|
||||
(:block/page (db-utils/entity [:block/uuid block-uuid]))
|
||||
(db-utils/entity [:block/uuid block-uuid])
|
||||
(ldb/get-page (conn/get-db) current-page))
|
||||
current-page' (:block/title page)]
|
||||
(page-ref/->page-ref current-page')))})
|
||||
(when current-page' (page-ref/->page-ref current-page'))))})
|
||||
|
||||
(def template-re #"<%([^%].*?)%>")
|
||||
|
||||
;; TODO: programmable
|
||||
;; context information, date, current page
|
||||
(defn resolve-dynamic-template!
|
||||
[content]
|
||||
(string/replace content #"<%([^%].*?)%>"
|
||||
(string/replace content template-re
|
||||
(fn [[_ match]]
|
||||
(let [match (string/trim match)]
|
||||
(cond
|
||||
(string/blank? match)
|
||||
""
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
:else
|
||||
(if-let [nld (date/nld-parse match)]
|
||||
(let [;; NOTE: This following cannot handle timezones
|
||||
(string/blank? match)
|
||||
""
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
(get (variable-rules) (string/lower-case match))
|
||||
:else
|
||||
(if-let [nld (date/nld-parse match)]
|
||||
(let [;; NOTE: This following cannot handle timezones
|
||||
;; date (tc/to-local-date-time nld)
|
||||
date (doto (goog.date.DateTime.) (.setTime (.getTime nld)))]
|
||||
(page-ref/->page-ref (date/journal-name date)))
|
||||
match))))))
|
||||
date (doto (goog.date.DateTime.) (.setTime (.getTime nld)))]
|
||||
(page-ref/->page-ref (date/journal-name date)))
|
||||
match))))))
|
||||
|
||||
Reference in New Issue
Block a user