]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Resource/Object.hs
Fixing build breakage...
[Rakka.git] / Rakka / Resource / Object.hs
index cd2c36463d93f8975db6bf9e9dee26b70ffdb62f..8365381932b7a41fb8460c8c1f1676d1b991a917 100644 (file)
@@ -3,15 +3,12 @@ module Rakka.Resource.Object
     ( resObject
     )
     where
-
-import           Data.ByteString.Char8 as C8
-import           Data.Maybe
 import           Network.HTTP.Lucu
-import           Network.HTTP.Lucu.Utils
 import           Rakka.Environment
 import           Rakka.Page
 import           Rakka.Storage
 import           Rakka.SystemConfig
+import           System.FilePath.Posix
 
 
 resObject :: Environment -> ResourceDef
@@ -27,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 Nothing
          case pageM of
-           Nothing
-               -> foundNoEntity Nothing
-
-           Just redir@(Redirection _ _ _ _)
-               -> handleRedirect env redir
-
-           Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _ _)
-               -> handleGetEntity entity
+           Nothing   -> foundNoEntity Nothing
+           Just page -> if isEntity page then
+                            handleGetEntity page
+                        else
+                            handleRedirect env page
 
 
 {-
@@ -62,11 +56,9 @@ handleRedirect env redir
 -}
 handleGetEntity :: Page -> Resource ()
 handleGetEntity page
-    = do case pageRevision page of
-           0   -> foundTimeStamp (pageLastMod page) -- 0 はデフォルトページ
-           rev -> foundEntity (strongETag $ show rev) (pageLastMod page)
+    = do case entityRevision page of
+           0   -> foundTimeStamp (entityLastMod page) -- 0 はデフォルトページ
+           rev -> foundEntity (strongETag $ show rev) (entityLastMod page)
 
-         setContentType (pageType page)
-         setHeader (C8.pack "Content-Disposition")
-                       (C8.pack $ "attachment; filename=" ++ quoteStr (pageFileName' page))
-         outputLBS (pageContent page)
+         setContentType (entityType page)
+         outputLBS (entityContent page)