Created
February 2, 2011 23:10
-
-
Save TelegramSam/808653 to your computer and use it in GitHub Desktop.
including the module
This file contains 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
meta { | |
... | |
use module a8x114 alias kpublicevents with url = | |
"http://www.google.com/calendar/feeds/[email protected]/public/basic" | |
} |
This file contains 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
ruleset a8x114 { | |
meta { | |
name "GCal Util Module" | |
description << | |
Utilities for Google Calendar, including onnow and next | |
>> | |
author "Sam Curren" | |
logging off | |
configure using | |
url = "http://www.google.com/calendar/feeds/[email protected]/public/basic" | |
provides onnow | |
} | |
dispatch {} | |
global { | |
//used for self reference | |
thisappid = "a8x114"; | |
//default calendar options. | |
caloptions = { | |
"singleevents":"true", | |
"alt":"jsonc", | |
"ctz":"America/Denver", | |
"orderby":"starttime", | |
"sortorder":"a" | |
}; | |
//this is needed for testing. 'configure' variables are not available when running as a ruleset | |
rawurl = url => url | "http://www.google.com/calendar/feeds/[email protected]/public/basic"; | |
calendarurl = rawurl.replace(re/basic$/i, "full"); //make it a 'full' feed if basic was specified | |
onnow = function(title){ | |
start = time:now(); | |
end = time:add(start, {"minutes":1}); | |
requestoptions = caloptions.put({"start-min": start,"start-max": end }); | |
onnow = http:get(calendarurl, requestoptions).pick("content").decode(); | |
alltitles = onnow.pick("$..items[*].title", true); | |
relevanttitles = alltitles.filter(function(t){t==title}); | |
relevanttitles.length() > 0; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment