Created
August 12, 2013 19:09
-
-
Save fractaledmind/6214050 to your computer and use it in GitHub Desktop.
This script inserts a Markdown Inline Link for a VoodooPad page into your current TextMate (or TextEdit) document. You can choose either whatever item is currently selected, or you can navigate your VoodooPad document to insert a URL for any item.
This file contains hidden or 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
| display dialog "Get Link of open page or choose other page?" buttons {"Get Selected", "Choose Other"} default button {"Get Selected"} | |
| --Get Markdown formatted info for selected item | |
| if result = {button returned:"Get Selected"} then | |
| tell application "VoodooPad" | |
| set voodoo_selection to the (current page name) as string | |
| if voodoo_selection is {} then display dialog "Please select something." | |
| set Markdown_link to "" | |
| set voodooID to uuid of page voodoo_selection of document 1 | |
| set ItemURL to "x-voodoopad-item://" & voodooID | |
| set theWikiLink to "[" & voodoo_selection & "]" & "(" & ItemURL & ")" | |
| set Markdown_link to (Markdown_link) & theWikiLink | |
| end tell | |
| tell application "TextMate" | |
| insert (Markdown_link) | |
| end tell | |
| (* If you don't have TextMate, here's the script for the universal Mac program TextEdit. To alter the code, merely delete or comment-out the TextMate tellblock and uncomment this block: | |
| *) | |
| -- tell application "TextEdit" | |
| -- activate | |
| -- make new word at end of text of document 1 with data Markdown_link | |
| -- end tell | |
| else if result = {button returned:"Choose Other"} then | |
| tell application "VoodooPad" | |
| set vp_docs to get name of every document of application "VoodooPad" | |
| set SelDoc to choose from list of vp_docs with title "Select Voodoopad Document" with prompt ¬ | |
| "Current Voodoopad Documents" OK button name "OK" | |
| set theDoc to item 1 of SelDoc | |
| set allPages to get name of every page of document theDoc | |
| set SelPage to choose from list of allPages with title "Select Voodoopad Page" with prompt ¬ | |
| "Current Voodoopad Pages" OK button name "OK" | |
| set thePage to item 1 of SelPage | |
| set Markdown_link to "" | |
| set voodooID to uuid of page thePage of document theDoc | |
| set ItemURL to "x-voodoopad-item://" & voodooID | |
| set theWikiLink to "[" & thePage & "]" & "(" & ItemURL & ")" | |
| set Markdown_link to (Markdown_link) & theWikiLink | |
| end tell | |
| tell application "TextMate" | |
| insert (Markdown_link) | |
| end tell | |
| (* If you don't have TextMate, here's the script for the universal Mac program TextEdit. To alter the code, merely delete or comment-out the TextMate tellblock and uncomment this block: | |
| *) | |
| -- tell application "TextEdit" | |
| -- activate | |
| -- make new word at end of text of document 1 with data Markdown_link | |
| -- end tell | |
| end if |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment