enhance: new classes can be case sensitive

pull/11177/head
Gabriel Horner 2024-04-24 15:18:20 -04:00
parent 94e6f78dc0
commit c87c077d29
4 changed files with 12 additions and 8 deletions

View File

@ -302,7 +302,7 @@
Useful when creating new pages from references or namespaces,
as there's no chance to introduce timestamps via editing in page"
[original-page-name with-id? db with-timestamp? date-formatter
& {:keys [from-page]}]
& {:keys [from-page class?]}]
(let [db-based? (ldb/db-based-graph? db)]
(cond
(and original-page-name (string? original-page-name))
@ -311,7 +311,10 @@
namespace? (and (not db-based?)
(not (boolean (text/get-nested-page-name original-page-name)))
(text/namespace-page? original-page-name))
page-entity (some-> db (ldb/get-page original-page-name))
page-entity (when db
(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)]
(merge
{:block/name page-name

View File

@ -188,12 +188,12 @@
(let [page* (string/trim page)
[_ page inline-class] (or (seq (map string/trim (re-find #"(.*)#(.*)$" page*)))
[nil page* nil])
id (:db/id (ldb/get-page (db/get-db) page))
id (:db/id (ldb/get-case-page (db/get-db) page))
class? (= :block/tags (:block/ident property))]
(if (nil? id)
(let [inline-class-uuid
(when inline-class
(or (:block/uuid (ldb/get-page (db/get-db) inline-class))
(or (:block/uuid (ldb/get-case-page (db/get-db) inline-class))
(do (log/error :msg "Given inline class does not exist" :inline-class inline-class)
nil)))]
(p/let [page (page-handler/<create! page {:redirect? false

View File

@ -323,14 +323,15 @@
(p/do!
(when db-based?
(let [tag (string/trim chosen)
edit-block (state/get-edit-block)]
edit-block (state/get-edit-block)
get-page-fn (if class? db/get-case-page db/get-page)]
(when (and (not (string/blank? tag)) (:block/uuid edit-block))
(p/let [tag-entity (db/get-page tag)
(p/let [tag-entity (get-page-fn tag)
_ (when-not tag-entity
(<create! tag {:redirect? false
:create-first-block? false
:class? class?}))
tag-entity (db/get-page tag)]
tag-entity (get-page-fn tag)]
(when class?
(add-tag (state/get-current-repo) (:block/uuid edit-block) tag {:tag-entity tag-entity}))))))
(editor-handler/insert-command! id

View File

@ -91,7 +91,7 @@
format (or format (common-config/get-preferred-format config))
pages (map (fn [page]
;; only apply uuid to the deepest hierarchy of page to create if provided.
(-> (gp-block/page-name->map page (if (= page title) with-uuid? true) @conn true date-formatter)
(-> (gp-block/page-name->map page (if (= page title) with-uuid? true) @conn true date-formatter :class? class?)
(assoc :block/format format)))
pages)
txs (when-not db-based?