]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Wiki/Interpreter/Base.hs
we can now create new pages
[Rakka.git] / Rakka / Wiki / Interpreter / Base.hs
index 70951e6884ab1d43936d0d830d35e41e3ac16a50..6feb92a77c82dcec77157cf3f0bff2929328a06f 100644 (file)
@@ -23,6 +23,7 @@ interpreters = [ lineBreakInterp
                , divInterp
                , pageNameInterp
                , otherLangsInterp
+               , newPageInterp
                , editPageInterp
                ]
 
@@ -100,6 +101,30 @@ otherLangsInterp
           = [Inline (PageLink (Just name) Nothing (Just langName))]
 
 
+-- <input type="button"
+--        value="Create new page"
+--        onclick="Rakka.newPage(\"http://example.org/\")"
+--        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)
+      }
+
+
 -- <input type="button"
 --        value="Edit"
 --        onclick="Rakka.editPage(\"http://example.org/\", \"Foo\")"