trilium icon indicating copy to clipboard operation
trilium copied to clipboard

Add #calendarType attribute to support monthly or weekly notes

Open AllanZyne opened this issue 2 years ago • 4 comments

Add new attribute #calendarType on calendar root note, its value can be monthly(default) or weekly. If #calendarType=monthly, then the calendar tree will be organized as "year/month/day", this is default option just like before; if #calendarType=weekly, then the calendar tree will be organized as "year/week/day".

Beside, year/month/week/day notes have their own title pattern: yearPattern(new), monthPattern, weekPattern(new) and datePattern, and they all support these macros:

  • {year}: "YYYY"
  • {month}: month name
  • {monthNumberPadded}: "MM"
  • {weekNumber}(new): ISO week number
  • {weekNumberPadded}(new): "WW"
  • {weekDay}: week name
  • {weekDay2} the first two characters of week name
  • {weekDay3}: the first three characters of week name
  • {dayInMonthPadded}: "DD"
  • {isoDate}: "YYYY-MM-DD" (Add custom macros support?)

To implement the design of https://github.com/zadam/trilium/issues/3461, I added a new attribute #calendarPattern which can control the note tree of calendar.

The default value of #calendarPattern is "year/month/day", this will keep the default calendar tree like before.

The label in #calendarPattern can be one of "day", "week", "month" or "year", and there must be at least one "day" in it.

Thanks for any suggestions.

AllanZyne avatar Jan 20 '23 04:01 AllanZyne

Hi, @zadam. In backend api document, BNote's cloneTo(parentNoteId) → {Object}, what's object?

AllanZyne avatar Mar 11 '23 08:03 AllanZyne

I think my logic might be right, but I encounter the following error message, would you like to give me some helps? Thank you very much!

"Encountered error "Process exceeded time limit 30000", check out the console."

AllanZyne avatar Mar 11 '23 14:03 AllanZyne

Hi, @zadam. In backend api document, BNote's cloneTo(parentNoteId) → {Object}, what's object?

Unfortunately JSDoc does not support object declaration in @returns, the value is better defined in the source.

zadam avatar Mar 12 '23 22:03 zadam

"Encountered error "Process exceeded time limit 30000", check out the console."

This usually means that the WebSocket message (with entity updates) has crashed some component in the frontend. Usually you will find the source of the problem above in the console.

zadam avatar Mar 12 '23 22:03 zadam

"Encountered error "Process exceeded time limit 30000", check out the console."

This usually means that the WebSocket message (with entity updates) has crashed some component in the frontend. Usually you will find the source of the problem above in the console.

Backend logs:

getParentNote day 2022-12-28
getWeekNote: find weekNote
getWeekNote: not year
getParentNote week 2022-12-28
getParentNote year 2022-12-28
Created new note 'szPqG5zh7kkj', branch 'u7dTta9kSl90_szPqG5zh7kkj' of type 'text', mime 'text/html'
getWeekNote: clone
Cloned note 'y9mnzt2gwt5E' to new parent note 'szPqG5zh7kkj' with prefix 'undefined'
getWeekNote: return
Created new note 'HMx7UmZwNJV9', branch 'y9mnzt2gwt5E_HMx7UmZwNJV9' of type 'text', mime 'text/html'
Slow 200 GET /api/special-notes/days/2022-12-28 with 301 bytes took 23ms
JS Error: Encountered error Process exceeded time limit 30000: timeLimit@http://127.0.0.1:8081/assets/v0.59.1/app/services/utils.js:293:28
@http://127.0.0.1:8081/assets/v0.59.1/app/services/ws.js:169:34
asyncFunctionResume@[native code]
@http://127.0.0.1:8081/assets/v0.59.1/app/services/ws.js:90:60
asyncFunctionResume@[native code]
@http://127.0.0.1:8081/assets/v0.59.1/app/services/ws.js:114:36
asyncFunctionResume@[native code], reloading frontend.
Stack: logError@http://127.0.0.1:8081/assets/v0.59.1/app/services/ws.js:24:29
@http://127.0.0.1:8081/assets/v0.59.1/app/services/ws.js:172:21
asyncFunctionResume@[native code]
@[native code]
promiseReactionJobWithoutPromise@[native code]
promiseReactionJob@[native code]
200 POST /api/tree/load with 7811 bytes took 1ms

Reproducer:

  1. Delete 2022 & 2023
  2. Create 2023-01-01 from calendar widget
  3. Create 2022-12-28 from calendar widget

Then you will timeout at frocaUpdater.processEntityChanges(nonProcessedEntityChanges). But if you reload the web page, then "2022/W0*/28 - Wednesday" will be displayed normally. BTW, if "2022" has been created already, then it will work fine.

AllanZyne avatar Apr 09 '23 12:04 AllanZyne

I don't need this feature anymore. If someone needs it, glad to let me know.

AllanZyne avatar May 25 '23 07:05 AllanZyne