You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by de...@apache.org on 2013/10/10 19:41:07 UTC
git commit: updated refs/heads/master to 5a10e82
Updated Branches:
refs/heads/master dddd617db -> 5a10e8246
Api URL documentation fix.
Adding documentation to the models/collections
Hide API url if there is no url on that route
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5a10e824
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5a10e824
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5a10e824
Branch: refs/heads/master
Commit: 5a10e82461393b8ec628f220c40aa51bff8610b5
Parents: dddd617
Author: suelockwood <de...@gmail.com>
Authored: Thu Oct 10 11:37:38 2013 -0400
Committer: suelockwood <de...@gmail.com>
Committed: Thu Oct 10 13:40:17 2013 -0400
----------------------------------------------------------------------
src/fauxton/app/addons/activetasks/resources.js | 1 +
src/fauxton/app/addons/activetasks/routes.js | 8 +++---
src/fauxton/app/addons/config/resources.js | 5 ++--
src/fauxton/app/addons/config/routes.js | 2 +-
src/fauxton/app/addons/logs/resources.js | 2 ++
src/fauxton/app/addons/logs/routes.js | 2 +-
src/fauxton/app/addons/replication/resources.js | 1 +
src/fauxton/app/addons/replication/route.js | 3 ++-
src/fauxton/app/addons/stats/resources.js | 3 ++-
src/fauxton/app/addons/stats/routes.js | 4 ++-
src/fauxton/app/api.js | 6 ++++-
src/fauxton/app/helpers.js | 14 +++++++---
src/fauxton/app/modules/databases/resources.js | 8 +++++-
src/fauxton/app/modules/databases/routes.js | 2 +-
src/fauxton/app/modules/documents/resources.js | 27 ++++++++++++++------
src/fauxton/app/modules/documents/routes.js | 8 +++---
src/fauxton/app/modules/fauxton/base.js | 19 +++++++++++---
src/fauxton/app/templates/fauxton/api_bar.html | 2 +-
18 files changed, 82 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/activetasks/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js
index 6d892dd..5646eec 100644
--- a/src/fauxton/app/addons/activetasks/resources.js
+++ b/src/fauxton/app/addons/activetasks/resources.js
@@ -37,6 +37,7 @@ function (app, backbone, Fauxton) {
"indexer": "Indexer",
"view_compaction": "View Compaction"
},
+ documentation: "_active_tasks",
url: function () {
return app.host + '/_active_tasks';
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/activetasks/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/routes.js b/src/fauxton/app/addons/activetasks/routes.js
index 03ece47..e0454b7 100644
--- a/src/fauxton/app/addons/activetasks/routes.js
+++ b/src/fauxton/app/addons/activetasks/routes.js
@@ -30,23 +30,23 @@ function (app, FauxtonAPI, Activetasks, Views) {
{"name": "Active tasks", "link": "activetasks"}
],
apiUrl: function(){
- return app.host+"/_active_tasks";
+ return [this.newtasks.url(), this.newtasks.documentation];
},
roles: ["_admin"],
defaultView: function(id){
- var newtasks = new Activetasks.Tasks({
+ this.newtasks = new Activetasks.Tasks({
currentView: "all",
id:'activeTasks'
});
this.setView("#sidebar-content", new Views.TabMenu({
currentView: "all",
- model: newtasks
+ model: this.newtasks
}));
this.setView("#dashboard-content", new Views.DataSection({
- model: newtasks,
+ model: this.newtasks,
currentView: "all"
}));
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/config/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index db26bb7..14d2474 100644
--- a/src/fauxton/app/addons/config/resources.js
+++ b/src/fauxton/app/addons/config/resources.js
@@ -21,7 +21,8 @@ function (app, FauxtonAPI) {
Config.Model = Backbone.Model.extend({});
Config.OptionModel = Backbone.Model.extend({
-
+ documentation: "config",
+
url: function () {
return app.host + '/_config/' + this.get("section") + '/' + this.get("name");
},
@@ -49,7 +50,7 @@ function (app, FauxtonAPI) {
Config.Collection = Backbone.Collection.extend({
model: Config.Model,
-
+ documentation: "config",
url: function () {
return app.host + '/_config';
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/config/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
index f521c53..6af8157 100644
--- a/src/fauxton/app/addons/config/routes.js
+++ b/src/fauxton/app/addons/config/routes.js
@@ -37,7 +37,7 @@ function(app, FauxtonAPI, Config) {
],
apiUrl: function () {
- this.configs.url();
+ return [this.configs.url(), this.configs.documentation];
},
routes: {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/logs/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
index 072290b..3a47b92 100644
--- a/src/fauxton/app/addons/logs/resources.js
+++ b/src/fauxton/app/addons/logs/resources.js
@@ -51,6 +51,8 @@ function (app, FauxtonAPI, Backbone) {
initialize: function (options) {
this.params = {bytes: 5000};
},
+
+ documentation: "log",
url: function () {
query = "?" + $.param(this.params);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/logs/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js
index 7c498b0..5c937af 100644
--- a/src/fauxton/app/addons/logs/routes.js
+++ b/src/fauxton/app/addons/logs/routes.js
@@ -37,7 +37,7 @@ function(app, FauxtonAPI, Log) {
roles: ["_admin"],
apiUrl: function() {
- return this.logs.url();
+ return [this.logs.url(), this.logs.documentation];
},
initialize: function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/replication/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/resources.js b/src/fauxton/app/addons/replication/resources.js
index 38ae139..14f255a 100644
--- a/src/fauxton/app/addons/replication/resources.js
+++ b/src/fauxton/app/addons/replication/resources.js
@@ -59,6 +59,7 @@ function (app, FauxtonAPI, ActiveTasks) {
});
Replication.Replicate = Backbone.Model.extend({
+ documentation: "replication_doc",
url: function(){
return app.host + "/_replicate";
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/replication/route.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/replication/route.js b/src/fauxton/app/addons/replication/route.js
index 7ea318c..17368f8 100644
--- a/src/fauxton/app/addons/replication/route.js
+++ b/src/fauxton/app/addons/replication/route.js
@@ -26,7 +26,7 @@ function(app, FauxtonAPI, Replication, Views) {
},
selectedHeader: "Replication",
apiUrl: function() {
- return app.host+"/_replication";
+ return [this.replication.url(), this.replication.documentation];
},
crumbs: [
{"name": "Replicate changes from: ", "link": "replication"}
@@ -34,6 +34,7 @@ function(app, FauxtonAPI, Replication, Views) {
defaultView: function(dbname){
this.databases = new Replication.DBList({});
this.tasks = new Replication.Tasks({id: "ReplicationTasks"});
+ this.replication = new Replication.Replicate({});
this.setView("#dashboard-content", new Views.ReplicationForm({
selectedDB: dbname ||"",
collection: this.databases,
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/stats/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/resources.js b/src/fauxton/app/addons/stats/resources.js
index 94be6bb..a761e6b 100644
--- a/src/fauxton/app/addons/stats/resources.js
+++ b/src/fauxton/app/addons/stats/resources.js
@@ -23,7 +23,8 @@ function (app, FauxtonAPI, backbone, _, Fauxton) {
Stats.Collection = Backbone.Collection.extend({
model: Backbone.Model,
- url: "/_stats",
+ documentation: "stats",
+ url: app.host+"/_stats",
parse: function(resp) {
return _.flatten(_.map(resp, function(doc, key) {
return _.map(doc, function(v, k){
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/addons/stats/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/stats/routes.js b/src/fauxton/app/addons/stats/routes.js
index 2eeced4..971c111 100644
--- a/src/fauxton/app/addons/stats/routes.js
+++ b/src/fauxton/app/addons/stats/routes.js
@@ -52,7 +52,9 @@ function(app, FauxtonAPI, Stats) {
return [this.stats.fetch()];
},
- apiUrl: "_stats"
+ apiUrl: function(){
+ return [ this.stats.url, this.stats.documentation];
+ }
});
Stats.RouteObjects = [StatsRouteObject];
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 9c2b523..d9f66fe 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -363,7 +363,11 @@ function(app, Fauxton) {
});
});
- if (this.get('apiUrl')) masterLayout.apiBar.update(this.get('apiUrl'));
+ if (this.get('apiUrl')){
+ masterLayout.apiBar.update(this.get('apiUrl'));
+ } else {
+ masterLayout.apiBar.hide();
+ }
// Track that we've done a full initial render
this.renderedState = true;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/helpers.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
index a8e0698..73a37ca 100644
--- a/src/fauxton/app/helpers.js
+++ b/src/fauxton/app/helpers.js
@@ -35,18 +35,24 @@ function() {
// Get the URL for documentation, wiki, wherever we store it.
// update the URLs in documentation_urls.js
Helpers.docs = {
- "docs": "http://docs.couchdb.org/en/latest/index.html",
+ "docs": "http://docs.couchdb.org/en/latest/intro/api.html#documents",
+ "all_dbs": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=all_dbs#get--_all_dbs",
"replication_doc": "http://docs.couchdb.org/en/latest/replication/replicator.html#basics",
"design_doc": "http://docs.couchdb.org/en/latest/couchapp/ddocs.html#design-docs",
"view_functions": "http://docs.couchdb.org/en/latest/couchapp/ddocs.html#view-functions",
"map_functions": "http://docs.couchdb.org/en/latest/couchapp/ddocs.html#map-functions",
"reduce_functions": "http://docs.couchdb.org/en/latest/couchapp/ddocs.html#reduce-and-rereduce-functions",
"api_reference": "http://docs.couchdb.org/en/latest/http-api.html",
- "database_permission": "http://docs.couchdb.org/en/latest/api/database/security.html#db-security"
+ "database_permission": "http://docs.couchdb.org/en/latest/api/database/security.html#db-security",
+ "stats": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=stats#get--_stats",
+ "_active_tasks": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=stats#active-tasks",
+ "log": "http://docs.couchdb.org/en/latest/api/server/common.html?highlight=stats#log",
+ "config": "http://docs.couchdb.org/en/latest/config/index.html",
+ "views": "http://docs.couchdb.org/en/latest/intro/overview.html#views"
};
- Helpers.getDocUrl = function(doc){
- return Helpers.docs[doc] || '#';
+ Helpers.getDocUrl = function(docKey){
+ return Helpers.docs[docKey] || '#';
};
// File size pretty printing, taken from futon.format.js
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/modules/databases/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
index f613cdf..6678d49 100644
--- a/src/fauxton/app/modules/databases/resources.js
+++ b/src/fauxton/app/modules/databases/resources.js
@@ -29,6 +29,10 @@ function(app, FauxtonAPI, Documents) {
});
},
+ documentation: function(){
+ return "all_dbs";
+ },
+
buildAllDocs: function(params) {
this.allDocs = new Documents.AllDocs(null, {
database: this,
@@ -137,7 +141,9 @@ function(app, FauxtonAPI, Documents) {
// TODO: shared databases - read from the user doc
Databases.List = Backbone.Collection.extend({
model: Databases.Model,
-
+ documentation: function(){
+ return "all_dbs";
+ },
url: function() {
return app.host + "/_all_dbs";
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/modules/databases/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
index 1977264..ac50b4b 100644
--- a/src/fauxton/app/modules/databases/routes.js
+++ b/src/fauxton/app/modules/databases/routes.js
@@ -37,7 +37,7 @@ function(app, FauxtonAPI, Databases, Views) {
},
apiUrl: function() {
- return this.databases.url();
+ return [this.databases.url(), this.databases.documentation()];
},
selectedHeader: "Databases",
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/modules/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index bbacb0f..901ba83 100644
--- a/src/fauxton/app/modules/documents/resources.js
+++ b/src/fauxton/app/modules/documents/resources.js
@@ -21,7 +21,9 @@ function(app, FauxtonAPI) {
Documents.Doc = Backbone.Model.extend({
idAttribute: "_id",
-
+ documentation: function(){
+ return "docs";
+ },
url: function(context) {
if (context === "app") {
return this.getDatabase().url("app") + "/" + this.safeID();
@@ -191,7 +193,9 @@ function(app, FauxtonAPI) {
Documents.DdocInfo = Backbone.Model.extend({
idAttribute: "_id",
-
+ documentation: function(){
+ return "docs";
+ },
initialize: function (_attrs, options) {
this.database = options.database;
},
@@ -220,7 +224,9 @@ function(app, FauxtonAPI) {
return this.id.match(/^_design/) ? "design doc" : "doc";
},
-
+ documentation: function(){
+ return "docs";
+ },
url: function(context) {
if (!this.isEditable()) return false;
@@ -249,13 +255,15 @@ function(app, FauxtonAPI) {
});
return deferred.promise();
- },
+ }
});
Documents.AllDocs = Backbone.Collection.extend({
model: Documents.Doc,
-
+ documentation: function(){
+ return "docs";
+ },
initialize: function(_models, options) {
this.database = options.database;
this.params = options.params;
@@ -296,7 +304,6 @@ function(app, FauxtonAPI) {
delete this.params.startkey;
delete this.params.startkey_docid;
}
-
return this.url('app');
},
@@ -348,7 +355,9 @@ function(app, FauxtonAPI) {
Documents.IndexCollection = Backbone.Collection.extend({
model: Documents.ViewRow,
-
+ documentation: function(){
+ return "docs";
+ },
initialize: function(_models, options) {
this.database = options.database;
this.params = _.extend({limit: 20, reduce: false}, options.params);
@@ -491,7 +500,9 @@ function(app, FauxtonAPI) {
Documents.PouchIndexCollection = Backbone.Collection.extend({
model: Documents.ViewRow,
-
+ documentation: function(){
+ return "docs";
+ },
initialize: function(_models, options) {
this.database = options.database;
this.rows = options.rows;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/modules/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
index 7a75740..572bf1f 100644
--- a/src/fauxton/app/modules/documents/routes.js
+++ b/src/fauxton/app/modules/documents/routes.js
@@ -111,7 +111,7 @@ function(app, FauxtonAPI, Documents, Databases) {
},
apiUrl: function() {
- return this.doc.url();
+ return [this.doc.url(), this.doc.documentation()];
}
});
@@ -219,7 +219,7 @@ function(app, FauxtonAPI, Documents, Databases) {
{"name": this.data.database.id, "link": Databases.databaseUrl(this.data.database)}
];
- this.apiUrl = this.data.database.allDocs.url();
+ this.apiUrl = [this.data.database.allDocs.url(), this.data.database.allDocs.documentation() ];
},
viewFn: function (databaseName, ddoc, view) {
@@ -270,7 +270,7 @@ function(app, FauxtonAPI, Documents, Databases) {
];
};
- this.apiUrl = this.data.indexedDocs.url();
+ this.apiUrl = [this.data.indexedDocs.url(), "docs"];
},
newViewEditor: function () {
@@ -388,7 +388,7 @@ function(app, FauxtonAPI, Documents, Databases) {
},
apiUrl: function() {
- return this.database.changes.url();
+ return [this.database.changes.url(), this.database.changes.documentation()];
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/modules/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index a4b3a5e..f1d2f70 100644
--- a/src/fauxton/app/modules/fauxton/base.js
+++ b/src/fauxton/app/modules/fauxton/base.js
@@ -190,6 +190,8 @@ function(app, Backbone, resizeColumns) {
template: "templates/fauxton/api_bar",
endpoint: '_all_docs',
+ documentation: 'docs',
+
events: {
"click .api-url-btn" : "toggleAPIbar"
},
@@ -207,13 +209,22 @@ function(app, Backbone, resizeColumns) {
},
serialize: function() {
- return {endpoint: this.endpoint};
+ return {
+ endpoint: this.endpoint,
+ documentation: this.documentation
+ };
},
+ hide: function(){
+ $(this.el).addClass('hide');
+ },
+ show: function(){
+ $(this.el).removeClass('hide');
+ },
update: function(endpoint) {
- // Take endpoint and write it into the api bar.
- console.log('ApiBar endpoint: ' + endpoint);
- this.endpoint = endpoint;
+ this.show();
+ this.endpoint = endpoint[0];
+ this.documentation = endpoint[1];
this.render();
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5a10e824/src/fauxton/app/templates/fauxton/api_bar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/fauxton/api_bar.html b/src/fauxton/app/templates/fauxton/api_bar.html
index cbed3d5..1f03a2c 100644
--- a/src/fauxton/app/templates/fauxton/api_bar.html
+++ b/src/fauxton/app/templates/fauxton/api_bar.html
@@ -20,7 +20,7 @@ the License.
<div class="input-prepend input-append">
<span class="add-on">
API reference
- <a href="<%=getDocUrl('api_reference')%>" target="_blank">
+ <a href="<%=getDocUrl(documentation)%>" target="_blank">
<i class="icon-question-sign"></i>
</a>
</span>