]> gitweb @ CieloNegro.org - Rakka.git/commitdiff
Record before big change
authorpho <pho@cielonegro.org>
Mon, 29 Oct 2007 11:46:01 +0000 (20:46 +0900)
committerpho <pho@cielonegro.org>
Mon, 29 Oct 2007 11:46:01 +0000 (20:46 +0900)
darcs-hash:20071029114601-62b54-77a7c718b52b4c9dfec4b1fc6bb0703bb1bc9f75.gz

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

index c4c8da062c93bdac1358046946867330b9c06c12..bcfd17f209f48cb526a8252247fa07c3e47f11f2 100644 (file)
@@ -255,11 +255,20 @@ notFoundToXHTML
                      += txt " - "
                      += getXPathTreesInDoc "/pageNotFound/@name/text()"
                    )
-                += ( eelem "link"
+                += ( getXPathTreesInDoc "/pageNotFound/styleSheets/styleSheet"
+                     >>>
+                     eelem "link"
                      += sattr "rel"  "stylesheet"
                      += sattr "type" "text/css"
                      += attr "href"
-                            ( getXPathTreesInDoc "/pageNotFound/@styleSheet/text()" )
+                            ( getXPathTrees "/styleSheet/@src/text()" )
+                   )
+                += ( getXPathTreesInDoc "/pageNotFound/scripts/script"
+                     >>>
+                     eelem "script"
+                     += sattr "type" "text/javascript"
+                     += attr "src"
+                            ( getXPathTrees "/script/@src/text()" )
                    )
               )
            += ( eelem "body"
index 71bbf99e62d6350c9ce0165f7be77140f601d07f..5817106e6bbac83418ad9955ea3ebc5457325e43 100644 (file)
     padding: 0.2em 0 0 0;
 }
 
+table.pageEditor {
+    width: 100%;
+}
+.pageEditor td, .pageEditor th {
+    padding: 3px;
+}
+.pageEditor th {
+    width: 6em;
+}
+.pageEditor ul {
+    list-style-type: none;
+    margin: 0;
+}
+.pageEditor li {
+    margin: 0;
+    padding: 3px;
+}
+.pageEditor input[type="radio"] {
+    margin-right: 10px;
+}
+.pageEditor input[type="text"], 
+.pageEditor input[type="file"],
+.pageEditor textarea {
+    width: 97%;
+    padding: 3px;
+}
+.pageEditor textarea {
+    height: 30em;
+}
+.pageEditor input[type="button"] {
+    margin: 0 2px;
+}
+
 /* color and text *************************************************************/
 * {
     font-family: sans-serif;
@@ -175,6 +208,19 @@ hr {
     border-style: dashed;
 }
 
+th, td {
+    border-color: #dddddd;
+    border-width: 1px;
+    border-style: solid;
+}
+th {
+    background-color: #eeeeee;
+    font-weight: bold;
+}
+td {
+    background-color: #fafafa;
+}
+
 .title {
     background-color: #fafafa;
 
@@ -285,6 +331,16 @@ input[type="button"]:active {
     background-color: #e0e0e0;
 }
 
+.pageEditor input[type="text"],
+.pageEditor input[type="file"],
+.pageEditor textarea {
+    border-color: #dddddd #fafafa #fafafa #dddddd;
+    border-width: 2px;
+    border-style: solid;
+
+    background-color: white;
+}
+
 /* float **********************************************************************/
 h1, h2, h3, h4, h5, h6 {
     clear: both;
index 7e54fbbb75381e773848783a6408e7872070354a..5297e057726aee809148a390a8f6291c3f3ba286 100644 (file)
@@ -9,17 +9,17 @@ Rakka.editPage = function (baseURI, pageName) {
         success: function (pageXml) {
                      var $page         = $(pageXml).find("page");
                      var oldRevision   = $page.attr("revision");
-                     var defaultAction = $page.attr("isBinary") == "yes"          ? "uploadFile"
-                                       : $page.attr("type")     == "text/x-rakka" ? "editAsWiki"
-                                       : $page.attr("type")     == "text/css"     ? "editAsCSS"
+                     var defaultType   = $page.attr("isBinary") == "yes"          ? "binary"
+                                       : $page.attr("type")     == "text/x-rakka" ? "rakka"
+                                       : $page.attr("type")     == "text/css"     ? "css"
                                        :                                            "unknown"
                                        ;
                      var source        = $page.find("source").text();
-                     Rakka.displayPageEditor($body, pageName, oldRevision, defaultAction, source);
+                     Rakka.displayPageEditor($body, pageName, oldRevision, defaultType, source);
                  },
         error  : function (req) {
                      if (req.status == 404) {
-                         Rakka.displayPageEditor($body, pageName, null, "editAsWiki");
+                         Rakka.displayPageEditor($body, pageName, null, "rakka", null);
                      }
                      else {
                          $body.text("Error: " + req.status + " " + req.statusText);
@@ -28,74 +28,123 @@ Rakka.editPage = function (baseURI, pageName) {
         });
 };
 
-Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultAction, source) {
+Rakka.displayPageEditor = function ($place, pageName, oldRevision, defaultType, source) {
     $place.empty();
 
+    $place.append($.H1({}, "Edit page"));
+
     var fldPageName
       = $.INPUT({type : "text", value: pageName});
 
-    var btnEditAsWiki
+    var btnTypeRakka
       = $.INPUT({type   : "radio",
-                 name   : "action",
-                 checked: (defaultAction == "editAsWiki" ? "checked" : "")});
+                 name   : "type",
+                 checked: (defaultType == "rakka"  ? "checked" : "")});
 
-    var btnEditAsCSS
+    var btnTypeCSS
       = $.INPUT({type   : "radio",
-                 name   : "action",
-                 checked: (defaultAction == "editAsCSS"  ? "checked" : "")});
+                 name   : "type",
+                 checked: (defaultType == "css"    ? "checked" : "")});
 
-    var btnUploadFile
+    var btnTypeBinary
       = $.INPUT({type   : "radio",
-                 name   : "action",
-                 checked: (defaultAction == "uploadFile" ? "checked" : "")});
+                 name   : "type",
+                 checked: (defaultType == "binary" ? "checked" : "")});
+    
+
+    var fldRakkaSource
+      = $.TEXTAREA({}, (defaultType == "rakka" && source != null ? source : ""));
+
+    var fldCSSSource
+      = $.TEXTAREA({}, (defaultType == "css"   && source != null ? source : ""));
+
+    var fldUploadFile
+      = $.INPUT({type: "file"});
+
+    var trContent
+      = $.TR({}, 
+          $.TH({}),
+          $.TD({})
+        );
+
+    var btnPreview
+      = $.INPUT({type: "button", value: "Preview page"});
+
+    var btnSubmit
+      = $.INPUT({type: "button", value: "Submit page"});
 
     var btnDelete
-      = $.INPUT({type   : "radio",
-                 name   : "action",
-                 checked: ""});
+      = $.INPUT({type: "button", value: "Delete this page"});
+    
+    var updateTRContent = function () {
+        if (btnTypeRakka.checked) {
+            $(trContent).find("th").text("Wiki source");
+            $(trContent).find("td").empty().append(fldRakkaSource);
+            $(trContent).show();
+        }
+        else if (btnTypeCSS.checked) {
+            $(trContent).find("th").text("CSS source");
+            $(trContent).find("td").empty().append(fldCSSSource);
+            $(trContent).show();
+        }
+        else if (btnTypeBinary.checked) {
+            $(trContent).find("th").text("File");
+            $(trContent).find("td").empty().append(fldUploadFile);
+            $(trContent).show();
+        }
+        else {
+            $(trContent).hide();
+        }
+    };
+    $(btnTypeRakka ).change(updateTRContent);
+    $(btnTypeCSS   ).change(updateTRContent);
+    $(btnTypeBinary).change(updateTRContent);
+    updateTRContent();
 
     var pageEditor
       = $.TABLE({className: "pageEditor"},
           $.TBODY({},
             $.TR({},
-              $.TH({}, "Name of the page"),
+              $.TH({}, "Page name"),
               $.TD({}, fldPageName)
             ),
             $.TR({},
-              $.TH({}, "Action"),
+              $.TH({}, "Page type"),
               $.TD({},
                 $.UL({},
                   $.LI({},
                     $.LABEL({},
-                      btnEditAsWiki,
-                      "Edit as a Wiki page"
+                      btnTypeRakka,
+                      "Wiki page"
                     )
                   ),
                   $.LI({},
                     $.LABEL({},
-                      btnEditAsCSS,
-                      "Edit as a style sheet"
+                      btnTypeCSS,
+                      "Style sheet"
                     )
                   ),
                   $.LI({},
                     $.LABEL({},
-                      btnUploadFile,
-                      "Upload a file"
+                      btnTypeBinary,
+                      "Binary file"
                     )
-                  ),
-                  (oldRevision != "" && oldRevision != 0
-                     ? $.LI({},
-                         $.LABEL({},
-                           btnDelete,
-                           "Delete this page"
-                         )
-                       )
-                     : [])
+                  )
                 )
               )
+            ),
+            trContent,
+            $.TR({},
+              $.TH({}),
+              $.TD({}, btnPreview, btnSubmit, btnDelete)
             )
           )
         );
 
+    if (oldRevision == null || oldRevision == 0) {
+        // 削除不可
+        $(btnDelete).hide();
+    }
+
     $place.append(pageEditor);
 };