diff options
author | Garren Smith <garren.smith@gmail.com> | 2014-01-13 11:09:19 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2014-01-13 11:09:19 +0200 |
commit | 3465b04d696c8d47f4a5ab9ef748bcc93f1c53d8 (patch) | |
tree | 04dbbe01267fd3cad3e664f88b8889fa400e32e7 | |
parent | 89810cce9837d52db4b6beae3206c7b36b6854df (diff) | |
download | couchdb-3465b04d696c8d47f4a5ab9ef748bcc93f1c53d8.tar.gz |
Rename mixins to utils, add app.host to urls
20 files changed, 98 insertions, 105 deletions
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js index b1d40ccd5..970d55bb9 100644 --- a/src/fauxton/app/addons/auth/resources.js +++ b/src/fauxton/app/addons/auth/resources.js @@ -47,7 +47,7 @@ function (app, FauxtonAPI) { }); Auth.Session = FauxtonAPI.Session.extend({ - url: '/_session', + url: app.host + '/_session', initialize: function (options) { if (!options) { options = {}; } @@ -155,7 +155,7 @@ function (app, FauxtonAPI) { return $.ajax({ cache: false, type: "POST", - url: "/_session", + url: app.host + "/_session", dataType: "json", data: {name: username, password: password} }).then(function () { @@ -168,7 +168,7 @@ function (app, FauxtonAPI) { return $.ajax({ type: "DELETE", - url: "/_session", + url: app.host + "/_session", dataType: "json", username : "_", password : "_" diff --git a/src/fauxton/app/addons/config/assets/less/config.less b/src/fauxton/app/addons/config/assets/less/config.less index 86d9bf17a..8495b6982 100644 --- a/src/fauxton/app/addons/config/assets/less/config.less +++ b/src/fauxton/app/addons/config/assets/less/config.less @@ -1,3 +1,47 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +.config-item { + height: 41px; + + .edit-button { + float: right; + .btn; + .btn-mini; + display:none; + } + + td:hover .edit-button { + display: block; + } + + .value-input { + width: 98%; + } + + #delete-value { + cursor: pointer; + } +} + +.button-margin { + margin-bottom: 15px; +} + +#add-section-modal { + width: 400px; +} + table.config { #config-trash { width: 5%; diff --git a/src/fauxton/app/addons/config/templates/item.html b/src/fauxton/app/addons/config/templates/item.html index 3e6e4eeb8..1c808b943 100644 --- a/src/fauxton/app/addons/config/templates/item.html +++ b/src/fauxton/app/addons/config/templates/item.html @@ -20,7 +20,7 @@ the License. <td> <%= option.name %> </td> <td> <div id="show-value"> - <%= option.value %> <button class="edit-button"> Edit </button> + <%= option.value %> <button class="edit-button btn-mini btn"> Edit </button> </div> <div id="edit-value-form" style="display:none"> <input class="value-input" type="text" value="<%= option.value %>" /> diff --git a/src/fauxton/assets/less/database.less b/src/fauxton/app/addons/databases/assets/less/databases.less index 377b136a8..3d86d8192 100644 --- a/src/fauxton/assets/less/database.less +++ b/src/fauxton/app/addons/databases/assets/less/databases.less @@ -13,6 +13,8 @@ /* =database ---------------------------------------------------------------------- */ +@import "../../../../../assets/less/bootstrap/variables.less"; +@import "../../../../../assets/less/bootstrap/mixins.less"; #db-tools { position: absolute; top: -7px; diff --git a/src/fauxton/app/addons/databases/base.js b/src/fauxton/app/addons/databases/base.js index 1a3dc66ef..ea1719cb3 100644 --- a/src/fauxton/app/addons/databases/base.js +++ b/src/fauxton/app/addons/databases/base.js @@ -28,7 +28,7 @@ function(app, FauxtonAPI, Databases, Views) { // Utility functions Databases.databaseUrl = function(database) { var name = _.isObject(database) ? database.id : database, - dbname = app.mixins.safeURLName(name); + dbname = app.utils.safeURLName(name); return ["/database/", dbname, "/_all_docs?limit=" + Databases.DocLimit].join(''); }; diff --git a/src/fauxton/app/addons/databases/resources.js b/src/fauxton/app/addons/databases/resources.js index b6d6536fd..35101547a 100644 --- a/src/fauxton/app/addons/databases/resources.js +++ b/src/fauxton/app/addons/databases/resources.js @@ -67,10 +67,10 @@ function(app, FauxtonAPI, Documents) { } }, safeName: function(){ - return app.mixins.safeURLName(this.get("name")); + return app.utils.safeURLName(this.get("name")); }, safeID: function() { - return app.mixins.safeURLName(this.id); + return app.utils.safeURLName(this.id); }, buildChanges: function (params) { this.changes = new Databases.Changes({ @@ -182,7 +182,7 @@ function(app, FauxtonAPI, Documents) { // TODO: pagination! return _.map(resp, function(database) { return { - id: app.mixins.safeURLName(database), + id: app.utils.safeURLName(database), name: database }; }); diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js index 80d64ed0c..006830544 100644 --- a/src/fauxton/app/addons/databases/views.js +++ b/src/fauxton/app/addons/databases/views.js @@ -29,7 +29,7 @@ function(app, Components, FauxtonAPI, Databases) { }, serialize: function() { return { - encoded: app.mixins.safeURLName(this.model.get("name")), + encoded: app.utils.safeURLName(this.model.get("name")), database: this.model, docLimit: Databases.DocLimit }; @@ -77,11 +77,11 @@ function(app, Components, FauxtonAPI, Databases) { dbname = selectedName; } - if (dbname && this.collection.where({"id":app.mixins.safeURLName(dbname)}).length > 0){ + if (dbname && this.collection.where({"id":app.utils.safeURLName(dbname)}).length > 0){ // TODO: switch to using a model, or Databases.databaseUrl() // Neither of which are in scope right now // var db = new Database.Model({id: dbname}); - var url = ["/database/", app.mixins.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join(''); + var url = ["/database/", app.utils.safeURLName(dbname), "/_all_docs?limit=" + Databases.DocLimit].join(''); FauxtonAPI.navigate(url); } else { FauxtonAPI.addNotification({ @@ -173,7 +173,7 @@ function(app, Components, FauxtonAPI, Databases) { type: "success", clear: true }); - var route = "#/database/" + app.mixins.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit; + var route = "#/database/" + app.utils.safeURLName(name) + "/_all_docs?limit=" + Databases.DocLimit; app.router.navigate(route, { trigger: true }); } ).error(function(xhr) { diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js index 5254302a7..5e10dedaf 100644 --- a/src/fauxton/app/addons/documents/resources.js +++ b/src/fauxton/app/addons/documents/resources.js @@ -27,7 +27,7 @@ function(app, FauxtonAPI) { if (context === "app") { return this.getDatabase().url("app") + "/" + this.safeID(); } else if (context === "web-index") { - return this.getDatabase().url("app") + "/" + app.mixins.safeURLName(this.id); + return this.getDatabase().url("app") + "/" + app.utils.safeURLName(this.id); } else if (context === "apiurl"){ return window.location.origin + "/" + this.getDatabase().safeID() + "/" + this.safeID(); } else { @@ -143,9 +143,9 @@ function(app, FauxtonAPI) { safeID: function() { if (this.isDdoc()){ var ddoc = this.id.replace(/^_design\//,""); - return "_design/"+app.mixins.safeURLName(ddoc); + return "_design/"+app.utils.safeURLName(ddoc); }else{ - return app.mixins.safeURLName(this.id); + return app.utils.safeURLName(this.id); } }, @@ -219,7 +219,7 @@ function(app, FauxtonAPI) { // json editor for docs, or into a ddoc specific page. safeID: function() { var ddoc = this.id.replace(/^_design\//,""); - return "_design/"+app.mixins.safeURLName(ddoc); + return "_design/"+app.utils.safeURLName(ddoc); } }); @@ -247,7 +247,7 @@ function(app, FauxtonAPI) { return this.docType() != "reduction"; }, safeID: function() { - return app.mixins.safeURLName(this.id); + return app.utils.safeURLName(this.id); }, prettyJSON: function() { @@ -423,8 +423,8 @@ function(app, FauxtonAPI) { } else if (context === "apiurl"){ startOfUrl = window.location.origin; } - var design = app.mixins.safeURLName(this.design), - view = app.mixins.safeURLName(this.view); + var design = app.utils.safeURLName(this.design), + view = app.utils.safeURLName(this.view); var url = [startOfUrl, this.database.safeID(), "_design", design, this.idxType, view]; return url.join("/") + query; diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js index d120feb1f..6786edfbc 100644 --- a/src/fauxton/app/addons/documents/routes.js +++ b/src/fauxton/app/addons/documents/routes.js @@ -92,7 +92,7 @@ function(app, FauxtonAPI, Documents, Databases) { doc.copy(newId).then(function () { doc.set({_id: newId}); docView.forceRender(); - FauxtonAPI.navigate('/database/' + database.safeID() + '/' + app.mixins.safeURLName(newId), {trigger: true}); + FauxtonAPI.navigate('/database/' + database.safeID() + '/' + app.utils.safeURLName(newId), {trigger: true}); FauxtonAPI.addNotification({ msg: "Document has been duplicated." }); @@ -259,7 +259,7 @@ function(app, FauxtonAPI, Documents, Databases) { ddocInfo: ddocInfo })); - this.sidebar.setSelectedTab(app.mixins.removeSpecialCharacters(ddoc) + '_' + app.mixins.removeSpecialCharacters(view)); + this.sidebar.setSelectedTab(app.utils.removeSpecialCharacters(ddoc) + '_' + app.utils.removeSpecialCharacters(view)); this.crumbs = function () { return [ diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js index 97d58e3e0..80c0d8700 100644 --- a/src/fauxton/app/addons/documents/views.js +++ b/src/fauxton/app/addons/documents/views.js @@ -241,7 +241,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum duplicate: function (event) { event.preventDefault(); var newId = this.$('#dup-id').val(), - encodedID = app.mixins.safeURLName(newId); + encodedID = app.utils.safeURLName(newId); this.hideModal(); FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID); @@ -423,11 +423,11 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum index: this.index, ddoc: this.ddoc, database: this.database, - index_clean: app.mixins.removeSpecialCharacters(this.index), - ddoc_clean: app.mixins.removeSpecialCharacters(this.ddoc), - index_encoded: app.mixins.safeURLName(this.index), - ddoc_encoded: app.mixins.safeURLName(this.ddoc), - database_encoded: app.mixins.safeURLName(this.database), + index_clean: app.utils.removeSpecialCharacters(this.index), + ddoc_clean: app.utils.removeSpecialCharacters(this.ddoc), + index_encoded: app.utils.safeURLName(this.index), + ddoc_encoded: app.utils.safeURLName(this.ddoc), + database_encoded: app.utils.safeURLName(this.database), selected: this.selected }; }, @@ -470,7 +470,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum } return { - database: app.mixins.safeURLName(this.collection.database.id), + database: app.utils.safeURLName(this.collection.database.id), updateSeq: updateSeq, offset: recordStart, totalRows: totalRows, @@ -1365,7 +1365,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum }); if (that.newView) { - var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.mixins.safeURLName(viewName); + var fragment = '/database/' + that.database.safeID() +'/' + ddoc.safeID() + '/_view/' + app.utils.safeURLName(viewName); FauxtonAPI.navigate(fragment, {trigger: false}); that.newView = false; @@ -1375,7 +1375,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum that.showIndex = true; that.render(); FauxtonAPI.triggerRouteEvent('reloadDesignDocs', { - selectedTab: app.mixins.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.mixins.removeSpecialCharacters(viewName) + selectedTab: app.utils.removeSpecialCharacters(ddocName.replace(/_design\//,'')) + '_' + app.utils.removeSpecialCharacters(viewName) }); } @@ -1675,7 +1675,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum jumpToDoc: function (event) { event.preventDefault(); var docId = this.$('#jump-to-doc-id').val().trim(); - FauxtonAPI.navigate('/database/' + app.mixins.safeURLName(this.database.id) +'/' + app.mixins.safeURLName(docId), {trigger: true}); + FauxtonAPI.navigate('/database/' + app.utils.safeURLName(this.database.id) +'/' + app.utils.safeURLName(docId), {trigger: true}); }, afterRender: function () { diff --git a/src/fauxton/assets/less/logs.less b/src/fauxton/app/addons/logs/assets/less/logs.less index e50f903f5..e50f903f5 100644 --- a/src/fauxton/assets/less/logs.less +++ b/src/fauxton/app/addons/logs/assets/less/logs.less diff --git a/src/fauxton/app/addons/permissions/resources.js b/src/fauxton/app/addons/permissions/resources.js index 66eaffd7b..8acaddd00 100644 --- a/src/fauxton/app/addons/permissions/resources.js +++ b/src/fauxton/app/addons/permissions/resources.js @@ -39,7 +39,7 @@ function (app, FauxtonAPI ) { }, url: function () { - return this.database.id + '/_security'; + return app.host + this.database.id + '/_security'; }, addItem: function (value, type, section) { diff --git a/src/fauxton/app/addons/verifyinstall/resources.js b/src/fauxton/app/addons/verifyinstall/resources.js index 8a98883f9..aa08997c2 100644 --- a/src/fauxton/app/addons/verifyinstall/resources.js +++ b/src/fauxton/app/addons/verifyinstall/resources.js @@ -130,7 +130,7 @@ function (app, FauxtonAPI, Databases, Documents) { setupReplicate: function () { return $.ajax({ - url: '/_replicate', + url: app.host + '/_replicate', contentType: 'application/json', type: 'POST', dataType: 'json', @@ -145,11 +145,6 @@ function (app, FauxtonAPI, Databases, Documents) { testReplicate: function () { var deferred = FauxtonAPI.Deferred(); - /*var dbReplicate = new Databases.Model({ - id: 'verifytestdb_replicate', - name: 'verifytestdb_replicate' - });*/ - var promise = dbReplicate.fetch(); promise.then(function () { diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js index c9d08bf94..f423ef512 100644 --- a/src/fauxton/app/api.js +++ b/src/fauxton/app/api.js @@ -132,7 +132,7 @@ function(app, Fauxton) { }); FauxtonAPI.Session = Backbone.Model.extend({ - url: '/_session', + url: app.host + '/_session', user: function () { var userCtx = this.get('userCtx'); diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js index 9ac5bc2d5..5325f77fe 100644 --- a/src/fauxton/app/app.js +++ b/src/fauxton/app/app.js @@ -21,7 +21,7 @@ define([ "bootstrap", "helpers", - "mixins", + "utils", // Modules "resizeColumns", @@ -31,7 +31,7 @@ define([ ], -function(app, $, _, Backbone, Bootstrap, Helpers, Mixins, resizeColumns) { +function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns) { // Make sure we have a console.log if (typeof console == "undefined") { @@ -43,7 +43,7 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Mixins, resizeColumns) { // Provide a global location to place configuration settings and module // creation also mix in Backbone.Events _.extend(app, Backbone.Events, { - mixins: Mixins, + utils: Utils, renderView: function(baseView, selector, view, options, callback) { baseView.setView(selector, new view(options)).render().then(callback); diff --git a/src/fauxton/app/helpers.js b/src/fauxton/app/helpers.js index 73a37caa0..d4836b909 100644 --- a/src/fauxton/app/helpers.js +++ b/src/fauxton/app/helpers.js @@ -48,7 +48,8 @@ function() { "_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" + "views": "http://docs.couchdb.org/en/latest/intro/overview.html#views", + "changes": "http://docs.couchdb.org/en/latest/api/database/changes.html?highlight=changes#post--db-_changes" }; Helpers.getDocUrl = function(docKey){ diff --git a/src/fauxton/app/resizeColumns.js b/src/fauxton/app/resizeColumns.js index 9cf7115c3..bb5076742 100644 --- a/src/fauxton/app/resizeColumns.js +++ b/src/fauxton/app/resizeColumns.js @@ -18,10 +18,10 @@ // "purely functional" helper system. define([ - "mixins" + "utils" ], -function(mixins) { +function(utils) { var Resize = function(options){ this.options = options; @@ -42,8 +42,8 @@ function(mixins) { var that = this; //add throttler :) this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this); - mixins.addWindowResize(this.lazyLayout,"animation"); - mixins.initWindowResize(); + utils.addWindowResize(this.lazyLayout,"animation"); + utils.initWindowResize(); this.onResizeHandler(); }, updateOptions:function(options){ @@ -52,7 +52,7 @@ function(mixins) { this.options.selectorElements = options.selectorElements || ".window-resizeable"; }, turnOff:function(){ - mixins.removeWindowResize("animation"); + utils.removeWindowResize("animation"); }, cleanupCallback: function(){ this.callback = null; diff --git a/src/fauxton/app/mixins.js b/src/fauxton/app/utils.js index 3679ec1ea..ded7dace4 100644 --- a/src/fauxton/app/mixins.js +++ b/src/fauxton/app/utils.js @@ -25,23 +25,23 @@ define([ function($, _ ) { - var mixins = {}; + var utils = {}; var onWindowResize = {}; - mixins.addWindowResize = function(fun, key){ + utils.addWindowResize = function(fun, key){ onWindowResize[key]=fun; // You shouldn't need to call it here. Just define it at startup and each time it will loop // through all the functions in the hash. //app.initWindowResize(); }; - mixins.removeWindowResize = function(key){ + utils.removeWindowResize = function(key){ delete onWindowResize[key]; - mixins.initWindowResize(); + utils.initWindowResize(); }; - mixins.initWindowResize = function(){ + utils.initWindowResize = function(){ //when calling this it should be overriding what was called previously window.onresize = function(e) { // could do this instead of the above for loop @@ -51,16 +51,16 @@ function($, _ ) { }; }; - mixins.removeSpecialCharacters = function(name){ + utils.removeSpecialCharacters = function(name){ return name.replace(/[^\w\s]/gi,""); }; - mixins.safeURLName = function(name){ + utils.safeURLName = function(name){ var testName = name || ""; var checkforBad = testName.match(/[\$\-/_,+-]/g); return (checkforBad !== null)?encodeURIComponent(name):name; }; - return mixins; + return utils; }); diff --git a/src/fauxton/assets/less/config.less b/src/fauxton/assets/less/config.less deleted file mode 100644 index fe0379628..000000000 --- a/src/fauxton/assets/less/config.less +++ /dev/null @@ -1,46 +0,0 @@ -/* Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -.config-item { - height: 41px; - - .edit-button { - float: right; - .btn; - .btn-mini; - display:none; - } - - td:hover .edit-button { - display: block; - } - - .value-input { - width: 98%; - } - - #delete-value { - cursor: pointer; - } -} - -.button-margin { - margin-bottom: 15px; -} - -#add-section-modal { - width: 400px; -} - - - diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less index 510c3c1d7..d41780a03 100644 --- a/src/fauxton/assets/less/fauxton.less +++ b/src/fauxton/assets/less/fauxton.less @@ -19,10 +19,7 @@ @import "bootstrap/bootstrap.less"; @import "bootstrap/mixins.less"; @import "variables.less"; -@import "config.less"; -@import "logs.less"; @import "prettyprint.less"; -@import "database.less"; @import "icons.less"; |