( fallbackPageEntity
)
where
-
-import qualified Codec.Binary.UTF8.String as UTF8
import Control.Monad.Trans
import qualified Data.ByteString.Lazy as L hiding (ByteString)
import Data.Char
import qualified Data.Map as M
import Data.Maybe
import Data.Time
+import qualified Data.Time.W3C as W3C
import Network.HTTP.Lucu
import Network.URI hiding (path)
import Rakka.Environment
import Rakka.Storage
import Rakka.SystemConfig
import Rakka.Utils
-import Rakka.W3CDateTime
import Rakka.Wiki.Engine
import System.FilePath.Posix
import Text.HyperEstraier hiding (getText)
-import Text.XML.HXT.Arrow
import Text.XML.HXT.XPath
fallbackPageEntity :: Environment -> [String] -> IO (Maybe ResourceDef)
fallbackPageEntity env path
- | null path = return Nothing
- | null $ head path = return Nothing
- | isLower $ head $ head path = return Nothing -- 先頭の文字が小文字であってはならない
+ | null name = return Nothing
+ | isLower $ head name = return Nothing -- 先頭の文字が小文字であってはならない
| otherwise
= return $ Just $ ResourceDef {
resUsesNativeThread = False
, resIsGreedy = True
- , resGet = Just $ handleGet env (toPageName path)
+ , resGet = Just $ handleGet env name
, resHead = Nothing
, resPost = Nothing
- , resPut = Just $ handlePut env (toPageName path)
- , resDelete = Just $ handleDelete env (toPageName path)
+ , resPut = Just $ handlePut env name
+ , resDelete = Just $ handleDelete env name
}
where
- toPageName :: [String] -> PageName
- toPageName = decodePageName . dropExtension . joinPath
+ name :: PageName
+ name = (dropExtension . UTF8.decodeString . joinPath) path
handleGet :: Environment -> PageName -> Resource ()
+= ( eelem "dc:date"
+= ( arrIO (utcToLocalZonedTime . entityLastMod)
>>>
- arr formatW3CDateTime
+ arr W3C.format
>>>
mkText
)