Tienson Qin 5 gadi atpakaļ
vecāks
revīzija
25246888f5

+ 0 - 5
api/yarn.lock

@@ -768,11 +768,6 @@ [email protected]:
   resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
   integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
 
-node-fetch@^2.6.0:
-  version "2.6.0"
-  resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"
-  integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==
-
 node-libs-browser@^2.0.0:
   version "2.2.1"
   resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425"

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
web/public/static/css/org.css


+ 4 - 3
web/public/static/css/style.css

@@ -238,7 +238,7 @@ h1, h2, h3, h4, h5, h6 {
 }
 
 textarea {
-    overflow: auto;
+    overflow: hidden;
     padding: 8px;
     border: 1px solid rgba(39,41,43,.15);
     border-radius: 4px;
@@ -249,6 +249,7 @@ textarea {
     outline: none;
 }
 
-li ol, li ul {
-    margin-left: 1rem;
+#content ol, #content ui {
+    list-style: disc;
+    margin-left: 1em;
 }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 0
web/public/static/js/manifest.edn


+ 38 - 51
web/src/frontend/components/agenda.cljs

@@ -58,60 +58,47 @@
       [:h2.mb-3 "Agenda"]
       (if (seq tasks)
         [:div.ml-1
-         (let [parent-tasks (block/group-by-parent (block/sort-tasks tasks))]
-           (for [[parent tasks] parent-tasks]
-             (let [parent (cond
-                            (string? parent)
-                            parent
+         (let [tasks (block/sort-tasks tasks)]
+           (for [{:heading/keys [uuid marker title priority level tags children timestamps meta repo file] :as task} tasks]
+             [:div.mb-2
+              {:key (str "task-" uuid)
+               :style {:padding-left 8
+                       :padding-right 8}}
+              [:div.column
+               [:div.row {:style {:align-items "center"}}
+                (case marker
+                  (list "DOING" "IN-PROGRESS" "TODO")
+                  (ui/checkbox {:on-change (fn [_]
+                                             ;; FIXME: Log timestamp
+                                             (handler/check task))})
 
-                            (and (map? parent)
-                                 (:label parent))
-                            (title-cp (:label parent))
+                  "WAIT"
+                  [:span {:style {:font-weight "bold"}}
+                   "WAIT"]
 
-                            :else
-                            "uncategorized")]
-               [:div.mt-10
-                [:h4.mb-3.text-gray-500 parent]
-                (for [{:heading/keys [uuid marker title priority level tags children timestamps meta repo file] :as task} tasks]
-                  [:div.mb-2
-                   {:key (str "task-" uuid)
-                    :style {:padding-left 8
-                            :padding-right 8}}
-                   [:div.column
-                    [:div.row {:style {:align-items "center"}}
-                     (case marker
-                       (list "DOING" "IN-PROGRESS" "TODO")
-                       (ui/checkbox {:on-change (fn [_]
-                                                  ;; FIXME: Log timestamp
-                                                  (handler/check task))})
+                  "DONE"
+                  (ui/checkbox {:checked true
+                                :on-change (fn [_]
+                                             ;; FIXME: Log timestamp
+                                             (handler/uncheck task)
+                                             )})
 
-                       "WAIT"
-                       [:span {:style {:font-weight "bold"}}
-                        "WAIT"]
+                  nil)
+                [:div.row.ml-2
+                 (if priority
+                   [:span.priority.mr-1
+                    (str "#[" priority "]")])
+                 (title-cp title)
+                 (marker-cp marker)
+                 (when (seq tags)
+                   (tags-cp tags))]]
+               (when (seq timestamps)
+                 (timestamps-cp timestamps))
 
-                       "DONE"
-                       (ui/checkbox {:checked true
-                                     :on-change (fn [_]
-                                                  ;; FIXME: Log timestamp
-                                                  (handler/uncheck task)
-                                                  )})
+               ;; FIXME: parse error
+               ;; (when (seq children)
+               ;;   (children-cp children))
 
-                       nil)
-                     [:div.row.ml-2
-                      (if priority
-                        [:span.priority.mr-1
-                         (str "#[" priority "]")])
-                      (title-cp title)
-                      (marker-cp marker)
-                      (when (seq tags)
-                        (tags-cp tags))]]
-                    (when (seq timestamps)
-                      (timestamps-cp timestamps))
-
-                    ;; FIXME: parse error
-                    ;; (when (seq children)
-                    ;;   (children-cp children))
-
-                    ]]
-                  )])))]
+               ]]
+             ))]
         "Empty")])))

+ 1 - 0
web/src/frontend/components/file.cljs

@@ -52,6 +52,7 @@
         commit-message (get state ::commit-message)
         rows (if (nil? @content) initial-rows (+ 3 (count-newlines @content)))
         [_encoded-path path] (get-path state)]
