Created
May 6, 2018 17:19
-
-
Save gunderwonder/72f12ec25828c812b04b8e961bee73ba to your computer and use it in GitHub Desktop.
Creates a named DEVONthink group, a Bear note and Things project, linked together
This file contains 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 characters
on run {input, parameters} | |
set theProjectTitle to input as string | |
tell application id "com.devon-technologies.thinkpro2" | |
set theParentID to "66603FF9-03FE-4AE8-86AE-9621AA22FCA7" | |
set theGroup to get record with uuid theParentID | |
set theProjectGroup to create record with {name:theProjectTitle, type:group} in theGroup | |
set theProjectGroupID to the uuid of theProjectGroup | |
set theProjectGroupURL to "x-devonthink-item://" & theProjectGroupID | |
set theQuotedProjectName to do shell script "/bin/echo " & quoted form of theProjectTitle & ¬ | |
" | perl -MURI::Escape -lne 'print uri_escape($_)'" | |
set theBearIdentifier to do shell script "/Applications/xcall.app/Contents/MacOS/xcall -url 'bear://x-callback-url/create?title=" & theQuotedProjectName & "' -activateApp NO | /usr/local/bin/jq -r '.identifier'" | |
set theBearURL to "bear://x-callback-url/open-note?id=" & theBearIdentifier | |
set theBearRecord to create record with {name:"Notater", type:bookmark, URL:theBearURL} in theProjectGroup | |
set theThingsNote to theProjectGroupURL & " | |
" & theBearURL | |
tell application "Things3" | |
set theThingsProject to make new project with properties {name:theProjectTitle, notes:theThingsNote} | |
set theThingsProjectURL to "things://x-callback-url/show?id=" & the id of theThingsProject | |
end tell | |
set theThingsRecord to create record with {name:"Todo", type:bookmark, URL:theThingsProjectURL} in theProjectGroup | |
set theBearNote to "## Lenker | |
- " & theProjectGroupURL & " | |
- " & theThingsProjectURL & " | |
#master" | |
set theEscapedBearNote to do shell script "/bin/echo " & quoted form of theBearNote & ¬ | |
" | perl -MURI::Escape -wlne 'print uri_escape($_)'" | |
set AppleScript's text item delimiters to {return & linefeed, return, linefeed, character id 8233, character id 8232} | |
set theNewEscapedBearNote to text items of theEscapedBearNote | |
set AppleScript's text item delimiters to {"%0A"} | |
set theNewEscapedBearNote to theNewEscapedBearNote as text | |
set a to do shell script "/Applications/xcall.app/Contents/MacOS/xcall -url 'bear://x-callback-url/add-text?id=" & theBearIdentifier & "&mode=append&text=" & theNewEscapedBearNote & "' -activateApp NO" | |
end tell | |
return a | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment