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
-- <input type="button"
-- value="Create new page"
--- onclick="Rakka.newPage(\"http://example.org/\")"
+-- onclick="Rakka.newPage()"
-- class="newButton" />
newPageInterp :: Interpreter
newPageInterp
= InlineCommandInterpreter {
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")
+ ]
+ in
+ return (Input attrs)
}
-- <input type="button"
-- value="Edit"
--- onclick="Rakka.editPage(\"http://example.org/\", \"Foo\")"
+-- onclick="Rakka.editPage(\"Foo\")"
-- class="editButton" />
editPageInterp :: Interpreter
editPageInterp
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 (ctxPageName ctx) (lookup "page" args)
+ label = fromMaybe "Edit this page" (lookup "label" args)
+ attrs = [ ("type" , "button")
+ , ("value" , label)
+ , ("onclick", "Rakka.editPage(\"" ++ name ++ "\")")
+ , ("class" , "editButton")
+ ]
+ in
+ return (Input attrs)
}