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
, divInterp
, pageNameInterp
, otherLangsInterp
+ , editPageInterp
]
mkLangLink :: (LanguageName, PageName) -> ListItem
mkLangLink (langName, pageName)
- = [Inline (PageLink (Just pageName) Nothing (Just langName))]
\ No newline at end of file
+ = [Inline (PageLink (Just pageName) Nothing (Just langName))]
+
+
+-- <input type="button"
+-- value="Edit"
+-- onclick="Rakka.editPage(\"http://example.org/\", \"Foo\")"
+-- class="editButton" />
+editPageInterp :: Interpreter
+editPageInterp
+ = InlineCommandInterpreter {
+ iciName = "editPage"
+ , iciInterpret
+ = \ ctx (InlineCommand _ args _) ->
+ do BaseURI baseURI <- getSysConf (ctxSysConf ctx)
+
+ let pageName = 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 ++ "\", \"" ++ pageName ++ "\")")
+ , ("class" , "editButton")
+ ]
+
+ return (Input attrs)
+ }