├── .gitignore ├── README.md ├── Support.applescript ├── Support.scpt ├── icon.key └── .dropbox.attr └── icon.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.jpg 3 | 4 | icon.key/Contents/PkgInfo 5 | 6 | *.plist 7 | 8 | *.gz 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Support.scpt 2 | ## by Chris Sauvé of [pxldot](http://pxldot.com) 3 | 4 | 5 | ## Description 6 | This script gives you the ability to set a "support" folder in a project's notes, and will automatically open this folder in Finder (or PathFinder, if running) when you run the script. You can either set the folder path manually (not recommended; if you want to, make sure you are using the POSIX path of the desired folder), or allow the script to prompt you to select the folder (which happens automatically if you have a folder that does not already have a support folder declared in the project notes). Projects can be selected by selecting the project itself in the content area/ sidebar, or by selecting any of the project's tasks. 7 | 8 | 9 | ## Runtime Options 10 | - The script will ask you what string you would like to use to denote the folder path: either `@support`, `@folder` or `@reference` (default is `@support`) 11 | 12 | 13 | ## Compile-Time Options 14 | - By default, the script will look only at the first project you have selected (and thus, will only open this project's support folder). You can change this by changing the `defaultToFirstProject` property of the script to `false`. 15 | 16 | 17 | ## Installation 18 | Download the most recent version of the script. Once you have downloaded the script, navigate to your Application script folder located at `~/Library/Scripts/Applications/OmniFocus`. Apple hides the Library folder in Mac OS X 10.7 or later by default, so the easiest way to get to this folder is to select the menu item `Go > Go To Folder...` in Finder.app. You may have to manually create an OmniFocus folder in the `~/Library/Scripts/Applications` directory if you do not have any previous scripts for OmniFocus (you may have to create more of the folders in the directory; if you don't have an Applications folder or even a Scripts folder, you will have to create those as well). 19 | 20 | 21 | ## Using The Script 22 | There are countless ways you can run the script. If you are a pro user, you likely know even more ways than I do: options like launching the script from FastScripts, Alfred, LaunchBar, or a Keyboard Maestro macro are all available to you. Below I'll explain two ways to run the script, primarily targetted at more novice users. 23 | 24 | Your first option is to run the script from Apple's AppleScript menu. If you don't have a little script icon near the clock in your Mac's menubar, you need to turn this on manually. Open AppleScript Editor.app from your `Applications > Utilities` folder. Go to AppleScript's preferences by selecting `AppleScript Editor > Preferences...` from the menubar. On the "General" pane, you should check the checkbox to "Show Script menu in menu bar". Now, when in OmniFocus, select the new script menubar item and you will see the script at the bottom of the list, ready to be clicked and run. 25 | 26 | OmniFocus has another way to run scripts, and it's even easier than the method described above. Once the script is installed, go to OmniFocus and right- (control-) click on the toolbar (the gray bar at the top of the window that shows icons for your inbox, projects, and more). Choose "Customize Toolbar..." from the contextual menu that pops up. You will then see a list of all items that can be put in your menubar, including (at the bottom) any scripts that you have installed. Drag the script anywhere on the toolbar and click "Done". You now have one-click access to run this script! 27 | 28 | 29 | ## Version History 30 | - **0.1.0** (April 2, 2013): Initial release. 31 | 32 | 33 | ## License 34 | Use it, change it, repackage it, whatever. Try not to take credit for my work. -------------------------------------------------------------------------------- /Support.applescript: -------------------------------------------------------------------------------- 1 | (* 2 | SUPPORT.SCPT 3 | Developed by Chris Sauve of [pxldot](http://pxldot.com). 4 | See README for details. 5 | *) 6 | 7 | property folderDelim : "@support" 8 | property firstRun : true 9 | property defaultToFirstProject : true 10 | property debug : false 11 | 12 | if firstRun and not debug then 13 | try 14 | set folderDelim to item 1 of (choose from list {"@support", "@reference", "@folder"} with prompt "Which syntax would you like to denote reference folders in the project notes?") 15 | set firstRun to false 16 | on error 17 | return 18 | end try 19 | end if 20 | 21 | tell application "OmniFocus" 22 | tell front document window of default document 23 | try 24 | set theSelection to value of selected trees of content 25 | if length of theSelection is 0 then set theSelection to value of selected trees of sidebar 26 | if ((count of theSelection) is 0) then 27 | display alert "Please select at least one project or task." 28 | return 29 | end if 30 | set theProjects to {} 31 | repeat with theItem in theSelection 32 | if (class of theSelection is project) and (not my inList(theItem, theProjects)) then 33 | set the end of theProjects to theItem 34 | else if not my inList(containing project of theItem, theProjects) then 35 | set the end of theProjects to (containing project of theItem) 36 | end if 37 | end repeat 38 | on error 39 | display alert "Please select at least one project or task." 40 | return 41 | end try 42 | 43 | if (length of theProjects > 1) and (not defaultToFirstProject) then 44 | set projectNames to my getNames(theProjects) 45 | set selectedProjectNames to (choose from list projectNames with prompt "Which project(s) would you like to open/ create a project folder for?" with multiple selections allowed) 46 | if selectedProjectNames is false then return 47 | if length of selectedProjectNames is 0 then 48 | return 49 | end if 50 | set selectedProjects to my assessList(selectedProjectNames, projectNames, theProjects) 51 | else 52 | set selectedProjects to item 1 of theProjects 53 | end if 54 | 55 | set thePaths to {} 56 | repeat with theProject in selectedProjects 57 | if (note of theProject contains folderDelim) then 58 | set the end of thePaths to my identifyFolder(note of theProject) 59 | else 60 | try 61 | set chosenFolder to (choose folder with prompt "Select the folder that contains the reference material for the project " & quote & (name of theProject) & quote & ".") as string 62 | set chosenFolder to my removeHomeFolder(chosenFolder) 63 | on error 64 | return 65 | end try 66 | if the note of theProject is "" then 67 | set the note of theProject to (folderDelim & " " & chosenFolder) 68 | else 69 | set the note of theProject to (the note of theProject & return & folderDelim & " " & chosenFolder) 70 | end if 71 | return 72 | end if 73 | end repeat 74 | 75 | 76 | tell application id "com.apple.finder" 77 | repeat with aFolder in thePaths 78 | open folder aFolder 79 | end repeat 80 | activate 81 | end tell 82 | 83 | end tell 84 | end tell 85 | 86 | on removeHomeFolder(chosenFolder) 87 | set text item delimiters to (path to home folder as text) 88 | set chosenFolder to every text item of chosenFolder 89 | set text item delimiters to "" 90 | return chosenFolder as string 91 | end removeHomeFolder 92 | 93 | on inList(theItem, theList) 94 | if length of theList is 0 then return false 95 | repeat with anItem in theList 96 | if id of anItem is id of theItem then return true 97 | end repeat 98 | return false 99 | end inList 100 | 101 | on getNames(theList) 102 | tell application "OmniFocus" 103 | tell default document 104 | set theReturn to {} 105 | repeat with theItem in theList 106 | set the end of theReturn to name of theItem 107 | end repeat 108 | return theReturn 109 | end tell 110 | end tell 111 | end getNames 112 | 113 | on assessList(theSelection, theList, theOriginals) 114 | set theReturn to {} 115 | repeat with j from 1 to (length of theSelection) 116 | repeat with i from 1 to (length of theList) 117 | if (item j of theSelection) is (item i of theList) then 118 | set the end of theReturn to item i of theOriginals 119 | exit repeat 120 | end if 121 | end repeat 122 | end repeat 123 | return theReturn 124 | end assessList 125 | 126 | on identifyFolder(theNote) 127 | set paras to every paragraph of theNote 128 | repeat with para in paras 129 | if para starts with folderDelim then 130 | set theText to para 131 | exit repeat 132 | end if 133 | end repeat 134 | set text item delimiters to {folderDelim & " ", folderDelim} 135 | set theText to every text item of theText 136 | set text item delimiters to "" 137 | set theText to (path to home folder as text) & (theText as text) 138 | end identifyFolder -------------------------------------------------------------------------------- /Support.scpt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lemonmade/support/26d95636e94412156ea488ecc718cc000d88e23a/Support.scpt -------------------------------------------------------------------------------- /icon.key/.dropbox.attr: -------------------------------------------------------------------------------- 1 | {"mac": {"com.apple.FinderInfo": {"data": "QUFBQUFBQUFBQUFnRUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQT0="}}} -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lemonmade/support/26d95636e94412156ea488ecc718cc000d88e23a/icon.png --------------------------------------------------------------------------------