diff --git a/.gitignore b/.gitignore index eb5a316..c5dd462 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ target +.env diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..5d0a70b --- /dev/null +++ b/TODO.txt @@ -0,0 +1,2 @@ +- handle URL fields in ical files +- handle escape codes in ical files diff --git a/notes/!!!meta.json b/notes/!!!meta.json index 863f4dc..ca33f07 100644 --- a/notes/!!!meta.json +++ b/notes/!!!meta.json @@ -1,6 +1,6 @@ { "formatVersion": 1, - "appVersion": "0.46.9", + "appVersion": "0.47.2", "files": [ { "isClone": false, @@ -378,6 +378,30 @@ } ] }, + { + "isClone": false, + "noteId": "Q7KqwQ1693Bj", + "notePath": [ + "vP5DkrdHVvv0", + "Q7KqwQ1693Bj" + ], + "title": "duplicate into next week button", + "notePosition": 81, + "prefix": null, + "isExpanded": 0, + "type": "code", + "mime": "application/javascript;env=frontend", + "attributes": [ + { + "type": "label", + "name": "run", + "value": "frontendStartup", + "isInheritable": false, + "position": 10 + } + ], + "dataFileName": "duplicate into next week button.js" + }, { "isClone": false, "noteId": "X5pzYZriILAz", diff --git a/notes/Implementation/duplicate into next week button.js b/notes/Implementation/duplicate into next week button.js new file mode 100644 index 0000000..b9ac60f --- /dev/null +++ b/notes/Implementation/duplicate into next week button.js @@ -0,0 +1,30 @@ +api.addButtonToToolbar({ + title: 'Duplicate into next week', + icon: 'right-arrow-alt', + action: async () => { + await api.runOnBackend(async (noteId) => { +const note = await api.getNote(noteId); +const targetTemplate = await note.getRelation('template').value; +const startTime = await note.getLabelValue('startTime'); +const location = await note.getLabelValue('location'); +const date = new Date(startTime); +date.setTime(date.getTime() + (7*24*60*60*1000)); + +const todayDateStr = date.toISOString().substr(0,10); +const todayNote = await api.getDateNote(todayDateStr); +const newTime = todayDateStr + "T" + date.getHours().toString().padStart(2, '0') + ":" + date.getMinutes().toString().padStart(2, '0') + ":" + date.getSeconds().toString().padStart(2, '0'); + +const resp = await api.createNewNote({ + parentNoteId: todayNote.noteId, + title: note.title, + content: '', + type: 'text' +}); +await resp.note.setAttribute("relation", "template", targetTemplate); +await resp.note.setAttribute("label", "startTime", newTime); +if (location) { + await resp.note.setAttribute("label", "location", location); +} +}, [api.getActiveTabNote().noteId]); + } +}); \ No newline at end of file diff --git a/notes/Implementation/new_event handler.js b/notes/Implementation/new_event handler.js index 80c9901..98e1abe 100644 --- a/notes/Implementation/new_event handler.js +++ b/notes/Implementation/new_event handler.js @@ -7,6 +7,7 @@ const {req, res} = api; const uid = req.body["uid"]; const name = req.body["name"]; const summary = req.body["summary"]; +const summaryHtml = req.body["summaryHtml"]; const location = req.body["location"]; const fileName = req.body["fileName"]; const fileData = req.body["fileData"]; @@ -31,8 +32,9 @@ const targetTemplate = await api.currentNote.getRelationValue('targetTemplate'); const options = { "parentNoteId": dayNote.noteId, "title": name, - "content": summary, - "type": "text" + "content": summaryHtml != "" ? summaryHtml : summary, + "type": "text", + "mime": summaryHtml != "" ? "text/html" : "text/plain" }; const resp = await api.createNewNote(options); const note = resp.note; diff --git a/notes/navigation.html b/notes/navigation.html index f5a878e..e268fb7 100644 --- a/notes/navigation.html +++ b/notes/navigation.html @@ -35,6 +35,8 @@ +
  • duplicate into next week button +
  • event template
  • new_event handler diff --git a/src/main.rs b/src/main.rs index 57d0ded..249ca31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,8 @@ async fn process_one(update: Update, context: &mut Context) -> Result<(), Error> if CLIENT.get(&trilium_url("/custom/new_event")).form(&json!({ "uid": calendar.events[0].uid, "name": calendar.events[0].summary, - "summary": calendar.events[0].description_html.as_deref().unwrap_or(&calendar.events[0].description), + "summary": calendar.events[0].description, + "summaryHtml": calendar.events[0].description_html.as_deref().unwrap_or_default(), "fileName": document.file_name, "fileData": text, "location": calendar.events[0].location,