소스 검색

Merge branch 'master' into feat/ui-tweaks-settings

Tienson Qin 4 년 전
부모
커밋
5a072bce91

+ 1 - 1
package.json

@@ -68,7 +68,7 @@
         "gulp-cached": "^1.1.1",
         "ignore": "^5.1.8",
         "jszip": "^3.5.0",
-        "mldoc": "^0.4.8",
+        "mldoc": "^0.4.9",
         "mousetrap": "^1.6.5",
         "path": "^0.12.7",
         "react": "^17.0.1",

+ 6 - 1
src/electron/electron/updater.cljs

@@ -21,10 +21,15 @@
 ;Event: 'update-downloaded'
 ;Event: 'completed'
 
+(def electron-version
+  (let [parts (string/split version #"\.")
+        parts (take 3 parts)]
+    (string/join "." parts)))
+
 (defn get-latest-artifact-info
   [repo]
   (let [;endpoint "https://update.electronjs.org/xyhp915/cljs-todo/darwin-x64/0.0.4"
-        endpoint (str "https://update.electronjs.org/" repo "/" js/process.platform "-" js/process.arch "/" version)]
+        endpoint (str "https://update.electronjs.org/" repo "/" js/process.platform "-" js/process.arch "/" electron-version)]
     (debug "[updater]" endpoint)
     (p/catch
      (p/let [res (fetch endpoint)

+ 1 - 1
src/main/frontend/components/search.cljs

@@ -243,7 +243,7 @@
         search-q (state/sub :search/q)
         show-result? (boolean (seq search-result))
         blocks-count (or (db/blocks-count) 0)
-        timeout (if (> blocks-count 2000) 300 100)]
+        timeout (if (> blocks-count 2000) 500 100)]
     (rum/with-context [[t] i18n/*tongue-context*]
       [:div#search.flex-1.flex
        [:div.inner

+ 1 - 2
src/main/frontend/components/settings.cljs

@@ -376,5 +376,4 @@
               (ui/button (t :user/delete-your-account)
                          :on-click (fn []
                                      (ui-handler/toggle-settings-modal!)
-                                     (js/setTimeout #(state/set-modal! delete-account-confirm))))]]]])]])))
-
+                                     (js/setTimeout #(state/set-modal! delete-account-confirm))))]]]])]])))

+ 0 - 1
src/main/frontend/components/theme.cljs

@@ -2,7 +2,6 @@
   (:require [rum.core :as rum]
             [frontend.util :as util]
             [frontend.handler.route :as route-handler]
-            [frontend.version :refer [version]]
             [frontend.components.svg :as svg]))
 
 (rum/defc container

+ 6 - 6
src/main/frontend/db/query_dsl.cljs

@@ -147,9 +147,7 @@
        page-ref?
        (let [page-name (-> (text/page-ref-un-brackets! e)
                            (string/lower-case))]
-         (when (and (not (string/blank? page-name))
-                    (some? (db-utils/entity repo [:page/name page-name])))
-           [['?b :block/path-ref-pages [:page/name page-name]]]))
+         [['?b :block/path-ref-pages [:page/name page-name]]])
 
        (contains? #{'and 'or 'not} fe)
        (let [clauses (->> (map (fn [form]
@@ -301,9 +299,11 @@
                tags (map (comp string/lower-case name) tags)]
            (when (seq tags)
              (let [tags (set (map (comp text/page-ref-un-brackets! string/lower-case name) tags))]
-               [['?p :page/tags '?t]
-                ['?t :page/name '?tag]
-                [(list 'contains? tags '?tag)]]))))
+               (let [sym-1 (uniq-symbol counter "?t")
+                     sym-2 (uniq-symbol counter "?tag")]
+                 [['?p :page/tags sym-1]
+                  [sym-1 :page/name sym-2]
+                  [(list 'contains? tags sym-2)]])))))
 
        (= 'all-page-tags fe)
        [['?e :page/tags '?p]]

+ 10 - 10
src/main/frontend/format/block.cljs

@@ -313,18 +313,18 @@
                 [path-refs (conj parents block)])
 
               (< level-diff 0)              ; new parent
-              (let [parents (take-while (fn [p] (< (:block/level p) cur-level)) parents)
+              (let [parents (vec (take-while (fn [p] (< (:block/level p) cur-level)) parents))
                     path-refs (mapcat :block/ref-pages parents)]
-                [path-refs (conj parents block)]))]
+                [path-refs (conj parents block)]))
+            path-ref-pages (->> path-refs
+                                (concat (:block/ref-pages block))
+                                (remove string/blank?)
+                                (map string/lower-case)
+                                (distinct)
+                                (map (fn [p]
+                                       {:page/name p})))]
         (recur (rest blocks)
-               (conj acc (assoc block :block/path-ref-pages
-                                (->> path-refs
-                                     (concat (:block/ref-pages block))
-                                     (remove string/blank?)
-                                     (map string/lower-case)
-                                     (distinct)
-                                     (map (fn [p]
-                                            {:page/name p})))))
+               (conj acc (assoc block :block/path-ref-pages path-ref-pages))
                parents)))))
 
 (defn extract-blocks

+ 4 - 0
src/main/frontend/handler/config.cljs

@@ -31,3 +31,7 @@
   [project]
   (when-not (string/blank? project)
     (set-config! [:project :name] project)))
+
+(defn set-preferred-workflow!
+  [workflow]
+  (set-config! :preferred-workflow (name workflow)))

+ 13 - 7
src/main/frontend/search.cljs

@@ -37,7 +37,9 @@
                       (bean/->js))
           indice (fuse. blocks
                         (clj->js {:keys ["uuid" "content"]
-                                  }))]
+                                  :shouldSort true
+                                  :minMatchCharLength 2
+                                  :threshold 0.4}))]
       (swap! indices assoc-in [repo :blocks] indice)
       indice)))
 
@@ -50,7 +52,10 @@
                      (bean/->js))
           indice (fuse. pages
                         (clj->js {:keys ["name"]
-                                  :threshold 0.4}))]
+                                  :shouldSort true
+                                  :minMatchCharLength 2
+                                  :threshold 0.2
+                                  }))]
       (swap! indices assoc-in [repo :pages] indice)
       indice)))
 
@@ -153,11 +158,12 @@
                    result (bean/->clj result)]
                (->>
                 (map
-                 (fn [{:keys [item] :as block}]
-                   (let [{:keys [content uuid]} item]
-                     {:block/uuid uuid
-                      :block/content content
-                      :block/page (:block/page (db/entity [:block/uuid (medley/uuid (str uuid))]))}))
+                  (fn [{:keys [item matches] :as block}]
+                    (let [{:keys [content uuid]} item]
+                      {:block/uuid uuid
+                       :block/content content
+                       :block/page (:block/page (db/entity [:block/uuid (medley/uuid (str uuid))]))
+                       :search/matches matches}))
                  result)
                 (remove nil?))))))))))
 

+ 1 - 1
src/main/frontend/version.cljs

@@ -1,3 +1,3 @@
 (ns frontend.version)
 
-(defonce version "0.0.10.1")
+(defonce version "0.0.10.3")

+ 4 - 4
yarn.lock

@@ -3906,10 +3906,10 @@ mkdirp@^0.5.4, mkdirp@~0.5.1:
   dependencies:
     minimist "^1.2.5"
 
-mldoc@^0.4.8:
-  version "0.4.8"
-  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.4.8.tgz#d52ad35378fdde1cdf7aa527a530488e39db3437"
-  integrity sha512-BZ8zXo2wgdnYOUXbZtpX5ocegtMIVRz1b+132xGKWlksu0VUEE0QJS7MjZYOMCnKVT7jmr/flpYENX/JkuUunw==
+mldoc@^0.4.9:
+  version "0.4.9"
+  resolved "https://registry.yarnpkg.com/mldoc/-/mldoc-0.4.9.tgz#22b9a42975251b619c9e1efd59008b8eec95ee55"
+  integrity sha512-zgFTZuio1vPXldcgQGDEKA8533Ub1RXAYez1jqdbXA3rwhU5Ad3PpKpgPKlc48zubJ7kazzFO5pmfpcdELc5zA==
   dependencies:
     yargs "^12.0.2"