From: pho Date: Mon, 29 Oct 2007 11:46:01 +0000 (+0900) Subject: Record before big change X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=ee28059eadd401e5f9256df590bbb7491f952685;p=Rakka.git Record before big change darcs-hash:20071029114601-62b54-77a7c718b52b4c9dfec4b1fc6bb0703bb1bc9f75.gz --- diff --git a/Rakka/Resource/Render.hs b/Rakka/Resource/Render.hs index c4c8da0..bcfd17f 100644 --- a/Rakka/Resource/Render.hs +++ b/Rakka/Resource/Render.hs @@ -255,11 +255,20 @@ notFoundToXHTML += txt " - " += getXPathTreesInDoc "/pageNotFound/@name/text()" ) - += ( eelem "link" + += ( getXPathTreesInDoc "/pageNotFound/styleSheets/styleSheet" + >>> + eelem "link" += sattr "rel" "stylesheet" += sattr "type" "text/css" += attr "href" - ( getXPathTreesInDoc "/pageNotFound/@styleSheet/text()" ) + ( getXPathTrees "/styleSheet/@src/text()" ) + ) + += ( getXPathTreesInDoc "/pageNotFound/scripts/script" + >>> + eelem "script" + += sattr "type" "text/javascript" + += attr "src" + ( getXPathTrees "/script/@src/text()" ) ) ) += ( eelem "body" diff --git a/defaultPages/StyleSheet/Default b/defaultPages/StyleSheet/Default index 71bbf99..5817106 100644 --- a/defaultPages/StyleSheet/Default +++ b/defaultPages/StyleSheet/Default @@ -151,6 +151,39 @@ padding: 0.2em 0 0 0; } +table.pageEditor { + width: 100%; +} +.pageEditor td, .pageEditor th { + padding: 3px; +} +.pageEditor th { + width: 6em; +} +.pageEditor ul { + list-style-type: none; + margin: 0; +} +.pageEditor li { + margin: 0; + padding: 3px; +} +.pageEditor input[type="radio"] { + margin-right: 10px; +} +.pageEditor input[type="text"], +.pageEditor input[type="file"], +.pageEditor textarea { + width: 97%; + padding: 3px; +} +.pageEditor textarea { + height: 30em; +} +.pageEditor input[type="button"] { + margin: 0 2px; +} + /* color and text *************************************************************/ * { font-family: sans-serif; @@ -175,6 +208,19 @@ hr { border-style: dashed; } +th, td { + border-color: #dddddd; + border-width: 1px; + border-style: solid; +} +th { + background-color: #eeeeee; + font-weight: bold; +} +td { + background-color: #fafafa; +} + .title { background-color: #fafafa; @@ -285,6 +331,16 @@ input[type="button"]:active { background-color: #e0e0e0; } +.pageEditor input[type="text"], +.pageEditor input[type="file"], +.pageEditor textarea { + border-color: #dddddd #fafafa #fafafa #dddddd; + border-width: 2px; + border-style: solid; + + background-color: white; +} + /* float **********************************************************************/ h1, h2, h3, h4, h5, h6 { clear: both; diff --git a/js/editPage.js b/js/editPage.js index 7e54fbb..5297e05 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -9,17 +9,17 @@ Rakka.editPage = function (baseURI, pageName) { success: function (pageXml) { var $page = $(pageXml).find("page"); var oldRevision = $page.attr("revision"); - var defaultAction = $page.attr("isBinary") == "yes" ? "uploadFile" - : $page.attr("type") == "text/x-rakka" ? "editAsWiki" - : $page.attr("type") == "text/css" ? "editAsCSS" + var defaultType = $page.attr("isBinary") == "yes" ? "binary" + : $page.attr("type") == "text/x-rakka" ? "rakka" + : $page.attr("type") == "text/css" ? "css" : "unknown" ; var source = $page.find("source").text(); - Rakka.displayPageEditor($body, pageName, oldRevision, defaultAction, source); + Rakka.displayPageEditor($body, pageName, oldRevision, defaultType, source); }, error : function (req) { if (req.status == 404) { - Rakka.displayPageEditor($body, pageName, null, "editAsWiki"); + Rakka.displayPageEditor($body, pageName, null, "rakka", null); } else { $body.text("Error: " + req.status + " " + req.statusText); @@ -28,74 +28,123 @@ Rakka.editPage = function (baseURI, pageName) { }); }; -Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultAction, source) { +Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultType, source) { $place.empty(); + $place.append($.H1({}, "Edit page")); + var fldPageName = $.INPUT({type : "text", value: pageName}); - var btnEditAsWiki + var btnTypeRakka = $.INPUT({type : "radio", - name : "action", - checked: (defaultAction == "editAsWiki" ? "checked" : "")}); + name : "type", + checked: (defaultType == "rakka" ? "checked" : "")}); - var btnEditAsCSS + var btnTypeCSS = $.INPUT({type : "radio", - name : "action", - checked: (defaultAction == "editAsCSS" ? "checked" : "")}); + name : "type", + checked: (defaultType == "css" ? "checked" : "")}); - var btnUploadFile + var btnTypeBinary = $.INPUT({type : "radio", - name : "action", - checked: (defaultAction == "uploadFile" ? "checked" : "")}); + name : "type", + checked: (defaultType == "binary" ? "checked" : "")}); + + + var fldRakkaSource + = $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : "")); + + var fldCSSSource + = $.TEXTAREA({}, (defaultType == "css" && source != null ? source : "")); + + var fldUploadFile + = $.INPUT({type: "file"}); + + var trContent + = $.TR({}, + $.TH({}), + $.TD({}) + ); + + var btnPreview + = $.INPUT({type: "button", value: "Preview page"}); + + var btnSubmit + = $.INPUT({type: "button", value: "Submit page"}); var btnDelete - = $.INPUT({type : "radio", - name : "action", - checked: ""}); + = $.INPUT({type: "button", value: "Delete this page"}); + + var updateTRContent = function () { + if (btnTypeRakka.checked) { + $(trContent).find("th").text("Wiki source"); + $(trContent).find("td").empty().append(fldRakkaSource); + $(trContent).show(); + } + else if (btnTypeCSS.checked) { + $(trContent).find("th").text("CSS source"); + $(trContent).find("td").empty().append(fldCSSSource); + $(trContent).show(); + } + else if (btnTypeBinary.checked) { + $(trContent).find("th").text("File"); + $(trContent).find("td").empty().append(fldUploadFile); + $(trContent).show(); + } + else { + $(trContent).hide(); + } + }; + $(btnTypeRakka ).change(updateTRContent); + $(btnTypeCSS ).change(updateTRContent); + $(btnTypeBinary).change(updateTRContent); + updateTRContent(); var pageEditor = $.TABLE({className: "pageEditor"}, $.TBODY({}, $.TR({}, - $.TH({}, "Name of the page"), + $.TH({}, "Page name"), $.TD({}, fldPageName) ), $.TR({}, - $.TH({}, "Action"), + $.TH({}, "Page type"), $.TD({}, $.UL({}, $.LI({}, $.LABEL({}, - btnEditAsWiki, - "Edit as a Wiki page" + btnTypeRakka, + "Wiki page" ) ), $.LI({}, $.LABEL({}, - btnEditAsCSS, - "Edit as a style sheet" + btnTypeCSS, + "Style sheet" ) ), $.LI({}, $.LABEL({}, - btnUploadFile, - "Upload a file" + btnTypeBinary, + "Binary file" ) - ), - (oldRevision != "" && oldRevision != 0 - ? $.LI({}, - $.LABEL({}, - btnDelete, - "Delete this page" - ) - ) - : []) + ) ) ) + ), + trContent, + $.TR({}, + $.TH({}), + $.TD({}, btnPreview, btnSubmit, btnDelete) ) ) ); + if (oldRevision == null || oldRevision == 0) { + // 削除不可 + $(btnDelete).hide(); + } + $place.append(pageEditor); };