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)
}
-Rakka.editPage = function (baseURI, pageName) {
+Rakka.editPage = function (pageName) {
var $area = Rakka.switchScreen();
Rakka.displayWaitingMessage("Loading... please wait.");
// XML 版のページを取得する。
$.ajax({
- url : baseURI + pageName + ".xml",
+ url : Rakka.baseURI + pageName + ".xml",
success: function (pageXml) {
Rakka.hideWaitingMessage();
= $page.attr("redirect") != null ? $page.attr("redirect")
: $page.find("textData").text()
;
- Rakka.displayPageEditor(baseURI, pageName, oldRevision, defaultType, source);
+ Rakka.displayPageEditor(pageName, oldRevision, defaultType, source);
},
error : function (req) {
Rakka.hideWaitingMessage();
if (req.status == 404) {
- Rakka.displayPageEditor(baseURI, pageName, null, "rakka", null);
+ Rakka.displayPageEditor(pageName, null, "rakka", null);
}
else {
$area.text("Error: " + req.status + " " + req.statusText);
});
};
-Rakka.newPage = function (baseURI) {
- Rakka.displayPageEditor(baseURI, "", null, "rakka", null);
+Rakka.newPage = function () {
+ Rakka.displayPageEditor("", null, "rakka", null);
};
-Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, source) {
+Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) {
var $area = Rakka.switchScreen();
$area.empty();
$(btnSubmit).click(function () {
if (btnTypeRakka.checked) {
Rakka.submitTextPage(
- baseURI,
pageName,
oldRevision,
fldPageName.value,
}
else if (btnTypeCSS.checked) {
Rakka.submitTextPage(
- baseURI,
pageName,
oldRevision,
fldPageName.value,
}
else if (btnTypeBinary.checked) {
Rakka.submitBinaryPage(
- baseURI,
pageName,
oldRevision,
fldPageName.value,
}
else if (btnTypeRedirect.checked) {
Rakka.submitRedirection(
- baseURI,
pageName,
oldRevision,
fldPageName.value,
$area.append(pageEditor);
};
-Rakka.submitTextPage = function (baseURI, pageName, oldRevision, givenPageName, mimeType, text) {
+Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, text) {
var doc = document.implementation.createDocument(
"http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
Rakka.displayWaitingMessage("Submitting... please wait.");
- var url = baseURI + encodeURI(givenPageName);
+ var url = Rakka.baseURI + encodeURI(givenPageName);
$.ajax({
type : "PUT",
url : url,
});
};
-Rakka.submitRedirection = function (baseURI, pageName, oldRevision, givenPageName, destination) {
+Rakka.submitRedirection = function (pageName, oldRevision, givenPageName, destination) {
var doc = document.implementation.createDocument(
"http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
Rakka.displayWaitingMessage("Submitting... please wait.");
- var url = baseURI + encodeURI(givenPageName);
+ var url = Rakka.baseURI + encodeURI(givenPageName);
$.ajax({
type : "PUT",
url : url,