mirror of
https://github.com/logseq/logseq.git
synced 2026-05-21 03:12:38 +00:00
Merge branch 'master' into feat/cliable
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
-/resources/static/js/react-force-graph.min.js
|
||||
-/resources/js/lsplugin.user.js
|
||||
-/resources/js/pdf_viewer2.js
|
||||
-/deps/db-sync/test/logseq/db_sync/fixtures/*.edn
|
||||
-/src/test/fixtures/*.transit
|
||||
-/src/test/migration/*.transit
|
||||
-/deps/graph-parser/test/resources/
|
||||
-/ios/App/App/public
|
||||
-/android/
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
[logseq.common.util :as common-util]))
|
||||
|
||||
(def ^:private yyyyMMdd-formatter (tf/formatter "yyyyMMdd"))
|
||||
(def ^:api default-journal-title-formatter "MMM do, yyyy")
|
||||
|
||||
;; (tf/parse (tf/formatter "dd.MM.yyyy") "2021Q4") => 20040120T000000
|
||||
(defn safe-journal-title-formatters
|
||||
[date-formatter]
|
||||
(->> [date-formatter "MMM do, yyyy" "yyyy-MM-dd" "yyyy_MM_dd"]
|
||||
(->> [date-formatter default-journal-title-formatter "yyyy-MM-dd" "yyyy_MM_dd"]
|
||||
(remove string/blank?)
|
||||
distinct))
|
||||
|
||||
@@ -106,4 +107,4 @@
|
||||
tc/from-long
|
||||
t/to-default-time-zone
|
||||
(tf/unparse yyyyMMdd-formatter)
|
||||
parse-long))
|
||||
parse-long))
|
||||
|
||||
2
deps/db/src/logseq/db/sqlite/export.cljs
vendored
2
deps/db/src/logseq/db/sqlite/export.cljs
vendored
@@ -85,7 +85,7 @@
|
||||
(merge (select-keys pvalue [:block/created-at :block/updated-at])))
|
||||
property-value-content')))
|
||||
|
||||
(defonce ignored-properties [:logseq.property/created-by-ref])
|
||||
(defonce ignored-properties [:logseq.property/created-by-ref :logseq.property.embedding/hnsw-label-updated-at])
|
||||
;; buildable-properties and build-blocks-export depend on each other
|
||||
(declare build-blocks-export)
|
||||
|
||||
|
||||
@@ -297,8 +297,9 @@
|
||||
;; for page names to change which breaks looking up journal refs for unconfigured journal pages
|
||||
(if export-to-db-graph? [date-formatter] (date-time-util/safe-journal-title-formatters date-formatter))))]
|
||||
(if day
|
||||
(let [original-page-name' (date-time-util/int->journal-title day date-formatter)]
|
||||
[original-page-name' (common-util/page-name-sanity-lc original-page-name') day])
|
||||
(let [original-page-name' (date-time-util/int->journal-title day date-formatter)
|
||||
default-journal-page-name (date-time-util/int->journal-title day date-time-util/default-journal-title-formatter)]
|
||||
[original-page-name' (common-util/page-name-sanity-lc default-journal-page-name) day])
|
||||
[original-page-name page-name day]))))
|
||||
|
||||
(def convert-page-if-journal (memoize convert-page-if-journal-impl))
|
||||
|
||||
6
deps/outliner/src/logseq/outliner/core.cljs
vendored
6
deps/outliner/src/logseq/outliner/core.cljs
vendored
@@ -6,6 +6,7 @@
|
||||
[datascript.core :as d]
|
||||
[datascript.impl.entity :as de :refer [Entity]]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.date-time :as date-time-util]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[logseq.common.uuid :as common-uuid]
|
||||
[logseq.db :as ldb]
|
||||
@@ -300,7 +301,10 @@
|
||||
(outliner-validate/validate-page-title-characters block-title {:node m*}))
|
||||
m (if page-title-changed?
|
||||
(let [_ (outliner-validate/validate-page-title (:block/title m*) {:node m*})
|
||||
page-name (common-util/page-name-sanity-lc (:block/title m*))]
|
||||
page-name (if-let [journal-day (:block/journal-day block-entity)]
|
||||
(common-util/page-name-sanity-lc
|
||||
(date-time-util/int->journal-title journal-day date-time-util/default-journal-title-formatter))
|
||||
(common-util/page-name-sanity-lc (:block/title m*)))]
|
||||
(assoc m* :block/name page-name))
|
||||
m*)
|
||||
_ (when (and ;; page or object changed?
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[datascript.core :as d]
|
||||
[logseq.common.config :as common-config]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.date-time :as date-time-util]
|
||||
[logseq.common.util.page-ref :as page-ref]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.common.order :as db-order]
|
||||
@@ -171,3 +173,16 @@
|
||||
:block/tags
|
||||
(map #(:db/ident (d/entity @conn (:db/id %))))))
|
||||
"New journal only has Journal tag")))
|
||||
|
||||
(deftest create-journal-keeps-default-block-name-with-custom-title-format
|
||||
(let [conn (db-test/create-conn)
|
||||
_ (d/transact! conn [[:db/add :logseq.class/Journal :logseq.property.journal/title-format "yyyy-MM-dd EEEE"]])
|
||||
[_ page-uuid] (outliner-page/create! conn "Dec 16th, 2024" {})
|
||||
page (d/entity @conn [:block/uuid page-uuid])
|
||||
default-name (-> (:block/journal-day page)
|
||||
(date-time-util/int->journal-title date-time-util/default-journal-title-formatter)
|
||||
common-util/page-name-sanity-lc)]
|
||||
(is (= "2024-12-16 Monday" (:block/title page))
|
||||
"Journal title follows configured formatter")
|
||||
(is (= default-name (:block/name page))
|
||||
"Journal block/name remains the default formatter, independent of title format")))
|
||||
|
||||
@@ -754,7 +754,9 @@
|
||||
(last child)
|
||||
(let [{:keys [content children]} (last child)
|
||||
page-name (subs content 2 (- (count content) 2))]
|
||||
(rum/with-key (page-reference (assoc config :children children) page-name nil) page-name))))
|
||||
(rum/with-key (page-reference (assoc config :children children)
|
||||
(or (:block/uuid page-entity) page-name)
|
||||
nil) page-name))))
|
||||
(cond
|
||||
(and label
|
||||
(string? label)
|
||||
@@ -3018,7 +3020,7 @@
|
||||
:disable-preview? true)]
|
||||
(when (seq parents)
|
||||
(let [parents-props (doall
|
||||
(for [{:block/keys [uuid name title] :as block} parents]
|
||||
(for [{:block/keys [uuid name] :as block} parents]
|
||||
(if name
|
||||
[block (page-cp (cond-> {:disable-preview? true}
|
||||
disabled?
|
||||
@@ -3027,7 +3029,7 @@
|
||||
(let [result (block/parse-title-and-body
|
||||
uuid
|
||||
(get block :block/format :markdown)
|
||||
title)
|
||||
(:block/raw-title block))
|
||||
ast-body (:block.temp/ast-body result)
|
||||
ast-title (:block.temp/ast-title result)
|
||||
config (assoc config :block/uuid uuid)]
|
||||
|
||||
@@ -433,7 +433,7 @@
|
||||
(let [format (util/evalue e)]
|
||||
(when-not (string/blank? format)
|
||||
(p/do!
|
||||
(property-handler/set-block-property! :logseq.class/Journal
|
||||
(property-handler/set-block-property! (:block/uuid (db/entity :logseq.class/Journal))
|
||||
:logseq.property.journal/title-format
|
||||
format)
|
||||
(notification/show! (t :settings.general/refresh-required-feedback)))
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
(defn- ->block-id
|
||||
[block-or-id]
|
||||
(cond
|
||||
(keyword? block-or-id)
|
||||
(:block/uuid (db-utils/entity block-or-id))
|
||||
|
||||
(de/entity? block-or-id)
|
||||
(:block/uuid block-or-id)
|
||||
|
||||
|
||||
@@ -596,8 +596,6 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
(when-not (string/blank? q)
|
||||
(let [option (assoc option :enable-snippet? enable-snippet?)
|
||||
match-input (get-match-input q)
|
||||
page-count (count (d/datoms @conn :avet :block/name))
|
||||
large-graph? (> page-count 2500)
|
||||
non-match-input (when (<= (count q) 2)
|
||||
(str "%" (string/replace q #"\s+" "%") "%"))
|
||||
limit (or limit 100)
|
||||
@@ -615,11 +613,9 @@ DROP TRIGGER IF EXISTS blocks_au;
|
||||
(->> (search-blocks-aux search-db non-match-sql q non-match-input page limit-p)
|
||||
(map (fn [result]
|
||||
(assoc result :keyword-score (fuzzy/score q (:title result)))))))
|
||||
;; fuzzy is too slow for large graphs
|
||||
fuzzy-result (when-not (or page large-graph?)
|
||||
(->> (fuzzy-search repo @conn q option)
|
||||
(map (fn [result]
|
||||
(assoc result :keyword-score (fuzzy/score q (:title result)))))))
|
||||
fuzzy-result (->> (fuzzy-search repo @conn q option)
|
||||
(map (fn [result]
|
||||
(assoc result :keyword-score (fuzzy/score q (:title result))))))
|
||||
;; _ (prn :debug "Search results before combine:" enable-snippet? (map :snippet matched-result))
|
||||
;; _ (doseq [item (concat fuzzy-result matched-result)]
|
||||
;; (prn :debug :keyword-search-result item))
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
(let [next-time (get-next-time (t/plus now (t/weeks 10)) week-unit 1)]
|
||||
(is (= 11 (in-weeks next-time))))
|
||||
(let [next-time (get-next-time (t/plus now (t/months 10)) month-unit 1)]
|
||||
(is (= 11 (in-months next-time))))
|
||||
(is (contains? #{10 11} (in-months next-time))))
|
||||
(let [next-time (get-next-time (t/plus now (t/years 10)) year-unit 1)]
|
||||
(is (= 11 (in-years next-time)))))
|
||||
|
||||
|
||||
@@ -2,9 +2,12 @@
|
||||
(:require [cljs.test :refer [deftest is testing]]
|
||||
[datascript.core :as d]
|
||||
[frontend.worker.pipeline :as worker-pipeline]
|
||||
[logseq.common.util :as common-util]
|
||||
[logseq.common.util.date-time :as date-time-util]
|
||||
[logseq.db :as ldb]
|
||||
[logseq.db.common.order :as db-order]
|
||||
[logseq.db.test.helper :as db-test]))
|
||||
[logseq.db.test.helper :as db-test]
|
||||
[logseq.outliner.page :as outliner-page]))
|
||||
|
||||
(deftest test-built-in-page-updates-that-should-be-reverted
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
@@ -145,6 +148,21 @@
|
||||
(is (= "page1-renamed"
|
||||
(:block/title (d/entity (:db-after result) (:db/id page1)))))))))
|
||||
|
||||
(deftest create-journal-page-name-uses-default-formatter-test
|
||||
(let [conn (db-test/create-conn)]
|
||||
(d/transact! conn [[:db/add :logseq.class/Journal :logseq.property.journal/title-format "yyyy-MM-dd EEEE"]])
|
||||
(let [[_ page-uuid] (outliner-page/create! conn "Dec 16th, 2024" {})
|
||||
page (d/entity @conn [:block/uuid page-uuid])
|
||||
journal-day (:block/journal-day page)
|
||||
expected-title (date-time-util/int->journal-title journal-day "yyyy-MM-dd EEEE")
|
||||
expected-name (-> journal-day
|
||||
(date-time-util/int->journal-title date-time-util/default-journal-title-formatter)
|
||||
common-util/page-name-sanity-lc)]
|
||||
(is (= expected-title (:block/title page))
|
||||
"Journal title follows configured title format")
|
||||
(is (= expected-name (:block/name page))
|
||||
"Journal block/name keeps the default formatter for stable identity"))))
|
||||
|
||||
(deftest built-in-tag-must-not-convert-page-child-block-to-class-test
|
||||
(let [conn (db-test/create-conn-with-blocks
|
||||
{:pages-and-blocks [{:page {:block/title "page1"}}]})
|
||||
|
||||
Reference in New Issue
Block a user