|
11 | 11 | [org.apache.pdfbox.pdmodel.common PDRectangle]))
|
12 | 12 |
|
13 | 13 | (def paddings
|
14 |
| - {:layout-left 200 |
| 14 | + {:layout-left 220 |
15 | 15 | :layout-top 105})
|
16 | 16 |
|
17 | 17 | (def colors
|
18 |
| - {:gray (pdf/make-color 50 50 50) |
| 18 | + {:black (pdf/make-color 0 0 0) |
| 19 | + :gray (pdf/make-color 50 50 50) |
19 | 20 | :light-gray (pdf/make-color 100 100 100)})
|
20 | 21 |
|
21 | 22 | (def styles
|
|
25 | 26 |
|
26 | 27 | (def page-names
|
27 | 28 | {:day #(str "day-" %)
|
28 |
| - :weeks #(str "weeks-" %)}) |
| 29 | + :weeks #(str "weeks-" %) |
| 30 | + :weeks-inbox #(str "weeks-inbox-" %) |
| 31 | + :project #(str "project-" %1 "-" %2)}) |
29 | 32 |
|
| 33 | +(def line-height 52) |
30 | 34 | (def days-per-weeks-page 28)
|
31 | 35 | (def week-days-completion-mark-size 60)
|
| 36 | +(def week-projects-completion-mark-size 40) |
32 | 37 | (def day-completion-mark-size 60)
|
33 | 38 |
|
34 | 39 | (defn get-page-name [page-name & params]
|
|
44 | 49 |
|
45 | 50 | (def lines-layout-pattern
|
46 | 51 | {:width "100%"
|
47 |
| - :height 52 |
| 52 | + :height line-height |
48 | 53 | :outline (fn [{:as attrs :keys [side]} & children]
|
49 | 54 | (when (#{:bottom :top} side)
|
50 | 55 | light-gray-line))
|
51 |
| - :line light-gray-line}) |
| 56 | + :line light-gray-line |
| 57 | + :row (fn [{:as attrs :keys [row-content row-index]}] |
| 58 | + (when (and row-content row-index) |
| 59 | + (when-let [content (get row-content row-index)] |
| 60 | + content)))}) |
| 61 | + |
| 62 | +(defn leftline [{:keys [text target-page]}] |
| 63 | + [:padding {:padding-right 10} |
| 64 | + [:text {:text text |
| 65 | + :font-size 20 |
| 66 | + :color (:black colors) |
| 67 | + :halign :right |
| 68 | + :valign :center} |
| 69 | + (when target-page |
| 70 | + [:padding {:padding -10} |
| 71 | + [:page-link {:target-page target-page}]])]]) |
52 | 72 |
|
53 | 73 | (defn completion-mark [{:as attrs :keys [x1 y1 x2 y2]}]
|
54 | 74 | (let [attrs (merge attrs light-gray-line)
|
|
59 | 79 | [:line (assoc attrs :x1 x2 :y1 y :x2 x :y2 y1)]
|
60 | 80 | [:line (assoc attrs :x1 x :y1 y1 :x2 x1 :y2 y)]]))
|
61 | 81 |
|
| 82 | +(def page-completion-mark |
| 83 | + [:padding {:padding-top "25%" |
| 84 | + :padding-left 150} |
| 85 | + [:split {:direction :x :splits [day-completion-mark-size]} |
| 86 | + [:split {:direction :y :splits [day-completion-mark-size]} |
| 87 | + [completion-mark]]]]) |
| 88 | + |
62 | 89 | (defn page-layout [{:keys [top-left top-right bottom-left bottom-right]}]
|
63 | 90 | [:split {:direction :y :splits [(:layout-top paddings)]}
|
64 | 91 | [:div
|
|
75 | 102 | bottom-left]
|
76 | 103 | bottom-right]])
|
77 | 104 |
|
78 |
| -(defn weeks-page [{:keys [from-date]}] |
| 105 | +(defn weeks-page [{:keys [from-date to-date]}] |
79 | 106 | [:page {:name (get-page-name :weeks from-date)}
|
80 | 107 | [page-layout
|
81 |
| - {:bottom-right |
82 |
| - [:split {:direction :y :splits [700]} |
| 108 | + {:top-left |
| 109 | + page-completion-mark |
| 110 | + |
| 111 | + :top-right |
| 112 | + [:padding {:padding-left 20} |
| 113 | + [:text {:text (str |
| 114 | + (t/format (t/formatter "dd MMM") from-date) |
| 115 | + " - " |
| 116 | + (t/format (t/formatter "dd MMM") to-date)) |
| 117 | + :font-size 40 |
| 118 | + :valign :center |
| 119 | + :halign :left}]] |
| 120 | + |
| 121 | + :bottom-right |
| 122 | + [:split {:direction :y :splits [(* 1 line-height) |
| 123 | + (* 12 line-height) |
| 124 | + (* 6 line-height) |
| 125 | + (* 4 line-height) |
| 126 | + (* 1 line-height) |
| 127 | + (* 10 line-height)]} |
| 128 | + [:grid {:cols 7 :rows 1 |
| 129 | + :line light-gray-line |
| 130 | + :outline (fn [attrs & _] |
| 131 | + [bottom-outline attrs light-gray-line])} |
| 132 | + (fn [{:keys [index]}] |
| 133 | + (let [columns {0 "MON" |
| 134 | + 1 "TUE" |
| 135 | + 2 "WED" |
| 136 | + 3 "THU" |
| 137 | + 4 "FRI" |
| 138 | + 5 "SAT" |
| 139 | + 6 "SUN"}] |
| 140 | + [:text {:text (get columns index) |
| 141 | + :color (:gray colors) |
| 142 | + :font-size 20 |
| 143 | + :valign :center |
| 144 | + :halign :center}]))] |
| 145 | + |
83 | 146 | [:grid {:cols 7 :rows 4
|
84 | 147 | :line light-gray-line
|
85 | 148 | :outline (fn [attrs & _]
|
|
90 | 153 | [:padding {:padding 10}
|
91 | 154 | [:split {:direction :y :splits [30]}
|
92 | 155 | [:text {:text (t/format (t/formatter "dd") date)
|
93 |
| - :color (:gray colors) |
| 156 | + :color (:black colors) |
94 | 157 | :font-size 30
|
95 | 158 | :valign :top
|
96 | 159 | :halign :right}]
|
97 | 160 | [:text {:text (-> (t/format (t/formatter "MMM") date)
|
98 | 161 | (str/upper-case))
|
99 |
| - :color (:light-gray colors) |
| 162 | + :color (:gray colors) |
100 | 163 | :font-size 20
|
101 | 164 | :valign :top
|
102 | 165 | :halign :right}]]]
|
103 | 166 |
|
104 | 167 | [:split {:direction :x :splits [week-days-completion-mark-size]}
|
105 | 168 | [:split {:direction :y :splits [week-days-completion-mark-size]}
|
106 | 169 | [:padding (:week-days-completion-mark styles)
|
107 |
| - [completion-mark]]]]]))]]}]]) |
| 170 | + [completion-mark]]]]]))] |
| 171 | + |
| 172 | + [:pattern-grid {:pattern lines-layout-pattern}] |
| 173 | + |
| 174 | + [:grid {:cols 4 :rows 2 |
| 175 | + :line light-gray-line |
| 176 | + :outline (fn [attrs & _] |
| 177 | + [bottom-outline attrs light-gray-line])} |
| 178 | + (fn [{:keys [index]}] |
| 179 | + [:page-link {:target-page (get-page-name :project from-date index)} |
| 180 | + [:split {:direction :x :splits [60]} |
| 181 | + [:padding {:padding-top (/ line-height 2) |
| 182 | + :padding-bottom (/ line-height 2) |
| 183 | + :padding-left 10} |
| 184 | + [completion-mark]]]])] |
| 185 | + |
| 186 | + [:grid {:cols 28 :rows 1 |
| 187 | + :line light-gray-line |
| 188 | + :outline (fn [attrs & _] |
| 189 | + [bottom-outline attrs light-gray-line])} |
| 190 | + (fn [{:keys [index]}] |
| 191 | + (let [date (t/>> from-date (t/of-days index))] |
| 192 | + [:padding {:padding 0} |
| 193 | + [:text {:text (t/format (t/formatter "dd") date) |
| 194 | + :font-size 20 |
| 195 | + :color (:black colors) |
| 196 | + :halign :center |
| 197 | + :valign :center}]]))] |
| 198 | + |
| 199 | + [:grid {:cols 28 :rows 10 |
| 200 | + :line light-gray-line}]] |
| 201 | + |
| 202 | + :bottom-left |
| 203 | + [:pattern-grid {:pattern lines-layout-pattern |
| 204 | + :row-content {1 [leftline {:text "DAYS>"}] |
| 205 | + 13 [leftline {:text "NOTES>"}] |
| 206 | + 18 [leftline {:text "INBOX>" |
| 207 | + :target-page (get-page-name :weeks-inbox from-date)}] |
| 208 | + 19 [leftline {:text "PROJECTS>"}] |
| 209 | + 23 [leftline {:text "HABITS>"}]}}]}]]) |
108 | 210 |
|
109 | 211 | (defn day-page [{:keys [date weeks-date]}]
|
110 | 212 | [:page {:name (get-page-name :day date)
|
111 | 213 | :size (PDRectangle. 1404 6000)}
|
112 | 214 | [page-layout
|
113 | 215 | {:top-left
|
114 |
| - [:padding {:padding-top "25%" |
115 |
| - :padding-left 120} |
116 |
| - [:split {:direction :x :splits [day-completion-mark-size]} |
117 |
| - [:split {:direction :y :splits [day-completion-mark-size]} |
118 |
| - [completion-mark]]]] |
| 216 | + page-completion-mark |
119 | 217 |
|
120 | 218 | :top-right
|
121 | 219 | [:page-link {:target-page (get-page-name :weeks weeks-date)}
|
122 | 220 | [:padding {:padding-left 20}
|
123 | 221 | [:text {:text (t/format (t/formatter "dd MMM") date)
|
| 222 | + :color (:black colors) |
124 | 223 | :font-size 40
|
125 | 224 | :valign :center
|
126 | 225 | :halign :left}]]]
|
127 | 226 |
|
| 227 | + :bottom-left |
| 228 | + [:pattern-grid {:pattern lines-layout-pattern |
| 229 | + :row-content {1 [leftline {:text "INBOX>" |
| 230 | + :target-page (get-page-name :weeks-inbox weeks-date)}]}}] |
| 231 | + |
| 232 | + :bottom-right |
| 233 | + [:pattern-grid {:pattern lines-layout-pattern}]}]]) |
| 234 | + |
| 235 | +(defn project-page [{:keys [weeks-date index]}] |
| 236 | + [:page {:name (get-page-name :project weeks-date index) |
| 237 | + :size (PDRectangle. 1404 6000)} |
| 238 | + [page-layout |
| 239 | + {:top-left |
| 240 | + page-completion-mark |
| 241 | + |
| 242 | + :top-right |
| 243 | + [:page-link {:target-page (get-page-name :weeks weeks-date)}] |
| 244 | + |
| 245 | + :bottom-left |
| 246 | + [:pattern-grid {:pattern lines-layout-pattern}] |
| 247 | + |
| 248 | + :bottom-right |
| 249 | + [:pattern-grid {:pattern lines-layout-pattern}]}]]) |
| 250 | + |
| 251 | +(defn inbox-page [{:keys [weeks-date]}] |
| 252 | + [:page {:name (get-page-name :weeks-inbox weeks-date) |
| 253 | + :size (PDRectangle. 1404 6000)} |
| 254 | + [page-layout |
| 255 | + {:top-left |
| 256 | + page-completion-mark |
| 257 | + |
| 258 | + :top-right |
| 259 | + [:page-link {:target-page (get-page-name :weeks weeks-date)} |
| 260 | + [:padding {:padding-left 10} |
| 261 | + [:text {:text (str |
| 262 | + (str/upper-case (t/format (t/formatter "MMMM") weeks-date)) |
| 263 | + " INBOX") |
| 264 | + :font-size 40 |
| 265 | + :color (:black colors) |
| 266 | + :halign :left |
| 267 | + :valign :center}]]] |
| 268 | + |
128 | 269 | :bottom-left
|
129 | 270 | [:pattern-grid {:pattern lines-layout-pattern}]
|
130 | 271 |
|
|
138 | 279 | (concat
|
139 | 280 | (->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
|
140 | 281 | (mapv (fn [from-date]
|
141 |
| - [weeks-page {:from-date from-date}]))) |
| 282 | + [weeks-page {:from-date from-date |
| 283 | + :to-date (t/>> from-date (t/of-days (dec days-per-weeks-page)))}]))) |
142 | 284 |
|
143 | 285 | (->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
|
144 | 286 | (mapcat (fn [from-date]
|
145 | 287 | (let [weeks-to-date (t/>> from-date (t/of-days days-per-weeks-page))]
|
146 | 288 | (->> (dt/range-dates from-date weeks-to-date)
|
147 | 289 | (mapv (fn [date]
|
148 | 290 | [day-page {:date date
|
149 |
| - :weeks-date from-date}])))))))))) |
| 291 | + :weeks-date from-date}]))))))) |
| 292 | + |
| 293 | + (->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page)) |
| 294 | + (mapv (fn [from-date] |
| 295 | + [inbox-page {:weeks-date from-date}]))) |
| 296 | + |
| 297 | + (->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page)) |
| 298 | + (mapcat (fn [from-date] |
| 299 | + (->> (range 8) |
| 300 | + (mapv (fn [index] |
| 301 | + [project-page {:weeks-date from-date |
| 302 | + :index index}]))))))))) |
150 | 303 |
|
151 | 304 | (comment
|
152 | 305 | (render/render-document
|
|
0 commit comments