packages feed

panda-2008.9.29: Panda/View/Widget/RSS.hs

module Panda.View.Widget.RSS where

-- env
import Panda.Helper.Env -- hiding (Language)
import Prelude hiding ((.), (/), (^), id)
import qualified Panda.Config.Global as G
import Panda.Type.Pager as Pager
import Text.RSS

-- model
import Panda.Model.Post as Post


entry_uri x = "/" ++ Post.uid x.split "/".tail.join "/"

-- RSS
channel_rss_template = [ Language "en-us" ]

item_rss_template x = 
  [ Title $ x.Post.title
  , Description $ x.Post.markup.show
  , Author $ G.author_email
  , Link $ x.item_uri
  , PubDate $ x.Post.date 
  ]

item_uri x = nullURI { uriScheme = "http://", uriPath = G.host_name ++ x.entry_uri }
rss_uri x  = nullURI { uriScheme = "http://", uriPath = x / "rss.xml" }

rss categary s xs = RSS title  (rss_uri link) title channel_rss_template (xs.take 20 .map item_rss_template)
  .rssToXML.showXML
  where 
    link =  G.host_name / categary / s
    title = G.blog_title ++ " / " ++ s