@@ -97,7 +97,47 @@ module.setup = function()
97
97
}
98
98
end
99
99
100
- module .private = {
100
+ module .config .public = {
101
+ -- Which workspace to use for the journal files, the default behaviour
102
+ -- is to use the current workspace.
103
+ --
104
+ -- It is recommended to set this to a static workspace, but the most optimal
105
+ -- behaviour may vary from workflow to workflow.
106
+ workspace = nil ,
107
+
108
+ -- The name for the folder in which the journal files are put.
109
+ journal_folder = " journal" ,
110
+
111
+ -- The strategy to use to create directories.
112
+ -- May be "flat" (`2022-03-02.norg`), "nested" (`2022/03/02.norg`),
113
+ -- a lua string with the format given to `os.date()` or a lua function
114
+ -- that returns a lua string with the same format.
115
+ strategy = " nested" ,
116
+
117
+ -- The name of the template file to use when running `:Neorg journal template`.
118
+ template_name = " template.norg" ,
119
+
120
+ -- Whether to apply the template file to new journal entries.
121
+ use_template = true ,
122
+
123
+ -- Formatter function used to generate the toc file.
124
+ -- Receives a table that contains tables like { yy, mm, dd, link, title }.
125
+ --
126
+ -- The function must return a table of strings.
127
+ toc_format = nil ,
128
+ }
129
+
130
+ module .config .private = {
131
+ strategies = {
132
+ flat = " %Y-%m-%d.norg" ,
133
+ nested = " %Y" .. config .pathsep .. " %m" .. config .pathsep .. " %d.norg" ,
134
+ },
135
+ }
136
+
137
+ --- @class core.journal
138
+ module .public = {
139
+ version = " 0.0.9" ,
140
+
101
141
--- Opens a diary entry at the given time
102
142
--- @param time ? number #The time to open the journal entry at as returned by `os.time()`
103
143
--- @param custom_date ? string #A YYYY-mm-dd string that specifies a date to open the diary at instead
@@ -148,20 +188,19 @@ module.private = {
148
188
149
189
--- Opens a diary entry for tomorrow's date
150
190
diary_tomorrow = function ()
151
- module .private .open_diary (os.time () + 24 * 60 * 60 )
191
+ module .public .open_diary (os.time () + 24 * 60 * 60 )
152
192
end ,
153
193
154
194
--- Opens a diary entry for yesterday's date
155
195
diary_yesterday = function ()
156
- module .private .open_diary (os.time () - 24 * 60 * 60 )
196
+ module .public .open_diary (os.time () - 24 * 60 * 60 )
157
197
end ,
158
198
159
199
--- Opens a diary entry for today's date
160
200
diary_today = function ()
161
- module .private .open_diary ()
201
+ module .public .open_diary ()
162
202
end ,
163
203
164
- --- Creates a template file
165
204
create_template = function ()
166
205
local workspace = module .config .public .workspace
167
206
local folder_name = module .config .public .journal_folder
@@ -183,7 +222,7 @@ module.private = {
183
222
if module .required [" core.dirman" ].file_exists (folder_name .. config .pathsep .. index ) then
184
223
module .required [" core.dirman" ].open_file (workspace , folder_name .. config .pathsep .. index )
185
224
else
186
- module .private .create_toc ()
225
+ module .public .create_toc ()
187
226
end
188
227
end ,
189
228
@@ -377,48 +416,6 @@ module.private = {
377
416
end ,
378
417
}
379
418
380
- module .config .public = {
381
- -- Which workspace to use for the journal files, the default behaviour
382
- -- is to use the current workspace.
383
- --
384
- -- It is recommended to set this to a static workspace, but the most optimal
385
- -- behaviour may vary from workflow to workflow.
386
- workspace = nil ,
387
-
388
- -- The name for the folder in which the journal files are put.
389
- journal_folder = " journal" ,
390
-
391
- -- The strategy to use to create directories.
392
- -- May be "flat" (`2022-03-02.norg`), "nested" (`2022/03/02.norg`),
393
- -- a lua string with the format given to `os.date()` or a lua function
394
- -- that returns a lua string with the same format.
395
- strategy = " nested" ,
396
-
397
- -- The name of the template file to use when running `:Neorg journal template`.
398
- template_name = " template.norg" ,
399
-
400
- -- Whether to apply the template file to new journal entries.
401
- use_template = true ,
402
-
403
- -- Formatter function used to generate the toc file.
404
- -- Receives a table that contains tables like { yy, mm, dd, link, title }.
405
- --
406
- -- The function must return a table of strings.
407
- toc_format = nil ,
408
- }
409
-
410
- module .config .private = {
411
- strategies = {
412
- flat = " %Y-%m-%d.norg" ,
413
- nested = " %Y" .. config .pathsep .. " %m" .. config .pathsep .. " %d.norg" ,
414
- },
415
- }
416
-
417
- --- @class core.journal
418
- module .public = {
419
- version = " 0.0.9" ,
420
- }
421
-
422
419
module .load = function ()
423
420
if module .config .private .strategies [module .config .public .strategy ] then
424
421
module .config .public .strategy = module .config .private .strategies [module .config .public .strategy ]
452
449
module .on_event = function (event )
453
450
if event .split_type [1 ] == " core.neorgcmd" then
454
451
if event .split_type [2 ] == " journal.tomorrow" then
455
- module .private .diary_tomorrow ()
452
+ module .public .diary_tomorrow ()
456
453
elseif event .split_type [2 ] == " journal.yesterday" then
457
- module .private .diary_yesterday ()
454
+ module .public .diary_yesterday ()
458
455
elseif event .split_type [2 ] == " journal.custom" then
459
456
if not event .content [1 ] then
460
457
local calendar = modules .get_module (" core.ui.calendar" )
@@ -466,7 +463,7 @@ module.on_event = function(event)
466
463
467
464
calendar .select_date ({
468
465
callback = vim .schedule_wrap (function (osdate )
469
- module .private .open_diary (
466
+ module .public .open_diary (
470
467
nil ,
471
468
string.format (" %04d" , osdate .year )
472
469
.. " -"
@@ -477,16 +474,16 @@ module.on_event = function(event)
477
474
end ),
478
475
})
479
476
else
480
- module .private .open_diary (nil , event .content [1 ])
477
+ module .public .open_diary (nil , event .content [1 ])
481
478
end
482
479
elseif event .split_type [2 ] == " journal.today" then
483
- module .private .diary_today ()
480
+ module .public .diary_today ()
484
481
elseif event .split_type [2 ] == " journal.template" then
485
- module .private .create_template ()
482
+ module .public .create_template ()
486
483
elseif event .split_type [2 ] == " journal.toc.open" then
487
- module .private .open_toc ()
484
+ module .public .open_toc ()
488
485
elseif event .split_type [2 ] == " journal.toc.update" then
489
- module .private .create_toc ()
486
+ module .public .create_toc ()
490
487
end
491
488
end
492
489
end
0 commit comments