Initial commit
This commit is contained in:
16
.trash/Template/scripts/daily_note_tasks_query_builder.js
Normal file
16
.trash/Template/scripts/daily_note_tasks_query_builder.js
Normal file
@@ -0,0 +1,16 @@
|
||||
function daily_note_tasks_query_builder(tp) {
|
||||
// 1. Parse the file title using the custom format YYYY.MM.DD.dd
|
||||
const date = moment(tp.file.title, "YYYY.MM.DD.dd").format("YYYY-MM-DD");
|
||||
|
||||
// 2. Construct the full query string using the static date
|
||||
const query =
|
||||
`
|
||||
((not done) OR (done on ${date}))
|
||||
(((has start date) AND (starts on or before ${date})) OR (scheduled on or before ${date}) OR (due on or before ${date}))
|
||||
short mode
|
||||
`;
|
||||
|
||||
// 3. Wrap the query in the necessary ```tasks block and return it
|
||||
return "```tasks" + query + "```";
|
||||
}
|
||||
module.exports = daily_note_tasks_query_builder;
|
||||
38
.trash/Template/scripts/update_front_matter_and_log.js
Normal file
38
.trash/Template/scripts/update_front_matter_and_log.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// NOTE: We change the function arguments back to accept the Templater object (tp)
|
||||
// This is required when running the script directly via a Templater hotkey.
|
||||
async function update_front_matter_and_log(tp) {
|
||||
// 1. Define timestamps (using the reliable tp.date.now)
|
||||
const timestamp = tp.date.now("YYYY-MM-DDTHH:mm:ssZ");
|
||||
|
||||
// Get the current file object
|
||||
const file = app.workspace.getActiveFile();
|
||||
if (!file) {
|
||||
// Must throw an error here, otherwise Templater might insert 'undefined' text.
|
||||
throw new Error("No active file is open to update.");
|
||||
}
|
||||
|
||||
// 2. Update Frontmatter Property ('updated')
|
||||
await app.fileManager.processFrontMatter(file, (frontmatter) => {
|
||||
frontmatter['updated'] = timestamp;
|
||||
});
|
||||
|
||||
// 3. Prepare the Log Entry Text
|
||||
const logEntry = `\n- ${timestamp}: `;
|
||||
|
||||
// 4. Append the text to the bottom of the note body
|
||||
// Using app.vault.modify is the safest way to append text at the end of a file.
|
||||
await app.vault.append(file, logEntry);
|
||||
|
||||
// 5. Place the cursor at the end of the newly inserted text
|
||||
// This allows the user to immediately type the revision summary.
|
||||
|
||||
// Get the current editor object
|
||||
const editor = app.workspace.activeEditor.editor;
|
||||
|
||||
// Move cursor to the end of the file/newly added text (simulating an insertion)
|
||||
editor.setCursor(editor.lastLine() + 1);
|
||||
|
||||
// TEMPLATER RULE: Return an empty string so nothing else gets inserted by Templater
|
||||
return "";
|
||||
}
|
||||
module.exports = update_front_matter_and_log;
|
||||
Reference in New Issue
Block a user