You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2009/07/20 23:31:30 UTC

svn commit: r796027 - in /couchdb/trunk/share/www: database.html script/futon.browse.js

Author: cmlenz
Date: Mon Jul 20 21:31:30 2009
New Revision: 796027

URL: http://svn.apache.org/viewvc?rev=796027&view=rev
Log:
Make the view URL in Futon consistent with the URL for views in the HTTP interface (and thereby also avoid a redirect). Thanks to Volker Mische for the suggestion and patch. Closes COUCHDB-408.

Modified:
    couchdb/trunk/share/www/database.html
    couchdb/trunk/share/www/script/futon.browse.js

Modified: couchdb/trunk/share/www/database.html
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/database.html?rev=796027&r1=796026&r2=796027&view=diff
==============================================================================
--- couchdb/trunk/share/www/database.html [utf-8] (original)
+++ couchdb/trunk/share/www/database.html [utf-8] Mon Jul 20 21:31:30 2009
@@ -40,11 +40,6 @@
         if (page.redirecting) return;
         $("h1 strong").text(page.db.name);
         var viewPath = page.viewName || "_all_docs";
-        if (/^_design\//.test(viewPath)) {
-          var parts = viewPath.split("/");
-          parts.splice(2, 0, "_view");
-          viewPath = parts.join("/");
-        }
         if (viewPath != "_temp_view" && viewPath != "_design_docs") {
           $("h1 a.raw").attr("href", "/" + encodeURIComponent(page.db.name) +
             "/" + viewPath);
@@ -95,7 +90,7 @@
           var viewName = $(this).val();
           if (!viewName) $.cookies.remove(page.db.name + ".view");
           location.href = "?" + encodeURIComponent(page.db.name) +
-            (viewName ? "/" + encodeURIComponent(viewName)  : "");
+            (viewName ? "/" + viewName  : "");
         });
         $("#documents thead th.key").click(function() {
           $(this).toggleClass("desc");

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=796027&r1=796026&r2=796027&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Mon Jul 20 21:31:30 2009
@@ -104,7 +104,7 @@
         if (viewName) {
           this.redirecting = true;
           location.href = "database.html?" + encodeURIComponent(dbName) +
-            "/" + encodeDocId(viewName);
+            "/" + viewName;
         }
       }
       var db = $.couch.db(dbName);
@@ -258,9 +258,10 @@
                     .attr("label", doc._id.substr(8));
                   for (var name in doc.views) {
                     var option = $(document.createElement("option"))
-                      .attr("value", doc._id + "/" + name).text(name)
+                      .attr("value", encodeURIComponent(doc._id) + "/_view/" +
+                        encodeURIComponent(name)).text(name)
                       .appendTo(optGroup);
-                    if (doc._id + "/" + name == viewName) {
+                    if (doc._id + "/_view/" + name == viewName) {
                       option[0].selected = true;
                     }
                   }
@@ -283,7 +284,7 @@
         if (!page.storedViewCode) {
           var viewNameParts = viewName.split("/");
           var designDocId = viewNameParts[1];
-          var localViewName = viewNameParts[2];
+          var localViewName = viewNameParts[3];
           db.openDoc(["_design", designDocId].join("/"), {
             error: function(status, error, reason) {
               if (status == 404) {
@@ -332,7 +333,7 @@
         if (viewName && /^_design/.test(viewName)) {
           var viewNameParts = viewName.split("/");
           var designDocId = viewNameParts[1];
-          var localViewName = viewNameParts[2];
+          var localViewName = viewNameParts[3];
         } else {
           var designDocId = "", localViewName = "";
         }
@@ -407,7 +408,7 @@
                     page.isDirty = false;
                     location.href = "database.html?" + encodeURIComponent(dbName) +
                       "/" + encodeDocId(doc._id) +
-                      "/" + encodeURIComponent(data.name);
+                      "/_view/" + encodeURIComponent(data.name);
                   }
                 });
               }
@@ -428,7 +429,7 @@
       this.saveViewChanges = function() {
         var viewNameParts = viewName.split("/");
         var designDocId = viewNameParts[1];
-        var localViewName = viewNameParts[2];
+        var localViewName = viewNameParts[3];
         db.openDoc(["_design", designDocId].join("/"), {
           success: function(doc) {
             var numViews = 0;
@@ -635,7 +636,8 @@
             if (page.isDirty) {
               db.query(currentMapCode, currentReduceCode, page.viewLanguage, options);
             } else {
-              db.view(viewName.substr(8), options);
+              var viewParts = viewName.split('/');
+              db.view(viewParts[1] + "/" + viewParts[3], options);
             }
           }
         }