]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
more redirection
authorpho <pho@cielonegro.org>
Thu, 27 Dec 2007 09:55:48 +0000 (18:55 +0900)
committerpho <pho@cielonegro.org>
Thu, 27 Dec 2007 09:55:48 +0000 (18:55 +0900)
darcs-hash:20071227095548-62b54-26db036975e4a3b4cdb688e39f31ee339ba913fc.gz

Rakka/Resource/PageEntity.hs
Rakka/Wiki/Interpreter/Base.hs
js/base.js
js/editPage.js
js/redirection.js
js/screen.js

index d84ddc7b6af0024b9792aafff1d1c835fb29ead6..b894088913f5b4d49a6b91d655fcc9a4cc91dbab 100644 (file)
@@ -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"
index 6feb92a77c82dcec77157cf3f0bff2929328a06f..6b883c376c270d68a2ecfaa00b112706bb358b66 100644 (file)
@@ -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
 
 -- <input type="button"
 --        value="Create new page"
---        onclick="Rakka.newPage(\"http://example.org/\")"
+--        onclick="Rakka.newPage()"
 --        class="newButton" />
 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)
       }
 
 
 -- <input type="button"
 --        value="Edit"
---        onclick="Rakka.editPage(\"http://example.org/\", \"Foo\")"
+--        onclick="Rakka.editPage(\"Foo\")"
 --        class="editButton" />
 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)
       }
index a1be7689de2c5ae2c27ad368ed92ae7bdf8630f0..78c08cdc5a5b2818a389d3f6cf2069d3b7c5779f 100644 (file)
@@ -1,2 +1,4 @@
 /* Namespace Rakka */
 var Rakka = {};
+
+Rakka.baseURI = null;
index ad1765891dfb9b3093f32377f2654c8836c56522..4623849dec6e35fde133d2e10be86ec79d962854 100644 (file)
@@ -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,
index b3794378c91a5c1a918c61e3f0756a17e40b70ff..c8653204d8b354218971b8994c29335f4efe6bf7 100644 (file)
@@ -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);
     }
index 0ac558b9f6da97e52bcf479f8f2c9e937f1a7efb..2e5ff37bcacdc2e4808d1e19a7c55f66e0e80fc0 100644 (file)
@@ -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;