Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit a92b040

Browse files
authored
Merge pull request #1579 from TriliumNext/calendar
Add week note and quarter note support
2 parents 1822240 + 998abb3 commit a92b040

35 files changed

Lines changed: 1258 additions & 342 deletions

File tree

bin/tpl/anonymize-database.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label'
1414
'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'revisionsWidgetDisabled',
1515
'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass',
1616
'workspaceTabBackgroundColor', 'workspaceCalendarRoot', 'workspaceTemplate', 'searchHome', 'workspaceInbox',
17-
'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId',
17+
'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'weekPattern', 'enableWeekNote', 'monthPattern',
18+
'quarterPattern', 'yearPattern', 'enableQuarterNote', 'pageSize', 'viewType', 'mapRootNoteId',
1819
'bookmarkFolder', 'sorted', 'sortDirection', 'sortFoldersFirst', 'sortNatural', 'sortLocale', 'top',
1920
'fullContentWidth', 'shareHiddenFromTree', 'shareExternalLink', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription',
2021
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',
@@ -31,7 +32,8 @@ UPDATE attributes SET name = 'name' WHERE type = 'relation'
3132
'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'revisionsWidgetDisabled',
3233
'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass',
3334
'workspaceTabBackgroundColor', 'workspaceCalendarRoot', 'workspaceTemplate', 'searchHome', 'workspaceInbox',
34-
'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId',
35+
'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'weekPattern', 'enableWeekNote', 'monthPattern',
36+
'quarterPattern', 'yearPattern', 'enableQuarterNote', 'pageSize', 'viewType', 'mapRootNoteId',
3537
'bookmarkFolder', 'sorted', 'sortDirection', 'sortFoldersFirst', 'sortNatural', 'sortLocale', 'top',
3638
'fullContentWidth', 'shareHiddenFromTree', 'shareExternalLink', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription',
3739
'shareRaw', 'shareDisallowRobotIndexing', 'shareIndex', 'displayRelations', 'hideRelations', 'titleTemplate',

