|
@@ -19,27 +19,29 @@
|
|
|
(date/today))]
|
|
(date/today))]
|
|
|
(let [block-uuid (parse-uuid current-page)
|
|
(let [block-uuid (parse-uuid current-page)
|
|
|
page (if block-uuid
|
|
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))
|
|
(ldb/get-page (conn/get-db) current-page))
|
|
|
current-page' (:block/title 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
|
|
;; TODO: programmable
|
|
|
;; context information, date, current page
|
|
;; context information, date, current page
|
|
|
(defn resolve-dynamic-template!
|
|
(defn resolve-dynamic-template!
|
|
|
[content]
|
|
[content]
|
|
|
- (string/replace content #"<%([^%].*?)%>"
|
|
|
|
|
|
|
+ (string/replace content template-re
|
|
|
(fn [[_ match]]
|
|
(fn [[_ match]]
|
|
|
(let [match (string/trim match)]
|
|
(let [match (string/trim match)]
|
|
|
(cond
|
|
(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 (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))))))
|