Disable batch optimization for now

pull/645/head
Tienson Qin 2020-08-27 10:48:36 +08:00
parent 238deee9ee
commit 035d443b5e
13 changed files with 47 additions and 39 deletions

View File

@ -110,11 +110,11 @@
parts-2 (string/split path #"/")
current-dir (string/join "/" (drop-last 1 parts))]
(cond
(string/starts-with? path "/")
(util/starts-with? path "/")
path
(and (not (string/starts-with? path ".."))
(not (string/starts-with? path ".")))
(and (not (util/starts-with? path ".."))
(not (util/starts-with? path ".")))
(str current-dir "/" path)
:else
@ -138,7 +138,7 @@
;; TODO: safe encoding asciis
;; TODO: image link to another link
(defn image-link [config url href label]
(let [href (if (string/starts-with? href "http")
(let [href (if (util/starts-with? href "http")
href
(get-file-absolute-path config href))]
[:img.rounded-sm.shadow-xl.mb-2.mt-2
@ -555,7 +555,7 @@
(= name "embed")
(let [a (first arguments)]
(cond
(and (string/starts-with? a "[[")
(and (util/starts-with? a "[[")
(string/ends-with? a "]]"))
(let [page-name (-> (string/replace a "[[" "")
(string/replace "]]" "")
@ -563,7 +563,7 @@
(when-not (string/blank? page-name)
(page-embed config page-name)))
(and (string/starts-with? a "((")
(and (util/starts-with? a "((")
(string/ends-with? a "))"))
(when-let [s (-> (string/replace a "((" "")
(string/replace "))" "")

View File

@ -192,7 +192,7 @@
"Clone"
:on-click
(fn []
(when (string/starts-with? repo-url "https://github.com/")
(when (util/starts-with? repo-url "https://github.com/")
(let [repo-url (string/replace repo-url ".git" "")]
(repo-handler/clone-and-pull repo-url)
(route-handler/redirect-to-home!)))))

View File

@ -216,7 +216,7 @@
(defn draw?
[path]
(string/starts-with? path default-draw-directory))
(util/starts-with? path default-draw-directory))
(defonce local-repo "local")
(def config-file "config.edn")

View File

@ -48,7 +48,7 @@
(defn get-repo-path
[url]
(if (string/starts-with? url "http")
(if (util/starts-with? url "http")
(->> (take-last 2 (string/split url #"/"))
(string/join "/"))
url))
@ -610,7 +610,7 @@
[files]
(remove
(fn [file]
(string/starts-with? file "journals/"))
(util/starts-with? file "journals/"))
files))
(defn get-pages
@ -911,7 +911,7 @@
exists? (atom #{})
lines (doall
(mapv (fn [line]
(let [result (filter #(and (string/starts-with? line (prefix-f %))
(let [result (filter #(and (util/starts-with? line (prefix-f %))
%)
directive-keys)]
(if (seq result)
@ -1079,7 +1079,7 @@
[file ast]
;; headline
(let [ast (map first ast)]
(if (string/starts-with? file "pages/contents.")
(if (util/starts-with? file "pages/contents.")
"Contents"
(let [file-page-name (get-file-page file)
first-block (last (first (filter block/heading-block? ast)))
@ -1243,7 +1243,7 @@
[repo-url file content utf8-content]
(if (string/blank? content)
[]
(let [journal? (string/starts-with? file "journals/")
(let [journal? (util/starts-with? file "journals/")
format (format/get-format file)
ast (mldoc/->edn content
(mldoc/default-config format))

View File

@ -115,10 +115,10 @@
(let [content (string/trim (doall (map-join children)))]
(reset! *inside-pre? false)
(case format
:markdown (if (string/starts-with? content "```")
:markdown (if (util/starts-with? content "```")
content
(str "```\n" content "\n```"))
:org (if (string/starts-with? content "#+BEGIN_SRC")
:org (if (util/starts-with? content "#+BEGIN_SRC")
content
(util/format "#+BEGIN_SRC\n%s\n#+END_SRC" content))
nil)))

View File

@ -33,8 +33,8 @@
(= typ "Search")
(not (contains? #{\# \* \/ \( \[} (first (second (:url (second block))))))
(let [page (second (:url (second block)))]
(when (and (not (string/starts-with? page "http"))
(not (string/starts-with? page "file"))
(when (and (not (util/starts-with? page "http"))
(not (util/starts-with? page "file"))
(not (string/ends-with? page ".html")))
page)))

View File

@ -43,7 +43,7 @@
([dir path]
(create-if-not-exists dir path ""))
([dir path initial-content]
(let [path (if (string/starts-with? path "/")
(let [path (if (util/starts-with? path "/")
path
(str "/" path))]
(util/p-handle

View File

@ -101,8 +101,8 @@
(let [{:keys [selection-start selection-end format value block edit-id input]} m
empty-selection? (= selection-start selection-end)
selection (subs value selection-start selection-end)
selection-link? (and selection (or (string/starts-with? selection "http://")
(string/starts-with? selection "https://")))
selection-link? (and selection (or (util/starts-with? selection "http://")
(util/starts-with? selection "https://")))
[content back-pos] (cond
empty-selection?
(config/get-empty-link-and-back-pos format)
@ -622,15 +622,15 @@
content (state/get-edit-content)
new-content (->
(cond
(string/starts-with? content "TODO")
(util/starts-with? content "TODO")
(string/replace-first content "TODO" "DOING")
(string/starts-with? content "DOING")
(util/starts-with? content "DOING")
(string/replace-first content "DOING" "DONE")
(string/starts-with? content "LATER")
(util/starts-with? content "LATER")
(string/replace-first content "LATER" "NOW")
(string/starts-with? content "NOW")
(util/starts-with? content "NOW")
(string/replace-first content "NOW" "DONE")
(string/starts-with? content "DONE")
(util/starts-with? content "DONE")
(string/replace-first content "DONE" "")
:else
(str (if (= :now (state/get-preferred-workflow))
@ -661,7 +661,7 @@
(when (>= idx 0)
(let [block (nth blocks idx)
collapsed? (= "none" (d/style block "display"))
prefix-match? (string/starts-with? (gobj/get block "id") prefix)]
prefix-match? (util/starts-with? (gobj/get block "id") prefix)]
(if (or collapsed?
;; might be embed blocks
(not prefix-match?))
@ -678,7 +678,7 @@
(when (>= (count blocks) idx)
(when-let [block (util/nth-safe blocks idx)]
(let [collapsed? (= "none" (d/style block "display"))
prefix-match? (string/starts-with? (gobj/get block "id") prefix)]
prefix-match? (util/starts-with? (gobj/get block "id") prefix)]
(if (or collapsed?
;; might be embed blocks
(not prefix-match?))
@ -1283,7 +1283,7 @@
(defn append-paste-doc!
[format event]
(let [[html text] (util/get-clipboard-as-html event)]
(when-not (string/starts-with? (string/trim text) "http")
(when-not (util/starts-with? (string/trim text) "http")
(let [doc-text (html-parser/parse format html)]
(when-not (string/blank? doc-text)
(util/stop event)

View File

@ -58,7 +58,7 @@
(some (fn [pattern]
(or
(= path pattern)
(and (string/starts-with? pattern "/")
(and (util/starts-with? pattern "/")
(= (str "/" (first (string/split path #"/")))
pattern)))) patterns))

View File

@ -17,8 +17,8 @@
(fn [image]
(let [src (get-src image)]
(and src
(not (or (string/starts-with? src "http://")
(string/starts-with? src "https://"))))))
(not (or (util/starts-with? src "http://")
(util/starts-with? src "https://"))))))
images)]
(doseq [img local-images]
(gobj/set img

View File

@ -92,7 +92,7 @@
:markdown (str (string/lower-case k) ": ")
"")
exists? (atom false)
lines (remove #(string/starts-with? % prefix) lines)]
lines (remove #(util/starts-with? % prefix) lines)]
(string/join "\n" lines))
full-content (str new-directives-content "\n\n" (string/trim after-content))]
(file-handler/alter-file (state/get-current-repo)

View File

@ -300,11 +300,14 @@
(defn check-changed-files-status
[f]
(when (gobj/get js/window.workerThread "getChangedFiles")
(->
(p/let [files (js/window.workerThread.getChangedFiles (util/get-repo-dir (state/get-current-repo)))]
(let [files (bean/->clj files)]
(when (empty? files)
;; FIXME: getChangedFiles not return right result
(state/reset-changed-files! files))))))
(state/reset-changed-files! files))))
(p/catch (fn [error]
(js/console.dir error))))))
(defn push
([repo-url]

View File

@ -352,9 +352,14 @@
#{"DETAILS" "SUMMARY"}
(gobj/get node "tagName"))))
;; Debug
(defn starts-with?
[s substr]
(string/starts-with? s substr))
(defn journal?
[path]
(string/starts-with? path "journals/"))
(starts-with? path "journals/"))
(defn drop-first-line
[s]
@ -693,7 +698,7 @@
(loop [idx (dec index)]
(if (>= idx 0)
(let [block (nth blocks idx)
prefix-match? (string/starts-with? (gobj/get block "id") prefix)]
prefix-match? (starts-with? (gobj/get block "id") prefix)]
(if (and prefix-match?
(= level (d/attr block "level")))
block