+    (prn {:rows rows})
     (sidebar/sidebar
      [:div#content
       [:h3.mb-2 (str "Update " path)]

+ 40 - 0
web/src/frontend/components/journal.cljs

@@ -0,0 +1,40 @@
+(ns frontend.components.journal
+  (:require [rum.core :as rum]
+            [frontend.util :as util]
+            [frontend.handler :as handler]
+            [clojure.string :as string]
+            [frontend.ui :as ui]
+            [frontend.format :as format]
+            [frontend.mixins :as mixins]))
+
+(defonce content-atom (atom ""))
+(defonce edit?-atom (atom false))
+
+(rum/defc editor-box <
+  (mixins/event-mixin
+   (fn [state]
+     (mixins/close-when-esc-or-outside state
+                                       true
+                                       :on-close (fn []
+                                                   (reset! edit?-atom false)))))
+  [content-atom]
+  [:textarea
+   {:rows 10
+    :on-change #(reset! content-atom (.. % -target -value))
+    :value @content-atom
+    :auto-focus true
+    :style {:border "none"
+            :border-radius 0
+            :background "transparent"}}])
+
+(rum/defcs journal < rum/reactive
+  [state]
+  (let [content (rum/react content-atom)
+        edit? (rum/react edit?-atom)]
+    [:div#content
+     [:h1.text-gray-600 "April 4th, 2020"]
+     (if (or edit? (string/blank? content))
+       (editor-box content-atom)
+       [:div {:on-click (fn []
+                          (reset! edit?-atom true))}
+        (util/raw-html (format/to-html content "org"))])]))

+ 2 - 2
web/src/frontend/components/sidebar.cljs

@@ -4,6 +4,7 @@
             [frontend.mixins :as mixins]
             [frontend.db :as db]
             [frontend.components.repo :as repo]
+            [frontend.components.journal :as journal]
             [goog.crypt.base64 :as b64]
             [frontend.util :as util]
             [frontend.state :as state]))
@@ -59,8 +60,7 @@
   (let [repos (db/get-repos)]
     [:div.max-w-7xl.mx-auto.px-4.sm:px-6.md:px-8
     (if (seq repos)
-      [:div
-       (repo/repos repos)]
+      (journal/journal)
       (repo/add-repo))]))
 
 (rum/defcs sidebar < (mixins/modal)

+ 1 - 1
web/src/frontend/db.cljs

@@ -89,7 +89,7 @@
    :children :heading/children
    :tags :heading/tags
    :meta :heading/meta
-   :parent-title :heading/parent-title})
+   })
 
 ;; (def schema
 ;;   [{:db/ident       {:db/unique :db.unique/identity}}

+ 26 - 40
web/src/frontend/format/org/block.cljs

@@ -46,41 +46,32 @@
 
 (defn extract-headings
   [blocks]
-  [blocks]
-  (let [reversed-blocks (reverse blocks)]
-    (loop [child-level 0
-           current-heading-children []
-           children-headings []
-           result []
-           rblocks reversed-blocks
-           timestamps {}]
-      (if (seq rblocks)
-        (let [block (first rblocks)
-              level (:level (second block))]
-          (cond
-            (and (>= level child-level) (heading-block? block))
-            (let [heading (assoc (second block)
-                                 :children (reverse current-heading-children)
-                                 :timestamps timestamps)
-                  children-headings (conj children-headings heading)]
-              (recur level [] children-headings result (rest rblocks) {}))
+  (loop [headings []
+         heading-children []
+         blocks (reverse blocks)
+         timestamps {}
+         last-pos nil]
+    (if (seq blocks)
+      (let [block (first blocks)
+            level (:level (second block))]
+        (cond
+          (paragraph-timestamp-block? block)
+          (let [timestamp (extract-timestamp block)
+                timestamps' (conj timestamps timestamp)]
+            (recur headings heading-children (rest blocks) timestamps' last-pos))
 
-            (paragraph-timestamp-block? block)
-            (let [timestamp (extract-timestamp block)
-                  timestamps' (conj timestamps timestamp)]
-              (recur child-level current-heading-children children-headings result (rest rblocks) timestamps'))
+          (heading-block? block)
+          (let [heading (-> (assoc (second block)
+                                   :children (reverse heading-children)
+                                   :timestamps timestamps)
+                            (assoc-in [:meta :end-pos] last-pos))
+                last-pos' (get-in heading [:meta :pos])]
+            (recur (conj headings heading) [] (rest blocks) {} last-pos'))
 
-            :else
-            (let [children (conj current-heading-children block)]
-              (if (and level (< level child-level))
-                (let [parent-title (extract-title block)
-                      children-headings (map (fn [heading]
-                                               (assoc heading :parent-title parent-title))
-                                          children-headings)
-                      result (concat result children-headings)]
-                  (recur 0 children [] result (rest rblocks) timestamps))
-                (recur child-level children children-headings result (rest rblocks) timestamps)))))
-        (reverse result)))))
+          :else
+          (let [heading-children' (conj heading-children block)]
+            (recur headings heading-children' (rest blocks) timestamps last-pos))))
+      (reverse headings))))
 
 ;; marker: DOING | IN-PROGRESS > TODO > WAITING | WAIT > DONE > CANCELED | CANCELLED
 ;; priority: A > B > C
@@ -98,16 +89,11 @@
               (cond
                 (and (= m1 m2)
                      (= p1 p2))
-                (compare (:heading/title t1) (:heading/title t2))
+                (compare (str (:heading/title t1))
+                         (str (:heading/title t2)))
 
                 (= m1 m2)
                 (> p1 p2)
                 :else
                 (> m1 m2))))
           headings)))
-
-(defn group-by-parent
-  [headings]
-  (->> (group-by :heading/parent-title headings)
-       (into (sorted-map-by (fn [x y]
-                              (compare (str x) (str y)))))))

+ 1 - 1
web/src/frontend/mixins.cljs

@@ -67,7 +67,7 @@
 
 (defn event-mixin
   ([attach-listeners]
-   (event-mixin identity))
+   (event-mixin attach-listeners identity))
   ([attach-listeners init-callback]
    (merge
     event-handler-mixin

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels