Last active
August 29, 2023 06:16
-
-
Save heroheman/1fb19d6fd9ea05a848ecf1fa89ffb8fe to your computer and use it in GitHub Desktop.
Revisions
-
heroheman revised this gist
Jun 7, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # Add task metadata to current task - Obsidian Templater Script This script asks the user which type of metadata they want to insert, then prompts them for the appropriate input based on their choice. It handles all the types of metadata mentioned [here](https://publish.obsidian.md/tasks/Reference/Task+Formats/About+Task+Formats) -
heroheman revised this gist
Jun 7, 2023 . 2 changed files with 21 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ <%* const format = 'blub'; // default format // let metadataType = await tp.system.prompt('Enter the type of metadata (Priority, Repeat, Start, Scheduled, Due, Created, Completion)'); const metadataTypes = ['priority', 'repeat', 'start', 'scheduled', 'due', 'created', 'completion']; const priorityTypes = ['highest', 'high', 'medium', 'low', 'due', 'lowest']; @@ -56,27 +57,27 @@ if (format == 'emoji') { switch (metadataType.toLowerCase()) { case 'start': metadata = `π« ${dateValue} `; break; case 'scheduled': metadata = `β³ ${dateValue} `; break; case 'due': metadata = `π ${dateValue} `; break; case 'created': metadata = `β ${dateValue} `; break; case 'completion': metadata = `β ${dateValue} `; break; } } else { metadata = `[${metadataType}:: ${dateValue}] `; } break; default: metadata = ' β οΈ Invalid input '; } tR += metadata + ' '; -%> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,5 +22,17 @@ and appends the corresponding tag to the current line of the document. It defaults to the [Emoji Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format). You can change the `format` variable in the beginning to something else to use the [DataView Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Dataview+Format) ... and yes, this should be a boolean. Don't @mention me. π€·ββοΈ ## Screenshots      #obsidian #obsidian-md #obsidian-templater #templater #templater-script #tasks #obsidian-task -
heroheman revised this gist
Jun 7, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ and appends the corresponding tag to the current line of the document. - everything date related, you have several options - add a YYYY-MM-DD format - leave empty - defaults to today - write: `tomorrow`, `today` or `in [N] days`, where n stands for the amount of days in the future - In your documents, preferable in with the cursor in a task, press CMD+e (or whatever you call to call the templater template modal) and select the script. -
heroheman revised this gist
Jun 7, 2023 . 2 changed files with 25 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,12 +3,21 @@ then prompts them for the appropriate input based on their choice. It handles all the types of metadata mentioned [here](https://publish.obsidian.md/tasks/Reference/Task+Formats/About+Task+Formats) and appends the corresponding tag to the current line of the document. ## Installation - You will need the [Templater Plugin](https://github.com/SilentVoid13/Templater) - Add file to your Templates Folder where Templater is looking for your Templates. - In your documents, preferable in with the cursor in a task, press CMD+e (or whatever you call to call the templater template modal) and select the script. ## Usage - It first asks for what you want to add - Priority lets you choose a priority - everything date related, you have several options - add a YYYY-MM-DD format - leave empty - defaults to today - write: `tomorrow`, `today` or `in *n* days`, where n stands for the amount of days in the future - In your documents, preferable in with the cursor in a task, press CMD+e (or whatever you call to call the templater template modal) and select the script. ## Options It defaults to the [Emoji Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format). You can change the `format` variable in the beginning to something else to use the [DataView Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Dataview+Format) ... and yes, this should be a boolean. Don't @mention me. π€·ββοΈ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,9 +39,22 @@ case 'due': case 'created': case 'completion': // let dateValue = await tp.system.prompt(`Enter your date for ${metadataType}`); let dateValue = await tp.system.prompt(`Enter your date for ${metadataType}. You can also write 'today', 'tomorrow' or 'in n days'. Leave empty for today`); if (dateValue === '') { dateValue = tp.date.now('YYYY-MM-DD'); // use today's date if input is empty } else if (dateValue.toLowerCase() === 'today') { dateValue = tp.date.now('YYYY-MM-DD'); // use today's date if input is "today" } else if (dateValue.toLowerCase() === 'tomorrow') { dateValue = tp.date.now('YYYY-MM-DD', 1); // use tomorrow's date if input is "tomorrow" } else if (dateValue.toLowerCase().startsWith('in ') && dateValue.toLowerCase().endsWith(' days')) { let days = Number(dateValue.split(' ')[1]); if (!isNaN(days)) { dateValue = tp.date.now('YYYY-MM-DD', days); // use the date in X days if input is "in X days" } } if (format == 'emoji') { switch (metadataType.toLowerCase()) { case 'start': metadata = `π« ${dateValue}`; break; -
heroheman revised this gist
Jun 7, 2023 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,3 +13,5 @@ and appends the corresponding tag to the current line of the document. It defaults to the [Emoji Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format). You can change the `format` variable in the beginning to something else to use the [DataView Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Dataview+Format) ... and yes, this should be a boolean. Don't @mention me. π€·ββοΈ #obsidian #obsidian-md #obsidian-templater #templater #templater-script #tasks #obsidian-task -
heroheman revised this gist
Jun 7, 2023 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,3 +9,7 @@ and appends the corresponding tag to the current line of the document. - Add file to your Templates Folder where Templater is looking for your Templates. - In your documents, preferable in with the cursor in a task, press CMD+e (or whatever you call to call the templater template modal) and select the script. ## Options It defaults to the [Emoji Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format). You can change the `format` variable in the beginning to something else to use the [DataView Format](https://publish.obsidian.md/tasks/Reference/Task+Formats/Dataview+Format) ... and yes, this should be a boolean. Don't @mention me. π€·ββοΈ -
heroheman created this gist
Jun 7, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ This script asks the user which type of metadata they want to insert, then prompts them for the appropriate input based on their choice. It handles all the types of metadata mentioned [here](https://publish.obsidian.md/tasks/Reference/Task+Formats/About+Task+Formats) and appends the corresponding tag to the current line of the document. ## Installation - You will need the [Templater Plugin](https://github.com/SilentVoid13/Templater) - Add file to your Templates Folder where Templater is looking for your Templates. - In your documents, preferable in with the cursor in a task, press CMD+e (or whatever you call to call the templater template modal) and select the script. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ <%* const format = 'emoji'; // default format const metadataTypes = ['priority', 'repeat', 'start', 'scheduled', 'due', 'created', 'completion']; const priorityTypes = ['highest', 'high', 'medium', 'low', 'due', 'lowest']; const metadataType = await tp.system.suggester(metadataTypes, metadataTypes, true, 'Select the type of metadata'); let metadata; switch (metadataType.toLowerCase()) { case 'priority': let priorityValue = await tp.system.suggester(priorityTypes, priorityTypes, true, 'Enter your priority'); switch (priorityValue) { case 'highest': metadata = format == 'emoji' ? 'πΊ' : '[priority:: highest]'; break; case 'high': metadata = format == 'emoji' ? 'β«' : '[priority:: high]'; break; case 'medium': metadata = format == 'emoji' ? 'πΌ' : '[priority:: medium]'; break; case 'low': metadata = format == 'emoji' ? 'π½' : '[priority:: low]'; break; case 'lowest': metadata = format == 'emoji' ? 'β¬' : '[priority:: lowest]'; break; default: metadata = 'Invalid input'; } break; case 'repeat': let repeatValue = await tp.system.prompt('Enter your repeat frequency'); metadata = format == 'emoji' ? `π ${repeatValue}` : `[repeat:: ${repeatValue}]`; break; case 'start': case 'scheduled': case 'due': case 'created': case 'completion': let dateValue = await tp.system.prompt(`Enter your date for ${metadataType}`); if (format == 'emoji') { switch (metadataType) { case 'start': metadata = `π« ${dateValue}`; break; case 'scheduled': metadata = `β³ ${dateValue}`; break; case 'due': metadata = `π ${dateValue}`; break; case 'created': metadata = `β ${dateValue}`; break; case 'completion': metadata = `β ${dateValue}`; break; } } else { metadata = `[${metadataType}:: ${dateValue}]`; } break; default: metadata = 'Invalid input'; } tR += metadata + ' '; -%>