docs/User Guide/!!!meta.json

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"formatVersion": 2,
3-
"appVersion": "0.92.6",
3+
"appVersion": "0.92.7",
44
"files": [
55
{
66
"isClone": false,
@@ -3511,58 +3511,51 @@
35113511
"position": 20
35123512
},
35133513
{
3514-
"type": "label",
3515-
"name": "shareAlias",
3516-
"value": "search",
3517-
"isInheritable": false,
3518-
"position": 20
3519-
},
3520-
{
3521-
"type": "label",
3522-
"name": "iconClass",
3523-
"value": "bx bx-search-alt-2",
3514+
"type": "relation",
3515+
"name": "internalLink",
3516+
"value": "OR8WJ7Iz9K4U",
35243517
"isInheritable": false,
35253518
"position": 30
35263519
},
35273520
{
35283521
"type": "relation",
35293522
"name": "internalLink",
3530-
"value": "xYmIYSP6wE3F",
3523+
"value": "wX4HbRucYSDD",
35313524
"isInheritable": false,
35323525
"position": 40
35333526
},
35343527
{
35353528
"type": "relation",
35363529
"name": "internalLink",
3537-
"value": "YtSN43OrfzaA",
3530+
"value": "ivYnonVFBxbQ",
35383531
"isInheritable": false,
35393532
"position": 50
35403533
},
35413534
{
35423535
"type": "relation",
35433536
"name": "internalLink",
3544-
"value": "OR8WJ7Iz9K4U",
3537+
"value": "xYmIYSP6wE3F",
35453538
"isInheritable": false,
35463539
"position": 60
35473540
},
35483541
{
35493542
"type": "relation",
35503543
"name": "internalLink",
3551-
"value": "9sRHySam5fXb",
3544+
"value": "YtSN43OrfzaA",
35523545
"isInheritable": false,
35533546
"position": 70
35543547
},
35553548
{
35563549
"type": "relation",
35573550
"name": "internalLink",
3558-
"value": "m523cpzocqaD",
3551+
"value": "9sRHySam5fXb",
35593552
"isInheritable": false,
35603553
"position": 80
35613554
},
35623555
{
35633556
"type": "relation",
35643557
"name": "internalLink",
3565-
"value": "wX4HbRucYSDD",
3558+
"value": "m523cpzocqaD",
35663559
"isInheritable": false,
35673560
"position": 90
35683561
},
@@ -3590,16 +3583,23 @@
35903583
{
35913584
"type": "relation",
35923585
"name": "internalLink",
3593-
"value": "ivYnonVFBxbQ",
3586+
"value": "oPVyFC7WL2Lp",
35943587
"isInheritable": false,
35953588
"position": 130
35963589
},
35973590
{
3598-
"type": "relation",
3599-
"name": "internalLink",
3600-
"value": "oPVyFC7WL2Lp",
3591+
"type": "label",
3592+
"name": "shareAlias",
3593+
"value": "search",
36013594
"isInheritable": false,
3602-
"position": 140
3595+
"position": 20
3596+
},
3597+
{
3598+
"type": "label",
3599+
"name": "iconClass",
3600+
"value": "bx bx-search-alt-2",
3601+
"isInheritable": false,
3602+
"position": 30
36033603
}
36043604
],
36053605
"format": "markdown",
@@ -3852,16 +3852,16 @@
38523852
"mime": "text/html",
38533853
"attributes": [
38543854
{
3855-
"type": "label",
3856-
"name": "iconClass",
3857-
"value": "bx bx-search-alt-2",
3855+
"type": "relation",
3856+
"name": "internalLink",
3857+
"value": "MI26XDLSAlCD",
38583858
"isInheritable": false,
38593859
"position": 10
38603860
},
38613861
{
38623862
"type": "relation",
38633863
"name": "internalLink",
3864-
"value": "8YBEPzcpUgxw",
3864+
"value": "iPIMuisry3hd",
38653865
"isInheritable": false,
38663866
"position": 20
38673867
},
@@ -3875,16 +3875,16 @@
38753875
{
38763876
"type": "relation",
38773877
"name": "internalLink",
3878-
"value": "iPIMuisry3hd",
3878+
"value": "8YBEPzcpUgxw",
38793879
"isInheritable": false,
38803880
"position": 40
38813881
},
38823882
{
3883-
"type": "relation",
3884-
"name": "internalLink",
3885-
"value": "MI26XDLSAlCD",
3883+
"type": "label",
3884+
"name": "iconClass",
3885+
"value": "bx bx-search-alt-2",
38863886
"isInheritable": false,
3887-
"position": 50
3887+
"position": 10
38883888
}
38893889
],
38903890
"format": "markdown",

