X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter%2FBase.hs;h=8a3ada996290f8e1e1e2c00e7932974b52b50d95;hb=f19a294d54f38faaeab0027ecb5d85388243b924;hp=6feb92a77c82dcec77157cf3f0bff2929328a06f;hpb=743f4a87fd557832ce67d6eb51749582820577c4;p=Rakka.git
diff --git a/Rakka/Wiki/Interpreter/Base.hs b/Rakka/Wiki/Interpreter/Base.hs
index 6feb92a..8a3ada9 100644
--- a/Rakka/Wiki/Interpreter/Base.hs
+++ b/Rakka/Wiki/Interpreter/Base.hs
@@ -3,18 +3,14 @@ module Rakka.Wiki.Interpreter.Base
)
where
-import Control.Arrow
-import Control.Arrow.ListArrow
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe
-import Network.URI
import Rakka.Page
import Rakka.SystemConfig
import Rakka.Wiki
import Rakka.Wiki.Interpreter
-import Text.XML.HXT.Arrow.XmlArrow
-import Text.XML.HXT.Arrow.XmlNodeSet
+import Text.XML.HXT.Arrow
interpreters :: [Interpreter]
@@ -25,12 +21,15 @@ interpreters = [ lineBreakInterp
, otherLangsInterp
, newPageInterp
, editPageInterp
+ , loginInterp
+ , searchFieldInterp
+ , configurationInterp
]
lineBreakInterp :: Interpreter
lineBreakInterp = InlineCommandInterpreter {
- iciName = "br"
+ iciName = "br"
, iciInterpret
= \ _ (InlineCommand _ attrs _) -> return $ LineBreak attrs
}
@@ -38,7 +37,7 @@ lineBreakInterp = InlineCommandInterpreter {
spanInterp :: Interpreter
spanInterp = InlineCommandInterpreter {
- iciName = "span"
+ iciName = "span"
, iciInterpret
= \ _ (InlineCommand _ attrs contents) -> return $ Span attrs contents
}
@@ -46,7 +45,7 @@ spanInterp = InlineCommandInterpreter {
divInterp :: Interpreter
divInterp = BlockCommandInterpreter {
- bciName = "div"
+ bciName = "div"
, bciInterpret
= \ _ (BlockCommand _ attrs contents)
-> return $ Div attrs (map Block contents)
@@ -55,16 +54,16 @@ divInterp = BlockCommandInterpreter {
pageNameInterp :: Interpreter
pageNameInterp = InlineCommandInterpreter {
- iciName = "pageName"
+ iciName = "pageName"
, iciInterpret
- = \ ctx _ -> return $ Text (ctxPageName ctx)
+ = \ ctx _ -> return $ Text (fromMaybe "" $ ctxPageName ctx)
}
otherLangsInterp :: Interpreter
otherLangsInterp
= BlockCommandInterpreter {
- bciName = "inOtherLanguages"
+ bciName = "inOtherLanguages"
, bciInterpret
= \ ctx _ ->
let linkTable = case ctxMainPage ctx of
@@ -94,7 +93,7 @@ otherLangsInterp
(langName, name) : mergeTables m xs
mkLangList :: [(LanguageName, PageName)] -> BlockElement
- mkLangList xs = List Bullet (map mkLangLink xs)
+ mkLangList = List Bullet . map mkLangLink
mkLangLink :: (LanguageName, PageName) -> ListItem
mkLangLink (langName, name)
@@ -103,48 +102,93 @@ otherLangsInterp
--
+-- onclick="Rakka.newPage()"
+-- class="newButton controls" />
newPageInterp :: Interpreter
newPageInterp
= InlineCommandInterpreter {
- iciName = "newPage"
+ iciName = "newPage"
, iciInterpret
- = \ ctx (InlineCommand _ args _) ->
- do BaseURI baseURI <- getSysConf (ctxSysConf ctx)
-
- let label = fromMaybe "Create new page" (lookup "label" args)
- uri = uriToString id baseURI ""
- attrs = [ ("type" , "button")
- , ("value" , label)
- , ("onclick", "Rakka.newPage(\"" ++ uri ++ "\")")
- , ("class" , "newButton")
- ]
-
- return (Input attrs)
+ = \ _ (InlineCommand _ args _) ->
+ let label = fromMaybe "Create new page" (lookup "label" args)
+ attrs = [ ("type" , "button")
+ , ("value" , label)
+ , ("onclick", "Rakka.newPage()")
+ , ("class" , "newButton controls")
+ ]
+ in
+ return (Input attrs)
}
--
+-- onclick="Rakka.editPage(\"Foo\")"
+-- class="editButton controls" />
editPageInterp :: Interpreter
editPageInterp
= InlineCommandInterpreter {
- iciName = "editPage"
+ iciName = "editPage"
, iciInterpret
= \ ctx (InlineCommand _ args _) ->
- do BaseURI baseURI <- getSysConf (ctxSysConf ctx)
-
- let name = fromMaybe (ctxPageName ctx) (lookup "page" args)
- label = fromMaybe "Edit this page" (lookup "label" args)
- uri = uriToString id baseURI ""
- attrs = [ ("type" , "button")
- , ("value" , label)
- , ("onclick", "Rakka.editPage(\"" ++ uri ++ "\", \"" ++ name ++ "\")")
- , ("class" , "editButton")
- ]
-
- return (Input attrs)
+ let name = fromMaybe (fromMaybe "" $ ctxPageName ctx) (lookup "page" args)
+ label = fromMaybe "Edit this page" (lookup "label" args)
+ attrs = [ ("type" , "button")
+ , ("value" , label)
+ , ("onclick", "Rakka.editPage(\"" ++ name ++ "\")")
+ , ("class" , "editButton controls")
+ ]
+ in
+ return (Input attrs)
+ }
+
+
+--
+loginInterp :: Interpreter
+loginInterp
+ = InlineCommandInterpreter {
+ iciName = "login"
+ , iciInterpret
+ = \ _ _ ->
+ let attrs = [ ("type" , "button")
+ , ("value", "Login")
+ , ("class", "loginButton controls")
+ ]
+ in
+ return (Input attrs)
+ }
+
+
+--
+searchFieldInterp :: Interpreter
+searchFieldInterp
+ = InlineCommandInterpreter {
+ iciName = "searchField"
+ , iciInterpret
+ = \ _ _ ->
+ let attrs = [ ("type" , "text")
+ , ("class", "searchField")
+ ]
+ in
+ return (Input attrs)
+ }
+
+--
+configurationInterp :: Interpreter
+configurationInterp
+ = InlineCommandInterpreter {
+ iciName = "configuration"
+ , iciInterpret
+ = \ _ _ ->
+ let attrs = [ ("type" , "button")
+ , ("value", "Configuration")
+ , ("class", "configButton controls")
+ ]
+ in
+ return (Input attrs)
}