]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
implemented summary editor
authorpho <pho@cielonegro.org>
Tue, 8 Jan 2008 03:26:53 +0000 (12:26 +0900)
committerpho <pho@cielonegro.org>
Tue, 8 Jan 2008 03:26:53 +0000 (12:26 +0900)
darcs-hash:20080108032653-62b54-c48c1ff74a8b877ae8dd41fd8664f8488ab71c15.gz

Rakka/Resource.hs
defaultPages/StyleSheet/Default.xml
js/editPage.js

index 21acb4b02c16e74faea015adf5ea9743618bf8c5..8448ea11d137d53dae3866bdd4ea9f11994602ba 100644 (file)
@@ -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)
index af1cc9759232e0a96f35d8cb11c2aa6c6f5088f6..9ecbbce64504243d72495e1e4c2072cd27d29188 100644 (file)
@@ -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"] {
index 959d0889c72d5310df4c3fd3b68404331d099f7c..766d2e92383348749c008cff4c2ba4eee043c1ad 100644 (file)
@@ -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);