fix: new page path

pull/1197/head
Tienson Qin 2021-01-28 23:25:22 +08:00
parent a44eb81cdd
commit fbf461699d
3 changed files with 9 additions and 14 deletions

View File

@ -480,7 +480,7 @@
[:th (t :page/name)]
[:th (t :file/last-modified-at)]]]
[:tbody
(for [[page modified-at] pages]
(for [page pages]
(let [encoded-page (util/encode-str page)]
[:tr {:key encoded-page}
[:td [:a {:on-click (fn [e]
@ -495,10 +495,7 @@
:href (rfe/href :page {:name encoded-page})}
page]]
[:td [:span.text-gray-500.text-sm
(if (zero? modified-at)
(t :file/no-data)
(date/get-date-time-string
(t/to-default-time-zone (tc/to-date-time modified-at))))]]]))]]))])))
(t :file/no-data)]]]))]]))])))
(rum/defcs new < rum/reactive
(rum/local "" ::title)

View File

@ -323,7 +323,11 @@
(defn get-file-path
[repo-url relative-path]
(if (and (util/electron?) (local-db? repo-url))
(str (get-repo-dir repo-url) "/" relative-path)
(let [dir (get-repo-dir repo-url)]
(if (string/starts-with? relative-path dir)
relative-path
(str dir "/"
(string/replace relative-path #"^/" ""))))
relative-path))
(defn get-config-path

View File

@ -65,7 +65,7 @@
(->
(do
(protocol/write-file! (get-fs dir) repo dir path content opts)
(db/set-file-last-modified-at! repo path (js/Date.)))
(db/set-file-last-modified-at! repo (config/get-file-path repo path) (js/Date.)))
(p/catch (fn [error]
(log/error :file/write-failed? {:dir dir
:path path
@ -86,13 +86,7 @@
(defn stat
[dir path]
(let [append-path (if path
(str "/"
(if (= \/ (first path))
(subs path 1)
path))
"")]
(protocol/stat (get-fs dir) dir path)))
(protocol/stat (get-fs dir) dir path))
(defn open-dir
[ok-handler]