Tags: horde, php
During some recent quality-time I spent with my schedule (read: "trying to figure out how to add more time to a day"), I had an a-ha moment. Why am I switching back and forth between weather data and my calendar to see the weather for a day of interest in my calendar? Why can't it just display in the calendar? We already have some code in Horde that interfaces with the weather.com API (thanks to PEAR's Services_Weather package), so why not provide the weather data via the listTimeObjects API so Kronolith can pick it up?
The first step along this path was to create a new "mini" application - or an application that does nothing other than expose data via the listTimeObjects API. This resulted in the lightweight TimeObjects application that now lives in the horde-hatchery git repository. This does put another level of abstraction between the weather data and Kronolith, but what I didn't want to do was start a trend of having to write a new Kronolith Event driver for any new type of time data that might be desired. With TimeObjects, now all that is needed is to drop a new driver into TimeObjects' lib/Driver/ directory and it will be picked up and exposed via the API.
With the addition of the new TimeObjects application, Kronolith can
now display the forecast data for up to the next 5 days directly in the
calendar view. The high/low temperature along with the general
conditions for that day are displayed, with a tooltip popup showing
more detail. Currently, for this to work, you will need a contact in
Turba that is marked as your own and containing enough of your location
information to satisfy weather.com's service. Horde will also need to
be configured with the weather.com api keys...just like the weather.com
block requires. A future addition will be to allow choosing (multiple?) locations via a Google map in Horde's preferences.
Since the listTimeObjects API really isn't documented anywhere other than our source code, a little introduction may be in order. If you are not interested in Horde internals, you can skip to the end.
The API allows any Horde application to expose it's data as events to be displayed in Kronolith. For example, via this API, Turba can provide the data needed to display contact birthdays and anniversaries in Kronolith. Nag can display task due dates etc... For this to work, an application needs to expose two methods via it's own API: listTimeObjectCategories(), which returns the categories of time objects available (birthday, anniversary etc..) and listTimeObjects() which returns the actual data. The data returned includes information such as the start and end times, a title, a description, icon, and link. For more information I will direct you to the phpdoc at http://dev.horde.org.
As always, a warning that the TimeObjects code is Horde 4 only, and as such is not considered stable.