Last active
February 15, 2018 22:55
-
-
Save craigeley/6901647 to your computer and use it in GitHub Desktop.
Read upcoming Apple Reminders and sort them into an HTML table for use in Panic's Status Board
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 "Reminders" | |
set output to "" | |
set hasOne to false | |
repeat with i from 1 to (count of (reminders whose completed is false)) | |
set theReminder to reminder i of (reminders whose completed is false) | |
set reminderName to name of theReminder | |
set theList to name of container of theReminder | |
if due date of theReminder exists then | |
set dueDate to due date of theReminder | |
set timeStr to time string of dueDate | |
set dateStr to date string of dueDate | |
set dayInt to text -2 thru -1 of ("00" & day of dueDate) | |
set monthInt to text -2 thru -1 of ("00" & ((month of dueDate) as integer)) | |
set yearInt to year of dueDate | |
set output to output & yearInt & monthInt & dayInt & tab & theList & tab & reminderName & linefeed | |
end if | |
end repeat | |
end tell | |
set sortedValues to do shell script "echo " & quoted form of output & " | sort -n -k1" | |
set tid to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to ASCII character 10 | |
set AppleScript's text item delimiters to tid | |
set theData to paragraphs of sortedValues | |
set theBigList to {} | |
set text item delimiters to tab | |
repeat with i from 1 to count of theData | |
set theLine to text items of item i of theData | |
copy theLine to the end of theBigList | |
end repeat | |
set text item delimiters to "" | |
if hasOne is false then | |
set theDate to "" | |
set theTask to "" | |
set theCon to "" | |
set hasOne to true | |
set htmlOutput to "" | |
repeat with i from 2 to count of theBigList | |
set theD to text 7 thru 8 of item 1 of item i of theBigList | |
set theM to text 5 thru 6 of item 1 of item i of theBigList | |
set theTask to item 3 of item i of theBigList | |
set theCon to item 2 of item i of theBigList | |
set htmlOutput to htmlOutput & "<tr>" & return & "<td class=\"projectIcon\"><img src=\"http://www.clker.com/cliparts/T/c/V/a/h/H/checkbox-checked-gray-md.png\" /></td>" & return & "<td class=\"Last Modified\" style=\"width: 153px\">" & theM & "-" & theD & "</td>" & return & "<td class=\"projectName\" style=\"width: 228px\">" & theCon & "</td>" & return & "<td class=\"projectTask\" style=\"width: 480px\">" & theTask & "</td>" & "</tr>" & return | |
end repeat | |
end if | |
set preamble to "<table id=\"projects\">" & return & "<table style= font-size:0.8em>" | |
set outro to "</table>" | |
-- change the next line to point to a folder within your Dropbox | |
do shell script "echo " & quoted form of preamble & quoted form of htmlOutput & quoted form of outro & " > /Users/Uermane/Dropbox/StatusBoard/StatusMinders" & ".html" |
Amazing! I started writing my own script w/ local ruby and realized what a nightmare it is dealing with .ics's at a folder level.. I searched after investing an hour to see if anyone else did it and vola! Applescript is so beautiful. You did a great job! Thank you so much.
To answer the person above: what likely happened is your Reminder's don't have a Due Date set. I too didn't get the results I expected until I noticed the date is the only way it'll show.
Thanks, david! Brady, sorry I was AWOL on your comment. Any update?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So I'm running the script and it isn't working. The outputted html file just contains this for its source:
Not sure what I'm missing, any guidance would be appreciated!