module Panda.Model.Static where
import Panda.Helper.Env hiding (match, body)
import qualified Panda.Config.Global as G
import Panda.Type.Reader
import Panda.Model.Helper
data Static = Static
{ uid :: String
, body :: String
, reader :: Reader
}
deriving (Show, Eq)
instance Resource Static where
resource_title x = ("static" / x.uid.get_title) .spaced_url
instance Markable Static where
markup x = render_to_html (x.reader) (x.body)
instance Default Static where
def = Static def def def
instance FlatRead Static where
flat_read x = do
t <- get_body x
def {body = t, uid = x} .return
instance Gettable Static where
get id = do
x <- flat_read id
x { reader = get_reader id } .return
get_title = id_to_resource > drop_known_extension > split "/" > last
title = uid > get_title