[Config]
Name = hCalendar
Summary = Extracts details about scheduled events.

[Description]
This metadata module recognizes event details that have been embedded in feed items
using <a href="http://microformats.org/wiki/hcalendar" target="_blank">hCalendar</a>.

; NOTE: hCalendar elements are tagged with attributes that may contain multiple words. 
; Locating these is fiddly since we can't do the obvious contains(@attr,"findme")
; since this will also match things like "x-findme".
; We hack around this by putting a space before and after the attribute
; and then trying to match " findme " i.e.
;   @contains( concat(concat(" ",@attr)," ") , " findme " )

; NOTE: The lack of well-defined structure in hCalendar makes parsing tricky.
; We need some way of being able to match nodes that are child nodes (to an
; arbitrary depth) of the current XPathRoot node. We can't use a //* type of query 
; since it won't work properly if there is more than one event in a given feed item.

[Item Metadata]
_XPathRoot = //*[contains(concat(concat(" ",@class)," ")," vevent ")]
_MetadataGroupRoot = event
summary = *[contains(concat(concat(" ",@class)," ")," summary ")] | */*[contains(concat(concat(" ",@class)," ")," summary ")] | */*/*[contains(concat(concat(" ",@class)," ")," summary ")] 
description = *[contains(concat(concat(" ",@class)," ")," description ")] | */*[contains(concat(concat(" ",@class)," ")," description ")] | */*/*[contains(concat(concat(" ",@class)," ")," description ")] 
location = *[contains(concat(concat(" ",@class)," ")," location ")] | */*[contains(concat(concat(" ",@class)," ")," location ")] | */*/*[contains(concat(concat(" ",@class)," ")," location ")]
end = *[contains(concat(concat(" ",@class)," ")," dtend ")] | */*[contains(concat(concat(" ",@class)," ")," dtend ")] | */*/*[contains(concat(concat(" ",@class)," ")," dtend ")]
url = *[contains(concat(concat(" ",@class)," ")," url ")]/@href | */*[contains(concat(concat(" ",@class)," ")," url ")]/@href | */*/*[contains(concat(concat(" ",@class)," ")," url ")]/@href
start = *[contains(concat(concat(" ",@class)," ")," dtstart ")] | */*[contains(concat(concat(" ",@class)," ")," dtstart ")] | */*/*[contains(concat(concat(" ",@class)," ")," dtstart ")]

[Item Pane Columns]
_AvailabilityMsg=Available for channels that embed hCalendar information into their feed items.
Location=event/location
Time=event/start

[Item Description Template Block]
{%REPEAT% event}
    <div class="mm-hCalendar">
    {%?ITEM-METADATA% event/url}
        <a href="{%@%}"> <strong>Event</strong> </a>:
    {%ELSE%}
        <strong>Event</strong>:
    {%ENDIF%}
    {%ITEM-METADATA% event/summary}
    <em>
        {%ITEM-METADATA% event/location}
        {%?ITEM-METADATA% event/start}
            {%@%}
            {%?ITEM-METADATA% event/end} - {%@%} {%ENDIF%}
        {%ENDIF%}
    </em>
    {%?ITEM-METADATA% event/description}
        <div style="margin-left: 1em;"> {%@%} </div>
    {%ENDIF%}
    </div>
{%/REPEAT%}

