]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
Implemented sidebars
authorpho <pho@cielonegro.org>
Mon, 22 Oct 2007 05:36:55 +0000 (14:36 +0900)
committerpho <pho@cielonegro.org>
Mon, 22 Oct 2007 05:36:55 +0000 (14:36 +0900)
darcs-hash:20071022053655-62b54-c9abb0e0a3011fb7f51cd0615734f89c723f81dd.gz

12 files changed:
Rakka.cabal
Rakka/Page.hs
Rakka/Resource/Index.hs
Rakka/Resource/Render.hs
Rakka/SystemConfig.hs
Rakka/Wiki/Engine.hs
Rakka/Wiki/Interpreter/Base.hs
defaultPages/MainPage
defaultPages/PageTitle [new file with mode: 0644]
defaultPages/SideBar/Left [new file with mode: 0644]
defaultPages/SideBar/Right [new file with mode: 0644]
defaultPages/StyleSheet/Default

index 7380ae491857cadcf258de604fb8dfa424bc527d..efc767ae5e0cef1ece3a5a5302b900e3b6697c86 100644 (file)
@@ -41,6 +41,9 @@ Data-Files:
     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
 
index fdc622090771c780656cd80adac2548eaf9efc4d..93c7465c2079ea448571e78d0a7c804134eda0d1 100644 (file)
@@ -64,14 +64,14 @@ decodePageName = decode UTF8 . C8.pack . unEscapeString
 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)
       }
 
index 859b8eb5c3e07d81a3552dae31f15e6d4108efe7..9db16eb7ff5ec5f1db742afeb4269576b7821fd7 100644 (file)
@@ -5,6 +5,8 @@ module Rakka.Resource.Index
 
 import           Network.HTTP.Lucu
 import           Rakka.Environment
+import           Rakka.Page
+import           Rakka.SystemConfig
 
 
 resIndex :: Environment -> ResourceDef
@@ -12,8 +14,10 @@ resIndex env
     = 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
index 6aee49f684dbe0f63f5122aa5f85049439bc5e72..27671dac98738115ac85a815f7d41c9bb06bd4e0 100644 (file)
@@ -89,9 +89,22 @@ handleRedirect env
       <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 ())
@@ -103,6 +116,10 @@ handleGetEntity env
                 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
@@ -139,8 +156,28 @@ handleGetEntity env
                                               += 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
@@ -188,10 +225,11 @@ entityToXHTML
                      += sattr "class" "center"
                      += ( eelem "div"
                           += sattr "class" "title"
+                          += getXPathTreesInDoc "/page/pageTitle/*"
                         )
                      += ( eelem "div"
                           += sattr "class" "body"
-                          += getXPathTreesInDoc "/page/content/*"
+                          += getXPathTreesInDoc "/page/body/*"
                         )
                    )
                 += ( eelem "div"
@@ -201,12 +239,14 @@ entityToXHTML
                      += 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/*"
                         )
                    )
               )
index ea7e370cfe7aa8d31edb9b643d1e0d40ae01e59f..423e6c508d88402a9c1df0a2b264e88662bf22e6 100644 (file)
@@ -26,6 +26,7 @@ data SystemConfig = SystemConfig {
 data SysConfValue
     = SiteName String
     | BaseURI URI
+    | DefaultPage String
     | StyleSheet String
 
 
@@ -44,23 +45,26 @@ getSysConfA = (arrIO0 .) . getSysConf
 
 {- 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 -}
@@ -83,5 +87,8 @@ sysConfDefault sc (BaseURI _)
 
          return $ BaseURI $ fromJust $ parseURI defaultURI
 
+sysConfDefault _ (DefaultPage _)
+    = return $ DefaultPage "MainPage"
+
 sysConfDefault _ (StyleSheet _)
     = return $ StyleSheet "StyleSheet/Default"
index 1da0d0efc12439263a67aaeb817970afc41d1fd2..f0de8fb7b078ac6ae14ded434c47b0399ffd2a75 100644 (file)
@@ -1,5 +1,6 @@
 module Rakka.Wiki.Engine
     ( formatPage
+    , formatSubPage
     )
     where
 
@@ -35,6 +36,18 @@ formatPage env
           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
index 1475f461478c4d8694dd680216b449431a0cb3a8..fa225e6b27144a5a253852bb66faacaf36401dd8 100644 (file)
@@ -3,6 +3,7 @@ module Rakka.Wiki.Interpreter.Base
     )
     where
 
+import           Rakka.Page
 import           Rakka.Wiki
 import           Rakka.Wiki.Interpreter
 import           Rakka.Wiki.Interpreter.Base.Image
@@ -14,6 +15,8 @@ baseInterpreters = [ lineBreakInterp
                    , divInterp
                    , imageInterp
                    , imgFrameInterp
+
+                   , pageNameInterp
                    ]
 
 
@@ -39,3 +42,13 @@ divInterp = BlockCommandInterpreter {
             , 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
index 02abe6bdc46478ff8d55aabbe5c1f734802f013c..d042a31a9860a1957d2ba82b15e633f788a0a858 100644 (file)
@@ -2,7 +2,8 @@
 <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!
 
@@ -16,5 +17,8 @@ Another paragraph...
 
 == Subsection ==
 
+=== h3 ===
+==== h4 ====
+===== h5 =====
 ]]></textData>
 </page>
diff --git a/defaultPages/PageTitle b/defaultPages/PageTitle
new file mode 100644 (file)
index 0000000..3bd94c3
--- /dev/null
@@ -0,0 +1,8 @@
+<?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>
diff --git a/defaultPages/SideBar/Left b/defaultPages/SideBar/Left
new file mode 100644 (file)
index 0000000..9b3a18d
--- /dev/null
@@ -0,0 +1,13 @@
+<?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>
diff --git a/defaultPages/SideBar/Right b/defaultPages/SideBar/Right
new file mode 100644 (file)
index 0000000..c3b03b1
--- /dev/null
@@ -0,0 +1,15 @@
+<?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>
index 49dce5ce5027e04052bbd64f5e3277226ee587a9..584a8b7269dedc31f22219b8a251c22f3ff2961f 100644 (file)
 }
 
 /* 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;
 }
@@ -128,6 +192,11 @@ body {
 .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 {
@@ -197,6 +266,9 @@ img {
     border-color: #cccccc;
     border-width: 1px;
     border-style: solid;
+
+    margin-top: 5px;
+    margin-bottom: 5px;
 }
 
 .imageFrame p {