mirror of https://github.com/logseq/logseq
fix: substitute date/text in all quick-capture templates (#9529)
* fix: substitute date/text in all quick-capture templates Previously, sharing media to logseq via an android intent only substituted the url/time. Now it substitutes the date and replaces the text with nothing (which seems like a reasonable default when there is no text). --------- Co-authored-by: Andelf <andelf@gmail.com>pull/9496/head
parent
607345fa87
commit
ec643111dc
|
@ -65,6 +65,7 @@
|
|||
(p/let [basename (node-path/basename url)
|
||||
label (-> basename util/node-path.name)
|
||||
time (date/get-current-time)
|
||||
date-ref-name (date/today)
|
||||
path (editor-handler/get-asset-path basename)
|
||||
_file (p/catch
|
||||
(.copy Filesystem (clj->js {:from url :to path}))
|
||||
|
@ -75,21 +76,25 @@
|
|||
template (get-in (state/get-config)
|
||||
[:quick-capture-templates :media]
|
||||
"**{time}** [[quick capture]]: {url}")]
|
||||
(-> (string/replace template "{time}" time)
|
||||
(-> template
|
||||
(string/replace "{time}" time)
|
||||
(string/replace "{date}" date-ref-name)
|
||||
(string/replace "{text}" "")
|
||||
(string/replace "{url}" (or url "")))))
|
||||
|
||||
(defn- embed-text-file
|
||||
"Store external content with url into Logseq repo"
|
||||
[url title]
|
||||
(p/let [time (date/get-current-time)
|
||||
date-ref-name (date/today)
|
||||
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 (node-path/join (config/get-repo-dir (state/get-current-repo))
|
||||
(config/get-pages-directory)
|
||||
(str (js/encodeURI (fs-util/file-name-sanity title)) (node-path/extname url)))
|
||||
(config/get-pages-directory)
|
||||
(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]
|
||||
|
@ -98,7 +103,10 @@
|
|||
template (get-in (state/get-config)
|
||||
[:quick-capture-templates :text]
|
||||
"**{time}** [[quick capture]]: {url}")]
|
||||
(-> (string/replace template "{time}" time)
|
||||
(-> template
|
||||
(string/replace "{time}" time)
|
||||
(string/replace "{date}" date-ref-name)
|
||||
(string/replace "{text}" "")
|
||||
(string/replace "{url}" (or url "")))))
|
||||
|
||||
(defn- handle-received-media [result]
|
||||
|
|
Loading…
Reference in New Issue