Add aliase and replace an outdated alias

Also start making node-path consistent for frontend
This commit is contained in:
Gabriel Horner
2023-03-28 17:57:00 -04:00
committed by Andelf
parent f3f6bc4f84
commit 1e9fac25e4
7 changed files with 27 additions and 26 deletions

View File

@@ -35,7 +35,7 @@
[lambdaisland.glogi :as log]
[frontend.fs.capacitor-fs :as capacitor-fs]
["@capawesome/capacitor-background-task" :refer [BackgroundTask]]
["path" :as path]))
["path" :as node-path]))
;;; ### Commentary
;; file-sync related local files/dirs:
@@ -662,7 +662,7 @@
(let [favorite-pages* (set favorite-pages)]
(fn [^FileMetadata item]
(let [path (relative-path item)
journal-dir (path/join (config/get-journals-directory) path/sep)
journal-dir (node-path/join (config/get-journals-directory) node-path/sep)
journal? (string/starts-with? path journal-dir)
journal-day
(when journal?
@@ -1429,8 +1429,8 @@
(defn- is-journals-or-pages?
[filetxn]
(let [rel-path (relative-path filetxn)]
(or (string/starts-with? rel-path (path/join (config/get-journals-directory) path/sep))
(string/starts-with? rel-path (path/join (config/get-pages-directory) path/sep)))))
(or (string/starts-with? rel-path (node-path/join (config/get-journals-directory) node-path/sep))
(string/starts-with? rel-path (node-path/join (config/get-pages-directory) node-path/sep)))))
(defn- need-add-version-file?
"when we need to create a new version file:

View File

@@ -1,6 +1,6 @@
(ns frontend.mobile.intent
(:require ["@capacitor/filesystem" :refer [Filesystem]]
["path" :as path]
["path" :as node-path]
["send-intent" :refer [^js SendIntent]]
[clojure.pprint :as pprint]
[clojure.set :as set]
@@ -62,7 +62,7 @@
(defn- embed-asset-file [url format]
(p/let [basename (path/basename url)
(p/let [basename (node-path/basename url)
label (-> basename util/node-path.name)
time (date/get-current-time)
path (editor-handler/get-asset-path basename)
@@ -82,14 +82,14 @@
"Store external content with url into Logseq repo"
[url title]
(p/let [time (date/get-current-time)
title (some-> (or title (path/basename url))
title (some-> (or title (node-path/basename url))
gp-util/safe-decode-uri-component
util/node-path.name
;; make the title more user friendly
gp-util/page-name-sanity)
path (path/join (config/get-repo-dir (state/get-current-repo))
path (node-path/join (config/get-repo-dir (state/get-current-repo))
(config/get-pages-directory)
(str (js/encodeURI (fs-util/file-name-sanity title)) (path/extname url)))
(str (js/encodeURI (fs-util/file-name-sanity title)) (node-path/extname url)))
_ (p/catch
(.copy Filesystem (clj->js {:from url :to path}))
(fn [error]

View File

@@ -2,7 +2,7 @@
(ns frontend.util.fs
"Misc util fns built on top of frontend.fs"
(:require ["path" :as path]
(:require ["path" :as node-path]
[frontend.util :as util]
[logseq.graph-parser.util :as gp-util]
[clojure.string :as string]
@@ -34,12 +34,12 @@
(some #(string/ends-with? path %)
[".DS_Store" "logseq/graphs-txid.edn"])
;; hidden directory or file
(let [relpath (path/relative dir path)]
(let [relpath (node-path/relative dir path)]
(or (re-find #"/\.[^.]+" relpath)
(re-find #"^\.[^.]+" relpath)))
(let [path (string/lower-case path)]
(and
(not (string/blank? (path/extname path)))
(not (string/blank? (node-path/extname path)))
(not
(some #(string/ends-with? path %)
[".md" ".markdown" ".org" ".js" ".edn" ".css"]))))))))