From: pho Date: Thu, 27 Dec 2007 09:55:48 +0000 (+0900) Subject: more redirection X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=commitdiff_plain;h=f53425414d1861f105a3063cdbb4bf96cdc755a2 more redirection darcs-hash:20071227095548-62b54-26db036975e4a3b4cdb688e39f31ee339ba913fc.gz --- diff --git a/Rakka/Resource/PageEntity.hs b/Rakka/Resource/PageEntity.hs index d84ddc7..b894088 100644 --- a/Rakka/Resource/PageEntity.hs +++ b/Rakka/Resource/PageEntity.hs @@ -155,6 +155,10 @@ entityToXHTML env += sattr "type" "text/javascript" += attr "src" (arr id >>> mkText) ) + += ( eelem "script" + += sattr "type" "text/javascript" + += txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";") + ) ) += ( eelem "body" += ( eelem "div" @@ -256,6 +260,10 @@ notFoundToXHTML env += sattr "type" "text/javascript" += attr "src" (arr id >>> mkText) ) + += ( eelem "script" + += sattr "type" "text/javascript" + += txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";") + ) ) += ( eelem "body" += ( eelem "div" diff --git a/Rakka/Wiki/Interpreter/Base.hs b/Rakka/Wiki/Interpreter/Base.hs index 6feb92a..6b883c3 100644 --- a/Rakka/Wiki/Interpreter/Base.hs +++ b/Rakka/Wiki/Interpreter/Base.hs @@ -8,7 +8,6 @@ import Control.Arrow.ListArrow 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 @@ -103,31 +102,28 @@ otherLangsInterp -- 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) } -- editPageInterp :: Interpreter editPageInterp @@ -135,16 +131,13 @@ 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) } diff --git a/js/base.js b/js/base.js index a1be768..78c08cd 100644 --- a/js/base.js +++ b/js/base.js @@ -1,2 +1,4 @@ /* Namespace Rakka */ var Rakka = {}; + +Rakka.baseURI = null; diff --git a/js/editPage.js b/js/editPage.js index ad17658..4623849 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -1,11 +1,11 @@ -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(); @@ -22,13 +22,13 @@ Rakka.editPage = function (baseURI, pageName) { = $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); @@ -37,11 +37,11 @@ Rakka.editPage = function (baseURI, pageName) { }); }; -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(); @@ -101,7 +101,6 @@ Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, $(btnSubmit).click(function () { if (btnTypeRakka.checked) { Rakka.submitTextPage( - baseURI, pageName, oldRevision, fldPageName.value, @@ -110,7 +109,6 @@ Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, } else if (btnTypeCSS.checked) { Rakka.submitTextPage( - baseURI, pageName, oldRevision, fldPageName.value, @@ -119,7 +117,6 @@ Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, } else if (btnTypeBinary.checked) { Rakka.submitBinaryPage( - baseURI, pageName, oldRevision, fldPageName.value, @@ -127,7 +124,6 @@ Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, } else if (btnTypeRedirect.checked) { Rakka.submitRedirection( - baseURI, pageName, oldRevision, fldPageName.value, @@ -224,7 +220,7 @@ Rakka.displayPageEditor = function (baseURI, pageName, oldRevision, defaultType, $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); @@ -254,7 +250,7 @@ Rakka.submitTextPage = function (baseURI, pageName, oldRevision, givenPageName, Rakka.displayWaitingMessage("Submitting... please wait."); - var url = baseURI + encodeURI(givenPageName); + var url = Rakka.baseURI + encodeURI(givenPageName); $.ajax({ type : "PUT", url : url, @@ -273,7 +269,7 @@ Rakka.submitTextPage = function (baseURI, pageName, oldRevision, givenPageName, }); }; -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); @@ -297,7 +293,7 @@ Rakka.submitRedirection = function (baseURI, pageName, oldRevision, givenPageNam Rakka.displayWaitingMessage("Submitting... please wait."); - var url = baseURI + encodeURI(givenPageName); + var url = Rakka.baseURI + encodeURI(givenPageName); $.ajax({ type : "PUT", url : url, diff --git a/js/redirection.js b/js/redirection.js index b379437..c865320 100644 --- a/js/redirection.js +++ b/js/redirection.js @@ -18,12 +18,12 @@ $(document).ready(function () { value: from, title: "Edit the page"}); $(editButton).click(function () { - alert("not implemented"); + Rakka.editPage(from); }); var box = $.P({className: "redirection"}, - "This page is redirected from ", editButton, "."); + "This page is redirected from", editButton); $("div.title").after(box); } diff --git a/js/screen.js b/js/screen.js index 0ac558b..2e5ff37 100644 --- a/js/screen.js +++ b/js/screen.js @@ -8,6 +8,8 @@ $("div.sideBar div.outline").hide(); + $("p.redirection").hide(); + $("div.body") .children() .hide() @@ -28,6 +30,8 @@ $("div.sideBar div.outline").show(); + $("p.redirection").show(); + $(switchedArea).remove(); switchedArea = null;