Merge branch 'master' into feat/custom-children-list-style

pull/9141/head
charlie 2023-04-18 18:26:57 +08:00
commit 0449ee6bdc
10 changed files with 63 additions and 49 deletions

1
.gitignore vendored
View File

@ -51,7 +51,6 @@ startup.png
/src/test/docs*
~*~
ios/App/App/capacitor.config.json
android/app/src/main/assets/capacitor.config.json
*.sublime-*

View File

@ -131,13 +131,10 @@
[?b :block/properties ?prop]
[(missing? $ ?b :block/name)]
[(get ?prop ?key) ?v]
(or-join [?v]
[(= ?v ?val)]
[(contains? ?v ?val)]
;; For integer pages that aren't strings
(and
[(str ?val) ?str-val]
[(contains? ?v ?str-val)]))]
[(str ?val) ?str-val]
(or [(= ?v ?val)]
[(contains? ?v ?val)]
[(contains? ?v ?str-val)])]
:page-ref
'[(page-ref ?b ?page-name)

View File

@ -174,9 +174,6 @@
(name k))
v'
(string/blank? v')
nil
(gp-util/wrapped-by-quotes? v')
v'

View File

@ -10,7 +10,6 @@
[frontend.db.model :as model]
[frontend.handler.common :as common-handler]
[frontend.handler.route :as route-handler]
[frontend.handler.config :as config-handler]
[frontend.handler.whiteboard :as whiteboard-handler]
[frontend.rum :refer [use-bounding-client-rect use-breakpoint
use-click-outside]]
@ -311,7 +310,6 @@
(ui/button (t :on-boarding/welcome-whiteboard-modal-skip) :on-click close-fn :background "gray" :class "opacity-60")
(ui/button (t :on-boarding/welcome-whiteboard-modal-start)
:on-click (fn []
(config-handler/set-config! :feature/enable-whiteboards? true)
(quick-tour/ready
(fn []
(quick-tour/start-whiteboard)

View File

@ -8,7 +8,9 @@
[logseq.common.path :as path]
[logseq.graph-parser.config :as gp-config]
[logseq.graph-parser.util :as gp-util]
[shadow.resource :as rc]))
[shadow.resource :as rc]
[goog.crypt.Md5]
[goog.crypt :as crypt]))
(goog-define DEV-RELEASE false)
(defonce dev-release? DEV-RELEASE)
@ -338,6 +340,9 @@
(def export-css-file "export.css")
(def custom-js-file "custom.js")
(def config-default-content (rc/inline "config.edn"))
(def config-default-content-md5 (let [md5 (new crypt/Md5)]
(.update md5 (crypt/stringToUtf8ByteArray config-default-content))
(crypt/byteArrayToHex (.digest md5))))
;; NOTE: repo-url is the unique identifier of a repo.
;; - `local` => in-memory demo graph

View File

@ -592,10 +592,16 @@
"when diff all remote files and local files, following remote files always need to download(when checksum not matched),
even local-file's last-modified > remote-file's last-modified.
because these files will be auto created when the graph created, we dont want them to re-write related remote files."
#{"logseq/config.edn" "logseq/custom.css"
"pages/contents.md" "pages/contents.org"
#{"pages/contents.md" "pages/contents.org"
"logseq/metadata.edn"})
(def ^:private ignore-default-value-files
"when create a new local graph, some files will be created (config.edn, custom.css).
And related remote files wins if these files have default template value."
#{"logseq/config.edn" "logseq/custom.css"})
(def ^:private empty-custom-css-md5 "d41d8cd98f00b204e9800998ecf8427e")
;; TODO: use fn some to filter FileMetadata here, it cause too much loop
(defn diff-file-metadata-sets
"Find the `FileMetadata`s that exists in s1 and does not exist in s2,
@ -605,29 +611,33 @@
keep this `FileMetadata` in result"
[s1 s2]
(reduce
(fn [result item]
(let [path (:path item)
lower-case-path (some-> path string/lower-case)
;; encrypted-path (:encrypted-path item)
checksum (:etag item)
last-modified (:last-modified item)]
(if (some
#(cond
(not= lower-case-path (some-> (:path %) string/lower-case))
false
(= checksum (:etag %))
true
(>= last-modified (:last-modified %))
false
;; these special files have higher priority in s1
(contains? higher-priority-remote-files path)
false
(< last-modified (:last-modified %))
true)
s2)
result
(conj result item))))
#{} s1))
(fn [result item]
(let [path (:path item)
lower-case-path (some-> path string/lower-case)
;; encrypted-path (:encrypted-path item)
checksum (:etag item)
last-modified (:last-modified item)]
(if (some
#(cond
(not= lower-case-path (some-> (:path %) string/lower-case))
false
(= checksum (:etag %))
true
(>= last-modified (:last-modified %))
false
;; these special files have higher priority in s1
(contains? higher-priority-remote-files path)
false
;; higher priority in s1 when config.edn=default value or empty custom.css
(and (contains? ignore-default-value-files path)
(#{config/config-default-content-md5 empty-custom-css-md5} (:etag %)))
false
(< last-modified (:last-modified %))
true)
s2)
result
(conj result item))))
#{} s1))
(comment
(defn map->FileMetadata [m]

View File

@ -37,7 +37,6 @@
[frontend.fs.watcher-handler :as fs-watcher]
[frontend.handler.command-palette :as cp]
[frontend.handler.common :as common-handler]
[frontend.handler.config :as config-handler]
[frontend.handler.editor :as editor-handler]
[frontend.handler.file :as file-handler]
[frontend.handler.file-sync :as file-sync-handler]
@ -89,10 +88,7 @@
(defn- enable-beta-features!
[]
(when-not (false? (state/enable-sync?)) ; user turns it off
(file-sync-handler/set-sync-enabled! true))
(when-not (false? (state/enable-whiteboards?))
(config-handler/set-config! :feature/enable-whiteboards? true)))
(file-sync-handler/set-sync-enabled! true)))
(defmethod handle :user/fetch-info-and-graphs [[_]]
(state/set-state! [:ui/loading? :login] false)

View File

@ -45,13 +45,13 @@
[line]
(boolean
(and (string? line)
(re-find (re-pattern (str "^\\s?[^ ]+" gp-property/colons " ")) line))))
(re-find (re-pattern (str "^\\s?[^ ]+" gp-property/colons)) line))))
(defn front-matter-property?
[line]
(boolean
(and (string? line)
(util/safe-re-find #"^\s*[^ ]+: " line))))
(util/safe-re-find #"^\s*[^ ]+:" line))))
(defn get-property-key
[line format]

View File

@ -63,7 +63,7 @@
(is (= {:title 98
:alias 6
:tags 2 :permalink 2
:tags 3 :permalink 2
:name 1 :type 1 :related 1 :sample 1 :click 1 :id 1 :example 1}
(docs-graph-helper/get-all-page-properties db))
"Counts for all page properties")

View File

@ -49,7 +49,7 @@
"** hello"
(property/remove-properties :markdown "** hello\nx:: y\na::b\n")
"** hello\na::b"))
"** hello"))
(testing "properties with blank lines"
(are [x y] (= x y)
@ -152,7 +152,19 @@ SCHEDULED: <2021-10-25 Mon>\n:PROPERTIES:\n:a: b\n:END:\nworld\n" "c" "d")
"a\nfoo:: [[bar]], [[baz]]\nb"
(property/insert-properties :markdown "" {:foo "\"bar, baz\""})
"foo:: \"bar, baz\""))
"foo:: \"bar, baz\""
(property/insert-properties :markdown "abcd\nempty::" {:id "123" :foo "bar"})
"abcd\nempty::\nid:: 123\nfoo:: bar"
(property/insert-properties :markdown "abcd\nempty:: " {:id "123" :foo "bar"})
"abcd\nempty:: \nid:: 123\nfoo:: bar"
(property/insert-properties :markdown "abcd\nempty::" {:id "123"})
"abcd\nempty::\nid:: 123"
(property/insert-properties :markdown "abcd\nempty::\nanother-empty::" {:id "123"})
"abcd\nempty::\nanother-empty::\nid:: 123"))
(deftest test-build-properties-str
(are [x y] (= (property/build-properties-str :mardown x) y)