瀏覽代碼

chore: fix format

Tienson Qin 5 年之前
父節點
當前提交
9d083bc1f7

+ 56 - 56
src/main/frontend/db/model.cljs

@@ -243,11 +243,11 @@
     (when (conn/get-conn repo)
       (->
        (q repo [:blocks id] {}
-         '[:find (pull ?block [*])
-           :in $ ?id
-           :where
-           [?block :block/uuid ?id]]
-         id)
+          '[:find (pull ?block [*])
+            :in $ ?id
+            :where
+            [?block :block/uuid ?id]]
+          id)
        react
        ffirst))))
 
@@ -275,7 +275,7 @@
          [?page :page/tags ?e]
          [?page :page/original-name ?original-name]
          [?page :page/name ?name]]
-    (conn/get-conn repo)
+       (conn/get-conn repo)
        tag-name))
 
 (defn get-all-tagged-pages
@@ -286,7 +286,7 @@
          [?e :tag/name ?tag]
          [_ :page/name ?tag]
          [?page :page/name ?page-name]]
-    (conn/get-conn repo)))
+       (conn/get-conn repo)))
 
 (defn get-pages
   [repo]
@@ -294,7 +294,7 @@
         '[:find ?page-name
           :where
           [?page :page/original-name ?page-name]]
-         (conn/get-conn repo))
+        (conn/get-conn repo))
        (map first)))
 
 (defn get-pages-with-modified-at
@@ -305,7 +305,7 @@
             :where
             [?page :page/original-name ?page-name]
             [(get-else $ ?page :page/last-modified-at 0) ?modified-at]]
-           (conn/get-conn repo))
+          (conn/get-conn repo))
          (seq)
          (sort-by (fn [[page modified-at]]
                     [modified-at page]))
@@ -372,7 +372,7 @@
                [?file :file/path ?path]
                [(?pred $ ?path)]
                [?block :block/file ?file]]
-          (conn/get-conn repo-url) pred)
+             (conn/get-conn repo-url) pred)
         db-utils/seq-flatten)))
 
 (defn get-file-blocks
@@ -382,7 +382,7 @@
              :where
              [?file :file/path ?path]
              [?block :block/file ?file]]
-        (conn/get-conn repo-url) path)
+           (conn/get-conn repo-url) path)
       db-utils/seq-flatten))
 
 (defn get-file-after-blocks
@@ -396,7 +396,7 @@
                  [?block :block/file ?file-id]
                  [?block :block/meta ?meta]
                  [(?pred $ ?meta)]]
-            (conn/get-conn repo-url) file-id pred)
+               (conn/get-conn repo-url) file-id pred)
           db-utils/seq-flatten
           db-utils/sort-by-pos))))
 
@@ -422,7 +422,7 @@
              :where
              [?file :file/path ?path]
              [?page :page/file ?file]]
-        (conn/get-conn repo-url) path)
+           (conn/get-conn repo-url) path)
       db-utils/seq-flatten))
 
 (defn set-file-last-modified-at!
@@ -527,10 +527,10 @@
 (defn get-block-refs-count
   [repo]
   (->> (d/q
-         '[:find ?id2 ?id1
-           :where
-           [?id1 :block/ref-blocks ?id2]]
-         (conn/get-conn repo))
+        '[:find ?id2 ?id1
+          :where
+          [?id1 :block/ref-blocks ?id2]]
+        (conn/get-conn repo))
        (map first)
        (frequencies)))
 
@@ -541,7 +541,7 @@
     (map (fn [block]
            (assoc block :block/block-refs-count
                   (get refs (:db/id block))))
-      blocks)))
+         blocks)))
 
 (defn page-blocks-transform
   [repo-url result]
@@ -556,10 +556,10 @@
         pages (pull-many '[:db/id :page/last-modified-at :page/name :page/original-name] pages-ids)
         pages-map (reduce (fn [acc p] (assoc acc (:db/id p) p)) {} pages)
         blocks (map
-                 (fn [block]
-                   (assoc block :block/page
-                          (get pages-map (:db/id (:block/page block)))))
-                 blocks)]
+                (fn [block]
+                  (assoc block :block/page
+                         (get pages-map (:db/id (:block/page block)))))
+                blocks)]
     (db-utils/sort-by-pos blocks)))
 
 (defn get-marker-blocks
@@ -715,11 +715,11 @@
   (let [priority (string/capitalize priority)]
     (when (conn/get-conn repo)
       (->> (q repo [:priority/blocks priority] {}
-             '[:find (pull ?h [*])
-               :in $ ?priority
-               :where
-               [?h :block/priority ?priority]]
-             priority)
+              '[:find (pull ?h [*])
+                :in $ ?priority
+                :where
+                [?h :block/priority ?priority]]
+              priority)
            react
            db-utils/seq-flatten
            sort-blocks
@@ -833,7 +833,7 @@
            [?block :block/page ?page]
            [?block :block/meta ?meta]
            [(?pred $ ?meta)]]
