Created
March 14, 2011 01:19
-
-
Save parente/868626 to your computer and use it in GitHub Desktop.
Public todo list from a folder in OmniFocus
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
| #!/usr/bin/python | |
| import subprocess | |
| from BeautifulSoup import * | |
| fn = '/Users/parente/todo.html' | |
| title = "Pete's Public Todo List" | |
| subprocess.call(['osascript','todo.scpt']) | |
| f = file(fn) | |
| b = BeautifulSoup(f.read()) | |
| f.close() | |
| b.body.insert(0, '<h1>%s</h1>' % title) | |
| b.title.setString(title) | |
| s = b.prettify() | |
| f = file(fn, 'w') | |
| f.write(s) | |
| f.close() |
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
| tell application "OmniFocus" | |
| tell default document | |
| set aFolder to folder named "IBM Projects" | |
| end tell | |
| end tell | |
| OFSelectAny(aFolder) | |
| tell application "OmniFocus" to tell default document | |
| save in "/Users/parente/todo.html" as "HTML" | |
| end tell | |
| (* | |
| OFSelectAny(), code to select items in OmniFocus. | |
| By David Amis, version 4/8/2009 | |
| Using OFSelectAny() | |
| Used to select just about anything in the front window. | |
| Currenty only tested in planning mode. | |
| Pass any of the following to OFSelectAny(): | |
| Sidebar items: | |
| sidebar | |
| inbox | |
| library | |
| quick entry tree (not tested) | |
| section (not tested) | |
| folder | |
| project | |
| Content items: | |
| task | |
| inbox task | |
| group | |
| available task (not tested) | |
| remaining task (not tested) | |
| by ID, i.e. OFelectAny("pbV93_WpDMx"): | |
| project ID (text) | |
| task ID (text) | |
| List of any of the above | |
| Nothing: OFSelectAny({}) | |
| Note: Selects parent item in sidebar for a given content item. | |
| *) | |
| on OFSelectAny(selectItems) | |
| -- checks to see if we are processing a list, iterates if necessary | |
| local selectItem, extendSelection | |
| if class of selectItems is list then | |
| if (count of selectItems) is 0 then -- select nothing in the sidebar | |
| tell application "OmniFocus" | |
| tell default document | |
| tell front document window | |
| tell sidebar -- if Inbox, Library, Folder, Project, or SAL | |
| select {} | |
| end tell | |
| end tell | |
| end tell | |
| end tell | |
| end if | |
| set extendSelection to false | |
| repeat with selectItem in selectItems | |
| OFSelectOne(selectItem, extendSelection) | |
| set extendSelection to true | |
| end repeat | |
| else | |
| OFSelectOne(selectItems, false) | |
| end if | |
| end OFSelectAny | |
| on OFSelectOne(selectItem, extendSelection) | |
| local itemClass, textConvertFailed, containingProject | |
| tell application "OmniFocus" | |
| tell default document | |
| set itemClass to class of selectItem | |
| if itemClass is rich text then | |
| set textConvertFailed to true | |
| try | |
| set selectItem to task id selectItem | |
| set textConvertFailed to false | |
| end try | |
| if textConvertFailed then | |
| try | |
| set selectItem to project id selectItem | |
| set textConvertFailed to false | |
| end try | |
| end if | |
| if textConvertFailed then | |
| error "OFSelectOne:Couldn't find item ID:" & selectItem | |
| end if | |
| set itemClass to class of selectItem | |
| end if | |
| if itemClass is task then | |
| set containingProject to containing project of selectItem | |
| tell front document window | |
| tell sidebar | |
| select {containingProject} extending extendSelection | |
| end tell | |
| tell content | |
| select {selectItem} extending extendSelection | |
| set selected to true -- bug in OmniFocus 1.6: doesn't work | |
| end tell | |
| end tell | |
| else if itemClass is inbox task then | |
| tell front document window | |
| tell sidebar | |
| select inbox extending extendSelection | |
| end tell | |
| tell content | |
| select {selectItem} extending extendSelection | |
| set selected to true -- bug in OmniFocus 1.6: doesn't work | |
| end tell | |
| end tell | |
| else --Not needed: if (itemClass is project) or (itemClass is tree) or (itemClass is sidebar tree) then | |
| tell front document window | |
| tell sidebar | |
| select {selectItem} extending extendSelection | |
| end tell | |
| end tell | |
| end if | |
| end tell | |
| end tell | |
| end OFSelectOne |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment