^configure$
^dist(/|$)
^repos(/|$)
+
+^Rakka/Resource/JavaScript\.hs$
+^js/jquery-
+^js/yuicompressor\.jar$
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
resTree env
= mkResTree [ ([] , resIndex env)
, (["object"], resObject env)
+ , (["js" ], javaScript )
]
EXECUTABLE = sudo ./dist/build/rakka/rakka -p 8989 -l DEBUG
build: .setup-config Setup
+ $(MAKE) -C js $@
./Setup build
run: build
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
Rakka.Page
Rakka.Resource
Rakka.Resource.Index
+ Rakka.Resource.JavaScript
Rakka.Resource.Object
Rakka.Resource.Render
Rakka.Storage
, mkPageURI
, mkPageFragmentURI
, mkObjectURI
+ , mkFragmentURI
, mkAuxiliaryURI
, mkRakkaURI
)
-- 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)
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)
}
{-
<page site="CieloNegro"
- styleSheet="http://example.org/object/StyleSheet/Default"
name="Foo/Bar"
type="text/x-rakka"
lang="ja" -- 存在しない場合もある
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> -- 存在しない場合もある
+= 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"
tree <- ( eelem "/"
+= ( eelem "page"
+= sattr "site" siteName
- += sattr "styleSheet" (uriToString id (mkObjectURI baseURI cssName) "")
+= sattr "name" (pageName page)
+= sattr "type" (show $ pageType page)
+= ( case pageLanguage page of
+= sattr "revision" (show $ pageRevision page)
+= sattr "lastModified" (formatW3CDateTime $ pageLastMod page)
+ += ( eelem "styleSheets"
+ += ( eelem "styleSheet"
+ += sattr "src" (uriToString id (mkObjectURI baseURI cssName) "")
+ )
+ )
+
+ += ( eelem "scripts"
+ += ( eelem "script"
+ += sattr "src" (uriToString id (baseURI { uriPath = "/js" }) "")
+ )
+ )
+
+= ( case pageSummary page of
Nothing -> none
Just s -> eelem "summary" += txt s
-> let uri = case (page, fragment) of
(Just x, Just y) -> mkPageFragmentURI baseURI x y
(Just x, Nothing) -> mkPageURI baseURI x
- (Nothing, Just y) -> nullURI { uriFragment = ('#':y) }
+ (Nothing, Just y) -> mkFragmentURI y
href = uriToString id uri ""
dLabel = fromMaybe "" page ++ fromMaybe "" (fmap ('#':) fragment)
label = fromMaybe dLabel text
-- <ul>
-- <li>
-- <a href="...">...</a>
--- <span class="date">...</span>
+-- <div class="date">...</div>
-- <p> <!-- サマリが無ければ存在しない -->
-- blah blah...
-- </p>
, linkText = Nothing
}
)
- , Inline ( Span [("class", "date")]
- [Text (formatRFC1123DateTime (pageLastMod page))]
- )
+ , Block ( Div [("class", "date")]
+ [Inline (Text (formatRFC1123DateTime (pageLastMod page)))]
+ )
]
++
case pageSummary page of
margin-top: 1.2em;
}
+.sideBar .date {
+ padding: 0.2em 0 0 0;
+}
+
/* color and text *************************************************************/
* {
font-family: sans-serif;
--- /dev/null
+SOURCES = \
+ jquery-1.2.1.js \
+ $(NULL)
+
+
+build: ../Rakka/Resource/JavaScript.hs
+
+
+../Rakka/Resource/JavaScript.hs: $(SOURCES) yuicompressor.jar
+ cat $(SOURCES) > tmp.js
+ java -jar yuicompressor.jar --type js --charset UTF-8 -o tmp.packed.js --warn tmp.js
+ lucu-implant-file -o $@ -m Rakka.Resource.JavaScript -t text/javascript tmp.packed.js
+ rm tmp.js tmp.packed.js
+
+
+jquery-%.js:
+ @echo "Error: $@ has to be placed on this directory."
+ @echo " See http://jquery.com/"
+ @exit 1
+
+
+clean:
+ rm -f ../Rakka/Resource/JavaScript.hs
+
+
+yuicompressor.jar:
+ @echo "Error: yuicompressor.jar has to be placed on this directory."
+ @echo " See http://www.julienlecomte.net/yuicompressor/"
+ @exit 1