Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 24th, 2012  |  syntax: None  |  size: 3.30 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. (*
  2. Jered Benoit
  3. jeredb.com
  4.  
  5. Omnifocus -> Day One Daily Completed Task Log
  6.  
  7. Based upon [Version 1.0] [1] of [OmniFocus - Weekly Project Report Generator] [2]
  8. Originally Authored by Chris Brogan and Rob Trew
  9. February 5, 2012
  10.  
  11. AND
  12.  
  13. the usual brilliance of Brett Terpstra's
  14. [LOG TASKPAPER ARCHIVES TO DAY ONE Applescript] [3]
  15.  
  16.  
  17. [1]: http://veritrope.com/code/omnifocus-weekly-project-report-generator
  18. [2]: http://cl.ly/1H1M0S3R160x3401150u
  19. [3]: http://brettterpstra.com/log-taskpaper-archives-to-day-one/
  20.  
  21. // NOTES
  22.  
  23. This only selects tasks completed with in the last day.
  24.  
  25. As noted in [Brett's post] [3], you must have a symbolic link to the Day One.app CLI. I dorked mine up, so there you will have to modify the noted line noted to get this scrip to work properly.
  26.  
  27. Symbolic Link terminal goodness:
  28.  
  29. > ln -s "/Applications/Day One/Day One.app/Contents/MacOS/dayone" /usr/local/bin/dayone
  30.  
  31. *)
  32.  
  33. (*
  34. ======================================
  35. // MAIN PROGRAM
  36. ======================================
  37. *)
  38.  
  39. tell application "OmniFocus"
  40.        
  41.         --SET THE REPORT TITLE
  42.         set ExportList to (current date) & return & return & "Completed Projects in the Last Day" & return & "---" & return & return as Unicode text
  43.        
  44.         --PROCESS THE PROJECTS
  45.         tell default document
  46.                
  47.                 set refFolders to a reference to (flattened folders where hidden is false)
  48.                 repeat with idFolder in (id of refFolders) as list
  49.                         set oFolder to folder id idFolder
  50.                         set ExportList to ExportList & my IndentAndProjects(oFolder) & return
  51.                 end repeat
  52.                
  53.                 --ASSEMBLE THE COMPLETED TASK LIST
  54.                 set ExportList to ExportList & return & return & "Tasks Completed in the last day" & return & "---" & return & return & return
  55.                 set day_ago to (current date) - 1 * days
  56.                 set refDoneInLastWeek to a reference to (flattened tasks where (completion date ≥ day_ago))
  57.                 set {lstName, lstContext, lstProject, lstDate} to {name, name of its context, name of its containing project, completion date} of refDoneInLastWeek
  58.                 set strText to ""
  59.                 repeat with iTask from 1 to length of lstName
  60.                         set {strName, varContext, varProject, varDate} to {item iTask of lstName, item iTask of lstContext, item iTask of lstProject, item iTask of lstDate}
  61.                         if varDate is not missing value then set strText to strText & short date string of varDate & " - "
  62.                         if varProject is not missing value then set strText to strText & " [" & varProject & "] - "
  63.                         set strText to strText & strName
  64.                         if varContext is not missing value then set strText to strText & " *@" & varContext & "*"
  65.                         set strText to strText & "  " & return
  66.                 end repeat
  67.         end tell
  68.        
  69.         set ExportList to ExportList & strText as Unicode text
  70.        
  71.         -- Modify "/usr/local/bin/dayone/dayone" to "/usr/local/bin/dayone" if you didn't screw it up like I did.
  72.         do shell script "echo " & (quoted form of ExportList) & "|tr -d \"\\t\"|/usr/local/bin/dayone/dayone new"
  73.        
  74. end tell
  75.  
  76. (*
  77. ======================================
  78. // MAIN HANDLER SUBROUTINES
  79. ======================================
  80. *)
  81.  
  82. on IndentAndProjects(oFolder)
  83.         tell application id "OFOC"
  84.                
  85.                 set {dlm, my text item delimiters} to {my text item delimiters, return & return}
  86.                 set day_ago to (current date) - 1 * days
  87.                 set strCompleted to (name of (projects of oFolder where its status is done and completion date ≥ day_ago)) as string
  88.                
  89.                 set my text item delimiters to dlm
  90.                
  91.                 return strCompleted & return
  92.         end tell
  93. end IndentAndProjects