From: pho Date: Sun, 28 Oct 2007 01:14:55 +0000 (+0900) Subject: preparation for javascripts X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=859d4378c2e2a1ccc8028821a37eeaa43aaa23fb;p=Rakka.git preparation for javascripts darcs-hash:20071028011455-62b54-c3e5018130a8fa923d2fdbfb1a1529af29bcf09a.gz --- diff --git a/.boring b/.boring index 0a5b28a..d833803 100644 --- a/.boring +++ b/.boring @@ -55,3 +55,7 @@ ^configure$ ^dist(/|$) ^repos(/|$) + +^Rakka/Resource/JavaScript\.hs$ +^js/jquery- +^js/yuicompressor\.jar$ diff --git a/Main.hs b/Main.hs index 90a47ef..8027c7e 100644 --- a/Main.hs +++ b/Main.hs @@ -6,6 +6,7 @@ import Network import Network.HTTP.Lucu import Rakka.Environment import Rakka.Resource.Index +import Rakka.Resource.JavaScript import Rakka.Resource.Object import Rakka.Resource.Render import Rakka.Storage @@ -134,6 +135,7 @@ resTree :: Environment -> ResTree resTree env = mkResTree [ ([] , resIndex env) , (["object"], resObject env) + , (["js" ], javaScript ) ] diff --git a/Makefile b/Makefile index a130eff..99956d4 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ GHC = ghc EXECUTABLE = sudo ./dist/build/rakka/rakka -p 8989 -l DEBUG build: .setup-config Setup + $(MAKE) -C js $@ ./Setup build run: build diff --git a/Rakka.cabal b/Rakka.cabal index d536f4f..c8b62c1 100644 --- a/Rakka.cabal +++ b/Rakka.cabal @@ -23,7 +23,7 @@ Tested-With: Build-Depends: Crypto, FileManip, HUnit, HsHyperEstraier >= 0.2, HsSVN, Lucu, base, encoding, filepath, hslogger, hxt, mtl, network, parsec, - stm, unix + stm, unix, zlib Data-Files: defaultpages/Help/SampleImage/Large defaultpages/Help/SampleImage/Small @@ -45,6 +45,7 @@ Other-Modules: Rakka.Page Rakka.Resource Rakka.Resource.Index + Rakka.Resource.JavaScript Rakka.Resource.Object Rakka.Resource.Render Rakka.Storage diff --git a/Rakka/Page.hs b/Rakka/Page.hs index 1fd54c9..ec6ce80 100644 --- a/Rakka/Page.hs +++ b/Rakka/Page.hs @@ -12,6 +12,7 @@ module Rakka.Page , mkPageURI , mkPageFragmentURI , mkObjectURI + , mkFragmentURI , mkAuxiliaryURI , mkRakkaURI ) @@ -64,24 +65,29 @@ data Page -- UTF-8 に encode してから 0x20 - 0x7E の範圍を除いて URI escape する。 encodePageName :: PageName -> FilePath -encodePageName = escapeURIString isSafe . C8.unpack . encode UTF8 . fixPageName +encodePageName = escapeURIString isSafeChar . C8.unpack . encode UTF8 . fixPageName where - isSafe :: Char -> Bool - isSafe c - | c == '/' = True - | isReserved c = False - | c >= ' ' && c <= '~' = True - | otherwise = False - fixPageName :: PageName -> PageName fixPageName = (\ (x:xs) -> toUpper x : xs) . map (\ c -> if c == ' ' then '_' else c) +isSafeChar :: Char -> Bool +isSafeChar c + | c == '/' = True + | isReserved c = False + | c > ' ' && c <= '~' = True + | otherwise = False + + -- URI unescape して UTF-8 から decode する。 decodePageName :: FilePath -> PageName decodePageName = decode UTF8 . C8.pack . unEscapeString +encodeFragment :: String -> String +encodeFragment = escapeURIString isSafeChar . C8.unpack . encode UTF8 + + pageFileName' :: Page -> String pageFileName' page = fromMaybe (defaultFileName page) (pageFileName page) @@ -107,7 +113,14 @@ mkPageFragmentURI :: URI -> PageName -> String -> URI mkPageFragmentURI baseURI name fragment = baseURI { uriPath = foldl () "/" [uriPath baseURI, encodePageName name ++ ".html"] - , uriFragment = ('#':fragment) + , uriFragment = ('#' : encodeFragment fragment) + } + + +mkFragmentURI :: String -> URI +mkFragmentURI fragment + = nullURI { + uriFragment = ('#' : encodeFragment fragment) } diff --git a/Rakka/Resource/Render.hs b/Rakka/Resource/Render.hs index 66a1516..cb01bcd 100644 --- a/Rakka/Resource/Render.hs +++ b/Rakka/Resource/Render.hs @@ -70,7 +70,6 @@ handleRedirect env {- -- デフォルトでない場合のみ存在 lastModified="2000-01-01T00:00:00"> + + + + + +