The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Setting up an annual cycle of readings in OmniFocus Thread Tools Search this Thread Display Modes
A simple new year script, inspired by reading a biography of a 19c figure whose habits included making sure that he read every Shakespeare play once a year.
A secularisation, it seems, of more ancient traditions of reading cycles :-)

Code:
-- Creates projects, with start and due dates spread through the year,
-- for an annual cycle of reading all 40 Shakespeare plays, in a supposed chronological order of writing.

property pTitle : "Cycle of Reading"
property pVer : "0.4"

-- Ver 0.4	Defaults to making reading projects parallel rather than sequential, so that note-taking is 'available' during reading.
--			Includes the name of the play in the text of each item
-- Ver 0.3	Allows for an OF Context to be specified (pstrContext below)
--			Sets repetition to annual
--			Sets next review date to year hence
-- 			Shows progress in the Terminal and creates a log file

-- OPTIONALLY SPECIFY THE NAME OF A CONTEXT FOR THIS READING
-- (if the named context does not yet exist in your OF, the script will create it)
property pstrContext : ""

property pstrFolderName : "Reading Cycles"
property pstrVerb : "Read" & space
property pblnAnnualRepeat : true
property pstrLogFile : "ReadingScript.txt"
property pblnTermLog : true
property pblnSequential : false

property plstPlays : {
	{"Henry VI Part I"}, 
	{"Henry VI, Part II"}, 
	{"Henry VI, Part III"}, 
	{"Richard III"}, 
	{"The Comedy of Errors"}, 
	{"Titus Andronicus"}, 
	{"Taming of the Shrew"}, 
	{"The Two Gentlemen of Verona"}, 
	{"Love's Labour's Lost"}, 
	{"Romeo and Juliet"}, 
	{"Richard II"}, 
	{"A Midsummer Night's Dream"}, 
	{"King John"}, 
	{"Edward III"}, 
	{"The Merchant of Venice"}, 
	{"Henry IV, Part I"}, 
	{"Love's Labour's Won"}, 
	{"Henry IV, Part II"}, 
	{"Henry V"}, 
	{"Julius Caesar"}, 
	{"Much Ado About Nothing"}, 
	{"As You Like It"}, 
	{"The Merry Wives of Windsor"}, 
	{"Hamlet"}, 
	{"Twelfth Night"}, 
	{"Troilus and Cressida"}, 
	{"All's Well That Ends Well"}, 
	{"Othello"}, 
	{"King Lear"}, 
	{"Macbeth"}, 
	{"Measure For Measure"}, 
	{"Antony and Cleopatra"}, 
	{"Coriolanus"}, 
	{"Timon of Athens"}, 
	{"Pericles, Prince of Tyre"}, 
	{"Cymbeline"}, 
	{"The Winter's Tale"}, 
	{"The Tempest"}, 
	{"Henry VIII"}, 
	{"The Two Noble Kinsmen"}}


property plstStages : {"Choose text / audio / video of ", "Read / listen / watch to end of ", "Write notes of thoughts arising from reading of ", "Archive notes on "}

property plngInterval : (365 * days) / (length of plstPlays)


on run
	-- CHOOSE START DATE (THE DEFAULT IS NOW)
	set strToday to short date string of (current date)
	set varResponse to display dialog "Enter date for start of reading cycle:" default answer strToday with title pTitle
	if varResponse is false then return
	set strStart to text returned of varResponse
	try
		set dteStart to date strStart
	on error
		display dialog "Invalid Date: " & strStart with title pTitle
	end try
	
	tell application id "com.omnigroup.omnifocus"
		tell default document
			-- FIND OR CREATE THE FOLDER FOR READING CYCLES
			set lstFolders to flattened folders where name = pstrFolderName
			if length of lstFolders > 0 then
				set oFolder to first item of lstFolders
			else
				set oFolder to make new folder with properties {name:pstrFolderName}
			end if
			
			set oContext to missing value
			if pstrContext ≠ "" then
				try
					set oContext to first flattened context where name = pstrContext
				on error
					set oContext to make new context with properties {name:pstrContext}
				end try
			end if
			
			-- SET ANY REVIEW AND REPETITION INTERVALS
			set recReview to {fixed:true, steps:1, unit:year} as record
			if pblnAnnualRepeat then
				set recRepn to {fixed:true, steps:1, unit:year} as record
			else
				set recRepn to missing value
			end if
			
			-- DIVIDE THE YEAR AMONG THE READINGS IN THE LIST
			set lngPlays to length of plstPlays
			repeat with i from 1 to lngPlays
				set strPlay to first item of item i of plstPlays
				set oProj to make new project at end of projects of oFolder with properties 
					{name:pstrVerb & (strPlay), start date:dteStart, due date:dteStart + plngInterval, context:oContext, repetition:recRepn, review interval:recReview, sequential:pblnSequential} 
						
				set dteStart to dteStart + plngInterval
				repeat with iTask from 1 to length of plstStages
					make new task at end of tasks of oProj with properties {name:(item iTask of plstStages) & strPlay}
				end repeat
				
				if pblnTermLog then my TermLog(strPlay)
			end repeat
		end tell
	end tell
	activate
	display dialog (lngPlays as string) & " reading projects" & return & return & "written to OmniFocus folder: " & pstrFolderName buttons {"OK"} with title pTitle
end run

on TermLog(strText)
	tell application id "com.apple.Terminal"
		activate
		set strCmd to "echo " & (quoted form of strText) & "    " & (quoted form of ((current date) as string)) & " >> " & pstrLogFile
		do script strCmd in front window
	end tell
end TermLog

Last edited by RobTrew; 2011-01-06 at 02:29 AM.. Reason: Draft 0.4 (Projects parallel by default, to facilitate note-taking while reading)
 
... and if you have installed these reading projects in your OmniFocus database, a geeklet to display a reminder of the current reading on the OS X desktop might run a command like:
sqlite3 ~/Library/Caches/com.omnigroup.OmniFocus/OmniFocusDatabase2 'select pt.name from (projectinfo p join task t on p.pk=t.persistentidentifier) pt join folder f on pt.folder=f.persistentIdentifier where (f.name="Reading Cycles") and pt.datecompleted is null order by pt.dateDue limit 1;' | sed 's/Read //'
(Attached as a geeklet file below. Note that the SQL schema of the cache may well change in future builds of OmniFocus, requiring a rewrite of any SQL queries of this kind).

--

Last edited by RobTrew; 2011-07-05 at 07:46 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Easiest way of setting up OmniFocus on 2 machines? fmantek OmniFocus 1 for Mac 2 2007-12-06 09:08 AM
Cycle Project States spnyc OmniFocus Extras 0 2007-08-26 01:16 PM


All times are GMT -8. The time now is 06:37 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.