module Panda.Model.Static where
import Panda.Helper.Env hiding (match, body)
import Prelude hiding ((.), (/), (^), id, readFile)
import qualified Panda.Config.Global as G
import Panda.Type.Reader
data Static = Static
{ uid :: String
, body :: String
, reader :: Reader
}
deriving (Show, Eq)
instance Resource Static where
resource_title = uid >>> spaced_url
instance Markable Static where
markup x = render_to_html (x.reader) (x.body)
get id = liftM2 (Static id) (get_body id) (return $ get_reader id)
get_title = id_to_resource >>> dropExtension
get_body id = (G.flat_uri / id.to_utf8) .readFile
get_reader id = id.take_extension.guess_reader.fromMaybe G.default_reader
title = uid >>> get_title