docs/User Guide/User Guide/Advanced Usage/Advanced Showcases/Day Notes.md

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,91 @@ This pattern works well also because of [Cloning Notes](../../Basic%20Concepts%2
1313

1414
![](Day%20Notes_image.png)
1515

16-
You can see the structure of day notes appearing under "Journal" note - there's a note for the whole year 2017, under it, you have "12 - December" which then contains "18 - Monday". This is our "day note" which contains some text in its content and also has some child notes (some of them are from [Task manager](Task%20Manager.md)).
16+
You can see the structure of day notes appearing under "Journal" note - there's a note for the whole year 2025, under it, you have "03 - March" which then contains "09 - Monday". This is our "day note" which contains some text in its content and also has some child notes (some of them are from [Task manager](Task%20Manager.md)).
1717

1818
You can also notice how this day note has [promoted attribute](../Attributes/Promoted%20Attributes.md) "weight" where you can track your daily weight. This data is then used in [Weight tracker](Weight%20Tracker.md).
1919

20+
## Week Note and Quarter Note
21+
22+
Week and quarter notes are disabled by default, since it might be too much for some people. To enable them, you need to set `#enableWeekNotes` and `#enableQuarterNotes` attributes on the root calendar note, which is identified by `#calendarRoot` label. Week note is affected by the first week of year option. Be careful when you already have some week notes created, it will not automatically change the existing week notes and might lead to some duplicates.
23+
2024
## Templates
2125

2226
Trilium provides [template](../Templates.md) functionality, and it could be used together with day notes.
2327

2428
You can define one of the following relations on the root of the journal (identified by `#calendarRoot` label):
2529

2630
* yearTemplate
31+
* quarterTemplate (if `#enableQuarterNotes` is set)
2732
* monthTemplate
33+
* weekTemplate (if `#enableWeekNotes` is set)
2834
* dateTemplate
2935

3036
All of these are relations. When Trilium creates a new note for year or month or date, it will take a look at the root and attach a corresponding `~template` relation to the newly created role. Using this, you can e.g. create your daily template with e.g. checkboxes for daily routine etc.
3137

32-
## Date pattern
38+
## Naming pattern
39+
40+
You can customize the title of generated journal notes by defining a `#datePattern`, `#weekPattern`, `#monthPattern`, `#quarterPattern` and `#yearPattern` attribute on a root calendar note (identified by `#calendarRoot` label). The naming pattern replacements follow a level-up compatibility - each level can use replacements from itself and all levels above it. For example, `#monthPattern` can use month, quarter and year replacements, while `#weekPattern` can use week, month, quarter and year replacements. But it is not possible to use week replacements in `#monthPattern`.
3341

34-
It's possible to customize the title of generated date notes by defining a `#datePattern` label on a root calendar note (identified by `#calendarRoot` label). Following are possible values:
42+
### Date pattern
3543

36-
* `{dayInMonthPadded} - {weekDay}` day notes are named e.g. "24 - Monday"
37-
* `{dayInMonthPadded}: {weekDay3}` day notes are named e.g. "24: Mon"
38-
* `{dayInMonthPadded}: {weekDay2}` day notes are named e.g. "24: Mo"
39-
* `{isoDate} - {weekDay}` day notes are named e.g. "2020-12-24 - Monday"
44+
It's possible to customize the title of generated date notes by defining a `#datePattern` attribute on a root calendar note (identified by `#calendarRoot` label). Following are possible values:
45+
46+
* `{isoDate}` results in an ISO 8061 formatted date (e.g. "2025-03-09" for March 9, 2025)
47+
* `{dateNumber}` results in a number like `9` for the 9th day of the month, `11` for the 11th day of the month
48+
* `{dateNumberPadded}` results in a number like `09` for the 9th day of the month, `11` for the 11th day of the month
4049
* `{ordinal}` is replaced with the ordinal date (e.g. 1st, 2nd, 3rd) etc.
50+
* `{weekDay}` results in the full day name (e.g. `Monday`)
51+
* `{weekDay3}` is replaced with the first 3 letters of the day, e.g. Mon, Tue, etc.
52+
* `{weekDay2}` is replaced with the first 2 letters of the day, e.g. Mo, Tu, etc.
53+
54+
The default is `{dateNumberPadded} - {weekDay}`
55+
56+
### Week pattern
57+
58+
It is also possible to customize the title of generated week notes through the `#weekPattern` attribute on the root calendar note. The options are:
59+
60+
* `{weekNumber}` results in a number like `9` for the 9th week of the year, `11` for the 11th week of the year
61+
* `{weekNumberPadded}` results in a number like `09` for the 9th week of the year, `11` for the 11th week of the year
62+
* `{shortWeek}` results in a short week string like `W9` for the 9th week of the year, `W11` for the 11th week of the year
63+
* `{shortWeek3}` results in a short week string like `W09` for the 9th week of the year, `W11` for the 11th week of the year
64+
65+
The default is `Week {weekNumber}`
4166

42-
## Month pattern
67+
### Month pattern
4368

44-
It is also possible to customize the title of generated month notes through the `#monthPattern` attribute, much like `#datePattern`. The options are:
69+
It is also possible to customize the title of generated month notes through the `#monthPattern` attribute on the root calendar note. The options are:
4570

4671
* `{isoMonth}` results in an ISO 8061 formatted month (e.g. "2025-03" for March 2025)
72+
* `{monthNumber}` results in a number like `9` for September, and `11` for November
4773
* `{monthNumberPadded}` results in a number like `09` for September, and `11` for November
4874
* `{month}` results in the full month name (e.g. `September` or `October`)
4975
* `{shortMonth3}` is replaced with the first 3 letters of the month, e.g. Jan, Feb, etc.
5076
* `{shortMonth4}` is replaced with the first 4 letters of the month, e.g. Sept, Octo, etc.
5177

5278
The default is `{monthNumberPadded} - {month}`
5379

80+
### Quarter pattern
81+
82+
It is also possible to customize the title of generated quarter notes through the `#quarterPattern` attribute on the root calendar note. The options are:
83+
84+
* `{quarterNumber}` results in a number like `1` for the 1st quarter of the year
85+
* `{shortQuarter}` results in a short quarter string like `Q1` for the 1st quarter of the year
86+
87+
The default is `Quarter {quarterNumber}`
88+
89+
### Year pattern
90+
91+
It is also possible to customize the title of generated year notes through the `#yearPattern` attribute on the root calendar note. The options are:
92+
93+
* `{year}` results in the full year (e.g. `2025`)
94+
95+
The default is `{year}`
96+
5497
## Implementation
5598

5699
Trilium has some special support for day notes in the form of [backend Script API](https://triliumnext.github.io/Notes/backend_api/BackendScriptApi.html) - see e.g. getDayNote() function.
57100

58-
Day (and year, month) notes are created with a label - e.g. `#dateNote="2018-08-16"` this can then be used by other scripts to add new notes to day note etc.
101+
Day (and year, month) notes are created with a label - e.g. `#dateNote="2025-03-09"` this can then be used by other scripts to add new notes to day note etc.
59102

60-
Journal also has relation `child:child:child:template=Day template` (see \[\[attribute inheritance\]\]) which effectively adds \[\[template\]\] to day notes (grand-grand-grand children of Journal).
103+
Journal also has relation `child:child:child:template=Day template` (see \[\[attribute inheritance\]\]) which effectively adds \[\[template\]\] to day notes (grand-grand-grand children of Journal). Please note that, when you enable week notes or quarter notes, it will not automatically change the relation for the child level.

docs/frontend_api/FrontendScriptApi.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4680,7 +4680,7 @@ <h5>Returns:</h5>
46804680

46814681

46824682

4683-
<h4 class="name" id="getWeekNote"><span class="type-signature"></span>getWeekNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="FNote.html">FNote</a>>}</span></h4>
4683+
<h4 class="name" id="getWeekFirstDayNote"><span class="type-signature"></span>getWeekFirstDayNote<span class="signature">(date)</span><span class="type-signature"> &rarr; {Promise.&lt;<a href="FNote.html">FNote</a>>}</span></h4>
46844684

46854685

46864686

docs/frontend_api/services_frontend_script_api.js.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ <h1 class="page-title">Source: services/frontend_script_api.js</h1>
563563
* @param {string} date - e.g. "2019-04-29"
564564
* @returns {Promise&lt;FNote>}
565565
*/
566-
this.getWeekNote = dateNotesService.getWeekNote;
566+
this.getWeekFirstDayNote = dateNotesService.getWeekFirstDayNote;
567567

568568
/**
569569
* Returns month-note. If it doesn't exist, it is automatically created.

src/etapi/etapi.openapi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ paths:
694694
/calendar/weeks/{date}:
695695
get:
696696
description: returns a week note for a given date. Gets created if doesn't exist.
697-
operationId: getWeekNote
697+
operationId: getWeekFirstDayNote
698698
parameters:
699699
- name: date
700700
in: path

0 commit comments

Comments
 (0)