+ mergeTables m (x:xs) = let (langTag, name) = x
+ langName = fromMaybe langTag (M.lookup langTag m)
+ in
+ (langName, name) : mergeTables m xs
+
+ mkLangList :: [(LanguageName, PageName)] -> BlockElement
+ mkLangList xs = List Bullet (map mkLangLink xs)
+
+ mkLangLink :: (LanguageName, PageName) -> ListItem
+ mkLangLink (langName, name)
+ = [Inline (PageLink (Just name) Nothing (Just langName))]
+
+
+-- <input type="button"
+-- value="Create new page"
+-- onclick="Rakka.newPage()"
+-- class="newButton" />
+newPageInterp :: Interpreter
+newPageInterp
+ = InlineCommandInterpreter {
+ iciName = "newPage"
+ , iciInterpret
+ = \ _ (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(\"Foo\")"
+-- class="editButton" />
+editPageInterp :: Interpreter
+editPageInterp
+ = InlineCommandInterpreter {
+ iciName = "editPage"
+ , iciInterpret
+ = \ ctx (InlineCommand _ args _) ->
+ 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)
+ }
+
+
+-- <input type="button"
+-- value="Login"
+-- class="loginButton" />
+loginInterp :: Interpreter
+loginInterp
+ = InlineCommandInterpreter {
+ iciName = "login"
+ , iciInterpret
+ = \ _ _ ->
+ let attrs = [ ("type" , "button")
+ , ("value" , "Login")
+ , ("class" , "loginButton")
+ ]
+ in
+ return (Input attrs)
+ }
\ No newline at end of file