I was wondering if you can help setup a hookmark script so that Spaces. app can be onboarded to our list.
I see that in Spaces, there is a “Copy Link to Note” option, either when you directly right click a note (in the notes list), or through the “Note” menu option in the menubar while the note is active.
Please point out some resources to AppleScript that can help me learn how to build this (so I can contribute if I can). It would be great if you could comment your script to explain what’s happening in it.
Here is the script you can try on your mac. To integrate Spaces to Hookmark, go to Hookmark Preferences window → Scripts ->Click on “+” button, Find Spaces and add it. Copy the following script and paste it Get Address script editor for Spaces, click on Save button.
Please let us know how it goes.
Thank you
Get Address Script
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
on urlDecode(input)
tell current application's NSString to set urlString to stringWithString_(input)
set theDecodedURL to urlString's stringByRemovingPercentEncoding -- 4 is NSUTF8StringEncoding
return theDecodedURL as Unicode text
end urlDecode
set theURL to path to application id "app.marvey.spaces"
set appBundle to current application's NSBundle's bundleWithURL:theURL
set shortVersionString to (appBundle's objectForInfoDictionaryKey:"CFBundleShortVersionString") as string
set langStr to ""
try
set resultText to (do shell script "defaults read app.marvey.spaces AppleLanguages")
set langIDs to {}
set {TID, text item delimiters} to {text item delimiters, quote}
set resultItems to text items of resultText
text item 1 of resultText
set text item delimiters to TID
repeat with i from 1 to (count resultItems)
if i mod 2 = 0 then set end of langIDs to resultItems's item i
end repeat
set langStr to first item of langIDs
end try
if langStr is missing value or langStr is "" then
set langStr to first item of (current application's NSLocale's preferredLanguages as list)
end if
set langID to text 1 thru -4 of langStr
set copyLink to "Copy Link to Note"
set copyTitle to "Copy Title"
set noteMenu to "Note"
if langID = "zh-Hans" then
set copyLink to "复制链接到注释"
set copyTitle to "复制标题"
set noteMenu to "注意"
else if langID = "de" then
set copyLink to "Link in Notiz kopieren"
set copyTitle to "Titel kopieren"
set noteMenu to "Notiz"
else if langID = "fr" then
set copyTitle to "Copier le titre"
set copyLink to "Copier le lien vers la note"
set noteMenu to "Noter"
end if
delay 0.1
set the clipboard to ""
delay 0.1
set theURL to ""
set theTitle to ""
tell application "System Events" to tell process "Spaces"
click menu item copyLink of menu noteMenu of menu bar 1
delay 0.05
repeat 50 times -- poll clipboard for ~2.5 seconds
try
if (the clipboard) is not equal to "" then
set theURL to the clipboard
exit repeat
end if
end try
delay 0.05
end repeat
set the clipboard to ""
delay 0.03
click menu item copyTitle of menu noteMenu of menu bar 1
delay 0.05
repeat 50 times -- poll clipboard for ~2.5 seconds
try
if (the clipboard) is not equal to "" then
set theTitle to the clipboard
exit repeat
end if
end try
delay 0.05
end repeat
end tell
return "[" & theTitle & "](" & theURL & ")"
Thanks a lot for the quick response on this request!
The script works well for notes with a title no longer than 2 words. Titles with 3 or more words show up as a mangled string with % in between the words, and becomes less intelligible.
So I could restrict my note titles to two words, or let me know if there’s a workaround for this.
I have pasted the contents of the file. I’m new to Spaces myself, so I don’t see a better way to share the note itself.
# ISO27001 and ISO27002
#Notes/Index
@Issues/Hookmark
The _ISO27001_ standard provides requirements to secure organizational processes, in tandem with the _ISO27002_ standard, which provides detailed controls to achieve those requirements.
As of today (June 2023), ISO27001 has had an update in the form of ISO27001:2022. However, ISO27001:2013 is still in vogue, and will remain so for an year or two. Both are similar to a certain degree, and so we have:
* [[ISO27001:2013]]
* [[ISO27001:2022]]
* [[Differences: ISO27001:2013 & ISO27001:2022]]
Similarly, for ISO27002:
* [[ISO27002:2013]]
* [[ISO27002:2022]]
* [[Differences: ISO27002:2013 & ISO27002:2022]]
Actually, I deleted my existing note, and pasted these contents. Then it somehow corrected itself
I create a new note with your note content and it seems OK.
I am not sure it is Spaces’s problem or not. Next time when this happens, could you please do
(1)Spaces- >Note->Copy Title
(2)Spaces ->Note->Copy Link to Note