Hi, has anyone found a way to make Hook open up NotePlan’s UI when hooking to a new file?
I don’t think it’s possible to implement a “new item” script with UI scripted apps, unless perhaps the resulting URL is predictable. But normally the third-party app needs to be the one to do the URL. Also Hook assumes that the app can change the document title for some reason, and so Hook can handle that; but the title is not as important. The title would get updated by Hook when user invokes Hook on the new item.
Guess what, I’m still trying to decide on a core note-taking tool! And I’m still trying to constrain my decision to one that might work 100% fine with Hook (I hope I’m not wrong about NotePlan). Although NotePlan is still a single developer app, I’m stunned by its progress in the last two years.
You can try my implementation of hooking to the new note. It also creates a note inside Inbox folder and links this note to the «today» note
set noteText to do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv))\" " & quoted form of "[$title]($user_link)" set noteTitle to do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv))\" " & quoted form of "$title" set newNoteURL to "noteplan://x-callback-url/addNote?noteTitle=" & noteTitle & "&folder=Inbox&openNote=yes&text=" & noteText do shell script "open '" & newNoteURL & "'" delay 0.2 set NoteURL to "" set NoteTitle to "" tell application id "co.noteplan.NotePlan-setapp" if version ≥ "2.4.4" then set link to selectedNoteUrl set title to selectedNoteTitle if link is not missing value then set NoteURL to link set NoteTitle to title end if end if end tell do shell script "open 'noteplan://x-callback-url/addText?noteDate=today&mode=append&openNote=no&text=Hook%20Added%20[[" & NoteTitle & "]]'" return NoteURL
Awesome and thanks a lot, @ctrlok, this depends on one having
python (no longer a safe assumption in recent macOS I believe.) It didn’t work on my computer even if I do have python, but most of it worked marvellously from the Script Editor.
UPDATE: deleted the rest of this post since a newer post presents a better start.
set noteTitle to quoted form of "$encoded_title" set noteText to quoted form of "#hook%20from%20%5B$encoded_title%5D%28$user_link%29%0A" do shell script "open 'noteplan://x-callback-url/addNote?noteTitle=" & noteTitle & "&folder=Hook&openNote=yes&text=" & noteText & "'" delay 0.2 set noteUrl to "" tell application id "co.noteplan.NotePlan-setapp" if version ≥ "2.4.4" then set link to selectedNoteUrl if link is not missing value then set noteUrl to link end if end if end tell set textToAppendToDailyNote to "Hooked%20%5B%5B" & noteTitle & "%5D%5D" do shell script "open 'noteplan://x-callback-url/addText?noteDate=today&mode=append&openNote=no&text=" & textToAppendToDailyNote & "'" return noteUrl
After hooking a few things and summoning Hook to navigate to NotePlan from its bookmarks, some things don’t always seem to work entirely coherently. Sometimes NotePlan seems to fail to open up a hooked note. But it’s a very nice start, for sure!
Here’s my daily note after having Hook create 3 new NotePlan notes:
Here’s one of those notes, showing the backlink on top from the daily note:
And the expanded UI tying this up together:
Works like a charm, thank you!
The only thing I changed was the tell application line and version checking (I use NotePlan3) to this:
tell application id "co.noteplan.NotePlan3" set link to selectedNoteUrl if link is not missing value then set noteUrl to link end if end tell
I am a newbie, but I would really like to do this with NotePlan. Can someone tell me how or what I’m supposed to do with all of that scripting? It would be very helpful I can follow directions well.
Hi, well I feel a bit shy to observe that finally, I ended up not really using it, b/c I felt building a habit of Hooking to New NotePlan notes was dangerous, as the callback URL’s recipe… isn’t robust. Doing a simple move or rename of the note in NotePlan breaks it, and I’m someone who needs to move or rename things “often”. So I resist helping anyone do something that’s not truly robust. I honestly feel the script is… useless.
The next step would be to contact NotePlan’s developer and ask them to implement robustness in their links, or proper scripting support, which I feel would be much better. Pointing them to this page should be a good starting point to help them understand the issue.
thanks, @danieljomphe . For all: exceptions aside ( per Principles That Determine the URL Scheme Returned by
Copy Link for a Given App – Hookmark) Hookmark uses the 3rd party app’s URL scheme, so it’s up to the third party app to ensure robustness of their URLs. Normally, they are perfectly robust. E.g., I have no concern regarding OmniFocus and DEVONthink links.
If one is in doubt regarding a third-party’s app URL scheme, there are typically very solid alternatives to choose from.
Coming back to this (I hope to be working again on the Mac full time soon), I see the integration between Hookmark & NotePlan improved in some areas since the last time I checked it.
Now, it seems that however I rename a note’s title in NotePlan, even if I completely scramble it, Hookmark doesn’t get lost and the link stays robust. I was puzzled as to how that works, since the link NotePlan gave to Hookmark does not contain a permanent ID, but the original title of the note:
I first thought @EduardMe (the app’s author) might have implemented some durable internal index in the app to keep track of a note’s historical renamed titles to know how to redirect properly, but looking into the file storage, I realize the strategy is much simpler: when we change a note’s title, the app doesn’t (anymore?) rename the file on disk:
I’m not sure if I feel okay about this but at least for now, it helps get stabler links. (Filenames might be important to me in the future.)
On the other hand, something that’s still broken is if I don’t just rename a note, but move it inside another folder in NotePlan and summon Hookmark from the moved note, then Hookmark isn’t given the expected note ID and can’t therefore recognize it and show the links it used to show for it before I moved it. I suppose this capitally important use case could only work if the note’s callback URL had been based, from the start, on a permanent ID (e.g.
guid) instead of the note’s path name.
I hope to someday find an app completely and robustly linkable to use, guaranteeing that any link to its documents will never be broken. (Canonicality bears to mind here, I suppose.) An app good enough for my sensibilities. NotePlan might be it if these kinds of things continue to improve.
I went up and asked in NotePlan’s discord forums.
I often read that the developer is very much listening to user feedback.
Let’s hope this issue can see some progress!