]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Resource/Object.hs
Fixing build breakage...
[Rakka.git] / Rakka / Resource / Object.hs
index 1a81e6719dc7d61f7d8e20723b969a3e7ee7b667..8365381932b7a41fb8460c8c1f1676d1b991a917 100644 (file)
@@ -1,15 +1,14 @@
+-- -*- Coding: utf-8 -*-
 module Rakka.Resource.Object
     ( resObject
     )
     where
-
 import           Network.HTTP.Lucu
-import           Network.HTTP.Lucu.Utils
 import           Rakka.Environment
 import           Rakka.Page
 import           Rakka.Storage
 import           Rakka.SystemConfig
-import           System.Time
+import           System.FilePath.Posix
 
 
 resObject :: Environment -> ResourceDef
@@ -25,21 +24,18 @@ resObject env
       }
     where
       toPageName :: [String] -> PageName
-      toPageName = decodePageName . joinWith "/" 
+      toPageName = UTF8.decodeString . joinPath
 
 
 handleGet :: Environment -> PageName -> Resource ()
 handleGet env name
-    = do pageM <- getPage (envStorage env) name
+    = do pageM <- getPage (envStorage env) name Nothing
          case pageM of
-           Nothing
-               -> foundNoEntity Nothing
-
-           Just redir@(Redirection _ _ _ _)
-               -> handleRedirect env redir
-
-           Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _)
-               -> handleGetEntity env entity
+           Nothing   -> foundNoEntity Nothing
+           Just page -> if isEntity page then
+                            handleGetEntity page
+                        else
+                            handleRedirect env page
 
 
 {-
@@ -58,13 +54,11 @@ handleRedirect env redir
   
   ...
 -}
-handleGetEntity :: Environment -> Page -> Resource ()
-handleGetEntity env page
-    = do let lastMod = toClockTime $ pageLastMod page
-
-         case pageRevision page of
-           0   -> foundTimeStamp lastMod -- 0 はデフォルトページ
-           rev -> foundEntity (strongETag $ show rev) lastMod
+handleGetEntity :: Page -> Resource ()
+handleGetEntity page
+    = do case entityRevision page of
+           0   -> foundTimeStamp (entityLastMod page) -- 0 はデフォルトページ
+           rev -> foundEntity (strongETag $ show rev) (entityLastMod page)
 
-         setContentType (pageType    page)
-         outputLBS      (pageContent page)
+         setContentType (entityType page)
+         outputLBS (entityContent page)