summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-02-22 07:31:26 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-02-22 07:31:26 +0000
commit1ebc2117452516f6ac6f4f458d7372bc710b79d2 (patch)
treee6dc0c62e64e29247e5c2cf18343690d01e1bc0c /share
parent4838c35db5f4d49181b22d72f4cb5697b89c8870 (diff)
Link to design docs that have ddoc.couchapp.index or index.html, from Futon database index.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@746644 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/index.html3
-rw-r--r--share/www/script/couch.js13
-rw-r--r--share/www/script/futon.browse.js11
-rw-r--r--share/www/script/jquery.couch.js32
-rw-r--r--share/www/style/layout.css4
5 files changed, 58 insertions, 5 deletions
diff --git a/share/www/index.html b/share/www/index.html
index 704033e6..e1de6a2c 100644
--- a/share/www/index.html
+++ b/share/www/index.html
@@ -63,6 +63,7 @@ specific language governing permissions and limitations under the License.
<tr>
<th>Name</th>
<th class="size">Size</th>
+ <th class="apps">Applications</th>
<th class="count">Number of Documents</th>
<th class="seq">Update Seq</th>
</tr>
@@ -71,7 +72,7 @@ specific language governing permissions and limitations under the License.
</tbody>
<tbody class="footer">
<tr>
- <td colspan="4">
+ <td colspan="5">
<div id="paging">
<a class="prev">← Previous Page</a> |
<label>Rows per page: <select id="perpage">
diff --git a/share/www/script/couch.js b/share/www/script/couch.js
index 21382dd0..3f4db334 100644
--- a/share/www/script/couch.js
+++ b/share/www/script/couch.js
@@ -177,6 +177,10 @@ function CouchDB(name, httpHeaders) {
CouchDB.maybeThrowError(this.last_req);
return JSON.parse(this.last_req.responseText);
}
+
+ this.designDocs = function() {
+ return this.allDocs({startkey:"_design", endkey:"_design0"});
+ };
this.allDocsBySeq = function(options,keys) {
var req = null;
@@ -263,6 +267,15 @@ CouchDB.allDbs = function() {
return JSON.parse(CouchDB.last_req.responseText);
}
+CouchDB.allDesignDocs = function() {
+ var ddocs = {}, dbs = CouchDB.allDbs();
+ for (var i=0; i < dbs.length; i++) {
+ var db = new CouchDB(dbs[i]);
+ ddocs[dbs[i]] = db.designDocs();
+ };
+ return ddocs;
+};
+
CouchDB.getVersion = function() {
CouchDB.last_req = CouchDB.request("GET", "/");
CouchDB.maybeThrowError(CouchDB.last_req);
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index 30cff66e..6a282da6 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -52,9 +52,16 @@
$("#databases tbody.content").append("<tr>" +
"<th><a href='database.html?" + encodeURIComponent(dbName) + "'>" +
dbName + "</a></th>" +
- "<td class='size'></td><td class='count'></td>" +
+ "<td class='size'></td><td class='apps'></td><td class='count'></td>" +
"<td class='seq'></td></tr>");
- $.couch.db(dbName).info({
+ var db = $.couch.db(dbName);
+ db.allApps({
+ eachApp : function(name, path) {
+ $("#databases tbody.content tr:eq(" + idx + ")")
+ .find("td.apps").append('<a href="'+path+'">'+name+'</a> ');
+ }
+ });
+ db.info({
success: function(info) {
$("#databases tbody.content tr:eq(" + idx + ")")
.find("td.size").text($.futon.formatSize(info.disk_size)).end()
diff --git a/share/www/script/jquery.couch.js b/share/www/script/jquery.couch.js
index b4566e3a..c912a4bd 100644
--- a/share/www/script/jquery.couch.js
+++ b/share/www/script/jquery.couch.js
@@ -173,6 +173,38 @@
}
});
},
+ allDesignDocs: function(options) {
+ options = options || {};
+ this.allDocs($.extend({startkey:"_design", endkey:"_design0"}, options));
+ },
+ allApps: function(options) {
+ options = options || {};
+ var self = this;
+ if (options.eachApp) {
+ this.allDesignDocs({
+ success: function(resp) {
+ $.each(resp.rows, function() {
+ self.openDoc(this.id, {
+ success: function(ddoc) {
+ var index, appPath, appName = ddoc._id.split('/');
+ appName.shift();
+ appName = appName.join('/');
+ index = ddoc.couchapp && ddoc.couchapp.index;
+ if (index) {
+ appPath = ['', name, index[0], appName, index[1]].join('/');
+ } else if (ddoc._attachments["index.html"]) {
+ appPath = ['', name, '_design', appName, "index.html"].join('/');
+ }
+ if (appPath) options.eachApp(appName, appPath, ddoc);
+ }
+ });
+ });
+ }
+ });
+ } else {
+ alert("please provide an eachApp function for allApps()");
+ }
+ },
openDoc: function(docId, options) {
options = options || {};
$.ajax({
diff --git a/share/www/style/layout.css b/share/www/style/layout.css
index 0971c2ee..c17c1942 100644
--- a/share/www/style/layout.css
+++ b/share/www/style/layout.css
@@ -336,8 +336,8 @@ ul.suggest-dropdown li.selected { cursor: pointer; background: Highlight;
/* Database table */
-#databases thead th.size, #databases thead th.count, #databases thead th.seq,
-#databases tbody td.size, #databases tbody td.count, #databases tbody td.seq {
+#databases thead th.apps, #databases thead th.size, #databases thead th.count, #databases thead th.seq,
+#databases thead th.apps, #databases tbody td.size, #databases tbody td.count, #databases tbody td.seq {
text-align: right;
}