= $page.attr("isBinary") == "yes" ? "binary"
: $page.attr("type") == "text/x-rakka" ? "rakka"
: $page.attr("type") == "text/css" ? "css"
+ : $page.attr("redirect") != null ? "redirect"
: "unknown"
;
- var source = $page.find("textData").text();
+ var source
+ = $page.attr("redirect") != null ? $page.attr("redirect")
+ : $page.find("textData").text()
+ ;
Rakka.displayPageEditor(baseURI, pageName, oldRevision, defaultType, source);
},
error : function (req) {
var btnTypeRakka
= $.INPUT({type : "radio",
name : "type",
- checked: (defaultType == "rakka" ? "checked" : "")});
+ checked: (defaultType == "rakka" ? "checked" : "")});
var btnTypeCSS
= $.INPUT({type : "radio",
name : "type",
- checked: (defaultType == "css" ? "checked" : "")});
+ checked: (defaultType == "css" ? "checked" : "")});
var btnTypeBinary
= $.INPUT({type : "radio",
name : "type",
- checked: (defaultType == "binary" ? "checked" : "")});
-
+ checked: (defaultType == "binary" ? "checked" : "")});
+
+ var btnTypeRedirect
+ = $.INPUT({type : "radio",
+ name : "type",
+ checked: (defaultType == "redirect" ? "checked" : "")});
var fldRakkaSource
= $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : ""));
var fldUploadFile
= $.INPUT({type: "file"});
+ var fldRedirect
+ = $.INPUT({type: "text", value: (defaultType == "redirect" ? source : "")});
+
var trContent
= $.TR({},
$.TH({}),
fldPageName.value,
fldUploadFile.value);
}
+ else if (btnTypeRedirect.checked) {
+ Rakka.submitRedirection(
+ baseURI,
+ pageName,
+ oldRevision,
+ fldPageName.value,
+ fldRedirect.value);
+ }
});
var btnDelete
if (btnTypeRakka.checked) {
$(trContent).find("th").text("Wiki source");
$(trContent).find("td").empty().append(fldRakkaSource);
+ $(btnPreview).show();
}
else if (btnTypeCSS.checked) {
$(trContent).find("th").text("CSS source");
$(trContent).find("td").empty().append(fldCSSSource);
+ $(btnPreview).hide();
}
else if (btnTypeBinary.checked) {
$(trContent).find("th").text("File");
$(trContent).find("td").empty().append(fldUploadFile);
+ $(btnPreview).show();
+ }
+ else if (btnTypeRedirect.checked) {
+ $(trContent).find("th").text("Destination Page");
+ $(trContent).find("td").empty().append(fldRedirect);
+ $(btnPreview).hide();
}
};
- $(btnTypeRakka ).change(updateTRContent);
- $(btnTypeCSS ).change(updateTRContent);
- $(btnTypeBinary).change(updateTRContent);
+ $(btnTypeRakka ).change(updateTRContent);
+ $(btnTypeCSS ).change(updateTRContent);
+ $(btnTypeBinary ).change(updateTRContent);
+ $(btnTypeRedirect).change(updateTRContent);
updateTRContent();
var pageEditor
btnTypeBinary,
"Binary file"
)
+ ),
+ $.LI({},
+ $.LABEL({},
+ btnTypeRedirect,
+ "Redirection"
+ )
)
)
)
page.appendChild(updateInfo);
}
- if (0) {
- // redirection
- }
- else {
- page.setAttribute("type", mimeType);
+ page.setAttribute("type", mimeType);
- var textData = doc.createElement("textData");
- textData.appendChild(
- doc.createTextNode(text));
+ var textData = doc.createElement("textData");
+ textData.appendChild(
+ doc.createTextNode(text));
- page.appendChild(textData);
- }
+ page.appendChild(textData);
Rakka.displayWaitingMessage("Submitting... please wait.");
}
});
};
+
+Rakka.submitRedirection = function (baseURI, pageName, oldRevision, givenPageName, destination) {
+ var doc = document.implementation.createDocument(
+ "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null);
+
+ var page = doc.documentElement;
+
+ if (oldRevision != null) {
+ // ページ書換時
+ var updateInfo = doc.createElement("updateInfo");
+ updateInfo.setAttribute("oldRevision", oldRevision);
+
+ if (pageName != givenPageName) {
+ var move = doc.createElement("move");
+ move.setAttribute("from", pageName);
+ updateInfo.appendChild(move);
+ }
+
+ page.appendChild(updateInfo);
+ }
+
+ page.setAttribute("redirect", destination);
+
+ Rakka.displayWaitingMessage("Submitting... please wait.");
+
+ var url = baseURI + encodeURI(givenPageName);
+ $.ajax({
+ type : "PUT",
+ url : url,
+ contentType: "text/xml",
+ data : doc,
+ processData: false,
+ success : function () {
+ window.location.replace(url);
+ },
+ error : function (req) {
+ Rakka.hideWaitingMessage();
+
+ var $area = Rakka.switchScreen();
+ $area.text("Error: " + req.status + " " + req.statusText);
+ }
+ });
+};
\ No newline at end of file