View Single Post
Quote:
Is that the planned feature or just a quick work around for Alpha versions?
The planned feature is that you select a calendar for each context, but in current alpha builds the script (did I mention it's naive?) publishes to a single calendar which it rebuilds each time. (It does put the context name and project names in the task summary so you aren't totally lost when viewing them later.)

Here's the current script (again, note that this is not the planned feature!):

Code:
global targetCalendar
tell application "iCal"
	set CalendarName to "OmniFocus Export"
	try
		delete (first calendar whose name is CalendarName)
	end try
	make calendar with properties {name:CalendarName, color:{43176, 24158, 54227}, description:"OmniFocus tasks"}
	set targetCalendar to first calendar whose name is CalendarName
end tell

tell first document of application "OmniFocus"
	
	repeat with aContext in contexts
		set MyContextID to (id of aContext)
		set MyContext to context id MyContextID
		PublishContext of me from MyContext
	end repeat
	
end tell

tell application "iCal" to activate


on PublishContext from SomeContext
	using terms from application "OmniFocus"
		PublishContextTasks of me from SomeContext
		repeat with childContext in contexts of SomeContext
			PublishContext of me from childContext
		end repeat
	end using terms from
end PublishContext

on PublishContextTasks from SomeContext
	using terms from application "OmniFocus"
		repeat with aTask in (tasks of SomeContext where blocked is false)
			set taskName to name of aTask
			set taskProject to containing project of aTask
			using terms from application "iCal"
				tell targetCalendar
					make todo at end of todos with properties {summary:name of SomeContext & ": " & taskName & " [" & name of taskProject & "]"}
				end tell
			end using terms from
		end repeat
	end using terms from
end PublishContextTasks