Action
Send to Day One (via cli)
Posted by alastair,
Last update
over 1 year ago
- Unlisted
UPDATES
over 1 year ago
Added comments
over 1 year ago
Added comments
over 1 year ago
Use Template Tags to customize default journal and tag. Also other sugestions from @ditfantate, thanks!
over 1 year ago
Fixed previous update
over 1 year ago
Added journal arg to specify a specific journal.
over 1 year ago
Removed visibility on iOS
over 1 year ago
Now opens the new entry in Day One
Uses the dayone2 command line utility to send the current note - and metadata - to a new entry in Day One
Steps
-
defineTemplateTag
name dayone-journal
template -
defineTemplateTag
name dayone-uuid
template -
defineTemplateTag
name dayone-tag
template drafts
-
script (macOS only)
// retrieve the desired journal let journal = draft.getTemplateTag('dayone-journal') let journalarg = journal? `--journal "${journal}"` : "" // write out the draft to a temp file let filePath = `/${draft.uuid}.txt` let fmLocal = FileManager.createLocal(); if (!fmLocal.writeString(filePath, draft.content)) { throw new Error(`could not write, ${fmLocal.lastError}`); } // dayone doesn't like milliseconds, strip them let dt = draft.createdAt.toISOString().replace(/\.\d+Z$/, "Z"); // add tags from draft plus dayone-tag (default "drafts") let tags = [draft.getTemplateTag("dayone-tag")].concat(draft.tags); let script = `#!/bin/bash -eu /usr/local/bin/dayone2 \ ${journalarg} \ --isoDate=${dt} \ --coordinate ${draft.createdLatitude} ${draft.createdLongitude} \ --tags ${tags.join(" ")} -- \ new <${fmLocal.basePath}${filePath}` let runner = ShellScript.create(script); if (!runner.execute()) { throw new Error(`stdout:${runner.standardOutput}\nstderr:${runner.standardError}`) } // extract the UUID and save into the dayone-uuid template tag - this can be used by subsequent steps if desired let d1uuid = runner.standardOutput.match(/[0-9a-fA-F]{32}/) if (d1uuid.length) { draft.setTemplateTag('dayone-uuid', d1uuid[0]); app.openURL(`dayone://view?entryId=${d1uuid[0]}`); }
Options
-
After Success Ask Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.