proc rsstv_make_feed {title link description view {order asc}} { dom createDocument rss doc set rss [$doc documentElement] $rss setAttribute version 2.0 $rss setAttribute xmlns:tv http://www.grumet.net/rsstv set channel [$doc createElement channel] $rss appendChild $channel $channel appendChild [rsstv_simpleTextElement $doc title $title] $channel appendChild [rsstv_simpleTextElement $doc link $link] $channel appendChild [rsstv_simpleTextElement $doc description $description] $channel appendChild [rsstv_simpleTextElement $doc pubDate [rsstv_rfc822date [ns_time]]] $channel appendChild [rsstv_simpleTextElement $doc managingEditor aegrumet@alum.mit.edu] db_foreach q " select title, sub_title, description, tvchannel, to_char(when_start,'YYYYMMDDHH24MISS') as when_start, to_char(when_stop,'YYYYMMDDHH24MISS') as when_stop, to_char(case when when_order_by > current_timestamp then current_timestamp else when_order_by end,'Dy, DD Mon YYYY HH24:MI:SS') as pub_date, to_char(extract(timezone_hour from current_timestamp),'FM09') as tzhour, to_char(extract(timezone_minute from current_timestamp),'FM09') as tzminute from rsstv_feed_$view order by when_order_by $order " { append when_start " ${tzhour}${tzminute}" append when_stop " ${tzhour}${tzminute}" append pub_date " ${tzhour}${tzminute}" set item [$doc createElement item] $item appendChild [rsstv_simpleTextElement $doc title $title] $item appendChild [rsstv_simpleTextElement $doc description $description] $item appendChild [rsstv_simpleTextElement $doc pubDate $pub_date] if { ![string equal $sub_title ""] } { $item appendChild [rsstv_simpleTextElement $doc tv:sub-title $sub_title] } $item appendChild [rsstv_simpleTextElement $doc tv:tvchannel $tvchannel] $item appendChild [rsstv_simpleTextElement $doc tv:start "$when_start"] $item appendChild [rsstv_simpleTextElement $doc tv:stop "$when_stop"] set guid [rsstv_simpleTextElement $doc guid "$tvchannel|$when_start"] $guid setAttribute isPermaLink false $item appendChild $guid $channel appendChild $item } return [$doc asXML] } proc rsstv_rfc822date seconds { return [ns_fmttime $seconds "%a, %d %b %Y %T %Z"] } proc rsstv_simpleTextElement {doc name value} { set element_node [$doc createElement $name] set value_node [$doc createTextNode $value] $element_node appendChild $value_node return $element_node }