]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Resource/Render.hs
preparation for javascripts
[Rakka.git] / Rakka / Resource / Render.hs
index 3c0bd7a6a1ab4ae1dd4740d08fc672c01c10d34c..cb01bcd35f3aa5abca2c7da7f97a9b6d47944261 100644 (file)
@@ -25,9 +25,9 @@ import           Text.XML.HXT.DOM.TypeDefs
 
 fallbackRender :: Environment -> [String] -> IO (Maybe ResourceDef)
 fallbackRender env path
-    | null path                        = return Nothing
-    | null $ head path                 = return Nothing
-    | not $ isUpper $ head $ head path = return Nothing -- /Foo/bar のような形式でない。
+    | null path                  = return Nothing
+    | null $ head path           = return Nothing
+    | isLower $ head $ head path = return Nothing -- 先頭の文字が小文字であってはならない
     | otherwise
         = return $ Just $ ResourceDef {
             resUsesNativeThread = False
@@ -46,7 +46,7 @@ fallbackRender env path
 handleGet :: Environment -> PageName -> Resource ()
 handleGet env name
     = runIdempotentA $ proc ()
-    -> do pageM <- getPageA (envStorage env) -< name
+    -> do pageM <- getPageA (envStorage env) -< (name, Nothing)
           case pageM of
             Nothing
                 -> handlePageNotFound env -< name
@@ -54,7 +54,7 @@ handleGet env name
             Just redir@(Redirection _ _ _ _)
                 -> handleRedirect env -< redir
 
-            Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _)
+            Just entity@(Entity _ _ _ _ _ _ _ _ _ _ _ _ _ _)
                 -> handleGetEntity env -< entity
 
 {-
@@ -70,17 +70,25 @@ handleRedirect env
 
 {-
   <page site="CieloNegro"
-        styleSheet="http://example.org/object/StyleSheet/Default"
         name="Foo/Bar"
         type="text/x-rakka"
-        lang="ja"           -- 存在しない場合もある
-        isTheme="no"        -- text/css の場合のみ存在
-        isFeed="no"         -- text/x-rakka の場合のみ存在
+        lang="ja"            -- 存在しない場合もある
+        fileName="bar.rakka" -- 存在しない場合もある
+        isTheme="no"         -- text/css の場合のみ存在
+        isFeed="no"          -- text/x-rakka の場合のみ存在
         isLocked="no"
         isBinary="no"
-        revision="112">     -- デフォルトでない場合のみ存在
+        revision="112">      -- デフォルトでない場合のみ存在
         lastModified="2000-01-01T00:00:00">
 
+    <styleSheets>
+      <styleSheet src="http://example.org/object/StyleSheet/Default" />
+    </styleSheets>
+
+    <scripts>
+      <script src="http://example.org/js" />
+    </scripts>
+
     <summary>
         blah blah...
     </summary> -- 存在しない場合もある
@@ -142,11 +150,20 @@ entityToXHTML
                      += txt " - "
                      += getXPathTreesInDoc "/page/@name/text()"
                    )
-                += ( eelem "link"
+                += ( getXPathTreesInDoc "/page/styleSheets/styleSheet"
+                     >>>
+                     eelem "link"
                      += sattr "rel"  "stylesheet"
                      += sattr "type" "text/css"
                      += attr "href"
-                            ( getXPathTreesInDoc "/page/@styleSheet/text()" )
+                            ( getXPathTrees "/styleSheet/@src/text()" )
+                   )
+                += ( getXPathTreesInDoc "/page/scripts/script"
+                     >>>
+                     eelem "script"
+                     += sattr "type" "text/javascript"
+                     += attr "src"
+                            ( getXPathTrees "/script/@src/text()" )
                    )
               )
            += ( eelem "body"