panda-0.0.0.4: Panda/View/Theme/BluePrint/Template/Sidebar.hs
module Panda.View.Theme.BluePrint.Template.Sidebar where
import Panda.Helper.Env hiding (rss_link)
import Prelude hiding ((.), (/), id, span)
import qualified Panda.Config.Global as Config
import qualified Panda.Type.State as State
import Text.XHtml.Strict
import qualified Data.Set as Set
-- model
import Panda.Model.Tag as Tag
html_sidebar state =
div_class_id "column span-3 last" "sidebar" << unordList
[ feed state
, hr
, tag_list $ state.State.tags
]
feed state = toHtml
[ h2 << "Subscribe"
, p ! [theclass "feed"] << rss_link state
]
rss_link state =
if tagged
then
let tag_name = Tag.get_name uid in
link ("tag" / tag_name) tag_name
else link "" "Home"
where
uid = State.uid state
tagged = uid.match "^tag/.+" .isJust
link r s = hotlink ("/" / r / "rss.xml") ! [ theclass "feedlink" ] << s
tag_list tags = toHtml
[ h2 << "Tags"
, unordList $ tags.Tag.sorted.map tag_link]
tag_link x = hotlink ("/" ++ x.uid.urlEncode) << x.Tag.name +++ (" (" ++ x.Tag.resources.Set.size.show ++ ")")