1
0
Fork 0
mirror of https://github.com/marty-oehme/scripts.git synced 2024-12-22 07:58:08 +00:00

Merge pull request #21 from kantrol/multiplejournalperday

multiple journals per day
This commit is contained in:
Patrizio Bekerle 2017-12-18 06:27:54 +01:00 committed by GitHub
commit ff0b0bde1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View file

@ -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": "1.1.1", "version": "1.2.0",
"minAppVersion": "17.11.6", "minAppVersion": "17.11.6",
"authors": ["@pbek", "@sanderboom"], "authors": ["@pbek", "@sanderboom", "@kantrol"],
"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."
} }

View file

@ -7,6 +7,7 @@ import com.qownnotes.noteapi 1.0
QtObject { QtObject {
property string defaultFolder; property string defaultFolder;
property string defaultTags; property string defaultTags;
property bool singleJournalPerDay;
property variant settingsVariables: [ property variant settingsVariables: [
{ {
@ -23,13 +24,23 @@ QtObject {
"type": "string", "type": "string",
"default": "journal", "default": "journal",
}, },
{
"identifier": "singleJournalPerDay",
"name": "Single journal per day",
"description": "Creates a single journal per day instead of always adding a new journal.",
"type": "boolean",
"default": "true",
},
]; ];
/** /**
* Initializes the custom action * Initializes the custom action
*/ */
function init() { function init() {
script.registerCustomAction("journalEntry", "Create or open a journal entry", "Journal", "document-new"); if (singleJournalPerDay)
script.registerCustomAction("journalEntry", "Create or open a journal entry", "Journal", "document-new");
else
script.registerCustomAction("journalEntry", "Create a journal entry", "Journal", "document-new");
} }
/** /**
@ -46,6 +57,11 @@ QtObject {
// get the date headline // get the date headline
var m = new Date(); var m = new Date();
var headline = "Journal " + m.getFullYear() + ("0" + (m.getMonth()+1)).slice(-2) + ("0" + m.getDate()).slice(-2); var headline = "Journal " + m.getFullYear() + ("0" + (m.getMonth()+1)).slice(-2) + ("0" + m.getDate()).slice(-2);
// when the configuration option "singleJournalPerDay" is selected create journal entries including time
if (!singleJournalPerDay) {
headline = headline + "T"+ ("0" + m.getHours()).slice(-2) + ("0" + m.getMinutes()).slice(-2) + ("0" + m.getSeconds()).slice(-2)
}
var fileName = headline + ".md"; var fileName = headline + ".md";