-          (conn/get-conn repo)
+         (conn/get-conn repo)
          page
          pred)
         (block-and-children-transform repo block-uuid level))))
@@ -939,8 +939,8 @@
            [?page :page/journal? true]
            [?page :page/journal-day ?journal-day]
            [(<= ?journal-day ?today)]]
-      (conn/get-conn (state/get-current-repo))
-      today)))
+         (conn/get-conn (state/get-current-repo))
+         today)))
 
 (defn get-latest-journals
   ([n]
@@ -952,14 +952,14 @@
            today (db-utils/date->int (js/Date.))
            pages (->>
                   (q repo-url [:journals] {:use-cache? false}
-                    '[:find ?page-name ?journal-day
-                      :in $ ?today
-                      :where
-                      [?page :page/name ?page-name]
-                      [?page :page/journal? true]
-                      [?page :page/journal-day ?journal-day]
-                      [(<= ?journal-day ?today)]]
-                    today)
+                     '[:find ?page-name ?journal-day
+                       :in $ ?today
+                       :where
+                       [?page :page/name ?page-name]
+                       [?page :page/journal? true]
+                       [?page :page/journal-day ?journal-day]
+                       [(<= ?journal-day ?today)]]
+                     today)
                   (react)
                   (sort-by last)
                   (reverse)
@@ -1273,21 +1273,21 @@
 (defn get-collapsed-blocks
   []
   (d/q
-    '[:find ?content
-      :where
-      [?h :block/collapsed? true]
-      [?h :block/content ?content]]
-    (conn/get-conn)))
+   '[:find ?content
+     :where
+     [?h :block/collapsed? true]
+     [?h :block/content ?content]]
+   (conn/get-conn)))
 
 (defn get-public-pages
   [db]
   (-> (d/q
-        '[:find ?p
-          :where
-          [?p :page/properties ?d]
-          [(get ?d :public) ?pub]
-          [(= "true" ?pub)]]
-        db)
+       '[:find ?p
+         :where
+         [?p :page/properties ?d]
+         [(get ?d :public) ?pub]
+         [(= "true" ?pub)]]
+       db)
       (db-utils/seq-flatten)))
 
 (defn rebuild-page-blocks-children
@@ -1345,13 +1345,13 @@
   (let [pred (fn [db properties]
                (some? (get properties "template")))]
     (->> (d/q
-           '[:find ?b ?p
-             :in $ ?pred
-             :where
-             [?b :block/properties ?p]
-             [(?pred $ ?p)]]
-           (conn/get-conn)
-           pred)
+          '[:find ?b ?p
+            :in $ ?pred
+            :where
+            [?b :block/properties ?p]
+            [(?pred $ ?p)]]
+          (conn/get-conn)
+          pred)
          (map (fn [[e m]]
                 [(get m "template") e]))
          (into {}))))

+ 15 - 15
src/main/frontend/db/react.cljs

