From 0447be1b59496ca4266226ed52d264009cf41899 Mon Sep 17 00:00:00 2001 From: pho Date: Fri, 18 Jan 2008 18:55:45 +0900 Subject: [PATCH] improvements of page locking darcs-hash:20080118095545-62b54-9ebca7f4e7d5eca0bd7537eaeb97a8a90645b93c.gz --- Rakka/Page.hs | 8 +++++-- Rakka/Storage/Repos.hs | 6 ++++- Rakka/Wiki/Engine.hs | 2 ++ defaultPages/StyleSheet/Default.xml | 3 +++ js/Makefile | 2 +- js/editPage.js | 37 +++++++++++++++++++++++------ schemas/rakka-page-1.0.rng | 20 ++++++++-------- 7 files changed, 57 insertions(+), 21 deletions(-) diff --git a/Rakka/Page.hs b/Rakka/Page.hs index 0affbf5..16835d5 100644 --- a/Rakka/Page.hs +++ b/Rakka/Page.hs @@ -60,6 +60,7 @@ data Page = Redirection { redirName :: !PageName , redirDest :: !PageName + , redirIsLocked :: !Bool , redirRevision :: RevNum , redirLastMod :: UTCTime , redirUpdateInfo :: Maybe UpdateInfo @@ -91,8 +92,8 @@ data UpdateInfo isRedirect :: Page -> Bool -isRedirect (Redirection _ _ _ _ _) = True -isRedirect _ = False +isRedirect (Redirection _ _ _ _ _ _) = True +isRedirect _ = False isEntity :: Page -> Bool @@ -297,11 +298,14 @@ parseXmlizedPage = proc (name, tree) -> do updateInfo <- maybeA parseUpdateInfo -< tree redirect <- maybeA (getXPathTreesInDoc "/page/@redirect/text()" >>> getText) -< tree + isLocked <- (withDefault (getXPathTreesInDoc "/page/@isLocked/text()" >>> getText) "no" + >>> parseYesOrNo) -< tree case redirect of Nothing -> parseEntity -< (name, tree) Just dest -> returnA -< (Redirection { redirName = name , redirDest = dest + , redirIsLocked = isLocked , redirRevision = undefined , redirLastMod = undefined , redirUpdateInfo = updateInfo diff --git a/Rakka/Storage/Repos.hs b/Rakka/Storage/Repos.hs index 8430068..e1f4b8e 100644 --- a/Rakka/Storage/Repos.hs +++ b/Rakka/Storage/Repos.hs @@ -158,9 +158,13 @@ loadPageInRepository repos name rev lastMod <- getRevisionProp "svn:date" >>= return . fromJust . parseW3CDateTime . chomp . fromJust + isLocked <- getRevisionProp "rakka:isLocked" + >>= return . isJust + return Redirection { redirName = name , redirDest = dest + , redirIsLocked = isLocked , redirRevision = pageRev , redirLastMod = zonedTimeToUTC lastMod , redirUpdateInfo = undefined @@ -244,7 +248,7 @@ putPageIntoRepository repos userID page setNodeProp path "rakka:lang" Nothing setNodeProp path "rakka:isTheme" Nothing setNodeProp path "rakka:isFeed" Nothing - setNodeProp path "rakka:isLocked" Nothing + setNodeProp path "rakka:isLocked" (encodeFlag $ redirIsLocked page) setNodeProp path "rakka:isBinary" Nothing setNodeProp path "rakka:summary" Nothing setNodeProp path "rakka:otherLang" Nothing diff --git a/Rakka/Wiki/Engine.hs b/Rakka/Wiki/Engine.hs index 21bdad1..910ef15 100644 --- a/Rakka/Wiki/Engine.hs +++ b/Rakka/Wiki/Engine.hs @@ -318,6 +318,7 @@ makeDraft interpTable pName <- getXPathTreesInDoc "/page/@name/text()" >>> getText -< tree pRedir <- getXPathTreesInDoc "/page/@redirect/text()" >>> getText -< tree + pIsLocked <- getXPathTreesInDoc "/page/@isLocked/text()" >>> getText -< tree pRevision <- getXPathTreesInDoc "/page/@revision/text()" >>> getText -< tree pLastMod <- getXPathTreesInDoc "/page/@lastModified/text()" >>> getText -< tree @@ -325,6 +326,7 @@ makeDraft interpTable arrIO2 (flip setAttribute "@title" ) -< (doc, Just pName) arrIO2 (flip setAttribute "@type" ) -< (doc, Just "application/x-rakka-redirection") arrIO2 (flip setAttribute "@mdate" ) -< (doc, Just pLastMod) + arrIO2 (flip setAttribute "rakka:isLocked") -< (doc, Just pIsLocked) arrIO2 (flip setAttribute "rakka:revision") -< (doc, Just pRevision) -- リダイレクト先ページ名はテキストとして入れる diff --git a/defaultPages/StyleSheet/Default.xml b/defaultPages/StyleSheet/Default.xml index d235975..87515bd 100644 --- a/defaultPages/StyleSheet/Default.xml +++ b/defaultPages/StyleSheet/Default.xml @@ -175,6 +175,9 @@ table.pageEditor { .pageEditor input[type="radio"] { margin-right: 10px; } +.pageEditor input[type="checkbox"] { + margin-right: 5px; +} .pageEditor input[type="text"], .pageEditor input[type="file"], .pageEditor textarea { diff --git a/js/Makefile b/js/Makefile index b318275..f8f2f28 100644 --- a/js/Makefile +++ b/js/Makefile @@ -1,5 +1,5 @@ JQUERY_SOURCE = jquery-1.2.2.js -COMPRESSOR = yuicompressor-2.2.4.jar +COMPRESSOR = yuicompressor-2.2.5.jar SOURCES = \ $(JQUERY_SOURCE) \ diff --git a/js/editPage.js b/js/editPage.js index d50e5b4..f0d3d50 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -25,19 +25,20 @@ : $page.attr("redirect") != null ? "redirect" : "unknown" ; + var isLocked = $page.attr("isLocked") == "yes"; var source = $page.attr("redirect") != null ? $page.attr("redirect") : $page.find("textData").text() ; var summary = $page.find("summary").text(); - displayPageEditor(pageName, oldRevision, defaultType, source, summary); + displayPageEditor(pageName, oldRevision, defaultType, isLocked, source, summary); }, error : function (req) { Rakka.hideWaitingMessage(); if (req.status == 404) { - displayPageEditor(pageName, null, "rakka", null, ""); + displayPageEditor(pageName, null, "rakka", false, null, ""); } else { $area.text("Error: " + req.status + " " + req.statusText); @@ -47,10 +48,10 @@ }; Rakka.newPage = function () { - displayPageEditor("", null, "rakka", null, ""); + displayPageEditor("", null, "rakka", false, null, ""); }; - var displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) { + var displayPageEditor = function (pageName, oldRevision, defaultType, isLocked, source, summary) { var $area = Rakka.switchScreen(); $previewHeader = $( $.H1({}, "Preview") ); @@ -72,6 +73,20 @@ $(fldPageName).change(makeDirty); + var chkIsLocked + = $.INPUT({type : "checkbox", + checked: (isLocked ? "checked" : "")}); + + $(chkIsLocked).change(makeDirty); + + var trIsLocked + = $.TR({}, + $.TH({}, "Page lock"), + $.TD({}, + $.LABEL({}, + chkIsLocked, + "Disallow anonymous users to edit or delete this page"))); + var btnTypeRakka = $.INPUT({type : "radio", name : "type", @@ -161,6 +176,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/x-rakka", fldSummary.value, fldRakkaSource.value); @@ -170,6 +186,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/css", fldSummary.value, fldCSSSource.value); @@ -179,6 +196,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldSummary.value, fldUploadFile.value); } @@ -187,6 +205,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldRedirect.value); } }); @@ -253,6 +272,7 @@ $.TH({}, "Page name"), $.TD({}, fldPageName) ), + trIsLocked, $.TR({}, $.TH({}, "Page type"), $.TD({}, @@ -365,7 +385,7 @@ Rakka.scrollToTopLeft(); }; - var submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) { + var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, summary, text) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -385,6 +405,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", mimeType); if (summary != null) { @@ -424,7 +445,7 @@ }); }; - var submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) { + var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, summary, path) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -444,6 +465,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", ""); if (summary != null) { @@ -486,7 +508,7 @@ }); }; - var submitRedirection = function (pageName, oldRevision, givenPageName, destination) { + var submitRedirection = function (pageName, oldRevision, givenPageName, isLocked, destination) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -506,6 +528,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("redirect", destination); Rakka.displayWaitingMessage("Submitting... please wait."); diff --git a/schemas/rakka-page-1.0.rng b/schemas/rakka-page-1.0.rng index 5505166..e344f0f 100644 --- a/schemas/rakka-page-1.0.rng +++ b/schemas/rakka-page-1.0.rng @@ -28,6 +28,16 @@ binaryData の場合のみ許される。 --> + + + + + yes + no + + + + @@ -68,16 +78,6 @@ - - - - - yes - no - - - - -- 2.40.0