mirror of
https://github.com/marty-oehme/scripts.git
synced 2024-12-22 16:08:09 +00:00
Merge pull request #14 from sanderboom/autotagging
Add auto-tagging option to journal-entry script.
This commit is contained in:
commit
dd17fd729e
2 changed files with 27 additions and 4 deletions
|
@ -2,8 +2,8 @@
|
||||||
"name": "Journal entry",
|
"name": "Journal entry",
|
||||||
"identifier": "journal-entry",
|
"identifier": "journal-entry",
|
||||||
"script": "journal-entry.qml",
|
"script": "journal-entry.qml",
|
||||||
"version": "0.0.2",
|
"version": "1.0.0",
|
||||||
"minAppVersion": "17.05.6",
|
"minAppVersion": "17.05.6",
|
||||||
"authors": ["@pbek"],
|
"authors": ["@pbek", "@sanderboom"],
|
||||||
"description" : "This script creates a menu item and a button to create or jump to the current date's journal entry."
|
"description" : "This script creates a menu item and a button to create or jump to the current date's journal entry."
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,18 @@ import com.qownnotes.noteapi 1.0
|
||||||
* This script creates a menu item and a button to create or jump to the current date's journal entry
|
* This script creates a menu item and a button to create or jump to the current date's journal entry
|
||||||
*/
|
*/
|
||||||
QtObject {
|
QtObject {
|
||||||
|
property string defaultTags;
|
||||||
|
|
||||||
|
property variant settingsVariables: [
|
||||||
|
{
|
||||||
|
"identifier": "defaultTags",
|
||||||
|
"name": "Auto-tagging",
|
||||||
|
"description": "One or more default tags (separated by commas) to assign to a newly created journal note. Leave blank to disable auto-tagging.",
|
||||||
|
"type": "string",
|
||||||
|
"default": "journal",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the custom action
|
* Initializes the custom action
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +52,17 @@ QtObject {
|
||||||
// keep in mind that the note will not be created instantly on the disk
|
// keep in mind that the note will not be created instantly on the disk
|
||||||
script.log("creating new journal entry: " + headline);
|
script.log("creating new journal entry: " + headline);
|
||||||
script.createNote(headline + "\n================\n\n");
|
script.createNote(headline + "\n================\n\n");
|
||||||
|
|
||||||
|
// Auto-tagging.
|
||||||
|
if (defaultTags && defaultTags !== '') {
|
||||||
|
defaultTags
|
||||||
|
// Split on 0..* ws, 1..* commas, 0..* ws.
|
||||||
|
.split(/\s*,+\s*/)
|
||||||
|
.forEach(function(i) {
|
||||||
|
script.log('Auto-tag new journal entry with: ' + i);
|
||||||
|
script.tagCurrentNote(i);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue