Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update time.clj #19

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
chrome-user-profile/
classes/
resources/public/cljs-out/
/bin/
/bin/
/.calva/
/.clj-kondo/
/.lsp/
out/
23 changes: 17 additions & 6 deletions resources/public/css/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -447,17 +447,28 @@ a {
-webkit-print-color-adjust: exact !important;

&.emph-0 {background-color: none;}
&.emph-1 {background-color: rgba(0,255,100, .1);}
&.emph-2 {background-color: rgba(0,255,100, .2);}
&.emph-3 {background-color: rgba(0,255,100, .3);}
&.emph-4 {background-color: rgba(0,255,100, .4);}
&.emph-5 {background-color: rgba(0,255,100, .5);}
&.emph-6 {background-color: rgba(0,255,100, .6);}
&.emph-1 {background-color: rgba(0,255,100, 1);}
&.emph-2 {background-color: rgba(0,255,100, 1);}
&.emph-3 {background-color: rgba(0,255,100, 1);}
&.emph-4 {background-color: rgba(0,255,100, 1);}
&.emph-5 {background-color: rgba(0,255,100, 1);}
&.emph-6 {background-color: rgba(0,255,100, 1);}
&.emph-7 {background-color: rgba(0,255,100, .7);}
&.emph-8 {background-color: rgba(0,255,100, .8);}
&.emph-9 {background-color: rgba(0,255,100, .9);}
&.emph-10 {background-color: rgba(0,255,100, 1);}

// &.emph-1 {background-color: rgba(0,255,100, .1);}
// &.emph-2 {background-color: rgba(0,255,100, .2);}
// &.emph-3 {background-color: rgba(0,255,100, .3);}
// &.emph-4 {background-color: rgba(0,255,100, .4);}
// &.emph-5 {background-color: rgba(0,255,100, .5);}
// &.emph-6 {background-color: rgba(0,255,100, .6);}
// &.emph-7 {background-color: rgba(0,255,100, .7);}
// &.emph-8 {background-color: rgba(0,255,100, .8);}
// &.emph-9 {background-color: rgba(0,255,100, .9);}
// &.emph-10 {background-color: rgba(0,255,100, 1);}

&.selected.emph-0 {background-color: rgba(255,110,10, .3);}
&.selected.emph-1 {background-color: rgba(255,110,10, .3);}
&.selected.emph-2 {background-color: rgba(255,110,10, .3);}
Expand Down
3 changes: 2 additions & 1 deletion src/org_analyzer/http_server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@

(defn send-clocks-between
[org-files-and-dirs start end]
(let [{:keys [clocks org-files clock-count]} (get-clocks org-files-and-dirs)
(let [{:keys [clocks org-files clock-count]} (get-clocks org-files-and-dirs) ;;get-clocks解析org文件内容
clocks (clocks-between start end clocks)]
;; tmp (println clocks)] ;; 筛选指定时间的clocks
{:info {:clock-count clock-count
:org-files (map file-path org-files)}
:clocks (map clock-data clocks)}))
Expand Down
14 changes: 10 additions & 4 deletions src/org_analyzer/processing.clj
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@
(declare parent-entries all-tags-for)

(defnp find-clocks [org-data]
;; (println org-data) ;;debug
(for [{:keys [type text] :as entry} org-data
:when (= type :clock)]
(merge {:clock-string text
:sections (p ::parent-entries (parent-entries entry org-data))
:tags (p ::all-tags-for (all-tags-for entry org-data))}
;; :priority (println (parent-entries entry org-data))}
(parse-clock text))))

(defn clocks-by-section [clocks]
Expand All @@ -94,16 +96,20 @@
(def file-props-re #"^\s*#\+([0-9A-Za-z_\-]+):\s*(.*)")
(def metadata-re #"^\s*(CLOCK|DEADLINE|START|CLOSED|SCHEDULED|CREATED):.*")
(def simple-clock-re #"^\s*(CLOCK):.*")
(def section-keyword-re #"^(TODO|NEXT|MAYBE|WAIT|CANCELLED|DONE|REVIEW)\s*(.*)")
(def section-keyword-re #"^(TODO|NEXT|DELEGATED|HOLD|ABORT|MAYBE|WAIT|CANCELLED|DONE|REVIEW)\s*(.*)")
(def priority-re #"(.*)(\#\[[A-D]\])\s*(.*)") ;; #[B] ;;这里还是不对,需要深入研究

(defn parse-section-text-and-tags [text]
(let [[_ keyword text-no-kw] (re-find section-keyword-re text)
text (or text-no-kw text)
[_ text-no-tags raw-tags] (re-find #"(.*)\s+:([^ ]+):$" text)
text (s/trim (or text-no-tags text))]
[_ text-no-tags raw-tags] (re-find #"(.*)\s+:([^ ]+):$" text) ;; ":@Review:@Office:"
text (s/trim (or text-no-tags text))
[_ priority text-no-priority] (re-find priority-re text)
text (or text-no-priority text)]
(merge {:name text}
(when keyword {:keyword keyword})
(when raw-tags {:tags (keep not-empty (s/split raw-tags #":"))}))))
(when priority {:priority priority} (println priority))
(when raw-tags {:tags (keep not-empty (s/split raw-tags #":"))} (println raw-tags)))))

(defn read-org-lines [lines]
(for [[i line] (map-indexed vector lines)
Expand Down
2 changes: 1 addition & 1 deletion src/org_analyzer/time.clj
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,5 @@ Example:
([from-date to-date]
(let [from-date (adjust from-date :first-day-of-month)
to-date (adjust to-date :last-day-of-month)
n-days (time/time-between from-date to-date :days)]
n-days (+ (time/time-between from-date to-date :days) 1)]
(map simple-calendar-day (take n-days (time/iterate plus from-date (days 1)))))))
2 changes: 1 addition & 1 deletion test/org_analyzer/parsing_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ this should not show the elements from BBBB as children
(deftest localized-timestamps
(let [test-content "* Foo
:LOGBOOK:
CLOCK: [2018-03-26 m�. 13:14]--[2018-03-26 m�. 13:43] => 0:29
CLOCK: [2018-03-26 m�. 13:14]--[2018-03-26 m�. 13:43] => 0:29
:END:"
clocks (->> test-content
java.io.StringBufferInputStream.
Expand Down