From: pho Date: Tue, 8 Jan 2008 03:26:53 +0000 (+0900) Subject: implemented summary editor X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=commitdiff_plain;h=ed76b2142889f565bb226bd72c0ff862ff6e862a;p=Rakka.git implemented summary editor darcs-hash:20080108032653-62b54-c48c1ff74a8b877ae8dd41fd8664f8488ab71c15.gz --- diff --git a/Rakka/Resource.hs b/Rakka/Resource.hs index 21acb4b..8448ea1 100644 --- a/Rakka/Resource.hs +++ b/Rakka/Resource.hs @@ -15,6 +15,7 @@ import Network.HTTP.Lucu.Utils import Network.URI hiding (path) import Rakka.Environment import Rakka.Validation +import System.Log.Logger import Text.XML.HXT.Arrow.ReadDocument import Text.XML.HXT.Arrow.WriteDocument import Text.XML.HXT.Arrow.XmlIOStateArrow @@ -22,6 +23,10 @@ import Text.XML.HXT.DOM.TypeDefs import Text.XML.HXT.DOM.XmlKeywords +logger :: String +logger = "Rakka.Resource" + + -- "/" ==> "/" -- "/foo" ==> "/foo.html" -- "/foo/" ==> "/foo.html" @@ -101,6 +106,7 @@ getInputReader where getXmlReader = do req <- input defaultLimit + liftIO $ debugM logger req return $ readString [ (a_validate , v_0) , (a_check_namespaces , v_1) , (a_remove_whitespace, v_0) diff --git a/defaultPages/StyleSheet/Default.xml b/defaultPages/StyleSheet/Default.xml index af1cc97..9ecbbce 100644 --- a/defaultPages/StyleSheet/Default.xml +++ b/defaultPages/StyleSheet/Default.xml @@ -181,7 +181,10 @@ table.pageEditor { width: 97%; padding: 3px; } -.pageEditor textarea { +.pageEditor textarea.summary { + height: 5em; +} +.pageEditor textarea.source { height: 30em; } .pageEditor input[type="button"] { diff --git a/js/editPage.js b/js/editPage.js index 959d088..766d2e9 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -25,13 +25,15 @@ Rakka.editPage = function (pageName) { = $page.attr("redirect") != null ? $page.attr("redirect") : $page.find("textData").text() ; - Rakka.displayPageEditor(pageName, oldRevision, defaultType, source); + var summary = $page.find("summary").text(); + + Rakka.displayPageEditor(pageName, oldRevision, defaultType, source, summary); }, error : function (req) { Rakka.hideWaitingMessage(); if (req.status == 404) { - Rakka.displayPageEditor(pageName, null, "rakka", null); + Rakka.displayPageEditor(pageName, null, "rakka", null, ""); } else { $area.text("Error: " + req.status + " " + req.statusText); @@ -41,10 +43,10 @@ Rakka.editPage = function (pageName) { }; Rakka.newPage = function () { - Rakka.displayPageEditor("", null, "rakka", null); + Rakka.displayPageEditor("", null, "rakka", null, ""); }; -Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) { +Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) { var $area = Rakka.switchScreen(); $area.empty(); @@ -81,11 +83,21 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) name : "type", checked: (defaultType == "redirect" ? "checked" : "")}); + var fldSummary + = $.TEXTAREA({className: "summary"}, summary); + + var trSummary + = $.TR({}, + $.TH({}, "Summary"), + $.TD({}, fldSummary)); + var fldRakkaSource - = $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : "")); + = $.TEXTAREA({className: "source"}, + (defaultType == "rakka" && source != null ? source : "")); var fldCSSSource - = $.TEXTAREA({}, (defaultType == "css" && source != null ? source : "")); + = $.TEXTAREA({className: "source"}, + (defaultType == "css" && source != null ? source : "")); var fldUploadFile = $.INPUT({type: "file"}); @@ -123,6 +135,7 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) oldRevision, fldPageName.value, "text/x-rakka", + fldSummary.value, fldRakkaSource.value); } else if (btnTypeCSS.checked) { @@ -131,6 +144,7 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) oldRevision, fldPageName.value, "text/css", + fldSummary.value, fldCSSSource.value); } else if (btnTypeBinary.checked) { @@ -138,6 +152,7 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) pageName, oldRevision, fldPageName.value, + fldSummary.value, fldUploadFile.value); } else if (btnTypeRedirect.checked) { @@ -160,21 +175,25 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) var updateTRContent = function () { if (btnTypeRakka.checked) { + $(trSummary).show(); $(trContent).find("th").text("Wiki source"); $(trContent).find("td").empty().append(fldRakkaSource); $(btnPreview).show(); } else if (btnTypeCSS.checked) { + $(trSummary).show(); $(trContent).find("th").text("CSS source"); $(trContent).find("td").empty().append(fldCSSSource); $(btnPreview).hide(); } else if (btnTypeBinary.checked) { + $(trSummary).show(); $(trContent).find("th").text("File"); $(trContent).find("td").empty().append(fldUploadFile); $(btnPreview).show(); } else if (btnTypeRedirect.checked) { + $(trSummary).hide(); $(trContent).find("th").text("Destination Page"); $(trContent).find("td").empty().append(fldRedirect); $(btnPreview).hide(); @@ -224,6 +243,7 @@ Rakka.displayPageEditor = function (pageName, oldRevision, defaultType, source) ) ) ), + trSummary, trContent, $.TR({}, $.TH({}), @@ -300,7 +320,7 @@ Rakka.showPreview = function (doc) { } while (child = child.nextSibling); }; -Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, text) { +Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -322,6 +342,13 @@ Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, page.setAttribute("type", mimeType); + if (summary != null) { + var s = doc.createElement("summary"); + s.appendChild( + doc.createTextNode(summary)); + page.appendChild(s); + } + var textData = doc.createElement("textData"); textData.appendChild( doc.createTextNode(text)); @@ -349,7 +376,7 @@ Rakka.submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, }); }; -Rakka.submitBinaryPage = function (pageName, oldRevision, givenPageName, path) { +Rakka.submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -371,6 +398,13 @@ Rakka.submitBinaryPage = function (pageName, oldRevision, givenPageName, path) { page.setAttribute("type", ""); + if (summary != null) { + var s = doc.createElement("summary"); + s.appendChild( + doc.createTextNode(summary)); + page.appendChild(s); + } + var bin = Rakka.loadLocalBinaryFile(path); var b64 = Rakka.encodeBase64(bin);