Skip to content

Commit d33e776

Browse files
committed
Add new /end... commands, refactor code and documentation. WIP for v1.0.0
1 parent 5ad7612 commit d33e776

File tree

4 files changed

+92
-41
lines changed

4 files changed

+92
-41
lines changed

jgclark.DailyJournal/CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# What's changed in 💭 Journalling Plugin?
1+
# What's changed in 💭 Journalling Helpers Plugin?
22
_Please also see the Plugin [README](https://github.com/NotePlan/plugins/blob/main/jgclark.DailyJournal/README.md)._
33

44
<!-- TODO: improved flexibility of questions -->
55

66
## [1.0.0] - 2025-10-10
7-
_I've somewhat arbitrarily promoted this to v1.0 -- though I think it deserves it after 4.5 years._
7+
_I've somewhat arbitrarily promoted this to v1.0 -- though I think it deserves it after 4.5 years. Renamed it to "Journalling Helpers Plugin"._
88
### Added
9-
- new **/dayEnd**, **/todayEnd** and **/weekEnd** commands, that run pre-set Templates (like /dayStart etc.)
9+
- new **/dayEnd**, **/todayEnd** and **/weekEnd** commands, that run pre-set Templates (like /dayStart etc.). These can be useful for review or summary questions and/or tidy up operations.
1010
### Changed
1111
- re-wrote documentation to bring it up to date with NotePlan's improvements in Templating in the last 2 years.
1212

jgclark.DailyJournal/README.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
# 💭 Journalling plugin
1+
# 💭 Journalling Helpers Plugin
22
<img width="196px" src="calendar-notes-319@2x.png" align="right"/>
3-
This plugin helps you write daily, weekly, monthly, quarterly and/or yearly Journals, by speeding up applying your pre-set Templates to your calendar notes, and/or prompting you for review questions that you set in advance.
4-
5-
The commands are:
6-
- **/dayStart**: Apply your 'Daily Note' Template to the currently open daily note (or today's note if you're not editing a daily note)
7-
- **/todayStart**: Apply your 'Daily Note' Template to today's calendar note
8-
- **/weekStart**: Apply your 'Weekly Note' Template to the currently open weekly note (or the current weekly note if you're not editing a weekly note)
9-
- **/monthStart**: Apply your 'Monthly Note' Template to the currently open monthly note (or the current monthly note if you're not editing a monthly note)
10-
- **/dayReview**: Ask journal questions for an end-of-day review, and write answers in the current daily note. See below for details and examples.
11-
- **/weekReview**, **/monthReview**, **/quarterReview** and **/yearReview** all work similarly, asking the appropriately-configured journal questions, and write answers in the currently-open week/month/quarter/year note for that period, or if one of those isn't open, then offers to open the current note for that period.
3+
This plugin gives support for journalling in NotePlan, including making it easier to apply start-of-day Templates, and end-of-day/week Reviews, Summaries or Tidy Up.
124

135
### Configuration
14-
To use weekly/monthly/quarterly/yearly commands, you first need to have them turned on in **NotePlan Settings** > Calendar pane:
6+
To use this plugin on weekly/monthly/quarterly/yearly notes, you first need to have them turned on in **NotePlan Settings** > Calendar pane:
157

168
<img src="calendar-settings@2x.png"/>
179

18-
Then you will need to **configure the Plugin**: click the gear button on the 'Journalling' line in the Plugin Preferences panel, and fill in the settings according to which of the following commands you want to use. (On iOS or iPadOS, you need to use the separate **/Journalling: update plugin settings** command instead.)
10+
All the available commands require some **configuration** first. On Mac click the gear button on the 'Journalling' line in the Plugin Preferences panel, and fill in the settings according to which of the following commands you want to use. If you only use iPhone or iPad, you'll need to use the separate **/Journalling: update plugin settings** command instead.
1911

2012
## Quickly applying Templates at the start of each Day/Week
2113
The NotePlan website has good [articles on getting started with Templates](https://help.noteplan.co/article/136-templates), and a helpful [Template Gallery](https://noteplan.co/templates), to build from.
@@ -34,9 +26,9 @@ These commands make it quicker to apply a Template at the start or end of a day
3426
This acts very similarly to the /dayStart command above.
3527

3628
### /dayEnd, /todayEnd, /weekEnd commands
37-
These act in the same way as above, but can be tailored to adding items at the end of a day, perhaps like a Habit or Stats summary from the separate [**Habits & Summaries plugin**]().
29+
These act in the same way as above, but can be tailored to adding items at the end of a day, perhaps like a Habit or Stats summary from the separate [**Habits & Summaries plugin**](https://noteplan.co/plugins/jgclark.Summaries).
3830

39-
This is also a quick way of regularly running one or more commands from the separate [**Tidy Up plugin**]().
31+
This is also a quick way of regularly running one or more commands from the separate [**Tidy Up plugin**](https://noteplan.co/plugins/np.Tidy).
4032

4133
## Helping with periodic Reviews
4234
There's no right or wrong way to do reviews, and you'll no doubt change what you find helpful over time. But the key is to be taking some time to answer questions to help you pause and review what has and hasn't gone well over the last day/week/month/quarter. Some use it as a way of capturing their main **emotions**; others to track **goals**; others to write a simple **gratitude** journal.

jgclark.DailyJournal/plugin.json

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"noteplan.minAppVersion": "3.3.2",
33
"macOS.minVersion": "10.13.0",
44
"plugin.id": "jgclark.DailyJournal",
5-
"plugin.name": "💭 Journalling",
6-
"plugin.description": "Support for daily journalling in NotePlan, including start-of-day template, and end-of-day review questions. Before use it requires some configuration: please see website for details.",
5+
"plugin.name": "💭 Journalling Helpers",
6+
"plugin.description": "Supports daily journalling in NotePlan, including making it easier to apply start-of-day templates, and end-of-day/week Reviews, Summaries or Tidy Up. Before use it requires some configuration: please see website for details.",
77
"plugin.icon": "",
88
"plugin.author": "Jonathan Clark",
99
"plugin.url": "https://github.com/NotePlan/plugins/blob/main/jgclark.DailyJournal/README.md",
1010
"plugin.changelog": "https://github.com/NotePlan/plugins/blob/main/jgclark.DailyJournal/CHANGELOG.md",
1111
"plugin.version": "1.0.0",
12-
"plugin.lastUpdateInfo": "v1.0.0: Add new '/dayEnd', '/todayEnd' and '/weekEnd' commands, that run pre-set Templates (like /dayStart etc.).\nv0.15.1: New 'Journalling: update plugin settings' command for use on iOS/iPadOS. v0.15: Added support for Monthly, Quarterly and Yearly review questions. v0.14: Added /weekStart command. \nv0.13: Added support for /weekReview, /monthReview and /quarterlyReview, each of which have settings for their different Review Questions. /dayStart now uses the template's location field to determine where in the note to insert.",
12+
"plugin.lastUpdateInfo": "v1.0.0: Rename to 'Journalling Helpers Plugin'. Add new '/dayEnd', '/todayEnd' and '/weekEnd' commands, that run pre-set Templates for Reviews, Summaries or Tidy Up.\nv0.15.1: New 'Journalling: update plugin settings' command for use on iOS/iPadOS. v0.15: Added support for Monthly, Quarterly and Yearly review questions. v0.14: Added /weekStart command. \nv0.13: Added support for /weekReview, /monthReview and /quarterlyReview, each of which have settings for their different Review Questions. /dayStart now uses the template's location field to determine where in the note to insert.",
1313
"plugin.dependencies": [],
1414
"plugin.script": "script.js",
1515
"plugin.isRemote": "false",
@@ -18,7 +18,8 @@
1818
"name": "dayStart",
1919
"alias": [
2020
"daily",
21-
"template"
21+
"ds",
22+
"startDay"
2223
],
2324
"description": "Apply Daily Note Template",
2425
"jsFunction": "dayStart"
@@ -27,7 +28,8 @@
2728
"name": "dayEnd",
2829
"alias": [
2930
"daily",
30-
"template"
31+
"de",
32+
"endDay"
3133
],
3234
"description": "Apply Day End Template",
3335
"jsFunction": "dayEnd"
@@ -37,7 +39,7 @@
3739
"alias": [
3840
"day",
3941
"today",
40-
"template"
42+
"ts"
4143
],
4244
"description": "Apply Daily Note Template to Today's Calendar Note",
4345
"jsFunction": "todayStart"
@@ -46,8 +48,8 @@
4648
"name": "todayEnd",
4749
"alias": [
4850
"day",
49-
"today",
50-
"template"
51+
"endToday",
52+
"te"
5153
],
5254
"description": "Apply Day End Template to Today's Calendar Note",
5355
"jsFunction": "todayEnd"
@@ -56,7 +58,7 @@
5658
"name": "weekStart",
5759
"alias": [
5860
"weekly",
59-
"template"
61+
"ws"
6062
],
6163
"description": "Apply Weekly Note Template",
6264
"jsFunction": "weekStart"
@@ -71,7 +73,7 @@
7173
"name": "monthStart",
7274
"alias": [
7375
"monthly",
74-
"template"
76+
"ms"
7577
],
7678
"description": "Apply Monthly Note Template (requires configuring)",
7779
"jsFunction": "monthStart"
@@ -130,6 +132,11 @@
130132
"name": "Journalling: update plugin settings",
131133
"description": "Settings interface (even for iOS)",
132134
"jsFunction": "updateSettings"
135+
},
136+
{
137+
"name": "Journalling: Test onUpdateOrInstall",
138+
"description": "onUpdateOrInstall",
139+
"jsFunction": "onUpdateOrInstall"
133140
}
134141
],
135142
"plugin.settings": [
@@ -138,29 +145,53 @@
138145
"title": "Daily Journal settings"
139146
},
140147
{
141-
"key": "templateTitle",
142-
"title": "Daily Template Title",
148+
"key": "startDailyTemplateTitle",
149+
"title": "Start-of-Day Template Title",
143150
"description": "The name of the template that `/dayStart` and `/todayStart` commands will use.",
144151
"type": "string",
145152
"default": "Daily Note Template",
146-
"required": true
153+
"required": false
154+
},
155+
{
156+
"key": "endDailyTemplateTitle",
157+
"title": "End-of-DayTemplate Title",
158+
"description": "The name of the template that `/dayEnd` and `/todayEnd` commands will use.",
159+
"type": "string",
160+
"default": "Daily Review Template",
161+
"required": false
147162
},
148163
{
149-
"key": "weeklyTemplateTitle",
150-
"title": "Weekly Template Title",
164+
"key": "startWeeklyTemplateTitle",
165+
"title": "Start-of-Week Template Title",
151166
"description": "Optional name of the template that `/weekStart` command will use.",
152167
"type": "string",
153168
"default": "Weekly Note Template",
154169
"required": false
155170
},
156171
{
157-
"key": "monthlyTemplateTitle",
158-
"title": "Monthly Template Title",
172+
"key": "endWeeklyTemplateTitle",
173+
"title": "End-of-Week Template Title",
174+
"description": "Optional name of the template that `/weekEnd` command will use.",
175+
"type": "string",
176+
"default": "Weekly Review Template",
177+
"required": false
178+
},
179+
{
180+
"key": "startMonthlyTemplateTitle",
181+
"title": "Start-of-Month Template Title",
159182
"description": "Optional name of the template that `/monthStart` command will use.",
160183
"type": "string",
161184
"default": "Monthly Note Template",
162185
"required": false
163186
},
187+
{
188+
"key": "endMonthlyTemplateTitle",
189+
"title": "End-of-Month Template Title",
190+
"description": "Optional name of the template that `/monthEnd` command will use.",
191+
"type": "string",
192+
"default": "Monthly Review Template",
193+
"required": false
194+
},
164195
{
165196
"key": "reviewSectionHeading",
166197
"title": "Journal Section Heading",
@@ -172,13 +203,13 @@
172203
{
173204
"key": "moods",
174205
"title": "List of moods",
175-
"description": "A comma-separated list of possible moods to select from.",
206+
"description": "(Optional.) A comma-separated list of possible moods to select from.",
176207
"type": "string",
177208
"default": "🤩 Great,🙂 Good,😇 Blessed,🥱 Tired,😫 Stressed,😤 Frustrated,😔 Low,🥵 Sick,Other",
178209
"required": true
179210
},
180211
{
181-
"key": "reviewQuestions",
212+
"key": "dailyReviewQuestions",
182213
"title": "Daily Journal Questions",
183214
"description": "Optional string that includes both the Journal/Review questions and how to lay out the answers in the daily note. (NB: can include line breaks.) The special codes that define the type of question asked are '<int>', '<number>', '<string>', '<subheading>' and '<mood>'.",
184215
"type": "string",

jgclark.DailyJournal/src/index.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
// allow changes in plugin.json to trigger recompilation
1010
import pluginJson from '../plugin.json'
11-
import { JSP, logDebug, logInfo, logError } from "@helpers/dev"
12-
import { pluginUpdated, updateSettingData } from '@helpers/NPConfiguration'
11+
import { renameKeys } from '@helpers/dataManipulation'
12+
import { clo, compareObjects, JSP, logDebug, logInfo, logError } from "@helpers/dev"
13+
import { backupSettings, pluginUpdated, saveSettings } from '@helpers/NPConfiguration'
1314
import { editSettings } from '@helpers/NPSettings'
1415

1516
const pluginID = 'jgclark.DailyJournal'
@@ -24,8 +25,11 @@ export {
2425

2526
export {
2627
dayStart,
28+
dayEnd,
2729
todayStart,
30+
todayEnd,
2831
weekStart,
32+
weekEnd,
2933
monthStart,
3034
} from './templatesStartEnd'
3135

@@ -44,10 +48,34 @@ export function onSettingsUpdated(): void {
4448

4549
export async function onUpdateOrInstall(): Promise<void> {
4650
try {
47-
logDebug(pluginJson, `${pluginJson['plugin.id']} :: onUpdateOrInstall started`)
51+
logDebug(pluginJson, `onUpdateOrInstall() ...`)
52+
const initialSettings = (await DataStore.loadJSON(`../${pluginID}/settings.json`)) || DataStore.settings
53+
54+
// Migrate any necessary settings from v0.15 to v1.0
55+
// TODO(later): remove when all users have updated to v1.0
56+
await backupSettings(pluginID, `before_onUpdateOrInstall-v${pluginJson['plugin.version']}`)
57+
const keysToChange = {
58+
// oldKey: newKey
59+
templateTitle: 'startDailyTemplateTitle',
60+
weeklyTemplateTitle: 'startWeeklyTemplateTitle',
61+
monthlyTemplateTitle: 'startMonthlyTemplateTitle',
62+
reviewQuestions: 'dailyReviewQuestions',
63+
}
64+
const migratedSettings = renameKeys(initialSettings, keysToChange)
65+
const diff = compareObjects(migratedSettings, initialSettings, [], true)
66+
if (diff != null) {
67+
// Save the settings back to the DataStore
68+
logInfo(`onUpdateOrInstall`, `- changes to settings detected`)
69+
clo(initialSettings, `onUpdateOrInstall: initialSettings:`)
70+
clo(migratedSettings, `onUpdateOrInstall: migratedSettings:`)
71+
await saveSettings(pluginID, migratedSettings)
72+
} else {
73+
logDebug(`onUpdateOrInstall`, `- no changes detected to settings.`)
74+
}
75+
4876
// Tell user the plugin has been updated
49-
await updateSettingData(pluginJson)
50-
await pluginUpdated(pluginJson, { code: 2, message: `Plugin Installed.` })
77+
logInfo(pluginID, `- finished`)
78+
await pluginUpdated(pluginJson, { code: 2, message: `Plugin Installed or Updated.` })
5179
} catch (error) {
5280
logError(pluginID, `onUpdateOrInstall: ${JSP(error)}`)
5381
}

0 commit comments

Comments
 (0)