summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsuelockwood <deathbearbrown@gmail.com>2013-10-10 11:37:38 -0400
committersuelockwood <deathbearbrown@gmail.com>2013-10-10 13:40:17 -0400
commit5a10e82461393b8ec628f220c40aa51bff8610b5 (patch)
tree18a8283260c6d5bec788502500e9fcf664131b39
parentdddd617db674f6083d2ddb9585154cbafb0d3cb9 (diff)
downloadcouchdb-5a10e82461393b8ec628f220c40aa51bff8610b5.tar.gz
Api URL documentation fix.
Adding documentation to the models/collections Hide API url if there is no url on that route
-rw-r--r--src/fauxton/app/addons/activetasks/resources.js1
-rw-r--r--src/fauxton/app/addons/activetasks/routes.js8
-rw-r--r--src/fauxton/app/addons/config/resources.js5
-rw-r--r--src/fauxton/app/addons/config/routes.js2
-rw-r--r--src/fauxton/app/addons/logs/resources.js2
-rw-r--r--src/fauxton/app/addons/logs/routes.js2
-rw-r--r--src/fauxton/app/addons/replication/resources.js1
-rw-r--r--src/fauxton/app/addons/replication/route.js3
-rw-r--r--src/fauxton/app/addons/stats/resources.js3
-rw-r--r--src/fauxton/app/addons/stats/routes.js4
-rw-r--r--src/fauxton/app/api.js6
-rw-r--r--src/fauxton/app/helpers.js14
-rw-r--r--src/fauxton/app/modules/databases/resources.js8
-rw-r--r--src/fauxton/app/modules/databases/routes.js2
-rw-r--r--src/fauxton/app/modules/documents/resources.js27
-rw-r--r--src/fauxton/app/modules/documents/routes.js8
-rw-r--r--src/fauxton/app/modules/fauxton/base.js19
-rw-r--r--src/fauxton/app/templates/fauxton/api_bar.html2
18 files changed, 82 insertions, 35 deletions
diff --git a/src/fauxton/app/addons/activetasks/resources.js b/src/fauxton/app/addons/activetasks/resources.js
index 6d892dd94..5646eeccb 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';
},
diff --git a/src/fauxton/app/addons/activetasks/routes.js b/src/fauxton/app/addons/activetasks/routes.js
index 03ece4781..e0454b7a4 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"
}));
}
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js
index db26bb7da..14d247469 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';
},
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
index f521c530d..6af81572f 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: {
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
index 072290ba6..3a47b9261 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);
diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js
index 7c498b06f..5c937af6e 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 () {
diff --git a/src/fauxton/app/addons/replication/resources.js b/src/fauxton/app/addons/replication/resources.js
index 38ae13988..14f255aac 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";
}
diff --git a/src/fauxton/app/addons/replication/route.js b/src/fauxton/app/addons/replication/route.js
index 7ea318c01..17368f889 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,
diff --git a/src/fauxton/app/addons/stats/resources.js b/src/fauxton/app/addons/stats/resources.js
index 94be6bbf0..a761e6be0 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){
diff --git a/src/fauxton/app/addons/stats/routes.js b/src/fauxton/app/addons/stats/routes.js
index 2eeced41e..971c11174 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];
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 9c2b523c0..d9f66fe76 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;
diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js
index a8e069815..73a37caa0 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
diff --git a/src/fauxton/app/modules/databases/resources.js b/src/fauxton/app/modules/databases/resources.js
index f613cdf47..6678d4912 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";
},
diff --git a/src/fauxton/app/modules/databases/routes.js b/src/fauxton/app/modules/databases/routes.js
index 19772642a..ac50b4bc8 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",
diff --git a/src/fauxton/app/modules/documents/resources.js b/src/fauxton/app/modules/documents/resources.js
index bbacb0f0d..901ba8396 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;
diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js
index 7a757404a..572bf1f71 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()];
}
});
diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js
index a4b3a5e82..f1d2f70d2 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();
}
diff --git a/src/fauxton/app/templates/fauxton/api_bar.html b/src/fauxton/app/templates/fauxton/api_bar.html
index cbed3d568..1f03a2c08 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>