@@ -40,8 +40,8 @@
     (when page
       (let [page-name (util/url-decode (string/lower-case page))]
         (model/entity (if tag?
-                           [:tag/name page-name]
-                           [:page/name page-name]))))))
+                        [:tag/name page-name]
+                        [:page/name page-name]))))))
 
 (defn get-current-priority
   []
@@ -104,24 +104,24 @@
 
                              ;; refed-pages
                              (apply concat
-                               (for [{:block/keys [ref-pages]} blocks]
-                                 (map (fn [page]
-                                        (when-let [page (model/entity [:page/name (:page/name page)])]
-                                          [:page/refed-blocks (:db/id page)]))
-                                   ref-pages)))
+                                    (for [{:block/keys [ref-pages]} blocks]
+                                      (map (fn [page]
+                                             (when-let [page (model/entity [:page/name (:page/name page)])]
+                                               [:page/refed-blocks (:db/id page)]))
+                                           ref-pages)))
 
                              ;; refed-blocks
                              (apply concat
-                               (for [{:block/keys [ref-blocks]} blocks]
-                                 (map (fn [ref-block]
-                                        [:block/refed-blocks (last ref-block)])
-                                   ref-blocks))))
+                                    (for [{:block/keys [ref-blocks]} blocks]
+                                      (map (fn [ref-block]
+                                             [:block/refed-blocks (last ref-block)])
+                                           ref-blocks))))
                             (distinct))
               refed-pages (map
-                            (fn [[k page-id]]
-                              (if (= k :page/refed-blocks)
-                                [:page/ref-pages page-id]))
-                            handler-keys)
+                           (fn [[k page-id]]
+                             (if (= k :page/refed-blocks)
+                               [:page/ref-pages page-id]))
+                           handler-keys)
               custom-queries (some->>
                               (filter (fn [v]
                                         (and (= (first v) (state/get-current-repo))

+ 14 - 15
src/main/frontend/handler/block.cljs

@@ -66,7 +66,6 @@
           (map transform-fn)
           (apply util/join-newline)))))
 
-
 (defn get-block-end-pos-rec
   [repo block]
   (let [children (:block/children block)]
@@ -93,35 +92,35 @@
   [block]
   (let [repo (:block/repo block)]
     (db/transact! repo
-      [{:block/uuid (:block/uuid block)
-        :block/collapsed? true}])))
+                  [{:block/uuid (:block/uuid block)
+                    :block/collapsed? true}])))
 
 (defn collapse-blocks!
   [block-ids]
   (let [repo (state/get-current-repo)]
     (db/transact! repo
-      (map
-        (fn [id]
-          {:block/uuid id
-           :block/collapsed? true})
-        block-ids))))
+                  (map
+                   (fn [id]
+                     {:block/uuid id
+                      :block/collapsed? true})
+                   block-ids))))
 
 (defn expand-block!
   [block]
   (let [repo (:block/repo block)]
     (db/transact! repo
-      [{:block/uuid (:block/uuid block)
-        :block/collapsed? false}])))
+                  [{:block/uuid (:block/uuid block)
+                    :block/collapsed? false}])))
 
 (defn expand-blocks!
   [block-ids]
   (let [repo (state/get-current-repo)]
     (db/transact! repo
-      (map
-        (fn [id]
-          {:block/uuid id
-           :block/collapsed? false})
-        block-ids))))
+                  (map
+                   (fn [id]
+                     {:block/uuid id
+                      :block/collapsed? false})
+                   block-ids))))
 
 (defn pre-block-with-only-title?
   [repo block-id]

+ 1 - 1
src/main/frontend/handler/dnd.cljs

@@ -300,7 +300,7 @@
       ;;             path
       ;;             new-file-content
       ;;             {:re-render-root? true})
-      )))
+)))
 
 (defn- move-block-in-different-files
   [repo target-block to-block top-block bottom-block nested? top? target-child? direction target-content target-file original-top-block-start-pos block-changes]

+ 5 - 5
src/main/frontend/handler/extract.cljs

@@ -168,11 +168,11 @@
   (when (seq files)
     (let [result (->> files
                       (map
-                        (fn [{:file/keys [path content]} contents]
-                          (println "Parsing : " path)
-                          (when content
-                            (let [utf8-content (utf8/encode content)]
-                              (extract-blocks-pages repo-url path content utf8-content)))))
+                       (fn [{:file/keys [path content]} contents]
+                         (println "Parsing : " path)
+                         (when content
+                           (let [utf8-content (utf8/encode content)]
+                             (extract-blocks-pages repo-url path content utf8-content)))))
                       (remove empty?))]
       (when (seq result)
         (let [[pages block-ids blocks] (apply map concat result)

+ 2 - 2
src/main/frontend/handler/file.cljs

@@ -136,8 +136,8 @@
                file-content)
           tx (concat tx [(let [t (tc/to-long (t/now))]
                            (cond->
-                               {:file/path file
-                                :file/last-modified-at t}
+                            {:file/path file
+                             :file/last-modified-at t}
                              new?
                              (assoc :file/created-at t)))])]
       (db/transact! repo-url tx))))