defaultpages/Help/SampleImage/Small
defaultPages/Help/Syntax
defaultPages/MainPage
+ defaultPages/PageTitle
+ defaultPages/SideBar/Left
+ defaultPages/SideBar/Right
defaultPages/StyleSheet/Default
schemas/rakka-page-1.0.rng
mkPageURI :: URI -> PageName -> URI
mkPageURI baseURI name
= baseURI {
- uriPath = foldl combine "/" [uriPath baseURI, encodePageName name]
+ uriPath = foldl combine "/" [uriPath baseURI, encodePageName name ++ ".html"]
}
mkPageFragmentURI :: URI -> PageName -> String -> URI
mkPageFragmentURI baseURI name fragment
= baseURI {
- uriPath = foldl combine "/" [uriPath baseURI, encodePageName name]
+ uriPath = foldl combine "/" [uriPath baseURI, encodePageName name ++ ".html"]
, uriFragment = ('#':fragment)
}
import Network.HTTP.Lucu
import Rakka.Environment
+import Rakka.Page
+import Rakka.SystemConfig
resIndex :: Environment -> ResourceDef
= ResourceDef {
resUsesNativeThread = False
, resIsGreedy = False
- , resGet = Just $ do setContentType $ read "text/plain"
- output "FIXME: not implemented"
+ , resGet
+ = Just $ do BaseURI baseURI <- getSysConf (envSysConf env) (BaseURI undefined)
+ DefaultPage name <- getSysConf (envSysConf env) (DefaultPage undefined)
+ redirect Found (mkPageURI baseURI name)
, resHead = Nothing
, resPost = Nothing
, resPut = Nothing
<link lang="ja" page="Bar/Baz" />
</otherLang>
- <content>
+ <pageTitle>
blah blah...
- </content>
+ </pageTitle>
+
+ <sideBar>
+ <left>
+ blah blah...
+ </left>
+ <right>
+ blah blah...
+ </right>
+ </sideBar>
+
+ <body>
+ blah blah...
+ </body>
</page>
-}
handleGetEntity :: (ArrowXml a, ArrowChoice a, ArrowIO a) => Environment -> a Page (Resource ())
BaseURI baseURI <- getSysConfA sysConf (BaseURI undefined) -< ()
StyleSheet cssName <- getSysConfA sysConf (StyleSheet undefined) -< ()
+ Just pageTitle <- getPageA (envStorage env) -< "PageTitle"
+ Just leftSideBar <- getPageA (envStorage env) -< "SideBar/Left"
+ Just rightSideBar <- getPageA (envStorage env) -< "SideBar/Right"
+
tree <- ( eelem "/"
+= ( eelem "page"
+= sattr "site" siteName
+= sattr "page" page
| (lang, page) <- xs ]
)
- += ( eelem "content"
- += (constA page >>> formatPage env )
+ += ( eelem "pageTitle"
+ += ( (constA page &&& constA pageTitle)
+ >>>
+ formatSubPage env
+ )
+ )
+ += ( eelem "sideBar"
+ += ( eelem "left"
+ += ( (constA page &&& constA leftSideBar)
+ >>>
+ formatSubPage env
+ )
+ )
+ += ( eelem "right"
+ += ( (constA page &&& constA rightSideBar)
+ >>>
+ formatSubPage env
+ )
+ )
+ )
+ += ( eelem "body"
+ += (constA page >>> formatPage env)
)
>>>
uniqueNamespacesFromDeclAndQNames
+= sattr "class" "center"
+= ( eelem "div"
+= sattr "class" "title"
+ += getXPathTreesInDoc "/page/pageTitle/*"
)
+= ( eelem "div"
+= sattr "class" "body"
- += getXPathTreesInDoc "/page/content/*"
+ += getXPathTreesInDoc "/page/body/*"
)
)
+= ( eelem "div"
+= sattr "class" "left sideBar"
+= ( eelem "div"
+= sattr "class" "content"
+ += getXPathTreesInDoc "/page/sideBar/left/*"
)
)
+= ( eelem "div"
+= sattr "class" "right sideBar"
+= ( eelem "div"
+= sattr "class" "content"
+ += getXPathTreesInDoc "/page/sideBar/right/*"
)
)
)
data SysConfValue
= SiteName String
| BaseURI URI
+ | DefaultPage String
| StyleSheet String
{- paths -}
sysConfPath :: SysConfValue -> FilePath
-sysConfPath (SiteName _) = "/siteName"
-sysConfPath (BaseURI _) = "/baseURI"
-sysConfPath (StyleSheet _) = "/styleSheet"
+sysConfPath (SiteName _) = "/siteName"
+sysConfPath (BaseURI _) = "/baseURI"
+sysConfPath (DefaultPage _) = "/defaultPage"
+sysConfPath (StyleSheet _) = "/styleSheet"
{- marshalling -}
marshalSysConf :: SysConfValue -> String
-marshalSysConf (SiteName name) = name
-marshalSysConf (BaseURI uri ) = uriToString id uri ""
-marshalSysConf (StyleSheet name) = name
+marshalSysConf (SiteName name) = name
+marshalSysConf (BaseURI uri ) = uriToString id uri ""
+marshalSysConf (DefaultPage name) = name
+marshalSysConf (StyleSheet name) = name
{- unmarshalling -}
unmarshalSysConf :: SysConfValue -> String -> SysConfValue
-unmarshalSysConf (SiteName _) name = SiteName name
-unmarshalSysConf (BaseURI _) uri = BaseURI $ fromJust $ parseURI uri
-unmarshalSysConf (StyleSheet _) name = StyleSheet name
+unmarshalSysConf (SiteName _) name = SiteName name
+unmarshalSysConf (BaseURI _) uri = BaseURI $ fromJust $ parseURI uri
+unmarshalSysConf (DefaultPage _) name = DefaultPage name
+unmarshalSysConf (StyleSheet _) name = StyleSheet name
{- getting default value -}
return $ BaseURI $ fromJust $ parseURI defaultURI
+sysConfDefault _ (DefaultPage _)
+ = return $ DefaultPage "MainPage"
+
sysConfDefault _ (StyleSheet _)
= return $ StyleSheet "StyleSheet/Default"
module Rakka.Wiki.Engine
( formatPage
+ , formatSubPage
)
where
attachXHtmlNs -< tree
+formatSubPage :: (ArrowXml a, ArrowChoice a, ArrowIO a) =>
+ Environment
+ -> a (Page, Page) XmlTree
+formatSubPage env
+ = proc (mainPage, subPage)
+ -> do tree <- case pageType subPage of
+ MIMEType "text" "x-rakka" _
+ -> do let source = decodeLazy UTF8 (pageContent subPage)
+ formatWikiPage env -< (Just mainPage, source)
+ attachXHtmlNs -< tree
+
+
formatWikiPage :: (ArrowXml a, ArrowChoice a, ArrowIO a) =>
Environment
-> a (Maybe Page, String) XmlTree
)
where
+import Rakka.Page
import Rakka.Wiki
import Rakka.Wiki.Interpreter
import Rakka.Wiki.Interpreter.Base.Image
, divInterp
, imageInterp
, imgFrameInterp
+
+ , pageNameInterp
]
, bciInterpret
= \ _ (BlockCommand _ attrs contents) -> return $ Div attrs contents
}
+
+
+pageNameInterp :: Interpreter
+pageNameInterp = InlineCommandInterpreter {
+ iciName = "pageName"
+ , iciInterpret
+ = \ ctx (InlineCommand _ _ _) -> case ctxPage ctx of
+ Nothing -> return $ Text "(None)"
+ Just page -> return $ Text $ pageName page
+ }
\ No newline at end of file
<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
type="text/x-rakka"
isBoring="yes">
- <textData><![CDATA[= Main Page =
+ <textData><![CDATA[
+= Main Page =
This is the main page.
Hello, world!
== Subsection ==
+=== h3 ===
+==== h4 ====
+===== h5 =====
]]></textData>
</page>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
+ type="text/x-rakka"
+ isBoring="yes">
+ <textData><![CDATA[
+<pageName />
+]]></textData>
+</page>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
+ type="text/x-rakka"
+ isBoring="yes">
+ <textData><![CDATA[
+= Outline =
+
+= Menu =
+
+= Trackbacks =
+
+]]></textData>
+</page>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<page xmlns="http://cielonegro.org/schema/Rakka/Page/1.0"
+ type="text/x-rakka"
+ isBoring="yes">
+ <textData><![CDATA[
+= Control =
+
+= RSS feeds =
+
+= In other languages =
+
+= Recent updates =
+
+]]></textData>
+</page>
}
/* spacing */
+.title {
+ padding: 5px 20px;
+}
+
+.title p {
+ margin: 0;
+}
+
.body {
padding: 25px 30px;
}
margin-top: 0.9em;
}
+.sideBar h1 {
+ margin-bottom: 5px;
+ padding: 0px 5px;
+}
+
.sideBar .content {
padding: 20px;
}
}
/* color and text */
+* {
+ font-family: sans-serif;
+}
+
body {
- background-color: #white;
+ background-color: white;
color: black;
line-height: 1.3;
}
+h1, h2, h3, h4, h5, h6 {
+ font-weight: normal;
+}
+
+.title {
+ background-color: #fafafa;
+
+ border-color: #cccccc;
+ border-width: 0 0 3px 0;
+ border-style: double;
+
+ font-size: 1.2em;
+}
+
+.body h1 {
+ font-size: 180%;
+
+ background-color: #fafafa;
+
+ border-color: #dddddd;
+ border-width: 2px;
+ border-style: solid;
+
+ padding: 0 10px;
+}
+.body h2 {
+ font-size: 150%;
+}
+.body h3 {
+ font-size: 130%;
+}
+.body h4 {
+ font-size: 110%;
+}
+.body h5 {
+ font-size: 90%;
+}
+.body h2, .body h3, .body h4, .body h5 {
+ background-color: #fafafa;
+
+ border-color: #dddddd;
+ border-width: 0 0 1px 0;
+ border-style: solid;
+
+ padding: 0 10px;
+}
+
.header, .footer, .sideBar {
background-color: #eeeeee;
}
.sideBar h1 {
font-size: 120%;
font-weight: bold;
+ background-color: #fafafa;
+
+ border-color: #dddddd white white #dddddd;
+ border-width: 1px;
+ border-style: solid;
}
.sideBar a {
border-color: #cccccc;
border-width: 1px;
border-style: solid;
+
+ margin-top: 5px;
+ margin-bottom: 5px;
}
.imageFrame p {