mirror of https://github.com/logseq/logseq
Fix lint and other minor fixes
- Rename is-file-url to reflect boolean return val - Remove unused 3rd arg for set-config!pull/8914/head
parent
94f35bda18
commit
07c27b0f59
|
@ -12,7 +12,7 @@
|
|||
(js/console.error "decode-uri-component-failed" uri)
|
||||
uri)))
|
||||
|
||||
(defn is-file-url
|
||||
(defn is-file-url?
|
||||
[s]
|
||||
(and (string? s)
|
||||
(or (string/starts-with? s "file://") ;; mobile platform
|
||||
|
@ -29,7 +29,7 @@
|
|||
(let [fname (if (string/ends-with? path "/")
|
||||
nil
|
||||
(last (string/split path #"/")))]
|
||||
(if (and (seq fname) (is-file-url path))
|
||||
(if (and (seq fname) (is-file-url? path))
|
||||
(safe-decode-uri-component fname)
|
||||
fname)))
|
||||
|
||||
|
@ -167,7 +167,7 @@
|
|||
:else
|
||||
nil)
|
||||
|
||||
(if (is-file-url base)
|
||||
(if (is-file-url? base)
|
||||
(apply url-join base segments)
|
||||
(apply path-join-internal base segments)))
|
||||
|
||||
|
@ -190,7 +190,7 @@
|
|||
(defn path-normalize
|
||||
"Normalize path or URL"
|
||||
[path]
|
||||
(if (is-file-url path)
|
||||
(if (is-file-url? path)
|
||||
(url-normalize path)
|
||||
(path-normalize-internal path)))
|
||||
|
||||
|
@ -199,7 +199,7 @@
|
|||
|
||||
The reverse operation is (path-join protocol:// path)"
|
||||
[original-url]
|
||||
(if (is-file-url original-url)
|
||||
(if (is-file-url? original-url)
|
||||
;; NOTE: URL type is not consistent across all protocols
|
||||
;; Check file:// and assets://, pathname behavior is different
|
||||
(let [^js url (js/URL. (string/replace original-url "assets://" "file://"))
|
||||
|
@ -218,7 +218,7 @@
|
|||
[base-path sub-path]
|
||||
(let [base-path (path-normalize base-path)
|
||||
sub-path (path-normalize sub-path)
|
||||
is-url? (is-file-url base-path)]
|
||||
is-url? (is-file-url? base-path)]
|
||||
(if (string/starts-with? sub-path base-path)
|
||||
(if is-url?
|
||||
(safe-decode-uri-component (string/replace (subs sub-path (count base-path)) #"^/+", ""))
|
||||
|
@ -233,7 +233,7 @@
|
|||
[base-path sub-path]
|
||||
(let [base-path (path-normalize base-path)
|
||||
sub-path (path-normalize sub-path)
|
||||
is-url? (is-file-url base-path)]
|
||||
is-url? (is-file-url? base-path)]
|
||||
(if (string/starts-with? sub-path base-path)
|
||||
(if is-url?
|
||||
(safe-decode-uri-component (string/replace (subs sub-path (count base-path)) #"^/+", ""))
|
||||
|
@ -277,7 +277,7 @@
|
|||
[current-path target-path]
|
||||
(let [base-path (parent current-path)
|
||||
sub-path (path-normalize target-path)
|
||||
is-url? (is-file-url base-path)
|
||||
is-url? (is-file-url? base-path)
|
||||
base-segs (if base-path
|
||||
(string/split base-path #"/" -1)
|
||||
[])
|
||||
|
|
|
@ -432,44 +432,6 @@
|
|||
(path/path-join (get-repo-dir repo-url) path)
|
||||
(util/node-path.join (get-repo-dir repo-url) path)))
|
||||
|
||||
(defn get-file-path
|
||||
"Normalization happens here"
|
||||
[repo-url rpath]
|
||||
(js/console.error "BUG SHOULD-NOT-USE-BUGGY-FN" repo-url rpath)
|
||||
(when (and repo-url rpath)
|
||||
(let [path (cond
|
||||
(demo-graph?)
|
||||
(let [dir (get-repo-dir repo-url)
|
||||
r (path/path-join dir rpath)]
|
||||
(js/console.error "get-file-path" r)
|
||||
r)
|
||||
|
||||
(and (util/electron?) (local-db? repo-url))
|
||||
(let [dir (get-repo-dir repo-url)]
|
||||
(if (string/starts-with? rpath dir)
|
||||
rpath
|
||||
(str dir "/"
|
||||
(string/replace rpath #"^/" ""))))
|
||||
|
||||
(and (mobile-util/native-ios?) (local-db? repo-url))
|
||||
(let [dir (get-repo-dir repo-url)]
|
||||
(path/path-join dir rpath))
|
||||
|
||||
(and (mobile-util/native-android?) (local-db? repo-url))
|
||||
(let [dir (get-repo-dir repo-url)
|
||||
dir (if (or (string/starts-with? dir "file:")
|
||||
(string/starts-with? dir "content:"))
|
||||
dir
|
||||
(str "file:///" (string/replace dir #"^/+" "")))]
|
||||
(util/safe-path-join dir rpath))
|
||||
|
||||
(= "/" (first rpath))
|
||||
(subs rpath 1)
|
||||
|
||||
:else
|
||||
rpath)]
|
||||
(and (not-empty path) (gp-util/path-normalize path)))))
|
||||
|
||||
(defn get-repo-config-path
|
||||
([]
|
||||
(get-repo-config-path (state/get-current-repo)))
|
||||
|
|
|
@ -23,11 +23,9 @@
|
|||
(file-handler/set-file-content! repo path new-content) nil))))
|
||||
|
||||
(defn set-config!
|
||||
([k v]
|
||||
(set-config! (state/get-current-repo) k v))
|
||||
([_repo k v]
|
||||
[k v]
|
||||
(let [path "logseq/config.edn"]
|
||||
(repo-config-set-key-value path k v))))
|
||||
(repo-config-set-key-value path k v)))
|
||||
|
||||
(defn toggle-ui-show-brackets! []
|
||||
(let [show-brackets? (state/show-brackets?)]
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
Promise <void>"
|
||||
[repo format]
|
||||
(js/console.log (str "Writing character escaping format " format " of repo " repo))
|
||||
(set-config! repo :file/name-format format))
|
||||
(set-config! :file/name-format format))
|
||||
|
||||
(defn- calc-current-name
|
||||
"If the file body is parsed as the same page name, but the page name has a
|
||||
|
|
|
@ -37,6 +37,8 @@ when a plugin is installed, updated or removed"
|
|||
rewrite/parse-string
|
||||
(rewrite/assoc (keyword id) (select-keys plugin common-plugin-keys))
|
||||
str)]
|
||||
;; fs protocols require repo and dir when they aren't necessary. For this component,
|
||||
;; neither is needed so these are blank and nil respectively
|
||||
(fs/write-file! "" nil (plugin-config-path) updated-content {:skip-compare? true})))
|
||||
|
||||
(defn remove-plugin
|
||||
|
|
Loading…
Reference in New Issue