You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2014/01/20 14:28:41 UTC
[01/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Updated Branches:
refs/heads/fauxton-file-reorder 339329f0f -> 35d2ec190 (forced update)
Regex fix for creating (from duplicate) Design docs and deleting weirdly encoded docs what begin with _design
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/2e4d72bd
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/2e4d72bd
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/2e4d72bd
Branch: refs/heads/fauxton-file-reorder
Commit: 2e4d72bd66a5c0bf2e1779178ce9855870a9ffd5
Parents: 86b6a14
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 12:05:24 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 12:05:24 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/resources.js | 2 +-
src/fauxton/app/addons/documents/views.js | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/2e4d72bd/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 5e10ded..0fd99f1 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -56,7 +56,7 @@ function(app, FauxtonAPI) {
},
docType: function() {
- return this.id.match(/^_design/) ? "design doc" : "doc";
+ return this.id && this.id.match(/^_design\//) ? "design doc" : "doc";
},
isEditable: function() {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/2e4d72bd/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 94332a2..2502b58 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -242,7 +242,9 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
duplicate: function (event) {
event.preventDefault();
var newId = this.$('#dup-id').val(),
- encodedID = app.utils.safeURLName(newId);
+ isDDoc = newId.match(/^_design\//),
+ removeDDocID = newId.replace(/^_design\//,""),
+ encodedID = isDDoc? "_design/"+ app.utils.safeURLName(removeDDocID):app.utils.safeURLName(newId);
this.hideModal();
FauxtonAPI.triggerRouteEvent('duplicateDoc', encodedID);
[27/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Continue refactoring
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/5c735474
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/5c735474
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/5c735474
Branch: refs/heads/fauxton-file-reorder
Commit: 5c73547422ee3ecf61a656204265cc9a506bb89c
Parents: 5424100
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 14 17:35:39 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 20 10:08:06 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/fauxton/base.js | 29 +-
src/fauxton/app/addons/fauxton/components.js | 76 ++-
src/fauxton/app/addons/fauxton/resizeCoumns.js | 87 +++
src/fauxton/app/api.js | 593 --------------------
src/fauxton/app/app.js | 46 +-
src/fauxton/app/config.js | 3 +-
src/fauxton/app/core/api.js | 524 +++--------------
src/fauxton/app/core/base.js | 67 ++-
src/fauxton/app/core/couchdb.js | 78 ---
src/fauxton/app/core/couchdbSession.js | 80 +++
src/fauxton/app/core/resources.js | 2 +-
src/fauxton/app/main.js | 11 +-
src/fauxton/app/resizeColumns.js | 87 ---
src/fauxton/app/router.js | 4 +-
14 files changed, 433 insertions(+), 1254 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
index 1811e84..e2b8c5d 100644
--- a/src/fauxton/app/addons/fauxton/base.js
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -11,17 +11,11 @@
// the License.
define([
- "app",
- // Libs
- "backbone",
- "resizeColumns",
+ "api",
+ "addons/fauxton/resizeColumns"
],
-function(app, Backbone, resizeColumns) {
-
- //resizeAnimation
- app.resizeColumns = new resizeColumns({});
- app.resizeColumns.onResizeHandler();
+function(FauxtonAPI, resizeColumns) {
var Fauxton = {};
@@ -41,7 +35,9 @@ function(app, Backbone, resizeColumns) {
});
Fauxton.VersionInfo = Backbone.Model.extend({
- url: app.host
+ url: function () {
+ return FauxtonAPI.host;
+ }
});
// TODO: this View should extend from FauxtonApi.View.
@@ -76,6 +72,13 @@ function(app, Backbone, resizeColumns) {
bottomNavLinks: [],
footerNavLinks: [],
+ initialize: function () {
+ //resizeAnimation
+ this.resizeColumns = new resizeColumns({});
+ this.resizeColumns.onResizeHandler();
+
+ },
+
serialize: function() {
return {
navLinks: this.navLinks,
@@ -141,7 +144,7 @@ function(app, Backbone, resizeColumns) {
function toggleMenu(){
$selectorList.toggleClass('closeMenu');
menuOpen = $selectorList.hasClass('closeMenu');
- app.resizeColumns.onResizeHandler();
+ this.resizeColumns.onResizeHandler();
}
$('#primary-navbar').on("click", ".nav a", function(){
@@ -149,13 +152,13 @@ function(app, Backbone, resizeColumns) {
setTimeout(
function(){
$selectorList.addClass('closeMenu');
- app.resizeColumns.onResizeHandler();
+ this.resizeColumns.onResizeHandler();
},3000);
}
});
- app.resizeColumns.initialize();
+ this.resizeColumns.initialize();
},
beforeRender: function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index bc011e3..cafd69f 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -25,10 +25,11 @@ define([
// Libs
"api",
"ace_configuration",
+ "spin"
],
-function(app, FauxtonAPI, ace) {
- var Components = app.module();
+function(app, FauxtonAPI, ace, spin) {
+ var Components = FauxtonAPI.addon();
Components.Pagination = FauxtonAPI.View.extend({
template: "templates/fauxton/pagination",
@@ -347,6 +348,77 @@ function(app, FauxtonAPI, ace) {
});
+ //need to make this into a backbone view...
+ var routeObjectSpinner;
+ FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
+ if (!routeObject.disableLoader){
+ var opts = {
+ lines: 16, // The number of lines to draw
+ length: 8, // The length of each line
+ width: 4, // The line thickness
+ radius: 12, // The radius of the inner circle
+ color: '#333', // #rbg or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 10, // Afterglow percentage
+ shadow: false // Whether to render a shadow
+ };
+
+ if (!$('.spinner').length) {
+ $('<div class="spinner"></div>')
+ .appendTo('#app-container');
+ }
+
+ routeObjectSpinner = new Spinner(opts).spin();
+ $('.spinner').append(routeObjectSpinner.el);
+ }
+ });
+
+ var removeRouteObjectSpinner = function () {
+ if (routeObjectSpinner) {
+ routeObjectSpinner.stop();
+ $('.spinner').remove();
+ }
+ };
+
+ var removeViewSpinner = function () {
+ if (viewSpinner){
+ viewSpinner.stop();
+ $('.spinner').remove();
+ }
+ };
+
+ var viewSpinner;
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ removeRouteObjectSpinner();
+
+ if (!view.disableLoader){
+ var opts = {
+ lines: 16, // The number of lines to draw
+ length: 8, // The length of each line
+ width: 4, // The line thickness
+ radius: 12, // The radius of the inner circle
+ color: '#333', // #rbg or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 10, // Afterglow percentage
+ shadow: false // Whether to render a shadow
+ };
+
+ viewSpinner = new Spinner(opts).spin();
+ $('<div class="spinner"></div>')
+ .appendTo(selector)
+ .append(viewSpinner.el);
+ }
+ });
+
+ FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
+ removeViewSpinner();
+ });
+
+ FauxtonAPI.RouteObject.on('viewHasRendered', function () {
+ removeViewSpinner();
+ removeRouteObjectSpinner();
+ });
+
return Components;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/addons/fauxton/resizeCoumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/resizeCoumns.js b/src/fauxton/app/addons/fauxton/resizeCoumns.js
new file mode 100644
index 0000000..bb50767
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/resizeCoumns.js
@@ -0,0 +1,87 @@
+// 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.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+define([
+ "utils"
+],
+
+function(utils) {
+
+ var Resize = function(options){
+ this.options = options;
+ this.options.selectorElements = options.selectorElements || ".window-resizeable";
+ };
+
+ Resize.prototype = {
+ getPrimaryNavWidth: function(){
+ var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224;
+ return primaryNavWidth;
+ },
+ getPanelWidth: function(){
+ var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0;
+ return (this.getPrimaryNavWidth() + sidebarWidth);
+ },
+ initialize: function(){
+ // $(window).off('resize');
+ var that = this;
+ //add throttler :)
+ this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
+ utils.addWindowResize(this.lazyLayout,"animation");
+ utils.initWindowResize();
+ this.onResizeHandler();
+ },
+ updateOptions:function(options){
+ this.options = {};
+ this.options = options;
+ this.options.selectorElements = options.selectorElements || ".window-resizeable";
+ },
+ turnOff:function(){
+ utils.removeWindowResize("animation");
+ },
+ cleanupCallback: function(){
+ this.callback = null;
+ },
+ onResizeHandler: function (){
+ //if there is an override, do that instead
+ if (this.options.onResizeHandler){
+ this.options.onResizeHandler();
+ } else {
+ var combinedWidth = window.innerWidth - this.getPanelWidth(),
+ smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800,
+ panelWidth;
+
+ if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){
+ panelWidth = window.innerWidth - this.getPanelWidth();
+ } else if (combinedWidth < smallWidthConstraint){
+ panelWidth = smallWidthConstraint;
+ } else if(combinedWidth > 1400){
+ panelWidth = 1400;
+ }
+
+ $(this.options.selectorElements).innerWidth(panelWidth);
+ }
+ //if there is a callback, run that
+ if(this.options.callback) {
+ this.options.callback();
+ }
+ }
+ };
+
+ return Resize;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
deleted file mode 100644
index 9ac895e..0000000
--- a/src/fauxton/app/api.js
+++ /dev/null
@@ -1,593 +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.
-
-define([
- "app",
-
- // Modules
- "addons/fauxton/base",
- "spin"
-],
-
-function(app, Fauxton) {
- var FauxtonAPI = app.module();
-
- FauxtonAPI.moduleExtensions = {
- Routes: {
- }
- };
-
- FauxtonAPI.addonExtensions = {
- initialize: function() {}
- };
-
- // List of JSHINT errors to ignore
- // Gets around problem of anonymous functions not being a valid statement
- FauxtonAPI.excludedViewErrors = [
- "Missing name in function declaration.",
- "['{a}'] is better written in dot notation."
- ];
-
- FauxtonAPI.isIgnorableError = function(msg) {
- return _.contains(FauxtonAPI.excludedViewErrors, msg);
- };
-
- FauxtonAPI.View = Backbone.View.extend({
- // This should return an array of promises, an empty array, or null
- establish: function() {
- return null;
- },
-
- loaderClassname: 'loader',
-
- disableLoader: false,
-
- forceRender: function () {
- this.hasRendered = false;
- }
- });
-
- FauxtonAPI.navigate = function(url, _opts) {
- var options = _.extend({trigger: true}, _opts );
- app.router.navigate(url,options);
- };
-
- FauxtonAPI.beforeUnload = function () {
- app.router.beforeUnload.apply(app.router, arguments);
- };
-
- FauxtonAPI.removeBeforeUnload = function () {
- app.router.removeBeforeUnload.apply(app.router, arguments);
- };
-
- FauxtonAPI.addHeaderLink = function(link) {
- app.masterLayout.navBar.addLink(link);
- };
-
- FauxtonAPI.removeHeaderLink = function(link) {
- app.masterLayout.navBar.removeLink(link);
- };
-
- FauxtonAPI.Deferred = function() {
- return $.Deferred();
- };
-
- FauxtonAPI.when = function (deferreds) {
- if (deferreds instanceof Array) {
- return $.when.apply(null, deferreds);
- }
-
- return $.when(deferreds);
- };
-
- FauxtonAPI.addRoute = function(route) {
- app.router.route(route.route, route.name, route.callback);
- };
-
- FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
- app.router.triggerRouteEvent("route:"+routeEvent, args);
- };
-
- FauxtonAPI.module = function(extra) {
- return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
- };
-
- FauxtonAPI.addon = function(extra) {
- return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
- };
-
- FauxtonAPI.addNotification = function(options) {
- options = _.extend({
- msg: "Notification Event Triggered!",
- type: "info",
- selector: "#global-notifications"
- }, options);
- var view = new Fauxton.Notification(options);
-
- return view.renderNotification();
- };
-
- FauxtonAPI.UUID = Backbone.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
-
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
- },
-
- next: function() {
- return this.get("uuids").pop();
- }
- });
-
- FauxtonAPI.Session = Backbone.Model.extend({
- url: app.host + '/_session',
-
- user: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx || !userCtx.name) { return null; }
-
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
-
- fetchOnce: function (opt) {
- var options = _.extend({}, opt);
-
- if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
- this._deferred = this.fetch();
- }
-
- return this._deferred;
- },
-
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
-
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
-
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
-
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- app.session = FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- FauxtonAPI.setSession(new FauxtonAPI.Session());
-
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
-
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
-
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function() {},
-
- initialize: function() {
- var that = this;
- },
-
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
-
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
-
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
-
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
- }
- });
-
- FauxtonAPI.auth = new Auth();
-
- FauxtonAPI.RouteObject = function(options) {
- this._options = options;
-
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
-
- var broadcaster = {};
- _.extend(broadcaster, Backbone.Events);
-
- FauxtonAPI.RouteObject.on = function (eventName, fn) {
- broadcaster.on(eventName, fn);
- };
-
- /* How Route Object events work
- To listen to a specific route objects events:
-
- myRouteObject = FauxtonAPI.RouteObject.extend({
- events: {
- "beforeRender": "beforeRenderEvent"
- },
-
- beforeRenderEvent: function (view, selector) {
- console.log('Hey, beforeRenderEvent triggered',arguments);
- },
- });
-
- It is also possible to listen to events triggered from all Routeobjects.
- This is great for more general things like adding loaders, hooks.
-
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- console.log('hey, this will trigger when any routeobject renders a view');
- });
-
- Current Events to subscribe to:
- * beforeFullRender -- before a full render is being done
- * beforeEstablish -- before the routeobject calls establish
- * AfterEstablish -- after the routeobject has run establish
- * beforeRender -- before a view is rendered
- * afterRender -- a view is finished being rendered
- * renderComplete -- all rendering is complete
-
- */
-
- // Piggy-back on Backbone's self-propagating extend function
- FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function() {},
- route: function() {},
- roles: [],
- _promises: [],
- initialize: function() {}
- }, {
-
- renderWith: function(route, masterLayout, args) {
- var routeObject = this,
- triggerBroadcast = _.bind(this.triggerBroadcast, this);
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
- triggerBroadcast('beforeFullRender');
- $('#primary-navbar li').removeClass('active');
-
- if (this.selectedHeader) {
- app.selectedHeader = this.selectedHeader;
- $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
- }
- }
-
- masterLayout.clearBreadcrumbs();
- var crumbs = this.get('crumbs');
-
- if (crumbs.length) {
- masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
- crumbs: crumbs
- }));
- }
-
- triggerBroadcast('beforeEstablish');
- var establishPromise = this.establish();
- this.addPromise(establishPromise);
- FauxtonAPI.when(establishPromise).then(function(resp) {
- triggerBroadcast('afterEstablish');
- _.each(routeObject.getViews(), function(view, selector) {
- if(view.hasRendered) {
- triggerBroadcast('viewHasRendered', view, selector);
- return;
- }
-
- triggerBroadcast('beforeRender', view, selector);
- var viewPromise = view.establish();
- routeObject.addPromise(viewPromise);
- FauxtonAPI.when(viewPromise).then(function(resp) {
- masterLayout.setView(selector, view);
-
- masterLayout.renderView(selector);
- triggerBroadcast('afterRender', view, selector);
- }, function(resp) {
- view.establishError = {
- error: true,
- reason: resp
- };
-
- if (resp && resp.responseText) {
- var errorText = JSON.parse(resp.responseText).reason;
- FauxtonAPI.addNotification({
- msg: 'An Error occurred: ' + errorText,
- type: 'error',
- clear: true
- });
- }
-
- masterLayout.renderView(selector);
- });
-
- });
- }.bind(this), function (resp) {
- if (!resp || !resp.responseText) { return; }
- FauxtonAPI.addNotification({
- msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
- type: 'error',
- clear: true
- });
- });
-
- 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;
- triggerBroadcast('renderComplete');
- },
-
- triggerBroadcast: function (eventName) {
- var args = Array.prototype.slice.call(arguments);
- this.trigger.apply(this, args);
-
- args.splice(0,1, eventName, this);
- broadcaster.trigger.apply(broadcaster, args);
- },
-
- get: function(key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function(events) {
- events = events || this.get('events');
- _.each(events, function(method, event) {
- if (!_.isFunction(method) && !_.isFunction(this[method])) {
- throw new Error("Invalid method: "+method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
- }, this);
- },
-
- _configure: function(options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function(selector) {
- return this.views[selector];
- },
-
- setView: function(selector, view) {
- this.views[selector] = view;
- return view;
- },
-
- getViews: function() {
- return this.views;
- },
-
- removeViews: function () {
- _.each(this.views, function (view, selector) {
- view.remove();
- delete this.views[selector];
- }, this);
- },
-
- addPromise: function (promise) {
- if (_.isEmpty(promise)) { return; }
-
- if (_.isArray(promise)) {
- return _.each(promise, function (p) {
- this._promises.push(p);
- }, this);
- }
-
- this._promises.push(promise);
- },
-
- cleanup: function () {
- this.removeViews();
- this.rejectPromises();
- },
-
- rejectPromises: function () {
- _.each(this._promises, function (promise) {
- if (promise.state() === "resolved") { return; }
- if (promise.abort) {
- return promise.abort("Route change");
- }
-
- promise.reject();
- }, this);
-
- this._promises = [];
- },
-
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
- }
-
- routeCallback.apply(this, args);
- },
-
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
-
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
- }
-
- return this.roles;
- }
-
- });
-
- // We could look at moving the spinner code out to its own module
- var routeObjectSpinner;
- FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
- if (!routeObject.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- if (!$('.spinner').length) {
- $('<div class="spinner"></div>')
- .appendTo('#app-container');
- }
-
- routeObjectSpinner = new Spinner(opts).spin();
- $('.spinner').append(routeObjectSpinner.el);
- }
- });
-
- var removeRouteObjectSpinner = function () {
- if (routeObjectSpinner) {
- routeObjectSpinner.stop();
- $('.spinner').remove();
- }
- };
-
- var removeViewSpinner = function () {
- if (viewSpinner){
- viewSpinner.stop();
- $('.spinner').remove();
- }
- };
-
- var viewSpinner;
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- removeRouteObjectSpinner();
-
- if (!view.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- viewSpinner = new Spinner(opts).spin();
- $('<div class="spinner"></div>')
- .appendTo(selector)
- .append(viewSpinner.el);
- }
- });
-
- FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
- removeViewSpinner();
- });
-
- FauxtonAPI.RouteObject.on('viewHasRendered', function () {
- removeViewSpinner();
- removeRouteObjectSpinner();
- });
-
- var extensions = _.extend({}, Backbone.Events);
- // Can look at a remove function later.
- FauxtonAPI.registerExtension = function (name, view) {
- if (!extensions[name]) {
- extensions[name] = [];
- }
-
- extensions.trigger('add:' + name, view);
- extensions[name].push(view);
- };
-
- FauxtonAPI.getExtensions = function (name) {
- var views = extensions[name];
-
- if (!views) {
- views = [];
- }
-
- return views;
- };
-
- FauxtonAPI.extensions = extensions;
-
- app.fauxtonAPI = FauxtonAPI;
- return app.fauxtonAPI;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 5325f77..3b25be8 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -24,14 +24,15 @@ define([
"utils",
// Modules
"resizeColumns",
-
+ "core/api",
+ "addons/fauxton/base",
// Plugins.
"plugins/backbone.layoutmanager",
"plugins/jquery.form"
],
-function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns) {
+function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns, FauxtonAPI, Fauxton) {
// Make sure we have a console.log
if (typeof console == "undefined") {
@@ -45,15 +46,6 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns) {
_.extend(app, Backbone.Events, {
utils: Utils,
- renderView: function(baseView, selector, view, options, callback) {
- baseView.setView(selector, new view(options)).render().then(callback);
- },
-
- // Create a custom object with a nested Views object.
- module: function(additionalProps) {
- return _.extend({ Views: {} }, additionalProps);
- },
-
// Thanks to: http://stackoverflow.com/a/2880929
getParams: function(queryString) {
if (queryString) {
@@ -81,11 +73,37 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns) {
return urlParams;
}
+
});
- //resizeAnimation
- app.resizeColumns = new resizeColumns({});
- app.resizeColumns.onResizeHandler();
+ //MOVE THIS ELSEWHERE
+ app.footer = new Fauxton.Footer({el: "#footer-content"});
+ // TODO: move this to a proper Fauxton.View
+ $.when.apply(null, app.footer.establish()).done(function() {
+ app.footer.render();
+ });
+ app.navBar = new Fauxton.NavBar();
+ app.apiBar = new Fauxton.ApiBar();
+ // Define your master router on the application namespace and trigger all
+ // navigation from this instance.
+ app.router = new FauxtonAPI.Router();
+ FauxtonAPI.config({
+ router: app.router,
+ masterLayout: new Layout(app.navBar, app.apiBar),
+ addNotification: function (options) {
+ options = _.extend({
+ msg: "Notification Event Triggered!",
+ type: "info",
+ selector: "#global-notifications"
+ }, options);
+
+ var view = new Fauxton.Notification(options);
+ return view.renderNotification();
+ }
+ });
+ // Trigger the initial route and enable HTML5 History API support, set the
+ // root folder to '/' by default. Change in app.js.
+ Backbone.history.start({ pushState: false, root: app.root });
// Localize or create a new JavaScript Template object.
var JST = window.JST = window.JST || {};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
index 2977969..5dae1de 100644
--- a/src/fauxton/app/config.js
+++ b/src/fauxton/app/config.js
@@ -37,7 +37,8 @@ require.config({
map: {
"*": {
- 'underscore': 'lodash'
+ 'underscore': 'lodash',
+ 'api':'core/api'
}
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/core/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/api.js b/src/fauxton/app/core/api.js
index 0e4e730..5f5cbf8 100644
--- a/src/fauxton/app/core/api.js
+++ b/src/fauxton/app/core/api.js
@@ -11,510 +11,132 @@
// the License.
define([
- "app",
- "core/base",
+ "core/resources",
// Modules
- "modules/fauxton/base",
- "spin"
],
-function(app, FauxtonAPI, Fauxton) {
-
- FauxtonAPI.moduleExtensions = {
- Routes: {
- }
- };
-
- FauxtonAPI.addonExtensions = {
- initialize: function() {}
- };
-
- FauxtonAPI.module = function(extra) {
- return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
- };
-
- FauxtonAPI.addon = function(extra) {
- return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
- };
-
+function(FauxtonAPI, Fauxton) {
+
FauxtonAPI.navigate = function(url, _opts) {
var options = _.extend({trigger: true}, _opts );
- app.router.navigate(url,options);
+ FauxtonAPI.router.navigate(url,options);
};
FauxtonAPI.beforeUnload = function () {
- app.router.beforeUnload.apply(app.router, arguments);
+ FauxtonAPI.router.beforeUnload.apply(FauxtonAPI.router, arguments);
};
FauxtonAPI.removeBeforeUnload = function () {
- app.router.removeBeforeUnload.apply(app.router, arguments);
+ FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments);
};
FauxtonAPI.addHeaderLink = function(link) {
- app.masterLayout.navBar.addLink(link);
+ FauxtonAPI.masterLayout.navBar.addLink(link);
};
FauxtonAPI.removeHeaderLink = function(link) {
- app.masterLayout.navBar.removeLink(link);
+ FauxtonAPI.masterLayout.navBar.removeLink(link);
};
FauxtonAPI.addRoute = function(route) {
- app.router.route(route.route, route.name, route.callback);
+ FauxtonAPI.router.route(route.route, route.name, route.callback);
};
FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
- app.router.triggerRouteEvent("route:"+routeEvent, args);
+ FauxtonAPI.router.triggerRouteEvent("route:"+routeEvent, args);
};
- FauxtonAPI.addNotification = function(options) {
- options = _.extend({
- msg: "Notification Event Triggered!",
- type: "info",
- selector: "#global-notifications"
- }, options);
- var view = new Fauxton.Notification(options);
-
- return view.renderNotification();
- };
+ var beforeUnloads = {};
- FauxtonAPI.UUID = FauxtonAPI.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
+ FauxtonAPI.Router = Backbone.Router.extend({
+ routes: {},
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
+ beforeUnload: function (name, fn) {
+ beforeUnloads[name] = fn;
},
- next: function() {
- return this.get("uuids").pop();
- }
- });
-
- FauxtonAPI.Session = Backbone.Model.extend({
- url: '/_session',
-
- user: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx || !userCtx.name) { return null; }
-
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
+ removeBeforeUnload: function (name) {
+ delete beforeUnloads[name];
},
- fetchOnce: function (opt) {
- var options = _.extend({}, opt);
+ navigate: function (fragment, trigger) {
+ var continueNav = true,
+ msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
+ if (beforeReturn) { return true; }
+ });
- if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
- this._deferred = this.fetch();
+ if (msg) {
+ continueNav = window.confirm(msg);
}
- return this._deferred;
+ if (continueNav) {
+ Backbone.Router.prototype.navigate(fragment, trigger);
+ }
},
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
-
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
-
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
-
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- app.session = FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- FauxtonAPI.setSession(new FauxtonAPI.Session());
-
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
-
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
-
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function() {},
-
- initialize: function() {
+ addModuleRouteObject: function(RouteObject) {
var that = this;
- },
-
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
-
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
-
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
-
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
- }
- });
-
- FauxtonAPI.auth = new Auth();
-
- FauxtonAPI.RouteObject = function(options) {
- this._options = options;
-
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
-
- var broadcaster = {};
- _.extend(broadcaster, Backbone.Events);
-
- FauxtonAPI.RouteObject.on = function (eventName, fn) {
- broadcaster.on(eventName, fn);
- };
-
- /* How Route Object events work
- To listen to a specific route objects events:
-
- myRouteObject = FauxtonAPI.RouteObject.extend({
- events: {
- "beforeRender": "beforeRenderEvent"
- },
-
- beforeRenderEvent: function (view, selector) {
- console.log('Hey, beforeRenderEvent triggered',arguments);
- },
- });
-
- It is also possible to listen to events triggered from all Routeobjects.
- This is great for more general things like adding loaders, hooks.
-
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- console.log('hey, this will trigger when any routeobject renders a view');
- });
-
- Current Events to subscribe to:
- * beforeFullRender -- before a full render is being done
- * beforeEstablish -- before the routeobject calls establish
- * AfterEstablish -- after the routeobject has run establish
- * beforeRender -- before a view is rendered
- * afterRender -- a view is finished being rendered
- * renderComplete -- all rendering is complete
-
- */
-
- // Piggy-back on Backbone's self-propagating extend function
- FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function() {},
- route: function() {},
- roles: [],
- initialize: function() {}
- }, {
-
- renderWith: function(route, masterLayout, args) {
- var routeObject = this,
- triggerBroadcast = _.bind(this.triggerBroadcast, this);
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
- triggerBroadcast('beforeFullRender');
- $('#primary-navbar li').removeClass('active');
-
- if (this.selectedHeader) {
- app.selectedHeader = this.selectedHeader;
- $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
- }
- }
-
- masterLayout.clearBreadcrumbs();
- var crumbs = this.get('crumbs');
-
- if (crumbs.length) {
- masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
- crumbs: crumbs
- }));
- }
-
- triggerBroadcast('beforeEstablish');
- FauxtonAPI.when(this.establish()).then(function(resp) {
- triggerBroadcast('afterEstablish');
- _.each(routeObject.getViews(), function(view, selector) {
- if(view.hasRendered) {
- triggerBroadcast('viewHasRendered', view, selector);
- return;
- }
-
- triggerBroadcast('beforeRender', view, selector);
- FauxtonAPI.when(view.establish()).then(function(resp) {
- masterLayout.setView(selector, view);
-
- masterLayout.renderView(selector);
- triggerBroadcast('afterRender', view, selector);
- }, function(resp) {
- view.establishError = {
- error: true,
- reason: resp
- };
-
- if (resp) {
- var errorText = JSON.parse(resp.responseText).reason;
- FauxtonAPI.addNotification({
- msg: 'An Error occurred: ' + errorText,
- type: 'error',
- clear: true
- });
+ var masterLayout = FauxtonAPI.masterLayout,
+ routeUrls = RouteObject.prototype.getRouteUrls();
+
+ _.each(routeUrls, function(route) {
+ this.route(route, route.toString(), function() {
+ var args = Array.prototype.slice.call(arguments),
+ roles = RouteObject.prototype.getRouteRoles(route),
+ authPromise = app.auth.checkAccess(roles);
+
+ authPromise.then(function () {
+ if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
+ if (that.activeRouteObject) {
+ that.activeRouteObject.removeViews();
}
-
- masterLayout.renderView(selector);
+ that.activeRouteObject = new RouteObject(route, masterLayout, args);
+ }
+
+ var routeObject = that.activeRouteObject;
+ routeObject.routeCallback(route, args);
+ routeObject.renderWith(route, masterLayout, args);
+ }, function () {
+ FauxtonAPI.auth.authDeniedCb();
});
- });
- }.bind(this), function (resp) {
- if (!resp) { return; }
- FauxtonAPI.addNotification({
- msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
- type: 'error',
- clear: true
- });
- });
-
- 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;
- triggerBroadcast('renderComplete');
- },
-
- triggerBroadcast: function (eventName) {
- var args = Array.prototype.slice.call(arguments);
- this.trigger.apply(this, args);
-
- args.splice(0,1, eventName, this);
- broadcaster.trigger.apply(broadcaster, args);
- },
-
- get: function(key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function(events) {
- events = events || this.get('events');
- _.each(events, function(method, event) {
- if (!_.isFunction(method) && !_.isFunction(this[method])) {
- throw new Error("Invalid method: "+method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
+ });
}, this);
},
- _configure: function(options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function(selector) {
- return this.views[selector];
- },
-
- setView: function(selector, view) {
- this.views[selector] = view;
- return view;
- },
-
- getViews: function() {
- return this.views;
- },
-
- removeViews: function () {
- _.each(this.views, function (view, selector) {
- view.remove();
- delete this.views[selector];
+ setModuleRoutes: function() {
+ _.each(LoadAddons.addons, function(module) {
+ if (module){
+ module.initialize();
+ // This is pure routes the addon provides
+ if (module.RouteObjects) {
+ _.each(module.RouteObjects, this.addModuleRouteObject, this);
+ }
+ }
}, this);
},
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
- }
+ initialize: function() {
+ //TODO: It would be nice to handle this with a router
+ this.auth = app.auth = FauxtonAPI.auth;
+ // NOTE: This must be below creation of the layout
+ // FauxtonAPI header links and others depend on existence of the layout
+ this.setModuleRoutes();
- routeCallback.apply(this, args);
+ $("#app-container").html(FauxtonAPI.masterLayout.el);
+ FauxtonAPI.masterLayout.render();
},
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
-
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
+ triggerRouteEvent: function(event, args) {
+ if (this.activeRouteObject) {
+ var eventArgs = [event].concat(args);
+ this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
+ this.activeRouteObject.renderWith(eventArgs, FauxtonAPI.masterLayout, args);
}
-
- return this.roles;
- }
-
- });
-
- // We could look at moving the spinner code out to its own module
- var routeObjectSpinner;
- FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
- if (!routeObject.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- if (!$('.spinner').length) {
- $('<div class="spinner"></div>')
- .appendTo('#app-container');
- }
-
- routeObjectSpinner = new Spinner(opts).spin();
- $('.spinner').append(routeObjectSpinner.el);
- }
- });
-
- var removeRouteObjectSpinner = function () {
- if (routeObjectSpinner) {
- routeObjectSpinner.stop();
- $('.spinner').remove();
- }
- };
-
- var removeViewSpinner = function () {
- if (viewSpinner){
- viewSpinner.stop();
- $('.spinner').remove();
}
- };
-
- var viewSpinner;
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- removeRouteObjectSpinner();
-
- if (!view.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- viewSpinner = new Spinner(opts).spin();
- $('<div class="spinner"></div>')
- .appendTo(selector)
- .append(viewSpinner.el);
- }
- });
-
- FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
- removeViewSpinner();
- });
-
- FauxtonAPI.RouteObject.on('viewHasRendered', function () {
- removeViewSpinner();
- removeRouteObjectSpinner();
});
- var extensions = _.extend({}, Backbone.Events);
- // Can look at a remove function later.
- FauxtonAPI.registerExtension = function (name, view) {
- if (!extensions[name]) {
- extensions[name] = [];
- }
-
- extensions.trigger('add:' + name, view);
- extensions[name].push(view);
- };
-
- FauxtonAPI.getExtensions = function (name) {
- var views = extensions[name];
-
- if (!views) {
- views = [];
- }
-
- return views;
- };
-
- FauxtonAPI.extensions = extensions;
- app.fauxtonAPI = FauxtonAPI;
- return app.fauxtonAPI;
+ return FauxtonAPI;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 20dea73..f9bb065 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -14,7 +14,28 @@ define([
],
function() {
- var FauxtonAPI = {};
+ var FauxtonAPI = {
+ //add default objects
+ router: {
+ navigate: function () {}
+ },
+
+ masterLayout: {
+ // remove these by converting to extensions
+ navBar: {
+ addLink: function () {},
+ removeLink: function () {}
+ }
+ },
+
+ addNotification: function () {
+
+ },
+
+ config: function (options) {
+ return _.extend(this, options);
+ }
+ };
FauxtonAPI.Deferred = function() {
return $.Deferred();
@@ -28,6 +49,16 @@ function() {
return $.when(deferreds);
};
+ FauxtonAPI.addonExtensions = {
+ initialize: function() {},
+ RouteObjects: {},
+ Views: {}
+ };
+
+ FauxtonAPI.addon = function(extra) {
+ return _.extend(_.clone(FauxtonAPI.addonExtensions), extra);
+ };
+
FauxtonAPI.View = Backbone.View.extend({
// This should return an array of promises, an empty array, or null
establish: function() {
@@ -44,9 +75,41 @@ function() {
});
FauxtonAPI.Model = Backbone.Model.extend({
- //add fetchOnce
+ fetchOnce: function (opt) {
+ var options = _.extend({}, opt);
+
+ if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
+ this._deferred = this.fetch();
+ }
+
+ return this._deferred;
+ }
});
+ var extensions = _.extend({}, Backbone.Events);
+ // Can look at a remove function later.
+ FauxtonAPI.registerExtension = function (name, view) {
+ if (!extensions[name]) {
+ extensions[name] = [];
+ }
+
+ extensions.trigger('add:' + name, view);
+ extensions[name].push(view);
+ };
+
+ FauxtonAPI.getExtensions = function (name) {
+ var views = extensions[name];
+
+ if (!views) {
+ views = [];
+ }
+
+ return views;
+ };
+
+ FauxtonAPI.extensions = extensions;
+
+
return FauxtonAPI;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/core/couchdb.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdb.js b/src/fauxton/app/core/couchdb.js
deleted file mode 100644
index 39cdc1a..0000000
--- a/src/fauxton/app/core/couchdb.js
+++ /dev/null
@@ -1,78 +0,0 @@
-// 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.
-
-define([
- "app",
- "core/base"
-],
-function (app, FauxtonAPI) {
- //this later needs to be dynamically loaded
-
- FauxtonAPI.UUID = FauxtonAPI.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
-
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
- },
-
- next: function() {
- return this.get("uuids").pop();
- }
- });
-
- FauxtonAPI.Session = FauxtonAPI.Model.extend({
- url: app.host + '/_session',
-
- user: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx || !userCtx.name) { return null; }
-
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
-
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
-
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
-
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
-
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- app.session = FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- //set default session
- FauxtonAPI.setSession(new FauxtonAPI.Session());
-
- return FauxtonAPI;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdbSession.js b/src/fauxton/app/core/couchdbSession.js
new file mode 100644
index 0000000..532f3ea
--- /dev/null
+++ b/src/fauxton/app/core/couchdbSession.js
@@ -0,0 +1,80 @@
+// 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.
+
+define([
+ "core/base"
+],
+function (FauxtonAPI) {
+ //this later needs to be dynamically loaded
+ var app = {
+ host: ""
+ };
+
+ FauxtonAPI.UUID = FauxtonAPI.Model.extend({
+ initialize: function(options) {
+ options = _.extend({count: 1}, options);
+ this.count = options.count;
+ },
+
+ url: function() {
+ return app.host + "/_uuids?count=" + this.count;
+ },
+
+ next: function() {
+ return this.get("uuids").pop();
+ }
+ });
+
+ FauxtonAPI.Session = FauxtonAPI.Model.extend({
+ url: app.host + '/_session',
+
+ user: function () {
+ var userCtx = this.get('userCtx');
+
+ if (!userCtx || !userCtx.name) { return null; }
+
+ return {
+ name: userCtx.name,
+ roles: userCtx.roles
+ };
+ },
+
+ fetchUser: function (opt) {
+ var that = this,
+ currentUser = this.user();
+
+ return this.fetchOnce(opt).then(function () {
+ var user = that.user();
+
+ // Notify anyone listening on these events that either a user has changed
+ // or current user is the same
+ if (currentUser !== user) {
+ that.trigger('session:userChanged');
+ } else {
+ that.trigger('session:userFetched');
+ }
+
+ // this will return the user as a value to all function that calls done on this
+ // eg. session.fetchUser().done(user) { .. do something with user ..}
+ return user;
+ });
+ }
+ });
+
+ FauxtonAPI.setSession = function (newSession) {
+ FauxtonAPI.session = newSession;
+ return FauxtonAPI.session.fetchUser();
+ };
+
+ //set default session
+ FauxtonAPI.setSession(new FauxtonAPI.Session());
+
+ return FauxtonAPI;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/core/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/resources.js b/src/fauxton/app/core/resources.js
index 83111c7..249d7fc 100644
--- a/src/fauxton/app/core/resources.js
+++ b/src/fauxton/app/core/resources.js
@@ -12,7 +12,7 @@
define([
"app",
- "core/couchdb",
+ "core/couchdbSession",
"addons/fauxton/base",
"backbone"
],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
index 6fe9991..13b8370 100644
--- a/src/fauxton/app/main.js
+++ b/src/fauxton/app/main.js
@@ -13,19 +13,10 @@
require([
// Application.
"app",
-
- // Main Router.
- "router"
],
-function(app, Router) {
+function(app) {
- // Define your master router on the application namespace and trigger all
- // navigation from this instance.
- app.router = new Router();
- // Trigger the initial route and enable HTML5 History API support, set the
- // root folder to '/' by default. Change in app.js.
- Backbone.history.start({ pushState: false, root: app.root });
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/resizeColumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/resizeColumns.js b/src/fauxton/app/resizeColumns.js
deleted file mode 100644
index bb50767..0000000
--- a/src/fauxton/app/resizeColumns.js
+++ /dev/null
@@ -1,87 +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.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-define([
- "utils"
-],
-
-function(utils) {
-
- var Resize = function(options){
- this.options = options;
- this.options.selectorElements = options.selectorElements || ".window-resizeable";
- };
-
- Resize.prototype = {
- getPrimaryNavWidth: function(){
- var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224;
- return primaryNavWidth;
- },
- getPanelWidth: function(){
- var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0;
- return (this.getPrimaryNavWidth() + sidebarWidth);
- },
- initialize: function(){
- // $(window).off('resize');
- var that = this;
- //add throttler :)
- this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
- utils.addWindowResize(this.lazyLayout,"animation");
- utils.initWindowResize();
- this.onResizeHandler();
- },
- updateOptions:function(options){
- this.options = {};
- this.options = options;
- this.options.selectorElements = options.selectorElements || ".window-resizeable";
- },
- turnOff:function(){
- utils.removeWindowResize("animation");
- },
- cleanupCallback: function(){
- this.callback = null;
- },
- onResizeHandler: function (){
- //if there is an override, do that instead
- if (this.options.onResizeHandler){
- this.options.onResizeHandler();
- } else {
- var combinedWidth = window.innerWidth - this.getPanelWidth(),
- smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800,
- panelWidth;
-
- if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){
- panelWidth = window.innerWidth - this.getPanelWidth();
- } else if (combinedWidth < smallWidthConstraint){
- panelWidth = smallWidthConstraint;
- } else if(combinedWidth > 1400){
- panelWidth = 1400;
- }
-
- $(this.options.selectorElements).innerWidth(panelWidth);
- }
- //if there is a callback, run that
- if(this.options.callback) {
- this.options.callback();
- }
- }
- };
-
- return Resize;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/5c735474/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index 89c60cf..51b98ea 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -22,7 +22,7 @@ define([
"initialize",
// Load Fauxton API
- "api",
+ "core/api",
// Modules
"addons/fauxton/base",
@@ -94,6 +94,7 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
setModuleRoutes: function() {
_.each(LoadAddons.addons, function(module) {
+ console.log('aa', module);
if (module){
module.initialize();
// This is pure routes the addon provides
@@ -116,7 +117,6 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
// NOTE: This must be below creation of the layout
// FauxtonAPI header links and others depend on existence of the layout
- //this.setAddonHooks();
this.setModuleRoutes();
$("#app-container").html(this.masterLayout.el);
[24/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fauxton addon Verifyinstall missing from makefile
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/eabece10
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/eabece10
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/eabece10
Branch: refs/heads/fauxton-file-reorder
Commit: eabece10a40618875e9e43cbc3f9231f80adecb7
Parents: 424e25a
Author: suelockwood <de...@apache.org>
Authored: Fri Jan 17 11:20:35 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Fri Jan 17 11:20:35 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/eabece10/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 6666751..73e48b3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -105,6 +105,12 @@ FAUXTON_FILES = \
fauxton/app/addons/stats/templates/stats.html \
fauxton/app/addons/stats/templates/statselect.html \
fauxton/app/addons/stats/views.js \
+ fauxton/app/addons/verifyinstall/views.js \
+ fauxton/app/addons/verifyinstall/resources.js \
+ fauxton/app/addons/verifyinstall/base.js \
+ fauxton/app/addons/verifyinstall/routes.js \
+ fauxton/app/addons/verifyinstall/templates/main.html \
+ fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less \
fauxton/app/api.js \
fauxton/app/app.js \
fauxton/app/config.js \
[02/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Keep errors from fading on Doc Editor
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/6530f95c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/6530f95c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/6530f95c
Branch: refs/heads/fauxton-file-reorder
Commit: 6530f95c0d33b1657336c51b363c6135b5aa7be6
Parents: 2e4d72b
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 12:37:11 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 12:37:11 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/6530f95c/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 2502b58..80c8251 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -890,6 +890,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
notification = FauxtonAPI.addNotification({
msg: "Save failed: " + responseText,
type: "error",
+ fade: false,
clear: true,
selector: "#doc .errors-container"
});
[20/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fix for view preview bug with _count
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a09318fa
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a09318fa
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a09318fa
Branch: refs/heads/fauxton-file-reorder
Commit: a09318fa85365cf8e4d6718e3c3cb07aba76d990
Parents: c56e5a8
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 16 09:48:42 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 16 09:48:42 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 6 +++---
src/fauxton/app/addons/pouchdb/pouch.collate.js | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a09318fa/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 9902541..bde08f8 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1476,12 +1476,12 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
var promise = FauxtonAPI.Deferred();
- if (!this.database.allDocs) {
+ if (!this.database.allDocs || this.database.allDocs.params.include_docs !== true) {
this.database.buildAllDocs({limit: Databases.DocLimit.toString(), include_docs: true});
promise = this.database.allDocs.fetch();
- } else {
+ } else {
promise.resolve();
- }
+ }
promise.then(function () {
params.docs = that.database.allDocs.map(function (model) { return model.get('doc');});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a09318fa/src/fauxton/app/addons/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouch.collate.js b/src/fauxton/app/addons/pouchdb/pouch.collate.js
index 31e5650..8f15808 100644
--- a/src/fauxton/app/addons/pouchdb/pouch.collate.js
+++ b/src/fauxton/app/addons/pouchdb/pouch.collate.js
@@ -110,6 +110,6 @@ function(app, FauxtonAPI, Collate) {
return Pouch;
-}).call(this);
+});
[11/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fix for the link to edit docs on reductions
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e5cac792
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e5cac792
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e5cac792
Branch: refs/heads/fauxton-file-reorder
Commit: e5cac79282b7a631b969b59f9647b3a3dd47c37b
Parents: afd66a9
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 16:19:29 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 16:19:29 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/resources.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/e5cac792/src/fauxton/app/addons/documents/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/resources.js b/src/fauxton/app/addons/documents/resources.js
index 0fd99f1..831d5e3 100644
--- a/src/fauxton/app/addons/documents/resources.js
+++ b/src/fauxton/app/addons/documents/resources.js
@@ -238,8 +238,6 @@ function(app, FauxtonAPI) {
return "docs";
},
url: function(context) {
- if (!this.isEditable()) return false;
-
return this.collection.database.url(context) + "/" + this.safeID();
},
@@ -247,7 +245,9 @@ function(app, FauxtonAPI) {
return this.docType() != "reduction";
},
safeID: function() {
- return app.utils.safeURLName(this.id);
+ var id = this.id || this.get("id");
+
+ return app.utils.safeURLName(id);
},
prettyJSON: function() {
[10/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fix Permissions model url
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/afd66a9c
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/afd66a9c
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/afd66a9c
Branch: refs/heads/fauxton-file-reorder
Commit: afd66a9ceed5af91b2db48f80b3fcf9e7fc04f3e
Parents: 61d0617
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:58:35 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:58:35 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/permissions/resources.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/afd66a9c/src/fauxton/app/addons/permissions/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/resources.js b/src/fauxton/app/addons/permissions/resources.js
index 8acaddd..4ddd3ae 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 app.host + this.database.id + '/_security';
+ return window.location.origin +"/"+ this.database.safeID() + '/_security';
},
addItem: function (value, type, section) {
[22/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Set default reduce to none not _sum
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0fd6a7ed
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0fd6a7ed
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0fd6a7ed
Branch: refs/heads/fauxton-file-reorder
Commit: 0fd6a7ed63836bad36c75c3935e27804be30773c
Parents: 32bb6ce
Author: suelockwood <de...@apache.org>
Authored: Thu Jan 16 14:12:51 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Thu Jan 16 14:13:09 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0fd6a7ed/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index bde08f8..ba7e7d7 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -1593,7 +1593,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
beforeRender: function () {
if (this.newView) {
- this.reduceFunStr = '_sum';
+ this.reduceFunStr = '';
if (this.ddocs.length === 0) {
this.model = new Documents.Doc(null, {database: this.database});
} else {
[08/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Update the makefile with the refactoring changes for moving documents and databases into addons.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/86ef9eea
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/86ef9eea
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/86ef9eea
Branch: refs/heads/fauxton-file-reorder
Commit: 86ef9eea39a8006fd1dd875975b171164c09d5e0
Parents: ae03a97
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:15:49 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:15:49 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/86ef9eea/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 78bbfac..6666751 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,10 +133,15 @@ FAUXTON_FILES = \
fauxton/app/addons/databases/templates/item.html \
fauxton/app/addons/databases/templates/list.html \
fauxton/app/addons/databases/templates/newdatabase.html \
+ fauxton/app/addons/databases/templates/sidebar.html \
+ fauxton/app/addons/documents/templates/advanced_options.html \
fauxton/app/addons/documents/templates/all_docs_item.html \
+ fauxton/app/addons/documents/templates/all_docs_layout.html \
fauxton/app/addons/documents/templates/all_docs_list.html \
+ fauxton/app/addons/documents/templates/all_docs_number.html \
fauxton/app/addons/documents/templates/changes.html \
fauxton/app/addons/documents/templates/ddoc_info.html \
+ fauxton/app/addons/documents/templates/design_doc_selector.html \
fauxton/app/addons/documents/templates/doc.html \
fauxton/app/addons/documents/templates/doc_field_editor.html \
fauxton/app/addons/documents/templates/doc_field_editor_tabs.html \
[05/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Remove with_right_sidebar from makefile
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a37a3eb4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a37a3eb4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a37a3eb4
Branch: refs/heads/fauxton-file-reorder
Commit: a37a3eb4e3d52eba60d3c13b7d3e8b5a35fb7b41
Parents: bea8c6d
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 14:58:43 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 14:58:43 2014 -0500
----------------------------------------------------------------------
src/Makefile.am | 1 -
1 file changed, 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a37a3eb4/src/Makefile.am
----------------------------------------------------------------------
diff --git a/src/Makefile.am b/src/Makefile.am
index 4302048..78bbfac 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -160,7 +160,6 @@ FAUXTON_FILES = \
fauxton/app/addons/fauxton/templates/pagination.html \
fauxton/app/templates/layouts/one_pane.html \
fauxton/app/templates/layouts/two_pane.html \
- fauxton/app/templates/layouts/with_right_sidebar.html \
fauxton/app/templates/layouts/with_sidebar.html \
fauxton/app/templates/layouts/with_tabs.html \
fauxton/app/templates/layouts/with_tabs_sidebar.html \
[06/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
kill off app/templates for docs & dbs
They live under app/addons/databases &
app/addons/documents now (as with the
other addons).
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ae03a97b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ae03a97b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ae03a97b
Branch: refs/heads/fauxton-file-reorder
Commit: ae03a97b3bc001be9c3c031b20f7272adc532501
Parents: 134dd40
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Jan 13 13:53:57 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:09:15 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/databases/views.js | 8 +-
src/fauxton/app/addons/documents/views.js | 40 ++++----
src/fauxton/app/templates/databases/item.html | 24 -----
src/fauxton/app/templates/databases/list.html | 35 -------
.../app/templates/databases/newdatabase.html | 17 ----
.../templates/documents/advanced_options.html | 98 --------------------
.../app/templates/documents/all_docs_item.html | 26 ------
.../templates/documents/all_docs_layout.html | 20 ----
.../app/templates/documents/all_docs_list.html | 43 ---------
.../templates/documents/all_docs_number.html | 23 -----
.../app/templates/documents/changes.html | 38 --------
.../app/templates/documents/ddoc_info.html | 28 ------
.../documents/design_doc_selector.html | 35 -------
src/fauxton/app/templates/documents/doc.html | 55 -----------
.../templates/documents/doc_field_editor.html | 74 ---------------
.../documents/doc_field_editor_tabs.html | 19 ----
.../documents/duplicate_doc_modal.html | 36 -------
.../app/templates/documents/edit_tools.html | 44 ---------
.../templates/documents/index_menu_item.html | 17 ----
.../templates/documents/index_row_docular.html | 27 ------
.../templates/documents/index_row_tabular.html | 25 -----
.../app/templates/documents/jumpdoc.html | 19 ----
src/fauxton/app/templates/documents/search.html | 15 ---
.../app/templates/documents/sidebar.html | 67 -------------
src/fauxton/app/templates/documents/tabs.html | 18 ----
.../app/templates/documents/upload_modal.html | 42 ---------
.../app/templates/documents/view_editor.html | 87 -----------------
27 files changed, 24 insertions(+), 956 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/addons/databases/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/databases/views.js b/src/fauxton/app/addons/databases/views.js
index 0068305..df663eb 100644
--- a/src/fauxton/app/addons/databases/views.js
+++ b/src/fauxton/app/addons/databases/views.js
@@ -22,7 +22,7 @@ function(app, Components, FauxtonAPI, Databases) {
var Views = {};
Views.Item = FauxtonAPI.View.extend({
- template: "templates/databases/item",
+ template: "addons/databases/templates/item",
tagName: "tr",
establish: function(){
return [this.model.fetch()];
@@ -39,7 +39,7 @@ function(app, Components, FauxtonAPI, Databases) {
Views.List = FauxtonAPI.View.extend({
dbLimit: 20,
perPage: 20,
- template: "templates/databases/list",
+ template: "addons/databases/templates/list",
events: {
"click button.all": "selectAll",
"submit form#jump-to-db": "switchDatabase"
@@ -143,7 +143,7 @@ function(app, Components, FauxtonAPI, Databases) {
Views.NewDatabaseButton = FauxtonAPI.View.extend({
- template: "templates/databases/newdatabase",
+ template: "addons/databases/templates/newdatabase",
events: {
"click a#new": "newDatabase"
},
@@ -189,7 +189,7 @@ function(app, Components, FauxtonAPI, Databases) {
});
Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/databases/sidebar",
+ template: "addons/databases/templates/sidebar",
events: {
"click a#new": "newDatabase",
"click a#owned": "showMine",
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 80c8251..0139eca 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -31,7 +31,7 @@ define([
function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColumns) {
var Views = {};
Views.Tabs = FauxtonAPI.View.extend({
- template: "templates/documents/tabs",
+ template: "addons/documents/templates/tabs",
initialize: function(options){
this.collection = options.collection;
this.database = options.database;
@@ -81,7 +81,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.SearchBox = FauxtonAPI.View.extend({
- template: "templates/documents/search",
+ template: "addons/documents/templates/search",
tagName: "form",
initialize: function(options){
this.collection = options.collection;
@@ -131,7 +131,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.UploadModal = FauxtonAPI.View.extend({
- template: "templates/documents/upload_modal",
+ template: "addons/documents/templates/upload_modal",
disableLoader: true,
@@ -227,7 +227,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DuplicateDocModal = FauxtonAPI.View.extend({
- template: "templates/documents/duplicate_doc_modal",
+ template: "addons/documents/templates/duplicate_doc_modal",
initialize: function () {
_.bindAll(this);
@@ -299,7 +299,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.FieldEditorTabs = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor_tabs",
+ template: "addons/documents/templates/doc_field_editor_tabs",
disableLoader: true,
initialize: function(options) {
this.selected = options.selected;
@@ -330,7 +330,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Document = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_item",
+ template: "addons/documents/templates/all_docs_item",
tagName: "tr",
className: "all-docs-item",
@@ -390,7 +390,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Row = FauxtonAPI.View.extend({
- template: "templates/documents/index_row_docular",
+ template: "addons/documents/templates/index_row_docular",
tagName: "tr",
events: {
@@ -411,7 +411,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.IndexItem = FauxtonAPI.View.extend({
- template: "templates/documents/index_menu_item",
+ template: "addons/documents/templates/index_menu_item",
tagName: "li",
initialize: function(options){
@@ -444,7 +444,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AllDocsNumber = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_number",
+ template: "addons/documents/templates/all_docs_number",
initialize: function (options) {
this.newView = options.newView || false;
@@ -487,7 +487,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AllDocsLayout = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_layout",
+ template: "addons/documents/templates/all_docs_layout",
className: "row",
initialize: function (options) {
@@ -565,7 +565,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
// TODO: Rename to reflect that this is a list of rows or documents
Views.AllDocsList = FauxtonAPI.View.extend({
- template: "templates/documents/all_docs_list",
+ template: "addons/documents/templates/all_docs_list",
events: {
"click button.all": "selectAll",
"click button.bulk-delete": "bulkDelete",
@@ -759,7 +759,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Doc = FauxtonAPI.View.extend({
- template: "templates/documents/doc",
+ template: "addons/documents/templates/doc",
events: {
"click button.save-doc": "saveDoc",
"click button.delete": "destroy",
@@ -977,7 +977,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DocFieldEditor = FauxtonAPI.View.extend({
- template: "templates/documents/doc_field_editor",
+ template: "addons/documents/templates/doc_field_editor",
disableLoader: true,
events: {
"click button.save": "saveDoc"
@@ -1024,7 +1024,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.AdvancedOptions = FauxtonAPI.View.extend({
- template: "templates/documents/advanced_options",
+ template: "addons/documents/templates/advanced_options",
className: "advanced-options well",
initialize: function (options) {
@@ -1176,7 +1176,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DesignDocSelector = FauxtonAPI.View.extend({
- template: "templates/documents/design_doc_selector",
+ template: "addons/documents/templates/design_doc_selector",
events: {
"change select#ddoc": "updateDesignDoc"
@@ -1237,7 +1237,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.ViewEditor = FauxtonAPI.View.extend({
- template: "templates/documents/view_editor",
+ template: "addons/documents/templates/view_editor",
builtinReduces: ['_sum', '_count', '_stats'],
events: {
@@ -1668,7 +1668,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.JumpToDoc = FauxtonAPI.View.extend({
- template: "templates/documents/jumpdoc",
+ template: "addons/documents/templates/jumpdoc",
initialize: function (options) {
this.database = options.database;
@@ -1691,7 +1691,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.Sidebar = FauxtonAPI.View.extend({
- template: "templates/documents/sidebar",
+ template: "addons/documents/templates/sidebar",
events: {
"click button#delete-database": "deleteDatabase"
},
@@ -1800,7 +1800,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
Views.Indexed = FauxtonAPI.View.extend({});
Views.Changes = FauxtonAPI.View.extend({
- template: "templates/documents/changes",
+ template: "addons/documents/templates/changes",
establish: function() {
return [ this.model.changes.fetch()];
@@ -1819,7 +1819,7 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
});
Views.DdocInfo = FauxtonAPI.View.extend({
- template: "templates/documents/ddoc_info",
+ template: "addons/documents/templates/ddoc_info",
initialize: function (options) {
this.refreshTime = options.refreshTime || 5000;
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/databases/item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/item.html b/src/fauxton/app/templates/databases/item.html
deleted file mode 100644
index e2f8071..0000000
--- a/src/fauxton/app/templates/databases/item.html
+++ /dev/null
@@ -1,24 +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.
--->
-
-<td>
- <a href="#/database/<%=encoded%>/_all_docs?limit=<%=docLimit%>"><%= database.get("name") %></a>
-</td>
-<td><%= database.status.humanSize() %></td>
-<td><%= database.status.numDocs() %></td>
-<td><%= database.status.updateSeq() %></td>
-<td>
- <a class="db-actions btn fonticon-replicate set-replication-start" title="Replicate <%= database.get("name") %>" href="#/replication/new/<%=encoded%>"></a>
- <a class="db-actions btn icon-lock set-permissions" title="Set permissions for <%= database.get("name") %>" href="#/database/<%=encoded%>/permissions"></a>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/databases/list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/list.html b/src/fauxton/app/templates/databases/list.html
deleted file mode 100644
index 31c0977..0000000
--- a/src/fauxton/app/templates/databases/list.html
+++ /dev/null
@@ -1,35 +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.
--->
-
-<div class="result-tools" style="">
- <div id="newButton" class="pull-left"></div>
- <form id="jump-to-db" class="navbar-form pull-right input-append database-search">
- <input type="text" class="search-autocomplete" name="search-query" placeholder="Database name"></input>
- <button class="fonticon-search btn button red " type="submit"></button>
- </form>
-
-
-</div>
-<table class="databases table table-striped">
- <thead>
- <th>Name</th>
- <th>Size</th>
- <th># of Docs</th>
- <th>Update Seq</th>
- <th>Actions</th>
- </thead>
- <tbody>
- </tbody>
-</table>
-<div id="database-pagination"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/databases/newdatabase.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/databases/newdatabase.html b/src/fauxton/app/templates/databases/newdatabase.html
deleted file mode 100644
index b357e0b..0000000
--- a/src/fauxton/app/templates/databases/newdatabase.html
+++ /dev/null
@@ -1,17 +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.
--->
-
-<a class="button new" id="new"><i class="icon fonticon-new-database"></i>Add New Database</a>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/advanced_options.html b/src/fauxton/app/templates/documents/advanced_options.html
deleted file mode 100644
index e256325..0000000
--- a/src/fauxton/app/templates/documents/advanced_options.html
+++ /dev/null
@@ -1,98 +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.
--->
-<div class="errors-container"></div>
-<form class="view-query-update custom-inputs">
- <div class="controls-group">
- <div class="row-fluid">
- <div class="controls controls-row">
- <input name="key" class="span6" type="text" placeholder="Key">
- <input name="keys" class="span6" type="text" placeholder="Keys">
- </div>
- </div>
- <div class="row-fluid">
- <div class="controls controls-row">
- <input name="startkey" class="span6" type="text" placeholder="Start Key">
- <input name="endkey" class="span6" type="text" placeholder="End Key">
- </div>
- </div>
- </div>
- <div class="controls-group">
- <div class="row-fluid">
- <div class="controls controls-row">
- <div class="checkbox inline">
- <input id="check1" type="checkbox" name="include_docs" value="true">
- <label name="include_docs" for="check1">Include Docs</label>
- <% if (hasReduce) { %>
- <input id="check2" name="reduce" type="checkbox" value="true">
- <label for="check2">Reduce</label>
- </div>
- <label id="select1" class="drop-down inline">
- Group Level:
- <select id="select1" disabled name="group_level" class="input-small">
- <option value="0">None</option>
- <option value="1">1</option>
- <option value="2">2</option>
- <option value="3">3</option>
- <option value="4">4</option>
- <option value="5">5</option>
- <option value="6">6</option>
- <option value="7">7</option>
- <option value="8">8</option>
- <option value="9">9</option>
- <option value="999" selected="selected">exact</option>
- </select>
- </label>
- <% } else{ %>
- </div>
- <% } %>
-
- <div class="checkbox inline">
- <input id="check3" name="stale" type="checkbox" value="ok">
- <label for="check3">Stale</label>
- <input id="check4" name="descending" type="checkbox" value="true">
- <label for="check4">Descending</label>
- </div>
- <label class="drop-down inline">
- Limit:
- <select name="limit" class="input-small">
- <option>5</option>
- <option>10</option>
- <option selected="selected">20</option>
- <option>30</option>
- <option>50</option>
- <option>100</option>
- </select>
- </label>
- <div class="checkbox inline">
- <input id="check5" name="inclusive_end" type="checkbox" value="false">
- <label for="check5">Disable Inclusive End</label>
- <input id="check6" name="update_seq" type="checkbox" value="true">
- <label for="check6">Update Sequence</label>
- </div>
- </div>
- </div>
- </div>
- <div class="controls-group">
- <div class="row-fluid">
- <div id="button-options" class="controls controls-row">
- <button type="submit" class="button green">Query</button>
- <% if (showPreview) { %>
- <button class="button btn-info preview">Browser Preview</button>
- <% } %>
- </div>
- </div>
- </div>
-</form>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_item.html b/src/fauxton/app/templates/documents/all_docs_item.html
deleted file mode 100644
index bfedaaa..0000000
--- a/src/fauxton/app/templates/documents/all_docs_item.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<td class="select"><input type="checkbox" class="row-select"></td>
-<td>
- <div>
- <pre class="prettyprint"><%- doc.prettyJSON() %></pre>
- <% if (doc.isEditable()) { %>
- <div class="btn-group">
- <a href="#<%= doc.url('web-index') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
- <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
- </div>
- <% } %>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_layout.html b/src/fauxton/app/templates/documents/all_docs_layout.html
deleted file mode 100644
index 6b4a31b..0000000
--- a/src/fauxton/app/templates/documents/all_docs_layout.html
+++ /dev/null
@@ -1,20 +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.
--->
-<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
- <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-bypass="true" data-toggle="tab">Query Options</a></li>
-</ul>
-<div class="tab-content">
- <div class="tab-pane" id="query">
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_list.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_list.html b/src/fauxton/app/templates/documents/all_docs_list.html
deleted file mode 100644
index 335b040..0000000
--- a/src/fauxton/app/templates/documents/all_docs_list.html
+++ /dev/null
@@ -1,43 +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.
--->
-
-<div class="view show">
- <% if (!viewList) { %>
- <div class="row">
- <div class="btn-toolbar span6">
- <button type="button" class="btn all" data-toggle="button">✓ All</button>
- <button class="btn btn-small disabled bulk-delete"><i class="icon-trash"></i></button>
- <% if (expandDocs) { %>
- <button id="collapse" class="btn"><i class="icon-minus"></i> Collapse</button>
- <% } else { %>
- <button id="collapse" class="btn"><i class="icon-plus"></i> Expand</button>
- <% } %>
- </div>
- </div>
- <% } %>
- <p>
-
- <div id="item-numbers"> </div>
-
- <% if (requestDuration) { %>
- <span class="view-request-duration">
- View request duration: <strong> <%= requestDuration %> </strong>
- </span>
- <% } %>
- </p>
- <table class="all-docs table table-striped table-condensed">
- <tbody></tbody>
- </table>
- <div id="documents-pagination"></div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/all_docs_number.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/all_docs_number.html b/src/fauxton/app/templates/documents/all_docs_number.html
deleted file mode 100644
index df8fe07..0000000
--- a/src/fauxton/app/templates/documents/all_docs_number.html
+++ /dev/null
@@ -1,23 +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.
--->
-<% if (totalRows === "unknown"){ %>
- Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
-<% } else if (showNumbers) { %>
- Showing <%=offset%> - <%= numModels %> of <%= totalRows %> rows
-<% } else { %>
- Showing <%=pageStart%> - <%= pageEnd %>
-<%}%>
-<% if (updateSeq) { %>
- -- Update Sequence: <%= updateSeq %>
-<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/changes.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/changes.html b/src/fauxton/app/templates/documents/changes.html
deleted file mode 100644
index 9408979..0000000
--- a/src/fauxton/app/templates/documents/changes.html
+++ /dev/null
@@ -1,38 +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.
--->
-
-<table id="changes-table" class="table">
- <thead>
- <th id="seq"> seq </th>
- <th> id </th>
- <th id="changes"> changes </th>
- <th id="deleted"> deleted? </th>
- </thead>
- <tbody>
- <% _.each(changes, function (change) { %>
- <tr>
- <td> <%= change.seq %> </td>
- <% if (change.deleted) { %>
- <td> <%= change.id %> </td>
- <% } else { %>
- <td> <a href="#<%= database.url('app') %>/<%= change.id %>"><%= change.id %></a> </td>
- <% } %>
- <td>
- <pre class="prettyprint"> <%- JSON.stringify({changes: change.changes, doc: change.doc}, null, " ") %> </pre>
- </td>
- <td><%= change.deleted ? "true" : "false" %></td>
- </tr>
- <% }); %>
- </tbody>
-</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/ddoc_info.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/ddoc_info.html b/src/fauxton/app/templates/documents/ddoc_info.html
deleted file mode 100644
index ed0aed6..0000000
--- a/src/fauxton/app/templates/documents/ddoc_info.html
+++ /dev/null
@@ -1,28 +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.
--->
-<div>
- <h2> Design Doc MetaData </h2>
- <div class="row-fluid">
- <% i=0; _.map(view_index, function (val, key) { %>
- <% if(i%2==0){%>
- <div class="row-fluid">
- <% }; %>
- <div class="span6 well-item"><strong> <%= key %></strong> : <%= val %> </div>
- <% if(i%2==1){%>
- </div>
- <% }; %>
- <% ++i;
- }); %>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/design_doc_selector.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/design_doc_selector.html b/src/fauxton/app/templates/documents/design_doc_selector.html
deleted file mode 100644
index 7bbe310..0000000
--- a/src/fauxton/app/templates/documents/design_doc_selector.html
+++ /dev/null
@@ -1,35 +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.
--->
-<div class="span3">
- <label for="ddoc">Save to Design Document <a href="<%=getDocUrl('design_doc')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <select id="ddoc">
- <optgroup label="Select a document">
- <option value="new-doc">New document</option>
- <% ddocs.each(function(ddoc) { %>
- <% if (ddoc.id === ddocName) { %>
- <option selected="selected" value="<%= ddoc.id %>"><%= ddoc.id %></option>
- <% } else { %>
- <option value="<%= ddoc.id %>"><%= ddoc.id %></option>
- <% } %>
- <% }); %>
- </optgroup>
- </select>
-</div>
-
-<div id="new-ddoc-section" class="span5" style="display:none">
- <label class="control-label" for="new-ddoc"> _design/ </label>
- <div class="controls">
- <input type="text" id="new-ddoc" placeholder="newDesignDoc">
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc.html b/src/fauxton/app/templates/documents/doc.html
deleted file mode 100644
index 10bbf8b..0000000
--- a/src/fauxton/app/templates/documents/doc.html
+++ /dev/null
@@ -1,55 +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.
--->
-
-<div id="doc">
- <div class="errors-container"></div>
-
-<div class="row doc-editor-buttons">
- <div class="span3">
- <button class="save-doc button green btn-medium save fonticon-circle-check" type="button">Save</button>
- <button class="button cancel-button gray btn-medium">Back to _all_docs</button>
- </div>
-
- <div class="span7">
- <% if (attachments) { %>
- <div class="btn-group">
- <a class="button gray btn-medium dropdown-toggle btn" data-bypass="true" data-toggle="dropdown" href="#">
- View Attachments
- <span class="caret"></span>
- </a>
- <ul class="dropdown-menu">
- <%_.each(attachments, function (att) { %>
- <li>
- <a href="<%= att.url %>" target="_blank"> <strong> <%= att.fileName %> </strong> -
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </a>
- </li>
- <% }) %>
- </ul>
- </div>
- <% } %>
- <button class="button gray btn-medium upload"><i class="icon-circle-arrow-up"></i> Upload Attachment</button>
- <button class="button gray btn-medium duplicate"><i class="icon-repeat"></i> Duplicate document</button>
- </div>
-
- <button class="button red btn-medium delete"><i class="icon-trash"></i></button>
- </ul>
-
-<div id="upload-modal"> </div>
-<div id="duplicate-modal"> </div>
-</div>
-
- <div id="editor-container" class="doc-code"><%- JSON.stringify(doc.attributes, null, " ") %></div>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc_field_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor.html b/src/fauxton/app/templates/documents/doc_field_editor.html
deleted file mode 100644
index 77d9278..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor.html
+++ /dev/null
@@ -1,74 +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.
--->
-
-<div id="doc-field-editor">
- <div class="tools">
-
- <div class="btn-toolbar pull-left">
- <button class="btn btn-small all">✓ All</button>
- <button class="btn btn-small disabled delete"><i class="icon-trash"></i> Delete field</button>
- <button class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</button>
- </div>
- <div class="btn-toolbar pull-right">
- <button class="btn btn-small cancel button cancel-button outlineGray fonticon-circle-x">Cancel</button>
- <button class="btn btn-small save button green fonticon-circle-check">Save</button>
- </div>
- </div>
-
- <div class="clearfix"></div>
- <!-- <hr style="margin-top: 0"/> -->
-
- <table class="table table-striped table-condensed">
- <thead>
- <tr>
- <th class="select">
- </th>
- <th>Key</th>
- <th>Value</th>
- </tr>
- </thead>
- <tbody>
- <tr style="display:none">
- <td class="select"><input type="checkbox" /></td>
- <td class="key"><input type="text" class="input-large" value='' /></td>
- <td class="value"><input type="text" class="input-xxlarge" value='' /></td>
- </tr>
- <% _.each(doc, function(value, key) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td class="key">
- <input type="text" class="input-large" name="doc[<%= key %>]" value="<%= key %>" />
- </td>
- <td class="value"><input type="text" class="input-xxlarge" value='<%= JSON.stringify(value) %>' /></td>
- </tr>
- <% }); %>
- <tr>
- <th colspan="3">
- Attachments
- </th>
- </tr>
- <%_.each(attachments, function (att) { %>
- <tr>
- <td class="select"><input type="checkbox" /></td>
- <td colspan="2">
- <a href="<%= att.url %>" target="_blank"> <%= att.fileName %> </a>
- <span> <%= att.contentType %>, <%= formatSize(att.size)%> </span>
- </td>
- </tr>
- <% }) %>
- </tbody>
- </table>
- <a class="btn btn-small new" style="margin-left: 64px"><i class="icon-plus"></i> New field</a>
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html b/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
deleted file mode 100644
index 766647c..0000000
--- a/src/fauxton/app/templates/documents/doc_field_editor_tabs.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<!--<ul class="nav nav-tabs">
- <li id="field_editor" class="<%= isSelectedClass('field_editor') %>"><a href="#<%= doc.url('app') %>/field_editor">Doc fields</a></li>
- <li id="code_editor" class="<%= isSelectedClass('code_editor') %>"><a href="#<%= doc.url('app') %>/code_editor"><i class="icon-pencil"> </i> Code editor</a>
- </li>
-</ul>-->
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/duplicate_doc_modal.html b/src/fauxton/app/templates/documents/duplicate_doc_modal.html
deleted file mode 100644
index dbb25bc..0000000
--- a/src/fauxton/app/templates/documents/duplicate_doc_modal.html
+++ /dev/null
@@ -1,36 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Duplicate Document</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="hide alert alert-error"/>
- <form id="doc-duplicate" class="form" method="post">
- <p class="help-block">
- Set new documents ID:
- </p>
- <input id="dup-id" type="text" class="input-xlarge">
- </form>
-
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
- <a href="#" id="duplicate-btn" class="btn btn-primary button green save fonticon-circle-check">Duplicate</a>
- </div>
-</div>
-
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/edit_tools.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/edit_tools.html b/src/fauxton/app/templates/documents/edit_tools.html
deleted file mode 100644
index 40c884d..0000000
--- a/src/fauxton/app/templates/documents/edit_tools.html
+++ /dev/null
@@ -1,44 +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.
--->
-
-<div class="view show">
- <p>
- Showing 1-<%= numModels %> of <%= totalRows %> rows
- <% if (updateSeq) { %>
- -- Update Sequence: <%= updateSeq %>
- <% } %>
- <% if (requestDuration) { %>
- <span class="view-request-duration">
- View request duration: <strong> <%= requestDuration %> </strong>
- </span>
- <% } %>
- </p>
- <table class="all-docs table table-striped table-condensed">
- <tbody></tbody>
- </table>
- <!--
- <div class="pagination pagination-centered">
- <ul>
- <li class="disabled"><a href="#">«</a></li>
- <li class="active"><a href="#">1</a></li>
- <li><a href="#">2</a></li>
- <li><a href="#">3</a></li>
- <li><a href="#">4</a></li>
- <li><a href="#">5</a></li>
- <li><a href="#">»</a></li>
- </ul>
- </div>
- -->
-
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/index_menu_item.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_menu_item.html b/src/fauxton/app/templates/documents/index_menu_item.html
deleted file mode 100644
index 7ca9012..0000000
--- a/src/fauxton/app/templates/documents/index_menu_item.html
+++ /dev/null
@@ -1,17 +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.
--->
-
-<a id="<%= ddoc_clean %>_<%= index_clean %>" href="#database/<%= database_encoded %>/_design/<%= ddoc_encoded %>/_view/<%= index_encoded %>" class="toggle-view">
- <%= ddoc %><span class="divider">/</span><%= index %>
-</a>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_docular.html b/src/fauxton/app/templates/documents/index_row_docular.html
deleted file mode 100644
index f1b2217..0000000
--- a/src/fauxton/app/templates/documents/index_row_docular.html
+++ /dev/null
@@ -1,27 +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.
--->
-<% if (doc.isEditable()) { %>
- <td class="select"><input type="checkbox"></td>
-<% } %>
-<td>
- <div>
- <pre class="prettyprint"><%- doc.prettyJSON() %></pre>
- <% if (doc.isEditable()) { %>
- <div class="btn-group">
- <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
- <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
- </div>
- <% } %>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/index_row_tabular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/index_row_tabular.html b/src/fauxton/app/templates/documents/index_row_tabular.html
deleted file mode 100644
index f5f68fa..0000000
--- a/src/fauxton/app/templates/documents/index_row_tabular.html
+++ /dev/null
@@ -1,25 +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.
--->
-
-<td class="select"><input type="checkbox"></td>
-<td>
- <div>
- <pre class="prettyprint"><%- JSON.stringify(doc.get("key")) %></pre>
- </div>
-</td>
-<td>
- <div>
- <pre class="prettyprint"><%- JSON.stringify(doc.get("value")) %></pre>
- </div>
-</td>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/jumpdoc.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/jumpdoc.html b/src/fauxton/app/templates/documents/jumpdoc.html
deleted file mode 100644
index 43fdb9c..0000000
--- a/src/fauxton/app/templates/documents/jumpdoc.html
+++ /dev/null
@@ -1,19 +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.
--->
-
-<form id="jump-to-doc" class="form-inline input-append" >
- <input type="text" id="jump-to-doc-id" class="input-large" placeholder="Document ID"></input>
-
- <button class="fonticon-search btn button red " type="submit"></button>
-</form>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/search.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/search.html b/src/fauxton/app/templates/documents/search.html
deleted file mode 100644
index bb84891..0000000
--- a/src/fauxton/app/templates/documents/search.html
+++ /dev/null
@@ -1,15 +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.
--->
-
-<input id="searchbox" type="text" class="span12" placeholder="Search by doc id, view key or search index">
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/sidebar.html b/src/fauxton/app/templates/documents/sidebar.html
deleted file mode 100644
index 8a73ae9..0000000
--- a/src/fauxton/app/templates/documents/sidebar.html
+++ /dev/null
@@ -1,67 +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.
--->
-
-<div id="sidenav">
- <header class="row-fluid">
- <div class="span12">
- <div class="btn-group">
- <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
- Docs
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <!-- dropdown menu links -->
- <li><a class="icon-file" href="<%= db_url %>">Docs</a></li>
- <li><a class="icon-lock" href="<%= permissions_url %>">Permissions</a></li>
- <li><a class="icon-forward" href="<%= changes_url %>">Changes</a></li>
- <% _.each(docLinks, function (link) { %>
- <li><a class="<%= link.icon %>" href="<%= database_url + '/' + link.url %>"><%= link.title %></a></li>
- <% }); %>
- </ul>
- </div>
-
- <div class="btn-group">
- <button class="btn dropdown-toggle dropdown-toggle-btn" data-toggle="dropdown">
- New
- <span class="caret"></span>
- </button>
- <ul class="dropdown-menu">
- <!-- dropdown menu links -->
- <li>
- <a id="doc" href="#<%= database.url('app') %>/new">Document</a>
- </li>
- <li>
- <a href="#<%= database.url('app') %>/new_view">Secondary Index</a>
- <% _.each(newLinks, function (item) { %>
- <a href="#<%= database.url('app') %>/<%=item.url%>"> <%= item.name %></a>
- <% }); %>
- </li>
- </ul>
- </div>
- <button id="delete-database" class="btn"><i class="icon-trash"></i> Database</button>
- </div>
- </header>
-
- <nav>
- <ul class="nav nav-list">
- <li class="active"><a id="all-docs" href="#<%= database.url('index') %>?limit=<%= docLimit %>" class="toggle-view"> All documents</a></li>
- <li><a id="design-docs" href='#<%= database.url("index") %>?limit=<%= docLimit %>&startkey="_design"&endkey="_e"' class="toggle-view"> All design docs</a></li>
- </ul>
- <ul class="nav nav-list views">
- <li class="nav-header">Secondary Indexes</li>
- <li><a id="new-view" href="#<%= database.url('app') %>/new_view" class="new"><i class="icon-plus"></i> New</a></li>
- </ul>
- <div id="extension-navs"></div>
- </nav>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/tabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/tabs.html b/src/fauxton/app/templates/documents/tabs.html
deleted file mode 100644
index f8b0c4b..0000000
--- a/src/fauxton/app/templates/documents/tabs.html
+++ /dev/null
@@ -1,18 +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.
--->
-
-<ul class="nav nav-tabs">
- <li class="active"><a href="<%= db_url %>">Docs</a></li>
- <li id="changes"><a href="<%= changes_url %>">Changes</a></li>
-</ul>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/upload_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/upload_modal.html b/src/fauxton/app/templates/documents/upload_modal.html
deleted file mode 100644
index 9a5c5cd..0000000
--- a/src/fauxton/app/templates/documents/upload_modal.html
+++ /dev/null
@@ -1,42 +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.
--->
-
-<div class="modal hide fade">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h3>Upload an Attachment</h3>
- </div>
- <div class="modal-body">
- <div id="modal-error" class="alert alert-error hide" style="font-size: 16px;"> </div>
- <form id="file-upload" class="form" method="post">
- <p class="help-block">
- Please select the file you want to upload as an attachment to this document.
- Please note that this will result in the immediate creation of a new revision of the document,
- so it's not necessary to save the document after the upload.
- </p>
- <input id="_attachments" type="file" name="_attachments">
- <input id="_rev" type="hidden" name="_rev" value="" >
- <br/>
- </form>
-
- <div class="progress progress-info">
- <div class="bar" style="width: 0%"></div>
- </div>
- </div>
- <div class="modal-footer">
- <a href="#" data-dismiss="modal" data-bypass="true" class="btn button cancel-button outlineGray fonticon-circle-x">Cancel</a>
- <a href="#" id="upload-btn" data-bypass="true" class="btn btn-primary button green save fonticon-circle-check">Upload</a>
- </div>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ae03a97b/src/fauxton/app/templates/documents/view_editor.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/documents/view_editor.html b/src/fauxton/app/templates/documents/view_editor.html
deleted file mode 100644
index ddb5a0c..0000000
--- a/src/fauxton/app/templates/documents/view_editor.html
+++ /dev/null
@@ -1,87 +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.
--->
-<div class="row">
- <ul class="nav nav-tabs" id="db-views-tabs-nav">
- <li class="active"> <a data-bypass="true" id="index-nav" class="fonticon-wrench fonticon" data-toggle="tab" href="#index"><% if (newView) { %>Create Index <% } else { %>Edit Index <% } %></a></li>
- <% if (!newView) { %>
- <li><a data-bypass="true" id="query-nav" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
- <li><a data-bypass="true" id="meta-nav" href="#metadata" data-toggle="tab">Design Doc Metadata</a></li>
- <% } %>
- </ul>
- <div class="all-docs-list errors-container"></div>
- <div class="tab-content">
- <div class="tab-pane active" id="index">
- <div id="define-view" class="ddoc-alert well">
- <div class="errors-container"></div>
- <form class="form-horizontal view-query-save">
-
- <div class="control-group design-doc-group">
- </div>
-
- <div class="control-group">
- <label for="index-name">Index name <a href="<%=getDocUrl('view_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <input type="text" id="index-name" value="<%= viewName %>" placeholder="Index name" />
- </div>
-
-
- <div class="control-group">
- <label for="map-function">Map function <a href="<%=getDocUrl('map_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
- <% if (newView) { %>
- <div class="js-editor" id="map-function"><%= langTemplates.map %></div>
- <% } else { %>
- <div class="js-editor" id="map-function"><%- ddoc.get('views')[viewName].map %></div>
- <% } %>
- </div>
-
-
- <div class="control-group">
- <label for="reduce-function-selector">Reduce (optional) <a href="<%=getDocUrl('reduce_functions')%>" target="_blank"><i class="icon-question-sign"></i></a></label>
-
- <select id="reduce-function-selector">
- <option value="" <%= !reduceFunStr ? 'selected="selected"' : '' %>>None</option>
- <% _.each(["_sum", "_count", "_stats"], function(reduce) { %>
- <option value="<%= reduce %>" <% if (reduce == reduceFunStr) { %>selected<% } %>><%= reduce %></option>
- <% }) %>
- <option value="CUSTOM" <% if (isCustomReduce) { %>selected<% } %>>Custom Reduce function</option>
- </select>
- </div>
-
- <div class="control-group reduce-function">
- <label for="reduce-function">Custom Reduce function</label>
- <% if (newView) { %>
- <div class="js-editor" id="reduce-function"><%= langTemplates.reduce %></div>
- <% } else { %>
- <div class="js-editor" id="reduce-function"><%- ddoc.get('views')[viewName].reduce %></div>
- <% } %>
- </div>
-
- <div class="control-group">
- <button class="button green save fonticon-circle-check">Save & Build Index</button>
- <button class="button btn-info preview">Preview</button>
- <% if (!newView) { %>
- <button class="button delete outlineGray fonticon-circle-x">Delete</button>
- <% } %>
- </div>
- <div class="clearfix"></div>
- </form>
- </div>
- </div>
- <div class="tab-pane" id="metadata">
- <div id="ddoc-info" class="well"> </div>
- </div>
- <div class="tab-pane" id="query">
- </div>
- </div>
-</div>
-
[13/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Clean up active xhr
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/392f7b3e
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/392f7b3e
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/392f7b3e
Branch: refs/heads/fauxton-file-reorder
Commit: 392f7b3ec78bcd6eca2e9661afabbd4ec39c5337
Parents: b9d30b1
Author: Garren Smith <ga...@gmail.com>
Authored: Thu Dec 19 15:52:22 2013 +0200
Committer: suelockwood <de...@apache.org>
Committed: Tue Jan 14 10:45:55 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/api.js | 41 ++++++++++++++++++++++++++++++++++++++---
src/fauxton/app/router.js | 2 +-
2 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/392f7b3e/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index f423ef5..6d450de 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -290,6 +290,7 @@ function(app, Fauxton) {
establish: function() {},
route: function() {},
roles: [],
+ _promises: [],
initialize: function() {}
}, {
@@ -319,7 +320,9 @@ function(app, Fauxton) {
}
triggerBroadcast('beforeEstablish');
- FauxtonAPI.when(this.establish()).then(function(resp) {
+ var establishPromise = this.establish();
+ this.addPromise(establishPromise);
+ FauxtonAPI.when(establishPromise).then(function(resp) {
triggerBroadcast('afterEstablish');
_.each(routeObject.getViews(), function(view, selector) {
if(view.hasRendered) {
@@ -328,6 +331,8 @@ function(app, Fauxton) {
}
triggerBroadcast('beforeRender', view, selector);
+ var viewPromise = view.establish();
+ routeObject.addPromise(viewPromise);
FauxtonAPI.when(view.establish()).then(function(resp) {
masterLayout.setView(selector, view);
@@ -339,7 +344,7 @@ function(app, Fauxton) {
reason: resp
};
- if (resp) {
+ if (resp && resp.responseText) {
var errorText = JSON.parse(resp.responseText).reason;
FauxtonAPI.addNotification({
msg: 'An Error occurred: ' + errorText,
@@ -353,7 +358,7 @@ function(app, Fauxton) {
});
}.bind(this), function (resp) {
- if (!resp) { return; }
+ if (!resp || !resp.responseText) { return; }
FauxtonAPI.addNotification({
msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
type: 'error',
@@ -422,6 +427,36 @@ function(app, Fauxton) {
}, this);
},
+ addPromise: function (promise) {
+ if (_.isEmpty(promise)) { return; }
+
+ if (_.isArray(promise)) {
+ return _.each(promise, function (p) {
+ this._promises.push(p);
+ }, this);
+ }
+
+ this._promises.push(promise);
+ },
+
+ cleanup: function () {
+ this.removeViews();
+ this.rejectPromises();
+ },
+
+ rejectPromises: function () {
+ _.each(this._promises, function (promise) {
+ if (promise.state() === "resolved") { return; }
+ if (promise.abort) {
+ return promise.abort("Route change");
+ }
+
+ promise.reject();
+ }, this);
+
+ this._promises = [];
+ },
+
getRouteUrls: function () {
return _.keys(this.get('routes'));
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/392f7b3e/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index 7cf69ad..89c60cf 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -76,7 +76,7 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, LoadAddons) {
authPromise.then(function () {
if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
if (that.activeRouteObject) {
- that.activeRouteObject.removeViews();
+ that.activeRouteObject.cleanup();
}
that.activeRouteObject = new RouteObject(route, masterLayout, args);
}
[04/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Remove unused templates
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/bea8c6d1
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/bea8c6d1
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/bea8c6d1
Branch: refs/heads/fauxton-file-reorder
Commit: bea8c6d16b753d89fd0452eecb7d2bb766a3a06e
Parents: b71c719
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 14:45:31 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 14:46:00 2014 -0500
----------------------------------------------------------------------
.../app/templates/layouts/one_pane_notabs.html | 27 --------------------
.../templates/layouts/with_right_sidebar.html | 26 -------------------
2 files changed, 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bea8c6d1/src/fauxton/app/templates/layouts/one_pane_notabs.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/one_pane_notabs.html b/src/fauxton/app/templates/layouts/one_pane_notabs.html
deleted file mode 100644
index f58661f..0000000
--- a/src/fauxton/app/templates/layouts/one_pane_notabs.html
+++ /dev/null
@@ -1,27 +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.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid one-pane">
- <div class="fixed-header">
- <div id="breadcrumbs"></div>
- <div id="api-navbar"></div>
- </div>
-
-
- <div class="row-fluid content-area">
- <div id="dashboard-content" class="window-resizeable"></div>
- </div>
-</div>
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/bea8c6d1/src/fauxton/app/templates/layouts/with_right_sidebar.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/templates/layouts/with_right_sidebar.html b/src/fauxton/app/templates/layouts/with_right_sidebar.html
deleted file mode 100644
index ade5b82..0000000
--- a/src/fauxton/app/templates/layouts/with_right_sidebar.html
+++ /dev/null
@@ -1,26 +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.
--->
-
-<div id="primary-navbar"></div>
-<div id="dashboard" class="container-fluid">
- <div class="fixed-header">
- <div id="breadcrumbs"></div>
- <div id="api-navbar"></div>
- </div>
- <div class="with-sidebar-right content-area">
- <div id="dashboard-content" class="list"></div>
- <div id="sidebar-content" class="sidebar pull-right window-resizeable"></div>
- </div>
-</div>
-
[09/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fix so that you can edit view docs, but not delete them
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/61d06177
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/61d06177
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/61d06177
Branch: refs/heads/fauxton-file-reorder
Commit: 61d061771adbfd8d3023e38a46225dea46701e3c
Parents: 86ef9ee
Author: suelockwood <de...@apache.org>
Authored: Mon Jan 13 15:27:21 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:27:21 2014 -0500
----------------------------------------------------------------------
.../app/addons/documents/templates/index_row_docular.html | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/61d06177/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index f1b2217..446a031 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -17,11 +17,13 @@ the License.
<td>
<div>
<pre class="prettyprint"><%- doc.prettyJSON() %></pre>
- <% if (doc.isEditable()) { %>
+
<div class="btn-group">
<a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
- <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
+ <% if (doc.isEditable()) { %>
+ <button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
+ <% } %>
</div>
- <% } %>
+
</div>
</td>
[19/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
added fauxton grunt test stuff to .travis.yml
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/c56e5a88
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/c56e5a88
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/c56e5a88
Branch: refs/heads/fauxton-file-reorder
Commit: c56e5a88dfed49e0f8661b4b7d579d0860151997
Parents: f04485f
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Tue Jan 14 16:01:32 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 16 15:10:40 2014 +0200
----------------------------------------------------------------------
.travis.yml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/c56e5a88/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 827badf..f90895d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,11 @@ before_install:
- sudo apt-get -y install texlive-latex-extra texlive-fonts-recommended texinfo
- sudo apt-get -y install python-pygments python-docutils python-sphinx
before_script: ./bootstrap && ./configure
-script: make distcheck
+script:
+ - make distcheck
+ - cd src/fauxton
+ - npm install
+ - grunt test
language: erlang
otp_release:
- R16B
[29/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fauxton: Split up api.js
Split up api to core/*. Move tests to fit with this refactor.
Change addons/Fauxton with work with api extraction.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/35d2ec19
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/35d2ec19
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/35d2ec19
Branch: refs/heads/fauxton-file-reorder
Commit: 35d2ec190124b893b6d6ccdd799169d9fde58780
Parents: 28ade47
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 20 15:11:13 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 20 15:11:13 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 4 +-
.../app/addons/activetasks/tests/viewsSpec.js | 3 -
src/fauxton/app/addons/auth/resources.js | 7 +-
src/fauxton/app/addons/fauxton/base.js | 9 +
src/fauxton/app/addons/fauxton/layout.js | 4 +
.../app/addons/fauxton/tests/baseSpec.js | 74 +++++
.../app/addons/fauxton/tests/navbarSpec.js | 107 +++++++
.../app/addons/fauxton/tests/paginateSpec.js | 105 +++++++
src/fauxton/app/app.js | 10 +-
src/fauxton/app/config.js | 2 +-
src/fauxton/app/core/api.js | 108 +------
src/fauxton/app/core/auth.js | 67 +++++
src/fauxton/app/core/base.js | 20 +-
src/fauxton/app/core/couchdbSession.js | 95 +++----
src/fauxton/app/core/layout.js | 90 ++++++
src/fauxton/app/core/resources.js | 285 -------------------
src/fauxton/app/core/routeObject.js | 265 +++++++++++++++++
src/fauxton/app/core/router.js | 113 ++++++++
src/fauxton/app/core/tests/layoutSpec.js | 92 ++++++
src/fauxton/app/core/tests/routeObjectSpec.js | 96 +++++++
src/fauxton/tasks/couchserver.js | 2 +-
src/fauxton/test/core/layoutSpec.js | 94 ------
src/fauxton/test/core/navbarSpec.js | 107 -------
src/fauxton/test/core/paginateSpec.js | 109 -------
src/fauxton/test/core/routeObjectSpec.js | 105 -------
src/fauxton/test/mocha/testUtils.js | 5 +-
src/fauxton/test/test.config.underscore | 1 +
27 files changed, 1107 insertions(+), 872 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 32065b6..2c5a249 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -357,7 +357,7 @@ module.exports = function(grunt) {
mochaSetup: {
default: {
- files: { src: helper.watchFiles(['[Ss]pec.js'], ['./test/core/**/*[Ss]pec.js', './app/**/*[Ss]pec.js'])},
+ files: { src: helper.watchFiles(['[Ss]pec.js'], ['./app/**/*[Ss]pec.js'])},
template: 'test/test.config.underscore',
config: './app/config.js'
}
@@ -424,7 +424,7 @@ module.exports = function(grunt) {
grunt.registerTask('lint', ['clean', 'jshint']);
grunt.registerTask('test', ['lint', 'dependencies', 'test_inline']);
// lighter weight test task for use inside dev/watch
- grunt.registerTask('test_inline', ['mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
+ grunt.registerTask('test_inline', ['mochaSetup','jst', 'concat:test_config_js','mocha_phantomjs']);
// Fetch dependencies (from git or local dir), lint them and make load_addons
grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']);
// build templates, js and css
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/activetasks/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/activetasks/tests/viewsSpec.js b/src/fauxton/app/addons/activetasks/tests/viewsSpec.js
index 395b60a..13c9049 100644
--- a/src/fauxton/app/addons/activetasks/tests/viewsSpec.js
+++ b/src/fauxton/app/addons/activetasks/tests/viewsSpec.js
@@ -132,8 +132,5 @@ define([
});
});
-
-
-
});
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js
index 970d55b..321d302 100644
--- a/src/fauxton/app/addons/auth/resources.js
+++ b/src/fauxton/app/addons/auth/resources.js
@@ -12,10 +12,11 @@
define([
"app",
- "api"
+ "api",
+ "core/CouchdbSession"
],
-function (app, FauxtonAPI) {
+function (app, FauxtonAPI, CouchdbSession) {
var Auth = new FauxtonAPI.addon();
@@ -46,7 +47,7 @@ function (app, FauxtonAPI) {
}
});
- Auth.Session = FauxtonAPI.Session.extend({
+ Auth.Session = CouchdbSession.Session.extend({
url: app.host + '/_session',
initialize: function (options) {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
index ee6b794..2fee680 100644
--- a/src/fauxton/app/addons/fauxton/base.js
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -66,6 +66,15 @@ function(app, FauxtonAPI, resizeColumns) {
}));
}
});
+
+ FauxtonAPI.RouteObject.on('renderComplete', function (routeObject) {
+ var masterLayout = FauxtonAPI.masterLayout;
+ if (routeObject.get('apiUrl')){
+ masterLayout.apiBar.update(routeObject.get('apiUrl'));
+ } else {
+ masterLayout.apiBar.hide();
+ }
+ });
};
Fauxton.Breadcrumbs = Backbone.View.extend({
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/fauxton/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/layout.js b/src/fauxton/app/addons/fauxton/layout.js
index 3810c84..baac864 100644
--- a/src/fauxton/app/addons/fauxton/layout.js
+++ b/src/fauxton/app/addons/fauxton/layout.js
@@ -29,6 +29,10 @@ function(Backbone) {
this.el = this.layout.el;
};
+ Layout.configure = function (options) {
+ Backbone.Layout.configure(options);
+ };
+
// creatings the dashboard object same way backbone does
_.extend(Layout.prototype, {
render: function () {
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/fauxton/tests/baseSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/tests/baseSpec.js b/src/fauxton/app/addons/fauxton/tests/baseSpec.js
new file mode 100644
index 0000000..644002c
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/tests/baseSpec.js
@@ -0,0 +1,74 @@
+// 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.
+define([
+ 'testUtils',
+ 'api',
+ 'addons/fauxton/base',
+ "backbone"
+], function (testUtils, FauxtonAPI, Base) {
+ var assert = testUtils.assert;
+
+
+ describe('Fauxton RouteObject:beforeEstablish', function () {
+ var TestRouteObject, testRouteObject, mockLayout, _layout;
+
+ before(function () {
+ Base.initialize();
+ _layout = FauxtonAPI.masterLayout;
+ });
+
+ beforeEach(function () {
+ TestRouteObject = FauxtonAPI.RouteObject.extend({
+ crumbs: ['mycrumbs']
+ });
+
+ testRouteObject = new TestRouteObject();
+ var apiBar = {};
+ apiBar.hide = sinon.spy();
+
+ // Need to find a better way of doing this
+ mockLayout = {
+ setTemplate: sinon.spy(),
+ clearBreadcrumbs: sinon.spy(),
+ setView: sinon.spy(),
+ renderView: sinon.spy(),
+ hooks: [],
+ setBreadcrumbs: sinon.spy(),
+ apiBar: apiBar,
+ layout: {
+ setView: function () {}
+ }
+ };
+
+
+ });
+
+ after(function () {
+ FauxtonAPI.masterLayout = _layout;
+ });
+
+ it('Should clear breadcrumbs', function () {
+ FauxtonAPI.masterLayout = mockLayout;
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+ assert.ok(mockLayout.clearBreadcrumbs.calledOnce, 'Clear Breadcrumbs called');
+ });
+
+ it('Should set breadcrumbs when breadcrumbs exist', function () {
+ FauxtonAPI.masterLayout = mockLayout;
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+ assert.ok(mockLayout.setBreadcrumbs.calledOnce, 'Set Breadcrumbs was called');
+ });
+
+ });
+
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/fauxton/tests/navbarSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/tests/navbarSpec.js b/src/fauxton/app/addons/fauxton/tests/navbarSpec.js
new file mode 100644
index 0000000..3eca6f6
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/tests/navbarSpec.js
@@ -0,0 +1,107 @@
+// 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.
+define([
+ 'addons/fauxton/base',
+ 'testUtils'
+], function (Fauxton, testUtils) {
+ var assert = testUtils.assert,
+ NavBar = Fauxton.NavBar;
+
+ describe('NavBar', function () {
+
+ describe('adding links', function () {
+ var navBar;
+
+ beforeEach(function () {
+ navBar = new NavBar();
+ navBar.navLinks = [];
+ navBar.bottomNavLinks = [];
+ navBar.footerNavLinks = [];
+ });
+
+ it('Should add link to navlinks', function () {
+ navBar.addLink({href: '#/test', title: 'Test Title'});
+
+ assert.equal(navBar.navLinks.length, 1);
+ assert.equal(navBar.footerNavLinks.length, 0);
+ assert.equal(navBar.bottomNavLinks.length, 0);
+ });
+
+ it('Should add link to bottom links', function () {
+ navBar.addLink({href: '#/test', bottomNav: true, title: 'Test Title'});
+
+ assert.equal(navBar.bottomNavLinks.length, 1);
+ assert.equal(navBar.navLinks.length, 0);
+ assert.equal(navBar.footerNavLinks.length, 0);
+ });
+
+ it('Should add link to footer links', function () {
+ navBar.addLink({href: '#/test', footerNav: true, title: 'Test Title'});
+
+ assert.equal(navBar.footerNavLinks.length, 1);
+ assert.equal(navBar.bottomNavLinks.length, 0);
+ assert.equal(navBar.navLinks.length, 0);
+ });
+ });
+
+ describe('removing links', function () {
+ var navBar;
+
+ beforeEach(function () {
+ navBar = new NavBar();
+ navBar.navLinks = [];
+ navBar.bottomNavLinks = [];
+ navBar.footerNavLinks = [];
+ navBar.addLink({
+ href: '#/test',
+ footerNav: true,
+ title: 'Test Title Footer'
+ });
+
+ navBar.addLink({
+ href: '#/test',
+ bottomNav: true,
+ title: 'Test Title Bottom'
+ });
+
+ navBar.addLink({
+ href: '#/test',
+ title: 'Test Title'
+ });
+ });
+
+ it("should remove links from list", function () {
+ navBar.removeLink({
+ title: 'Test Title Footer',
+ footerNav: true
+ });
+
+ assert.equal(navBar.footerNavLinks.length, 0);
+ assert.equal(navBar.bottomNavLinks.length, 1);
+ assert.equal(navBar.navLinks.length, 1);
+ });
+
+ it("Should call render after removing links", function () {
+ var renderSpy = sinon.stub(navBar,'render');
+
+ navBar.removeLink({
+ title: 'Test Title Footer',
+ footerNav: true
+ });
+
+ assert.ok(renderSpy.calledOnce);
+ });
+
+ });
+ });
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/addons/fauxton/tests/paginateSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/tests/paginateSpec.js b/src/fauxton/app/addons/fauxton/tests/paginateSpec.js
new file mode 100644
index 0000000..535e26f
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/tests/paginateSpec.js
@@ -0,0 +1,105 @@
+// 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.
+define([
+ 'app',
+ 'addons/fauxton/components',
+ 'addons/documents/resources',
+ 'testUtils',
+ 'api'
+], function (app, Views, Models, testUtils, FauxtonAPI) {
+ var assert = testUtils.assert,
+ ViewSandbox = testUtils.ViewSandbox;
+
+
+ describe('IndexPaginate', function () {
+ var viewSandbox, paginate, collection, navigateMock;
+ beforeEach(function () {
+ collection = new Models.IndexCollection([{
+ id:'myId1',
+ doc: 'num1'
+ },
+ {
+ id:'myId2',
+ doc: 'num2'
+ }], {
+ database: {id: 'databaseId'},
+ design: '_design/myDoc'
+ });
+
+ paginate = new Views.IndexPagination({
+ collection: collection,
+ previousUrlfn: function () {},
+ nextUrlfn: function () {},
+ canShowPreviousfn: function () { return true; },
+ canShowNextfn: function () { return true;}
+ });
+ viewSandbox = new ViewSandbox();
+ viewSandbox.renderView(paginate);
+ });
+
+ afterEach(function () {
+ viewSandbox.remove();
+ });
+
+ describe('#next', function () {
+ beforeEach(function () {
+ //do this so it doesn't throw an error on other unwired up components
+ FauxtonAPI.triggerRouteEvent = function () {};
+ //FauxtonAPI.triggerRouteEvent.restore && FauxtonAPI.triggerRouteEvent.restore();
+ //FauxtonAPI.navigate.restore && FauxtonAPI.navigate.restore();
+ });
+
+ it('Should navigate', function () {
+ var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
+
+ paginate.$('a#next').click();
+
+ assert.ok(navigateMock.calledOnce);
+ FauxtonAPI.navigate.restore();
+ });
+
+ it('Should trigger routeEvent', function () {
+ var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
+
+ paginate.$('a#next').click();
+
+ assert.ok(navigateMock.calledOnce);
+ FauxtonAPI.triggerRouteEvent.restore();
+ });
+
+ });
+
+
+ describe('#previous', function () {
+
+ it('Should navigate', function () {
+ var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
+
+ paginate.$('a#previous').click();
+
+ assert.ok(navigateMock.calledOnce);
+ FauxtonAPI.navigate.restore();
+ });
+
+ it('Should trigger routeEvent', function () {
+ var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
+
+ paginate.$('a#previous').click();
+
+ assert.ok(navigateMock.calledOnce);
+ FauxtonAPI.triggerRouteEvent.restore();
+ });
+
+ });
+
+ });
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 23a72c7..74980ea 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -24,14 +24,14 @@ define([
"core/utils",
// Modules
"core/api",
- "addons/Fauxton/layout",
+ "core/couchdbSession",
// Plugins.
"plugins/backbone.layoutmanager",
"plugins/jquery.form"
],
-function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Layout, LoadAddons) {
+function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Couchdb) {
// Make sure we have a console.log
if (typeof console == "undefined") {
console = {
@@ -52,7 +52,7 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Layout, Loa
var JST = window.JST = window.JST || {};
// Configure LayoutManager with Backbone Boilerplate defaults.
- Backbone.Layout.configure({
+ FauxtonAPI.Layout.configure({
// Allow LayoutManager to augment Backbone.View.prototype.
manage: true,
@@ -84,11 +84,13 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Layout, Loa
}
});
+ FauxtonAPI.setSession(new Couchdb.Session());
+
// Define your master router on the application namespace and trigger all
// navigation from this instance.
FauxtonAPI.config({
el: "#app-container",
- masterLayout: new Layout(),
+ masterLayout: new FauxtonAPI.Layout(),
addHeaderLink: function(link) {
FauxtonAPI.registerExtension('navbar:addHeaderLink', link);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/config.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/config.js b/src/fauxton/app/config.js
index 5dae1de..c3000c7 100644
--- a/src/fauxton/app/config.js
+++ b/src/fauxton/app/config.js
@@ -25,7 +25,7 @@ require.config({
jquery: "../assets/js/libs/jquery",
lodash: "../assets/js/libs/lodash",
backbone: "../assets/js/libs/backbone",
- "backbone.layoutmanger": "../assets/js/plugins/backbone.layoutmanager",
+ "backbone.layoutmanager": "../assets/js/plugins/backbone.layoutmanager",
bootstrap: "../assets/js/libs/bootstrap",
spin: "../assets/js/libs/spin.min",
d3: "../assets/js/libs/d3",
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/api.js b/src/fauxton/app/core/api.js
index 81e9aa4..5483f44 100644
--- a/src/fauxton/app/core/api.js
+++ b/src/fauxton/app/core/api.js
@@ -11,12 +11,22 @@
// the License.
define([
- "core/resources",
+ "core/base",
+ "core/layout",
+ "core/router",
+ "core/routeObject",
+ "core/couchdbSession",
"core/utils"
],
-function(FauxtonAPI, utils) {
- FauxtonAPI.utils = utils;
+function(FauxtonAPI, Layout, Router, RouteObject, CouchdbSession, utils) {
+ FauxtonAPI = _.extend(FauxtonAPI, {
+ Layout: Layout,
+ Router: Router,
+ RouteObject: RouteObject,
+ utils: utils
+ });
+
FauxtonAPI.navigate = function(url, _opts) {
var options = _.extend({trigger: true}, _opts );
FauxtonAPI.router.navigate(url,options);
@@ -38,97 +48,7 @@ function(FauxtonAPI, utils) {
FauxtonAPI.router.triggerRouteEvent("route:"+routeEvent, args);
};
- var beforeUnloads = {};
-
- FauxtonAPI.Router = Backbone.Router.extend({
- routes: {},
-
- beforeUnload: function (name, fn) {
- beforeUnloads[name] = fn;
- },
-
- removeBeforeUnload: function (name) {
- delete beforeUnloads[name];
- },
-
- navigate: function (fragment, trigger) {
- var continueNav = true,
- msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
- if (beforeReturn) { return true; }
- });
-
- if (msg) {
- continueNav = window.confirm(msg);
- }
-
- if (continueNav) {
- Backbone.Router.prototype.navigate(fragment, trigger);
- }
- },
-
- addModuleRouteObject: function(RouteObject) {
- var that = this;
- var masterLayout = FauxtonAPI.masterLayout,
- routeUrls = RouteObject.prototype.getRouteUrls();
-
- _.each(routeUrls, function(route) {
- this.route(route, route.toString(), function() {
- var args = Array.prototype.slice.call(arguments),
- roles = RouteObject.prototype.getRouteRoles(route),
- authPromise = FauxtonAPI.auth.checkAccess(roles);
-
- authPromise.then(function () {
- if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
- if (that.activeRouteObject) {
- that.activeRouteObject.removeViews();
- }
- that.activeRouteObject = new RouteObject(route, masterLayout, args);
- }
-
- var routeObject = that.activeRouteObject;
- routeObject.routeCallback(route, args);
- routeObject.renderWith(route, masterLayout, args);
- }, function () {
- FauxtonAPI.auth.authDeniedCb();
- });
-
- });
- }, this);
- },
-
- setModuleRoutes: function(addons) {
- _.each(addons, function(module) {
- if (module){
- module.initialize();
- // This is pure routes the addon provides
- if (module.RouteObjects) {
- _.each(module.RouteObjects, this.addModuleRouteObject, this);
- }
- }
- }, this);
- },
-
- initialize: function(addons) {
- this.addons = addons;
- this.auth = FauxtonAPI.auth;
- // NOTE: This must be below creation of the layout
- // FauxtonAPI header links and others depend on existence of the layout
- this.setModuleRoutes(addons);
-
- $(FauxtonAPI.el).html(FauxtonAPI.masterLayout.el);
- FauxtonAPI.masterLayout.render();
- },
-
- triggerRouteEvent: function(event, args) {
- if (this.activeRouteObject) {
- var eventArgs = [event].concat(args);
- this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
- this.activeRouteObject.renderWith(eventArgs, FauxtonAPI.masterLayout, args);
- }
- }
- });
-
-
+
return FauxtonAPI;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/auth.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/auth.js b/src/fauxton/app/core/auth.js
new file mode 100644
index 0000000..15cf566
--- /dev/null
+++ b/src/fauxton/app/core/auth.js
@@ -0,0 +1,67 @@
+// 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.
+
+define([
+ "core/base",
+ "backbone"
+],
+function(FauxtonAPI, Backbone) {
+
+ // This is not exposed externally as it should not need to be accessed or overridden
+ var Auth = function (options) {
+ this._options = options;
+ this.initialize.apply(this, arguments);
+ };
+
+ // Piggy-back on Backbone's self-propagating extend function,
+ Auth.extend = Backbone.Model.extend;
+
+ _.extend(Auth.prototype, Backbone.Events, {
+ authDeniedCb: function() {},
+
+ initialize: function() {
+ var that = this;
+ },
+
+ authHandlerCb : function (roles) {
+ var deferred = $.Deferred();
+ deferred.resolve();
+ return deferred;
+ },
+
+ registerAuth: function (authHandlerCb) {
+ this.authHandlerCb = authHandlerCb;
+ },
+
+ registerAuthDenied: function (authDeniedCb) {
+ this.authDeniedCb = authDeniedCb;
+ },
+
+ checkAccess: function (roles) {
+ var requiredRoles = roles || [],
+ that = this;
+
+ if (!FauxtonAPI.session) {
+ throw new Error("Fauxton.session is not configured.");
+ }
+
+ return FauxtonAPI.session.fetchUser().then(function (user) {
+ return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
+ });
+ }
+ });
+
+// FauxtonAPI.auth = new Auth();
+
+ return Auth;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index 4601386..e98bdf8 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -11,26 +11,19 @@
// the License.
define([
+ "backbone"
],
-function() {
+function(Backbone) {
var FauxtonAPI = {
//add default objects
router: {
navigate: function () {}
},
- masterLayout: {
- // remove these by converting to extensions
- navBar: {
- addLink: function () {},
- removeLink: function () {}
- }
- },
-
- addNotification: function () {
+ masterLayout: {},
- },
+ addNotification: function () {},
config: function (options) {
return _.extend(this, options);
@@ -109,6 +102,11 @@ function() {
FauxtonAPI.extensions = extensions;
+ FauxtonAPI.setSession = function (newSession) {
+ FauxtonAPI.session = newSession;
+ return FauxtonAPI.session.fetchUser();
+ };
+
return FauxtonAPI;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdbSession.js b/src/fauxton/app/core/couchdbSession.js
index 532f3ea..6f13677 100644
--- a/src/fauxton/app/core/couchdbSession.js
+++ b/src/fauxton/app/core/couchdbSession.js
@@ -12,69 +12,62 @@ define([
"core/base"
],
function (FauxtonAPI) {
- //this later needs to be dynamically loaded
- var app = {
- host: ""
- };
-
- FauxtonAPI.UUID = FauxtonAPI.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
+ var CouchdbSession = {
+ UUID: FauxtonAPI.Model.extend({
+ initialize: function(options) {
+ options = _.extend({count: 1}, options);
+ this.count = options.count;
+ },
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
- },
+ url: function() {
+ return "/_uuids?count=" + this.count;
+ },
- next: function() {
- return this.get("uuids").pop();
- }
- });
+ next: function() {
+ return this.get("uuids").pop();
+ }
+ }),
- FauxtonAPI.Session = FauxtonAPI.Model.extend({
- url: app.host + '/_session',
+ Session: FauxtonAPI.Model.extend({
+ url: '/_session',
- user: function () {
- var userCtx = this.get('userCtx');
+ user: function () {
+ var userCtx = this.get('userCtx');
- if (!userCtx || !userCtx.name) { return null; }
+ if (!userCtx || !userCtx.name) { return null; }
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
+ return {
+ name: userCtx.name,
+ roles: userCtx.roles
+ };
+ },
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
+ fetchUser: function (opt) {
+ var that = this,
+ currentUser = this.user();
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
+ return this.fetchOnce(opt).then(function () {
+ var user = that.user();
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
+ // Notify anyone listening on these events that either a user has changed
+ // or current user is the same
+ if (currentUser !== user) {
+ that.trigger('session:userChanged');
+ } else {
+ that.trigger('session:userFetched');
+ }
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
+ // this will return the user as a value to all function that calls done on this
+ // eg. session.fetchUser().done(user) { .. do something with user ..}
+ return user;
+ });
+ }
+ })
};
+
//set default session
- FauxtonAPI.setSession(new FauxtonAPI.Session());
+ //FauxtonAPI.setSession(new FauxtonAPI.Session());
- return FauxtonAPI;
+ return CouchdbSession;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/layout.js b/src/fauxton/app/core/layout.js
new file mode 100644
index 0000000..a5ed88c
--- /dev/null
+++ b/src/fauxton/app/core/layout.js
@@ -0,0 +1,90 @@
+// 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.
+
+define([
+ "backbone",
+ "plugins/backbone.layoutmanager"
+], function(Backbone) {
+
+ // A wrapper of the main Backbone.layoutmanager
+ // Allows the main layout of the page to be changed by any plugin.
+ // Exposes the different views:
+ // navBar -> the top navigation bar
+ // dashboardContent -> Main display view
+ // breadcrumbs -> Breadcrumbs navigation section
+ var Layout = function () {
+ this.layout = new Backbone.Layout({
+ template: "templates/layouts/with_sidebar",
+ });
+
+ this.layoutViews = {};
+ this.el = this.layout.el;
+ };
+
+ Layout.configure = function (options) {
+ Backbone.Layout.configure(options);
+ };
+
+ // creatings the dashboard object same way backbone does
+ _.extend(Layout.prototype, {
+ render: function () {
+ return this.layout.render();
+ },
+
+ setTemplate: function(template) {
+ if (template.prefix){
+ this.layout.template = template.prefix + template.name;
+ } else{
+ this.layout.template = "templates/layouts/" + template;
+ }
+ // If we're changing layouts all bets are off, so kill off all the
+ // existing views in the layout.
+ _.each(this.layoutViews, function(view){view.remove();});
+ this.layoutViews = {};
+ this.render();
+ },
+
+ setTabs: function(view){
+ // TODO: Not sure I like this - seems fragile/repetitive
+ this.tabs = this.layout.setView("#tabs", view);
+ this.tabs.render();
+ },
+
+ setBreadcrumbs: function(view) {
+ this.breadcrumbs = this.layout.setView("#breadcrumbs", view);
+ this.breadcrumbs.render();
+ },
+
+ clearBreadcrumbs: function () {
+ if (!this.breadcrumbs) {return ;}
+
+ this.breadcrumbs.remove();
+ },
+
+ setView: function(selector, view) {
+ this.layoutViews[selector] = this.layout.setView(selector, view, false);
+ },
+
+ renderView: function(selector) {
+ var view = this.layoutViews[selector];
+ if (!view) {
+ return false;
+ } else {
+ return view.render();
+ }
+ }
+
+ });
+
+ return Layout;
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/resources.js b/src/fauxton/app/core/resources.js
deleted file mode 100644
index 3a29077..0000000
--- a/src/fauxton/app/core/resources.js
+++ /dev/null
@@ -1,285 +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.
-
-define([
- "app",
- "core/couchdbSession",
- "backbone"
-],
-function(app, FauxtonAPI) {
-
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
-
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
-
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function() {},
-
- initialize: function() {
- var that = this;
- },
-
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
-
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
-
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
-
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
-
- if (!FauxtonAPI.session) {
- throw new Error("Fauxton.session is not configured.");
- }
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
- }
- });
-
- FauxtonAPI.auth = new Auth();
-
- FauxtonAPI.RouteObject = function(options) {
- this._options = options;
-
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
-
- var broadcaster = {};
- _.extend(broadcaster, Backbone.Events);
-
- FauxtonAPI.RouteObject.on = function (eventName, fn) {
- broadcaster.on(eventName, fn);
- };
-
- /* How Route Object events work
- To listen to a specific route objects events:
-
- myRouteObject = FauxtonAPI.RouteObject.extend({
- events: {
- "beforeRender": "beforeRenderEvent"
- },
-
- beforeRenderEvent: function (view, selector) {
- console.log('Hey, beforeRenderEvent triggered',arguments);
- },
- });
-
- It is also possible to listen to events triggered from all Routeobjects.
- This is great for more general things like adding loaders, hooks.
-
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- console.log('hey, this will trigger when any routeobject renders a view');
- });
-
- Current Events to subscribe to:
- * beforeFullRender -- before a full render is being done
- * beforeEstablish -- before the routeobject calls establish
- * AfterEstablish -- after the routeobject has run establish
- * beforeRender -- before a view is rendered
- * afterRender -- a view is finished being rendered
- * renderComplete -- all rendering is complete
-
- */
-
- // Piggy-back on Backbone's self-propagating extend function
- FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function() {},
- route: function() {},
- roles: [],
- initialize: function() {}
- }, {
-
- renderWith: function(route, masterLayout, args) {
- var routeObject = this,
- triggerBroadcast = _.bind(this.triggerBroadcast, this);
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
- triggerBroadcast('beforeFullRender');
- }
-
- triggerBroadcast('beforeEstablish');
- FauxtonAPI.when(this.establish()).then(function(resp) {
- triggerBroadcast('afterEstablish');
- _.each(routeObject.getViews(), function(view, selector) {
- if(view.hasRendered) {
- triggerBroadcast('viewHasRendered', view, selector);
- return;
- }
-
- triggerBroadcast('beforeRender', view, selector);
- FauxtonAPI.when(view.establish()).then(function(resp) {
- masterLayout.setView(selector, view);
-
- masterLayout.renderView(selector);
- triggerBroadcast('afterRender', view, selector);
- }, function(resp) {
- view.establishError = {
- error: true,
- reason: resp
- };
-
- if (resp) {
- var errorText = JSON.parse(resp.responseText).reason;
- FauxtonAPI.addNotification({
- msg: 'An Error occurred: ' + errorText,
- type: 'error',
- clear: true
- });
- }
-
- masterLayout.renderView(selector);
- });
-
- });
- }.bind(this), function (resp) {
- if (!resp) { return; }
- FauxtonAPI.addNotification({
- msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
- type: 'error',
- clear: true
- });
- });
-
- 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;
- triggerBroadcast('renderComplete');
- },
-
- triggerBroadcast: function (eventName) {
- var args = Array.prototype.slice.call(arguments);
- this.trigger.apply(this, args);
-
- args.splice(0,1, eventName, this);
- broadcaster.trigger.apply(broadcaster, args);
- },
-
- get: function(key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function(events) {
- events = events || this.get('events');
- _.each(events, function(method, event) {
- if (!_.isFunction(method) && !_.isFunction(this[method])) {
- throw new Error("Invalid method: "+method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
- }, this);
- },
-
- _configure: function(options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function(selector) {
- return this.views[selector];
- },
-
- setView: function(selector, view) {
- this.views[selector] = view;
- return view;
- },
-
- getViews: function() {
- return this.views;
- },
-
- removeViews: function () {
- _.each(this.views, function (view, selector) {
- view.remove();
- delete this.views[selector];
- }, this);
- },
-
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
- }
-
- routeCallback.apply(this, args);
- },
-
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
-
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
- }
-
- return this.roles;
- }
-
- });
-
- return FauxtonAPI;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/routeObject.js b/src/fauxton/app/core/routeObject.js
new file mode 100644
index 0000000..9fe8f69
--- /dev/null
+++ b/src/fauxton/app/core/routeObject.js
@@ -0,0 +1,265 @@
+// 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.
+
+define([
+ "core/base",
+ "backbone"
+],
+function(FauxtonAPI, Backbone) {
+
+ var RouteObject = function(options) {
+ this._options = options;
+
+ this._configure(options || {});
+ this.initialize.apply(this, arguments);
+ this.addEvents();
+ };
+
+ var broadcaster = {};
+ _.extend(broadcaster, Backbone.Events);
+
+ RouteObject.on = function (eventName, fn) {
+ broadcaster.on(eventName, fn);
+ };
+
+ /* How Route Object events work
+ To listen to a specific route objects events:
+
+ myRouteObject = FauxtonAPI.RouteObject.extend({
+ events: {
+ "beforeRender": "beforeRenderEvent"
+ },
+
+ beforeRenderEvent: function (view, selector) {
+ console.log('Hey, beforeRenderEvent triggered',arguments);
+ },
+ });
+
+ It is also possible to listen to events triggered from all Routeobjects.
+ This is great for more general things like adding loaders, hooks.
+
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ console.log('hey, this will trigger when any routeobject renders a view');
+ });
+
+ Current Events to subscribe to:
+ * beforeFullRender -- before a full render is being done
+ * beforeEstablish -- before the routeobject calls establish
+ * AfterEstablish -- after the routeobject has run establish
+ * beforeRender -- before a view is rendered
+ * afterRender -- a view is finished being rendered
+ * renderComplete -- all rendering is complete
+
+ */
+
+ // Piggy-back on Backbone's self-propagating extend function
+ RouteObject.extend = Backbone.Model.extend;
+
+ var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
+
+ _.extend(RouteObject.prototype, Backbone.Events, {
+ // Should these be default vals or empty funcs?
+ views: {},
+ routes: {},
+ events: {},
+ crumbs: [],
+ layout: "with_sidebar",
+ apiUrl: null,
+ disableLoader: false,
+ loaderClassname: 'loader',
+ renderedState: false,
+ establish: function() {},
+ route: function() {},
+ roles: [],
+ _promises: [],
+ initialize: function() {}
+ }, {
+
+ renderWith: function(route, masterLayout, args) {
+ var routeObject = this,
+ triggerBroadcast = _.bind(this.triggerBroadcast, this);
+
+ // Only want to redo the template if its a full render
+ if (!this.renderedState) {
+ masterLayout.setTemplate(this.layout);
+ triggerBroadcast('beforeFullRender');
+ }
+
+ triggerBroadcast('beforeEstablish');
+ var establishPromise = this.establish();
+ this.addPromise(establishPromise);
+ FauxtonAPI.when(establishPromise).then(function(resp) {
+ triggerBroadcast('afterEstablish');
+ _.each(routeObject.getViews(), function(view, selector) {
+ if(view.hasRendered) {
+ triggerBroadcast('viewHasRendered', view, selector);
+ return;
+ }
+
+ triggerBroadcast('beforeRender', view, selector);
+ var viewPromise = view.establish();
+ routeObject.addPromise(viewPromise);
+ FauxtonAPI.when(viewPromise).then(function(resp) {
+ masterLayout.setView(selector, view);
+
+ masterLayout.renderView(selector);
+ triggerBroadcast('afterRender', view, selector);
+ }, function(resp) {
+ view.establishError = {
+ error: true,
+ reason: resp
+ };
+
+ if (resp && resp.responseText) {
+ var errorText = JSON.parse(resp.responseText).reason;
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred: ' + errorText,
+ type: 'error',
+ clear: true
+ });
+ }
+ masterLayout.renderView(selector);
+ });
+
+ });
+ }.bind(this), function (resp) {
+ if (!resp || !resp.responseText) { return; }
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
+ type: 'error',
+ clear: true
+ });
+ });
+
+ // Track that we've done a full initial render
+ this.renderedState = true;
+ triggerBroadcast('renderComplete');
+ },
+
+ triggerBroadcast: function (eventName) {
+ var args = Array.prototype.slice.call(arguments);
+ this.trigger.apply(this, args);
+
+ args.splice(0,1, eventName, this);
+ broadcaster.trigger.apply(broadcaster, args);
+ },
+
+ get: function(key) {
+ return _.isFunction(this[key]) ? this[key]() : this[key];
+ },
+
+ addEvents: function(events) {
+ events = events || this.get('events');
+ _.each(events, function(method, event) {
+ if (!_.isFunction(method) && !_.isFunction(this[method])) {
+ throw new Error("Invalid method: "+method);
+ }
+ method = _.isFunction(method) ? method : this[method];
+
+ this.on(event, method);
+ }, this);
+ },
+
+ _configure: function(options) {
+ _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
+ this[key] = options[key];
+ }, this);
+ },
+
+ getView: function(selector) {
+ return this.views[selector];
+ },
+
+ setView: function(selector, view) {
+ this.views[selector] = view;
+ return view;
+ },
+
+ getViews: function() {
+ return this.views;
+ },
+
+ removeViews: function () {
+ _.each(this.views, function (view, selector) {
+ view.remove();
+ delete this.views[selector];
+ }, this);
+ },
+
+ addPromise: function (promise) {
+ if (_.isEmpty(promise)) { return; }
+
+ if (_.isArray(promise)) {
+ return _.each(promise, function (p) {
+ this._promises.push(p);
+ }, this);
+ }
+
+ this._promises.push(promise);
+ },
+
+ cleanup: function () {
+ this.removeViews();
+ this.rejectPromises();
+ },
+
+ rejectPromises: function () {
+ _.each(this._promises, function (promise) {
+ if (promise.state() === "resolved") { return; }
+ if (promise.abort) {
+ return promise.abort("Route change");
+ }
+
+ promise.reject();
+ }, this);
+
+ this._promises = [];
+ },
+
+ getRouteUrls: function () {
+ return _.keys(this.get('routes'));
+ },
+
+ hasRoute: function (route) {
+ if (this.get('routes')[route]) {
+ return true;
+ }
+ return false;
+ },
+
+ routeCallback: function (route, args) {
+ var routes = this.get('routes'),
+ routeObj = routes[route],
+ routeCallback;
+
+ if (typeof routeObj === 'object') {
+ routeCallback = this[routeObj.route];
+ } else {
+ routeCallback = this[routeObj];
+ }
+
+ routeCallback.apply(this, args);
+ },
+
+ getRouteRoles: function (routeUrl) {
+ var route = this.get('routes')[routeUrl];
+
+ if ((typeof route === 'object') && route.roles) {
+ return route.roles;
+ }
+
+ return this.roles;
+ }
+
+ });
+ return RouteObject;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/router.js b/src/fauxton/app/core/router.js
new file mode 100644
index 0000000..966e171
--- /dev/null
+++ b/src/fauxton/app/core/router.js
@@ -0,0 +1,113 @@
+// 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.
+
+define([
+ "core/base",
+ "core/auth",
+ "backbone"
+],
+
+function(FauxtonAPI, Auth, Backbone) {
+
+ var beforeUnloads = {};
+
+ var Router = Backbone.Router.extend({
+ routes: {},
+
+ beforeUnload: function (name, fn) {
+ beforeUnloads[name] = fn;
+ },
+
+ removeBeforeUnload: function (name) {
+ delete beforeUnloads[name];
+ },
+
+ navigate: function (fragment, trigger) {
+ var continueNav = true,
+ msg = _.find(_.map(beforeUnloads, function (fn) { return fn(); }), function (beforeReturn) {
+ if (beforeReturn) { return true; }
+ });
+
+ if (msg) {
+ continueNav = window.confirm(msg);
+ }
+
+ if (continueNav) {
+ Backbone.Router.prototype.navigate(fragment, trigger);
+ }
+ },
+
+ addModuleRouteObject: function(RouteObject) {
+ var that = this;
+ var masterLayout = FauxtonAPI.masterLayout,
+ routeUrls = RouteObject.prototype.getRouteUrls();
+
+ _.each(routeUrls, function(route) {
+ this.route(route, route.toString(), function() {
+ var args = Array.prototype.slice.call(arguments),
+ roles = RouteObject.prototype.getRouteRoles(route),
+ authPromise = FauxtonAPI.auth.checkAccess(roles);
+
+ authPromise.then(function () {
+ if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
+ if (that.activeRouteObject) {
+ that.activeRouteObject.removeViews();
+ }
+ that.activeRouteObject = new RouteObject(route, masterLayout, args);
+ }
+
+ var routeObject = that.activeRouteObject;
+ routeObject.routeCallback(route, args);
+ routeObject.renderWith(route, masterLayout, args);
+ }, function () {
+ FauxtonAPI.auth.authDeniedCb();
+ });
+
+ });
+ }, this);
+ },
+
+ setModuleRoutes: function(addons) {
+ _.each(addons, function(module) {
+ if (module){
+ module.initialize();
+ // This is pure routes the addon provides
+ if (module.RouteObjects) {
+ _.each(module.RouteObjects, this.addModuleRouteObject, this);
+ }
+ }
+ }, this);
+ },
+
+ initialize: function(addons) {
+ this.addons = addons;
+ this.auth = FauxtonAPI.auth = new Auth();
+ // NOTE: This must be below creation of the layout
+ // FauxtonAPI header links and others depend on existence of the layout
+ this.setModuleRoutes(addons);
+
+ $(FauxtonAPI.el).html(FauxtonAPI.masterLayout.el);
+ FauxtonAPI.masterLayout.render();
+ },
+
+ triggerRouteEvent: function(event, args) {
+ if (this.activeRouteObject) {
+ var eventArgs = [event].concat(args);
+ this.activeRouteObject.trigger.apply(this.activeRouteObject, eventArgs );
+ this.activeRouteObject.renderWith(eventArgs, FauxtonAPI.masterLayout, args);
+ }
+ }
+ });
+
+ return Router;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/tests/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/tests/layoutSpec.js b/src/fauxton/app/core/tests/layoutSpec.js
new file mode 100644
index 0000000..b58966b
--- /dev/null
+++ b/src/fauxton/app/core/tests/layoutSpec.js
@@ -0,0 +1,92 @@
+// 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.
+define([
+ 'api',
+ 'testUtils'
+], function (FauxtonAPI, testUtils) {
+ var assert = testUtils.assert;
+
+ describe("Faxuton Layout", function () {
+ var layout;
+
+ beforeEach(function () {
+ layout = new FauxtonAPI.Layout();
+ });
+
+ describe('#setTemplate', function () {
+
+ it("Should set template without prefix", function () {
+ layout.setTemplate('myTemplate');
+
+ assert.equal(layout.layout.template, 'templates/layouts/myTemplate');
+
+ });
+
+ it("Should set template with prefix", function () {
+ layout.setTemplate({name: 'myTemplate', prefix: 'myPrefix/'});
+
+ assert.equal(layout.layout.template, 'myPrefix/myTemplate');
+ });
+
+ it("Should remove old views", function () {
+ var view = {
+ remove: function () {}
+ };
+
+ layout.layoutViews = {
+ 'selector': view
+ };
+
+ var mockRemove = sinon.spy(view, 'remove');
+ layout.setTemplate('myTemplate');
+ assert.ok(mockRemove.calledOnce);
+
+ });
+
+ it("Should render", function () {
+ var mockRender = sinon.spy(layout, 'render');
+
+ layout.setTemplate('myTemplate');
+
+ assert.ok(mockRender.calledOnce);
+
+ });
+
+ });
+
+ describe('#renderView', function () {
+
+ it('Should render existing view', function () {
+ var view = new Backbone.View();
+ var mockRender = sinon.spy(view, 'render');
+ layout.layoutViews = {
+ '#selector': view
+ };
+
+ var out = layout.renderView('#selector');
+
+ assert.ok(mockRender.calledOnce);
+ });
+
+ it('Should return false for non-existing view', function () {
+ var view = new Backbone.View();
+ layout.layoutViews = {
+ 'selector': view
+ };
+
+ var out = layout.renderView('wrongSelector');
+ assert.notOk(out, 'No view found');
+ });
+ });
+
+ });
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/app/core/tests/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/tests/routeObjectSpec.js b/src/fauxton/app/core/tests/routeObjectSpec.js
new file mode 100644
index 0000000..2fca94d
--- /dev/null
+++ b/src/fauxton/app/core/tests/routeObjectSpec.js
@@ -0,0 +1,96 @@
+// 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.
+define([
+ 'api',
+ 'testUtils'
+], function (FauxtonAPI, testUtils) {
+ var assert = testUtils.assert,
+ RouteObject = FauxtonAPI.RouteObject;
+
+ describe('RouteObjects', function () {
+
+ describe('renderWith', function () {
+ var TestRouteObject, testRouteObject, mockLayout;
+
+ beforeEach(function () {
+ TestRouteObject = RouteObject.extend({
+ crumbs: ['mycrumbs']
+ });
+
+ testRouteObject = new TestRouteObject();
+ var apiBar = {};
+ apiBar.hide = sinon.spy();
+
+ // Need to find a better way of doing this
+ mockLayout = {
+ setTemplate: sinon.spy(),
+ clearBreadcrumbs: sinon.spy(),
+ setView: sinon.spy(),
+ renderView: sinon.spy(),
+ hooks: [],
+ setBreadcrumbs: sinon.spy(),
+ apiBar: apiBar
+ };
+
+ });
+
+ it('Should set template for first render ', function () {
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+ assert.ok(mockLayout.setTemplate.calledOnce, 'setTempalte was called');
+ });
+
+ it('Should not set template after first render', function () {
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+
+ assert.ok(mockLayout.setTemplate.calledOnce, 'SetTemplate not meant to be called');
+ });
+
+
+ it("Should call establish of routeObject", function () {
+ var establishSpy = sinon.spy(testRouteObject,"establish");
+
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+ assert.ok(establishSpy.calledOnce, 'Calls establish');
+ });
+
+ it("Should render views", function () {
+ var view = new FauxtonAPI.View(),
+ getViewsSpy = sinon.stub(testRouteObject,"getViews"),
+ viewSpy = sinon.stub(view, "establish");
+
+ view.hasRendered = false;
+ getViewsSpy.returns({'#view': view});
+
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+ assert.ok(viewSpy.calledOnce, 'Should render view');
+ });
+
+ it("Should not re-render a view", function () {
+ var view = new FauxtonAPI.View(),
+ getViewsSpy = sinon.stub(testRouteObject,"getViews"),
+ viewSpy = sinon.stub(view, "establish");
+
+ view.hasRendered = true;
+ getViewsSpy.returns({'#view': view});
+
+ testRouteObject.renderWith('the-route', mockLayout, 'args');
+ assert.notOk(viewSpy.calledOnce, 'Should render view');
+ });
+ });
+
+ });
+
+
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index 5ccbfe1..21c2fcb 100644
--- a/src/fauxton/tasks/couchserver.js
+++ b/src/fauxton/tasks/couchserver.js
@@ -61,7 +61,7 @@ module.exports = function (grunt) {
// server js from app directory
filePath = path.join(app_dir, url.replace('/_utils/fauxton/',''));
} else if (!!url.match(/testrunner/)) {
- var testSetup = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['mochaSetup']}, function (error, result, code) {/* log.writeln(String(result));*/ });
+ var testSetup = grunt.util.spawn({cmd: 'grunt', grunt: true, args: ['test_inline']}, function (error, result, code) {/* log.writeln(String(result));*/ });
testSetup.stdout.pipe(process.stdout);
testSetup.stderr.pipe(process.stderr);
filePath = path.join('./test/runner.html');
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/core/layoutSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/layoutSpec.js b/src/fauxton/test/core/layoutSpec.js
deleted file mode 100644
index 4167100..0000000
--- a/src/fauxton/test/core/layoutSpec.js
+++ /dev/null
@@ -1,94 +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.
-define([
- 'addons/fauxton/layout',
- 'testUtils'
-], function (Layout, testUtils) {
- var assert = testUtils.assert;
-
- describe("Faxuton Layout", function () {
- var layout;
-
- beforeEach(function () {
- var navBar = new Backbone.View();
- var apiBar = new Backbone.View();
- layout = new Layout(navBar, apiBar);
- });
-
- describe('#setTemplate', function () {
-
- it("Should set template without prefix", function () {
- layout.setTemplate('myTemplate');
-
- assert.equal(layout.layout.template, 'templates/layouts/myTemplate');
-
- });
-
- it("Should set template with prefix", function () {
- layout.setTemplate({name: 'myTemplate', prefix: 'myPrefix/'});
-
- assert.equal(layout.layout.template, 'myPrefix/myTemplate');
- });
-
- it("Should remove old views", function () {
- var view = {
- remove: function () {}
- };
-
- layout.layoutViews = {
- 'selector': view
- };
-
- var mockRemove = sinon.spy(view, 'remove');
- layout.setTemplate('myTemplate');
- assert.ok(mockRemove.calledOnce);
-
- });
-
- it("Should render", function () {
- var mockRender = sinon.spy(layout, 'render');
-
- layout.setTemplate('myTemplate');
-
- assert.ok(mockRender.calledOnce);
-
- });
-
- });
-
- describe('#renderView', function () {
-
- it('Should render existing view', function () {
- var view = new Backbone.View();
- var mockRender = sinon.spy(view, 'render');
- layout.layoutViews = {
- '#selector': view
- };
-
- var out = layout.renderView('#selector');
-
- assert.ok(mockRender.calledOnce);
- });
-
- it('Should return false for non-existing view', function () {
- var view = new Backbone.View();
- layout.layoutViews = {
- 'selector': view
- };
-
- var out = layout.renderView('wrongSelector');
- assert.notOk(out, 'No view found');
- });
- });
-
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/core/navbarSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/navbarSpec.js b/src/fauxton/test/core/navbarSpec.js
deleted file mode 100644
index 3eca6f6..0000000
--- a/src/fauxton/test/core/navbarSpec.js
+++ /dev/null
@@ -1,107 +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.
-define([
- 'addons/fauxton/base',
- 'testUtils'
-], function (Fauxton, testUtils) {
- var assert = testUtils.assert,
- NavBar = Fauxton.NavBar;
-
- describe('NavBar', function () {
-
- describe('adding links', function () {
- var navBar;
-
- beforeEach(function () {
- navBar = new NavBar();
- navBar.navLinks = [];
- navBar.bottomNavLinks = [];
- navBar.footerNavLinks = [];
- });
-
- it('Should add link to navlinks', function () {
- navBar.addLink({href: '#/test', title: 'Test Title'});
-
- assert.equal(navBar.navLinks.length, 1);
- assert.equal(navBar.footerNavLinks.length, 0);
- assert.equal(navBar.bottomNavLinks.length, 0);
- });
-
- it('Should add link to bottom links', function () {
- navBar.addLink({href: '#/test', bottomNav: true, title: 'Test Title'});
-
- assert.equal(navBar.bottomNavLinks.length, 1);
- assert.equal(navBar.navLinks.length, 0);
- assert.equal(navBar.footerNavLinks.length, 0);
- });
-
- it('Should add link to footer links', function () {
- navBar.addLink({href: '#/test', footerNav: true, title: 'Test Title'});
-
- assert.equal(navBar.footerNavLinks.length, 1);
- assert.equal(navBar.bottomNavLinks.length, 0);
- assert.equal(navBar.navLinks.length, 0);
- });
- });
-
- describe('removing links', function () {
- var navBar;
-
- beforeEach(function () {
- navBar = new NavBar();
- navBar.navLinks = [];
- navBar.bottomNavLinks = [];
- navBar.footerNavLinks = [];
- navBar.addLink({
- href: '#/test',
- footerNav: true,
- title: 'Test Title Footer'
- });
-
- navBar.addLink({
- href: '#/test',
- bottomNav: true,
- title: 'Test Title Bottom'
- });
-
- navBar.addLink({
- href: '#/test',
- title: 'Test Title'
- });
- });
-
- it("should remove links from list", function () {
- navBar.removeLink({
- title: 'Test Title Footer',
- footerNav: true
- });
-
- assert.equal(navBar.footerNavLinks.length, 0);
- assert.equal(navBar.bottomNavLinks.length, 1);
- assert.equal(navBar.navLinks.length, 1);
- });
-
- it("Should call render after removing links", function () {
- var renderSpy = sinon.stub(navBar,'render');
-
- navBar.removeLink({
- title: 'Test Title Footer',
- footerNav: true
- });
-
- assert.ok(renderSpy.calledOnce);
- });
-
- });
- });
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/core/paginateSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/paginateSpec.js b/src/fauxton/test/core/paginateSpec.js
deleted file mode 100644
index d05b322..0000000
--- a/src/fauxton/test/core/paginateSpec.js
+++ /dev/null
@@ -1,109 +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.
-define([
- 'api',
- 'addons/fauxton/components',
- 'addons/documents/resources',
- 'testUtils',
- 'app'
-], function (FauxtonAPI, Views, Models, testUtils, app) {
- var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox;
-
-
- describe('IndexPaginate', function () {
- var viewSandbox, paginate, collection, navigateMock;
- beforeEach(function () {
- app.router = {
- navigate: function () {}
- };
-
- collection = new Models.IndexCollection([{
- id:'myId1',
- doc: 'num1'
- },
- {
- id:'myId2',
- doc: 'num2'
- }], {
- database: {id: 'databaseId'},
- design: '_design/myDoc'
- });
-
- paginate = new Views.IndexPagination({
- collection: collection,
- previousUrlfn: function () {},
- nextUrlfn: function () {},
- canShowPreviousfn: function () { return true; },
- canShowNextfn: function () { return true;}
- });
- viewSandbox = new ViewSandbox();
- viewSandbox.renderView(paginate);
- });
-
- afterEach(function () {
- viewSandbox.remove();
- });
-
- describe('#next', function () {
- beforeEach(function () {
- //do this so it doesn't throw an error on other unwired up components
- FauxtonAPI.triggerRouteEvent = function () {};
- //FauxtonAPI.triggerRouteEvent.restore && FauxtonAPI.triggerRouteEvent.restore();
- //FauxtonAPI.navigate.restore && FauxtonAPI.navigate.restore();
- });
-
- it('Should navigate', function () {
- var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
-
- paginate.$('a#next').click();
-
- assert.ok(navigateMock.calledOnce);
- FauxtonAPI.navigate.restore();
- });
-
- it('Should trigger routeEvent', function () {
- var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
-
- paginate.$('a#next').click();
-
- assert.ok(navigateMock.calledOnce);
- FauxtonAPI.triggerRouteEvent.restore();
- });
-
- });
-
-
- describe('#previous', function () {
-
- it('Should navigate', function () {
- var navigateMock = sinon.spy(FauxtonAPI, 'navigate');
-
- paginate.$('a#previous').click();
-
- assert.ok(navigateMock.calledOnce);
- FauxtonAPI.navigate.restore();
- });
-
- it('Should trigger routeEvent', function () {
- var navigateMock = sinon.spy(FauxtonAPI, 'triggerRouteEvent');
-
- paginate.$('a#previous').click();
-
- assert.ok(navigateMock.calledOnce);
- FauxtonAPI.triggerRouteEvent.restore();
- });
-
- });
-
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/core/routeObjectSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/core/routeObjectSpec.js b/src/fauxton/test/core/routeObjectSpec.js
deleted file mode 100644
index 987d5b7..0000000
--- a/src/fauxton/test/core/routeObjectSpec.js
+++ /dev/null
@@ -1,105 +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.
-define([
- 'api',
- 'testUtils'
-], function (FauxtonAPI, testUtils) {
- var assert = testUtils.assert,
- RouteObject = FauxtonAPI.RouteObject;
-
- describe('RouteObjects', function () {
-
- describe('renderWith', function () {
- var TestRouteObject, testRouteObject, mockLayout;
-
- beforeEach(function () {
- TestRouteObject = RouteObject.extend({
- crumbs: ['mycrumbs']
- });
-
- testRouteObject = new TestRouteObject();
- var apiBar = {};
- apiBar.hide = sinon.spy();
-
- // Need to find a better way of doing this
- mockLayout = {
- setTemplate: sinon.spy(),
- clearBreadcrumbs: sinon.spy(),
- setView: sinon.spy(),
- renderView: sinon.spy(),
- hooks: [],
- setBreadcrumbs: sinon.spy(),
- apiBar: apiBar
- };
-
- });
-
- it('Should set template for first render ', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- assert.ok(mockLayout.setTemplate.calledOnce, 'setTempalte was called');
- });
-
- it('Should not set template after first render', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
-
- assert.ok(mockLayout.setTemplate.calledOnce, 'SetTemplate not meant to be called');
- });
-
- it('Should clear breadcrumbs', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(mockLayout.clearBreadcrumbs.calledOnce, 'Clear Breadcrumbs called');
- });
-
- it('Should set breadcrumbs when breadcrumbs exist', function () {
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(mockLayout.setBreadcrumbs.calledOnce, 'Set Breadcrumbs was called');
- });
-
- it("Should call establish of routeObject", function () {
- var establishSpy = sinon.spy(testRouteObject,"establish");
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(establishSpy.calledOnce, 'Calls establish');
- });
-
- it("Should render views", function () {
- var view = new FauxtonAPI.View(),
- getViewsSpy = sinon.stub(testRouteObject,"getViews"),
- viewSpy = sinon.stub(view, "establish");
-
- view.hasRendered = false;
- getViewsSpy.returns({'#view': view});
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.ok(viewSpy.calledOnce, 'Should render view');
- });
-
- it("Should not re-render a view", function () {
- var view = new FauxtonAPI.View(),
- getViewsSpy = sinon.stub(testRouteObject,"getViews"),
- viewSpy = sinon.stub(view, "establish");
-
- view.hasRendered = true;
- getViewsSpy.returns({'#view': view});
-
- testRouteObject.renderWith('the-route', mockLayout, 'args');
- assert.notOk(viewSpy.calledOnce, 'Should render view');
- });
- });
-
- });
-
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/mocha/testUtils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/test/mocha/testUtils.js b/src/fauxton/test/mocha/testUtils.js
index f9643e8..08b80c7 100644
--- a/src/fauxton/test/mocha/testUtils.js
+++ b/src/fauxton/test/mocha/testUtils.js
@@ -11,11 +11,12 @@
// the License.
define([
+ "api",
"chai",
"sinon-chai",
"underscore"
],
-function(chai, sinonChai) {
+function(FauxtonAPI,chai, sinonChai) {
chai.use(sinonChai);
var ViewSandbox = function () {
@@ -24,7 +25,7 @@ function(chai, sinonChai) {
_.extend(ViewSandbox.prototype, {
initialize: function () {
- this.$el = $('<div style="display:none"></div>').appendTo('body');
+ this.$el = $('<div style="display:no1ne"></div>').appendTo('body');
this.$ = this.$el.find;
},
views: [],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/35d2ec19/src/fauxton/test/test.config.underscore
----------------------------------------------------------------------
diff --git a/src/fauxton/test/test.config.underscore b/src/fauxton/test/test.config.underscore
index dda16f2..5cebe78 100644
--- a/src/fauxton/test/test.config.underscore
+++ b/src/fauxton/test/test.config.underscore
@@ -5,6 +5,7 @@ require.config(
);
require([
+ "app",
<% _.each(testFiles, function (test) {%>
'../<%= test %>',
<% }) %>
[12/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fauxton: Bug fixes
* Fix failing tests
* Fix pagination not showing correct number when docs less than limit
* Fix create new view failing with new design doc
* Add Fauxton logo for grunt couchserver
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b9d30b14
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b9d30b14
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b9d30b14
Branch: refs/heads/fauxton-file-reorder
Commit: b9d30b1483f731358b8ace6dc052a2641132f16a
Parents: e5cac79
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 14 14:34:20 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Tue Jan 14 14:34:20 2014 +0200
----------------------------------------------------------------------
.../documents/templates/index_row_docular.html | 2 +-
src/fauxton/app/addons/documents/views.js | 3 ++-
src/fauxton/app/addons/fauxton/components.js | 4 ++++
.../app/addons/permissions/tests/viewsSpec.js | 2 +-
src/fauxton/tasks/couchserver.js | 18 +++++++++++++++++-
5 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index 446a031..e8973ad 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -19,7 +19,7 @@ the License.
<pre class="prettyprint"><%- doc.prettyJSON() %></pre>
<div class="btn-group">
- <a href="#<%= doc.url('app') %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
+ <a href="#<%= url %>" class="btn btn-small edits">Edit <%= doc.docType() %></a>
<% if (doc.isEditable()) { %>
<button href="#" class="btn btn-small btn-danger delete" title="Delete this document."><i class="icon icon-trash"></i></button>
<% } %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index 0139eca..9902541 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -405,7 +405,8 @@ function(app, FauxtonAPI, Components, Documents, Databases, pouchdb, resizeColum
serialize: function() {
return {
- doc: this.model
+ doc: this.model,
+ url: this.model.url('app')
};
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index a9f45ad..cda61c5 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -123,6 +123,10 @@ function(app, FauxtonAPI, ace) {
},
pageEnd: function () {
+ if (this.collection.length < this.pageLimit()) {
+ return this.collection.length;
+ }
+
return (this.previousParams.length * this.pageLimit()) + this.pageLimit();
}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/app/addons/permissions/tests/viewsSpec.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/permissions/tests/viewsSpec.js b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
index e5330c0..27abca4 100644
--- a/src/fauxton/app/addons/permissions/tests/viewsSpec.js
+++ b/src/fauxton/app/addons/permissions/tests/viewsSpec.js
@@ -25,7 +25,7 @@ define([
'names': ['_user'],
'roles': []
}
- }, {database: 'fakedb'});
+ }, {database: {id: 'fakedb', safeID: function () { return this.id; }}});
section = new Views.Permissions({
database: 'fakedb',
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b9d30b14/src/fauxton/tasks/couchserver.js
----------------------------------------------------------------------
diff --git a/src/fauxton/tasks/couchserver.js b/src/fauxton/tasks/couchserver.js
index b9ff3ef..5ccbfe1 100644
--- a/src/fauxton/tasks/couchserver.js
+++ b/src/fauxton/tasks/couchserver.js
@@ -19,7 +19,8 @@ module.exports = function (grunt) {
http = require("http"),
httpProxy = require('http-proxy'),
send = require('send'),
- options = grunt.config('couchserver');
+ options = grunt.config('couchserver'),
+ _ = grunt.util._;
// Options
var dist_dir = options.dist || './dist/debug/',
@@ -98,6 +99,21 @@ module.exports = function (grunt) {
watch.stdout.pipe(process.stdout);
watch.stderr.pipe(process.stderr);
+ var logo = [
+ [""],
+ [" ______ _ "],
+ ["| ____| | | "],
+ ["| |__ __ _ _ _ __ __ | |_ ___ _ __ "],
+ ["| __| / _` | | | | | \\ \\/ / | __| / _ \\ | '_ \\ "],
+ ["| | | (_| | | |_| | > < | |_ | (_) | | | | |"],
+ ["|_| \\__,_| \\__,_| /_/\\_\\ \\__| \\___/ |_| |_|"],
+ [""]
+ ];
+
+ _.each(logo, function (line) {
+ console.log(line.toString());
+ });
+
log.writeln('Listening on ' + port);
});
[17/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fix for running preview on indexes (I think this got accidentally commented out?)
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/0b9bb156
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0b9bb156
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0b9bb156
Branch: refs/heads/fauxton-file-reorder
Commit: 0b9bb15688821b5657ff81445ff1b88d6ffac7a6
Parents: 678d034
Author: suelockwood <de...@apache.org>
Authored: Wed Jan 15 16:22:52 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Wed Jan 15 16:22:52 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/addons/pouchdb/pouch.collate.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/0b9bb156/src/fauxton/app/addons/pouchdb/pouch.collate.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/pouchdb/pouch.collate.js b/src/fauxton/app/addons/pouchdb/pouch.collate.js
index 6c64410..31e5650 100644
--- a/src/fauxton/app/addons/pouchdb/pouch.collate.js
+++ b/src/fauxton/app/addons/pouchdb/pouch.collate.js
@@ -110,6 +110,6 @@ function(app, FauxtonAPI, Collate) {
return Pouch;
-//}).call(this);
+}).call(this);
+
-});
[03/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
blank files might sink ships
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b71c719d
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b71c719d
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b71c719d
Branch: refs/heads/fauxton-file-reorder
Commit: b71c719dc44bbda8ec169320a38216e560b863c2
Parents: 6530f95
Author: Jan Lehnardt <ja...@apache.org>
Authored: Mon Jan 13 20:25:45 2014 +0100
Committer: Jan Lehnardt <ja...@apache.org>
Committed: Mon Jan 13 20:26:05 2014 +0100
----------------------------------------------------------------------
.../priv/default.d/my_first_couchdb_plugin.ini | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b71c719d/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
----------------------------------------------------------------------
diff --git a/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini b/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
index e69de29..fbc2d98 100644
--- a/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
+++ b/src/my-first-couchdb-plugin/priv/default.d/my_first_couchdb_plugin.ini
@@ -0,0 +1,3 @@
+;per-plugin configuration goes here
+;[plugin-name]
+;config=value
[23/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
ignoring index.css in concat:index_css
Which is why it was showing up twice.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/424e25af
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/424e25af
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/424e25af
Branch: refs/heads/fauxton-file-reorder
Commit: 424e25afa329d4871e3cfeafd4e1cd253b897f4b
Parents: 0fd6a7e
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Thu Jan 16 14:59:27 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Fri Jan 17 09:39:57 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/424e25af/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index b42e6b5..32065b6 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -210,7 +210,7 @@ module.exports = function(grunt) {
},
index_css: {
- src: ["dist/debug/css/*.css", 'assets/css/*.css'],
+ src: ["dist/debug/css/*.css", '!dist/debug/css/index.css', 'assets/css/*.css'],
dest: 'dist/debug/css/index.css'
},
[16/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fauxton: update api bar with view query updates
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/678d034a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/678d034a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/678d034a
Branch: refs/heads/fauxton-file-reorder
Commit: 678d034a8ebe144c961467b8d25018a897e3494b
Parents: ad3edf8
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 15 17:32:52 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 15 17:32:52 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/documents/routes.js | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/678d034a/src/fauxton/app/addons/documents/routes.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/routes.js b/src/fauxton/app/addons/documents/routes.js
index 6786edf..1510485 100644
--- a/src/fauxton/app/addons/documents/routes.js
+++ b/src/fauxton/app/addons/documents/routes.js
@@ -304,6 +304,7 @@ function(app, FauxtonAPI, Documents, Databases) {
this.documentsView = this.setView("#dashboard-lower-content", new Documents.Views.AllDocsList({
collection: this.data.database.allDocs
}));
+ //this.apiUrl = [this.data.database.allDocs.url("apiurl"), this.data.database.allDocs.documentation() ];
return;
}
@@ -320,6 +321,8 @@ function(app, FauxtonAPI, Documents, Databases) {
nestedView: Documents.Views.Row,
viewList: true
}));
+
+ this.apiUrl = [this.data.indexedDocs.url("apiurl"), "docs"];
},
updateAllDocsFromPreview: function (event) {
[14/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Testing and improvements
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/42c44932
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/42c44932
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/42c44932
Branch: refs/heads/fauxton-file-reorder
Commit: 42c44932863d51758b849ac15e3d545e36039621
Parents: 392f7b3
Author: Garren Smith <ga...@gmail.com>
Authored: Tue Jan 14 11:49:35 2014 +0200
Committer: suelockwood <de...@apache.org>
Committed: Tue Jan 14 10:45:56 2014 -0500
----------------------------------------------------------------------
src/fauxton/app/api.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/42c44932/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 6d450de..9ac895e 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -333,7 +333,7 @@ function(app, Fauxton) {
triggerBroadcast('beforeRender', view, selector);
var viewPromise = view.establish();
routeObject.addPromise(viewPromise);
- FauxtonAPI.when(view.establish()).then(function(resp) {
+ FauxtonAPI.when(viewPromise).then(function(resp) {
masterLayout.setView(selector, view);
masterLayout.renderView(selector);
[21/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Fauxton: added dependencies to test task list
Added dependencies to test task list and
added test_inline task for use inside watchRun.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/32bb6ce4
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/32bb6ce4
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/32bb6ce4
Branch: refs/heads/fauxton-file-reorder
Commit: 32bb6ce45d42f971c5d772bc1cdb23a1e678509d
Parents: a09318f
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Wed Jan 15 13:27:06 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Thu Jan 16 19:50:41 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/32bb6ce4/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index cf70440..b42e6b5 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -422,7 +422,9 @@ module.exports = function(grunt) {
*/
// clean out previous build artefactsa and lint
grunt.registerTask('lint', ['clean', 'jshint']);
- grunt.registerTask('test', ['lint', 'mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
+ grunt.registerTask('test', ['lint', 'dependencies', 'test_inline']);
+ // lighter weight test task for use inside dev/watch
+ grunt.registerTask('test_inline', ['mochaSetup','jst', 'concat:test_config_js', 'mocha_phantomjs']);
// Fetch dependencies (from git or local dir), lint them and make load_addons
grunt.registerTask('dependencies', ['get_deps', 'gen_load_addons:default']);
// build templates, js and css
[28/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
First working version
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/28ade479
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/28ade479
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/28ade479
Branch: refs/heads/fauxton-file-reorder
Commit: 28ade4795fcf2c25f3c0f6b8e1813e8d16100fa2
Parents: 5c73547
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 15 15:33:07 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 20 10:08:06 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/documents/views.js | 2 +-
src/fauxton/app/addons/fauxton/base.js | 68 ++++++++++++--
src/fauxton/app/addons/fauxton/layout.js | 15 +---
src/fauxton/app/addons/fauxton/resizeColumns.js | 87 ++++++++++++++++++
src/fauxton/app/addons/fauxton/resizeCoumns.js | 87 ------------------
src/fauxton/app/app.js | 91 +++++--------------
src/fauxton/app/core/api.js | 30 +++----
src/fauxton/app/core/base.js | 1 -
src/fauxton/app/core/resources.js | 18 +---
src/fauxton/app/core/utils.js | 94 ++++++++++++++++++++
src/fauxton/app/main.js | 10 ++-
src/fauxton/app/router.js | 4 +-
src/fauxton/app/utils.js | 66 --------------
src/fauxton/settings.json.default | 1 +
14 files changed, 291 insertions(+), 283 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/addons/documents/views.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/views.js b/src/fauxton/app/addons/documents/views.js
index ba7e7d7..c8f1233 100644
--- a/src/fauxton/app/addons/documents/views.js
+++ b/src/fauxton/app/addons/documents/views.js
@@ -21,7 +21,7 @@ define([
"addons/pouchdb/base",
// Libs
- "resizeColumns",
+ "addons/Fauxton/resizeColumns",
// Plugins
"plugins/prettify"
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/addons/fauxton/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/base.js b/src/fauxton/app/addons/fauxton/base.js
index e2b8c5d..ee6b794 100644
--- a/src/fauxton/app/addons/fauxton/base.js
+++ b/src/fauxton/app/addons/fauxton/base.js
@@ -11,13 +11,62 @@
// the License.
define([
+ "app",
"api",
"addons/fauxton/resizeColumns"
],
-function(FauxtonAPI, resizeColumns) {
+function(app, FauxtonAPI, resizeColumns) {
- var Fauxton = {};
+ var Fauxton = FauxtonAPI.addon();
+ FauxtonAPI.addNotification = function (options) {
+ options = _.extend({
+ msg: "Notification Event Triggered!",
+ type: "info",
+ selector: "#global-notifications"
+ }, options);
+
+ var view = new Fauxton.Notification(options);
+ return view.renderNotification();
+ };
+
+ Fauxton.initialize = function () {
+ app.footer = new Fauxton.Footer({el: "#footer-content"}),
+ app.navBar = new Fauxton.NavBar();
+ app.apiBar = new Fauxton.ApiBar();
+
+ FauxtonAPI.when.apply(null, app.footer.establish()).done(function() {
+ FauxtonAPI.masterLayout.layout.setView("#primary-navbar", app.navBar);
+ FauxtonAPI.masterLayout.layout.setView("#api-navbar", app.apiBar);
+ app.navBar.render();
+ app.apiBar.render();
+
+ app.footer.render();
+ });
+
+ FauxtonAPI.masterLayout.navBar = app.navBar;
+ FauxtonAPI.masterLayout.apiBar = app.apiBar;
+
+ FauxtonAPI.RouteObject.on('beforeFullRender', function (routeObject) {
+ $('#primary-navbar li').removeClass('active');
+
+ if (routeObject.selectedHeader) {
+ app.selectedHeader = routeObject.selectedHeader;
+ $('#primary-navbar li[data-nav-name="' + routeObject.selectedHeader + '"]').addClass('active');
+ }
+ });
+
+ FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
+ FauxtonAPI.masterLayout.clearBreadcrumbs();
+ var crumbs = routeObject.get('crumbs');
+
+ if (crumbs.length) {
+ FauxtonAPI.masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
+ crumbs: crumbs
+ }));
+ }
+ });
+ };
Fauxton.Breadcrumbs = Backbone.View.extend({
template: "templates/fauxton/breadcrumbs",
@@ -36,7 +85,7 @@ function(FauxtonAPI, resizeColumns) {
Fauxton.VersionInfo = Backbone.Model.extend({
url: function () {
- return FauxtonAPI.host;
+ return app.host;
}
});
@@ -73,10 +122,12 @@ function(FauxtonAPI, resizeColumns) {
footerNavLinks: [],
initialize: function () {
+ _.bindAll(this);
//resizeAnimation
this.resizeColumns = new resizeColumns({});
this.resizeColumns.onResizeHandler();
-
+
+ FauxtonAPI.extensions.on('add:navbar:addHeaderLink', this.addLink);
},
serialize: function() {
@@ -102,6 +153,8 @@ function(FauxtonAPI, resizeColumns) {
} else {
this.navLinks.push(link);
}
+
+ //this.render();
},
removeLink: function (removeLink) {
@@ -127,7 +180,6 @@ function(FauxtonAPI, resizeColumns) {
},
afterRender: function(){
-
$('#primary-navbar li[data-nav-name="' + app.selectedHeader + '"]').addClass('active');
var menuOpen = true;
@@ -146,13 +198,14 @@ function(FauxtonAPI, resizeColumns) {
menuOpen = $selectorList.hasClass('closeMenu');
this.resizeColumns.onResizeHandler();
}
-
+
+ var that = this;
$('#primary-navbar').on("click", ".nav a", function(){
if (!($selectorList.hasClass('closeMenu'))){
setTimeout(
function(){
$selectorList.addClass('closeMenu');
- this.resizeColumns.onResizeHandler();
+ that.resizeColumns.onResizeHandler();
},3000);
}
@@ -268,6 +321,5 @@ function(FauxtonAPI, resizeColumns) {
}
});
-
return Fauxton;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/addons/fauxton/layout.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/layout.js b/src/fauxton/app/addons/fauxton/layout.js
index 1422241..3810c84 100644
--- a/src/fauxton/app/addons/fauxton/layout.js
+++ b/src/fauxton/app/addons/fauxton/layout.js
@@ -20,25 +20,12 @@ function(Backbone) {
// navBar -> the top navigation bar
// dashboardContent -> Main display view
// breadcrumbs -> Breadcrumbs navigation section
- var Layout = function (navBar, apiBar) {
- this.navBar = navBar;
- this.apiBar = apiBar;
-
+ var Layout = function () {
this.layout = new Backbone.Layout({
template: "templates/layouts/with_sidebar",
-
- views: {
- "#primary-navbar": this.navBar,
- "#api-navbar": this.apiBar
- },
- afterRender: function(){
-
- }
});
this.layoutViews = {};
- //this.hooks = {};
-
this.el = this.layout.el;
};
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/addons/fauxton/resizeColumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/resizeColumns.js b/src/fauxton/app/addons/fauxton/resizeColumns.js
new file mode 100644
index 0000000..abfcd2f
--- /dev/null
+++ b/src/fauxton/app/addons/fauxton/resizeColumns.js
@@ -0,0 +1,87 @@
+// 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.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+define([
+ "api"
+],
+
+function(FauxtonAPI) {
+
+ var Resize = function(options){
+ this.options = options;
+ this.options.selectorElements = options.selectorElements || ".window-resizeable";
+ };
+
+ Resize.prototype = {
+ getPrimaryNavWidth: function(){
+ var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224;
+ return primaryNavWidth;
+ },
+ getPanelWidth: function(){
+ var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0;
+ return (this.getPrimaryNavWidth() + sidebarWidth);
+ },
+ initialize: function(){
+ // $(window).off('resize');
+ var that = this;
+ //add throttler :)
+ this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
+ FauxtonAPI.utils.addWindowResize(this.lazyLayout,"animation");
+ FauxtonAPI.utils.initWindowResize();
+ this.onResizeHandler();
+ },
+ updateOptions:function(options){
+ this.options = {};
+ this.options = options;
+ this.options.selectorElements = options.selectorElements || ".window-resizeable";
+ },
+ turnOff:function(){
+ FauxtonAPI.utils.removeWindowResize("animation");
+ },
+ cleanupCallback: function(){
+ this.callback = null;
+ },
+ onResizeHandler: function (){
+ //if there is an override, do that instead
+ if (this.options.onResizeHandler){
+ this.options.onResizeHandler();
+ } else {
+ var combinedWidth = window.innerWidth - this.getPanelWidth(),
+ smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800,
+ panelWidth;
+
+ if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){
+ panelWidth = window.innerWidth - this.getPanelWidth();
+ } else if (combinedWidth < smallWidthConstraint){
+ panelWidth = smallWidthConstraint;
+ } else if(combinedWidth > 1400){
+ panelWidth = 1400;
+ }
+
+ $(this.options.selectorElements).innerWidth(panelWidth);
+ }
+ //if there is a callback, run that
+ if(this.options.callback) {
+ this.options.callback();
+ }
+ }
+ };
+
+ return Resize;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/addons/fauxton/resizeCoumns.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/resizeCoumns.js b/src/fauxton/app/addons/fauxton/resizeCoumns.js
deleted file mode 100644
index bb50767..0000000
--- a/src/fauxton/app/addons/fauxton/resizeCoumns.js
+++ /dev/null
@@ -1,87 +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.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-define([
- "utils"
-],
-
-function(utils) {
-
- var Resize = function(options){
- this.options = options;
- this.options.selectorElements = options.selectorElements || ".window-resizeable";
- };
-
- Resize.prototype = {
- getPrimaryNavWidth: function(){
- var primaryNavWidth = $('body').hasClass('closeMenu')? 64:224;
- return primaryNavWidth;
- },
- getPanelWidth: function(){
- var sidebarWidth = $('#sidebar-content').length > 0 ? $('#sidebar-content').width(): 0;
- return (this.getPrimaryNavWidth() + sidebarWidth);
- },
- initialize: function(){
- // $(window).off('resize');
- var that = this;
- //add throttler :)
- this.lazyLayout = _.debounce(that.onResizeHandler, 300).bind(this);
- utils.addWindowResize(this.lazyLayout,"animation");
- utils.initWindowResize();
- this.onResizeHandler();
- },
- updateOptions:function(options){
- this.options = {};
- this.options = options;
- this.options.selectorElements = options.selectorElements || ".window-resizeable";
- },
- turnOff:function(){
- utils.removeWindowResize("animation");
- },
- cleanupCallback: function(){
- this.callback = null;
- },
- onResizeHandler: function (){
- //if there is an override, do that instead
- if (this.options.onResizeHandler){
- this.options.onResizeHandler();
- } else {
- var combinedWidth = window.innerWidth - this.getPanelWidth(),
- smallWidthConstraint = ($('#sidebar-content').length > 0)? 470:800,
- panelWidth;
-
- if( combinedWidth > smallWidthConstraint && combinedWidth < 1400){
- panelWidth = window.innerWidth - this.getPanelWidth();
- } else if (combinedWidth < smallWidthConstraint){
- panelWidth = smallWidthConstraint;
- } else if(combinedWidth > 1400){
- panelWidth = 1400;
- }
-
- $(this.options.selectorElements).innerWidth(panelWidth);
- }
- //if there is a callback, run that
- if(this.options.callback) {
- this.options.callback();
- }
- }
- };
-
- return Resize;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/app.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/app.js b/src/fauxton/app/app.js
index 3b25be8..23a72c7 100644
--- a/src/fauxton/app/app.js
+++ b/src/fauxton/app/app.js
@@ -21,90 +21,33 @@ define([
"bootstrap",
"helpers",
- "utils",
+ "core/utils",
// Modules
- "resizeColumns",
"core/api",
- "addons/fauxton/base",
- // Plugins.
+ "addons/Fauxton/layout",
+ // Plugins.
"plugins/backbone.layoutmanager",
"plugins/jquery.form"
],
-function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns, FauxtonAPI, Fauxton) {
-
- // Make sure we have a console.log
+function(app, $, _, Backbone, Bootstrap, Helpers, Utils, FauxtonAPI, Layout, LoadAddons) {
+ // Make sure we have a console.log
if (typeof console == "undefined") {
console = {
- log: function(){}
+ log: function(){},
+ trace: function(){},
+ debug: function(){}
};
}
// Provide a global location to place configuration settings and module
// creation also mix in Backbone.Events
- _.extend(app, Backbone.Events, {
+ _.extend(app, {
utils: Utils,
-
- // Thanks to: http://stackoverflow.com/a/2880929
- getParams: function(queryString) {
- if (queryString) {
- // I think this could be combined into one if
- if (queryString.substring(0,1) === "?") {
- queryString = queryString.substring(1);
- } else if (queryString.indexOf('?') > -1) {
- queryString = queryString.split('?')[1];
- }
- }
- var hash = window.location.hash.split('?')[1];
- queryString = queryString || hash || window.location.search.substring(1);
- var match,
- urlParams = {},
- pl = /\+/g, // Regex for replacing addition symbol with a space
- search = /([^&=]+)=?([^&]*)/g,
- decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
- query = queryString;
-
- if (queryString) {
- while ((match = search.exec(query))) {
- urlParams[decode(match[1])] = decode(match[2]);
- }
- }
-
- return urlParams;
- }
-
+ getParams: FauxtonAPI.utils.getParams
});
- //MOVE THIS ELSEWHERE
- app.footer = new Fauxton.Footer({el: "#footer-content"});
- // TODO: move this to a proper Fauxton.View
- $.when.apply(null, app.footer.establish()).done(function() {
- app.footer.render();
- });
- app.navBar = new Fauxton.NavBar();
- app.apiBar = new Fauxton.ApiBar();
- // Define your master router on the application namespace and trigger all
- // navigation from this instance.
- app.router = new FauxtonAPI.Router();
- FauxtonAPI.config({
- router: app.router,
- masterLayout: new Layout(app.navBar, app.apiBar),
- addNotification: function (options) {
- options = _.extend({
- msg: "Notification Event Triggered!",
- type: "info",
- selector: "#global-notifications"
- }, options);
-
- var view = new Fauxton.Notification(options);
- return view.renderNotification();
- }
- });
- // Trigger the initial route and enable HTML5 History API support, set the
- // root folder to '/' by default. Change in app.js.
- Backbone.history.start({ pushState: false, root: app.root });
-
// Localize or create a new JavaScript Template object.
var JST = window.JST = window.JST || {};
@@ -141,6 +84,20 @@ function(app, $, _, Backbone, Bootstrap, Helpers, Utils, resizeColumns, FauxtonA
}
});
+ // Define your master router on the application namespace and trigger all
+ // navigation from this instance.
+ FauxtonAPI.config({
+ el: "#app-container",
+ masterLayout: new Layout(),
+
+ addHeaderLink: function(link) {
+ FauxtonAPI.registerExtension('navbar:addHeaderLink', link);
+ },
+
+ removeHeaderLink: function(link) {
+ // TODO add remove to extensions
+ }
+ });
return app;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/core/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/api.js b/src/fauxton/app/core/api.js
index 5f5cbf8..81e9aa4 100644
--- a/src/fauxton/app/core/api.js
+++ b/src/fauxton/app/core/api.js
@@ -12,11 +12,11 @@
define([
"core/resources",
- // Modules
+ "core/utils"
],
-function(FauxtonAPI, Fauxton) {
-
+function(FauxtonAPI, utils) {
+ FauxtonAPI.utils = utils;
FauxtonAPI.navigate = function(url, _opts) {
var options = _.extend({trigger: true}, _opts );
FauxtonAPI.router.navigate(url,options);
@@ -30,14 +30,6 @@ function(FauxtonAPI, Fauxton) {
FauxtonAPI.router.removeBeforeUnload.apply(FauxtonAPI.router, arguments);
};
- FauxtonAPI.addHeaderLink = function(link) {
- FauxtonAPI.masterLayout.navBar.addLink(link);
- };
-
- FauxtonAPI.removeHeaderLink = function(link) {
- FauxtonAPI.masterLayout.navBar.removeLink(link);
- };
-
FauxtonAPI.addRoute = function(route) {
FauxtonAPI.router.route(route.route, route.name, route.callback);
};
@@ -83,7 +75,7 @@ function(FauxtonAPI, Fauxton) {
this.route(route, route.toString(), function() {
var args = Array.prototype.slice.call(arguments),
roles = RouteObject.prototype.getRouteRoles(route),
- authPromise = app.auth.checkAccess(roles);
+ authPromise = FauxtonAPI.auth.checkAccess(roles);
authPromise.then(function () {
if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
@@ -104,8 +96,8 @@ function(FauxtonAPI, Fauxton) {
}, this);
},
- setModuleRoutes: function() {
- _.each(LoadAddons.addons, function(module) {
+ setModuleRoutes: function(addons) {
+ _.each(addons, function(module) {
if (module){
module.initialize();
// This is pure routes the addon provides
@@ -116,14 +108,14 @@ function(FauxtonAPI, Fauxton) {
}, this);
},
- initialize: function() {
- //TODO: It would be nice to handle this with a router
- this.auth = app.auth = FauxtonAPI.auth;
+ initialize: function(addons) {
+ this.addons = addons;
+ this.auth = FauxtonAPI.auth;
// NOTE: This must be below creation of the layout
// FauxtonAPI header links and others depend on existence of the layout
- this.setModuleRoutes();
+ this.setModuleRoutes(addons);
- $("#app-container").html(FauxtonAPI.masterLayout.el);
+ $(FauxtonAPI.el).html(FauxtonAPI.masterLayout.el);
FauxtonAPI.masterLayout.render();
},
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
index f9bb065..4601386 100644
--- a/src/fauxton/app/core/base.js
+++ b/src/fauxton/app/core/base.js
@@ -109,7 +109,6 @@ function() {
FauxtonAPI.extensions = extensions;
-
return FauxtonAPI;
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/core/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/resources.js b/src/fauxton/app/core/resources.js
index 249d7fc..3a29077 100644
--- a/src/fauxton/app/core/resources.js
+++ b/src/fauxton/app/core/resources.js
@@ -13,10 +13,9 @@
define([
"app",
"core/couchdbSession",
- "addons/fauxton/base",
"backbone"
],
-function(app, FauxtonAPI, Fauxton) {
+function(app, FauxtonAPI) {
// This is not exposed externally as it should not need to be accessed or overridden
var Auth = function (options) {
@@ -139,21 +138,6 @@ function(app, FauxtonAPI, Fauxton) {
if (!this.renderedState) {
masterLayout.setTemplate(this.layout);
triggerBroadcast('beforeFullRender');
- $('#primary-navbar li').removeClass('active');
-
- if (this.selectedHeader) {
- app.selectedHeader = this.selectedHeader;
- $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
- }
- }
-
- masterLayout.clearBreadcrumbs();
- var crumbs = this.get('crumbs');
-
- if (crumbs.length) {
- masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
- crumbs: crumbs
- }));
}
triggerBroadcast('beforeEstablish');
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/core/utils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/utils.js b/src/fauxton/app/core/utils.js
new file mode 100644
index 0000000..44945e8
--- /dev/null
+++ b/src/fauxton/app/core/utils.js
@@ -0,0 +1,94 @@
+// 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.
+
+
+// This file creates a set of helper functions that will be loaded for all html
+// templates. These functions should be self contained and not rely on any
+// external dependencies as they are loaded prior to the application. We may
+// want to change this later, but for now this should be thought of as a
+// "purely functional" helper system.
+
+
+define([
+ "jquery",
+ "lodash"
+],
+
+function($, _ ) {
+
+ var onWindowResize = {};
+
+ var utils = {
+ // Thanks to: http://stackoverflow.com/a/2880929
+ getParams: function(queryString) {
+ if (queryString) {
+ // I think this could be combined into one if
+ if (queryString.substring(0,1) === "?") {
+ queryString = queryString.substring(1);
+ } else if (queryString.indexOf('?') > -1) {
+ queryString = queryString.split('?')[1];
+ }
+ }
+ var hash = window.location.hash.split('?')[1];
+ queryString = queryString || hash || window.location.search.substring(1);
+ var match,
+ urlParams = {},
+ pl = /\+/g, // Regex for replacing addition symbol with a space
+ search = /([^&=]+)=?([^&]*)/g,
+ decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
+ query = queryString;
+
+ if (queryString) {
+ while ((match = search.exec(query))) {
+ urlParams[decode(match[1])] = decode(match[2]);
+ }
+ }
+
+ return urlParams;
+ },
+
+ 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();
+ },
+
+ removeWindowResize: function(key){
+ delete onWindowResize[key];
+ utils.initWindowResize();
+ },
+
+ 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
+ _.each(onWindowResize, function (fn) {
+ fn();
+ });
+ };
+ },
+
+ removeSpecialCharacters: function(name){
+ return name.replace(/[^\w\s]/gi,"");
+ },
+
+ safeURLName: function(name){
+ var testName = name || "";
+ var checkforBad = testName.match(/[\$\-/_,+-]/g);
+ return (checkforBad !== null)?encodeURIComponent(name):name;
+ }
+ };
+
+ return utils;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/main.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/main.js b/src/fauxton/app/main.js
index 13b8370..9df15c5 100644
--- a/src/fauxton/app/main.js
+++ b/src/fauxton/app/main.js
@@ -13,9 +13,17 @@
require([
// Application.
"app",
+ "api",
+ "load_addons"
],
-function(app) {
+function(app, FauxtonAPI, LoadAddons) {
+
+ app.addons = LoadAddons.addons;
+ FauxtonAPI.router = app.router = new FauxtonAPI.Router(app.addons);
+ // Trigger the initial route and enable HTML5 History API support, set the
+ // root folder to '/' by default. Change in app.js.
+ Backbone.history.start({ pushState: false, root: app.root });
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index 51b98ea..1e0caac 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -25,9 +25,9 @@ define([
"core/api",
// Modules
- "addons/fauxton/base",
+ //"addons/fauxton/base",
// Layout
- "addons/fauxton/layout",
+ //"addons/fauxton/layout",
"load_addons"
],
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/app/utils.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/utils.js b/src/fauxton/app/utils.js
deleted file mode 100644
index ded7dac..0000000
--- a/src/fauxton/app/utils.js
+++ /dev/null
@@ -1,66 +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.
-
-
-// This file creates a set of helper functions that will be loaded for all html
-// templates. These functions should be self contained and not rely on any
-// external dependencies as they are loaded prior to the application. We may
-// want to change this later, but for now this should be thought of as a
-// "purely functional" helper system.
-
-
-define([
- "jquery",
- "lodash"
-],
-
-function($, _ ) {
-
- var utils = {};
-
- var onWindowResize = {};
-
- 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();
- };
-
- utils.removeWindowResize = function(key){
- delete onWindowResize[key];
- utils.initWindowResize();
- };
-
- 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
- _.each(onWindowResize, function (fn) {
- fn();
- });
- };
- };
-
- utils.removeSpecialCharacters = function(name){
- return name.replace(/[^\w\s]/gi,"");
- };
-
- utils.safeURLName = function(name){
- var testName = name || "";
- var checkforBad = testName.match(/[\$\-/_,+-]/g);
- return (checkforBad !== null)?encodeURIComponent(name):name;
- };
-
- return utils;
-});
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/28ade479/src/fauxton/settings.json.default
----------------------------------------------------------------------
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index cb09eb2..807f6bf 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -3,6 +3,7 @@
{ "name": "databases" },
{ "name": "documents" },
{ "name": "pouchdb" },
+ { "name": "fauxton" },
{ "name": "activetasks" },
{ "name": "config" },
{ "name": "logs" },
[26/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
first file moving
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ccf1bb67
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ccf1bb67
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ccf1bb67
Branch: refs/heads/fauxton-file-reorder
Commit: ccf1bb67627fb45dccd0da954f84d8bb5d4aa039
Parents: eabece1
Author: Garren Smith <ga...@gmail.com>
Authored: Wed Jan 8 15:26:12 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 20 10:07:39 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/addons/fauxton/components.js | 15 +-
src/fauxton/app/core/api.js | 520 ++++++++++++++++++++++
src/fauxton/app/core/base.js | 52 +++
3 files changed, 585 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ccf1bb67/src/fauxton/app/addons/fauxton/components.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/fauxton/components.js b/src/fauxton/app/addons/fauxton/components.js
index cda61c5..bc011e3 100644
--- a/src/fauxton/app/addons/fauxton/components.js
+++ b/src/fauxton/app/addons/fauxton/components.js
@@ -297,7 +297,7 @@ function(app, FauxtonAPI, ace) {
var annotations = editor.getSession().getAnnotations();
var newAnnotations = _.reduce(annotations, function (annotations, error) {
- if (!FauxtonAPI.isIgnorableError(error.raw)) {
+ if (!this.isIgnorableError(error.raw)) {
annotations.push(error);
}
return annotations;
@@ -330,8 +330,19 @@ function(app, FauxtonAPI, ace) {
var errors = this.getAnnotations();
// By default CouchDB view functions don't pass lint
return _.every(errors, function(error) {
- return FauxtonAPI.isIgnorableError(error.raw);
+ return this.isIgnorableError(error.raw);
},this);
+ },
+
+ // List of JSHINT errors to ignore
+ // Gets around problem of anonymous functions not being a valid statement
+ excludedViewErrors: [
+ "Missing name in function declaration.",
+ "['{a}'] is better written in dot notation."
+ ],
+
+ isIgnorableError: function(msg) {
+ return _.contains(this.excludedViewErrors, msg);
}
});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ccf1bb67/src/fauxton/app/core/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/api.js b/src/fauxton/app/core/api.js
new file mode 100644
index 0000000..0e4e730
--- /dev/null
+++ b/src/fauxton/app/core/api.js
@@ -0,0 +1,520 @@
+// 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.
+
+define([
+ "app",
+ "core/base",
+ // Modules
+ "modules/fauxton/base",
+ "spin"
+],
+
+function(app, FauxtonAPI, Fauxton) {
+
+ FauxtonAPI.moduleExtensions = {
+ Routes: {
+ }
+ };
+
+ FauxtonAPI.addonExtensions = {
+ initialize: function() {}
+ };
+
+ FauxtonAPI.module = function(extra) {
+ return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
+ };
+
+ FauxtonAPI.addon = function(extra) {
+ return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
+ };
+
+ FauxtonAPI.navigate = function(url, _opts) {
+ var options = _.extend({trigger: true}, _opts );
+ app.router.navigate(url,options);
+ };
+
+ FauxtonAPI.beforeUnload = function () {
+ app.router.beforeUnload.apply(app.router, arguments);
+ };
+
+ FauxtonAPI.removeBeforeUnload = function () {
+ app.router.removeBeforeUnload.apply(app.router, arguments);
+ };
+
+ FauxtonAPI.addHeaderLink = function(link) {
+ app.masterLayout.navBar.addLink(link);
+ };
+
+ FauxtonAPI.removeHeaderLink = function(link) {
+ app.masterLayout.navBar.removeLink(link);
+ };
+
+ FauxtonAPI.addRoute = function(route) {
+ app.router.route(route.route, route.name, route.callback);
+ };
+
+ FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
+ app.router.triggerRouteEvent("route:"+routeEvent, args);
+ };
+
+ FauxtonAPI.addNotification = function(options) {
+ options = _.extend({
+ msg: "Notification Event Triggered!",
+ type: "info",
+ selector: "#global-notifications"
+ }, options);
+ var view = new Fauxton.Notification(options);
+
+ return view.renderNotification();
+ };
+
+ FauxtonAPI.UUID = FauxtonAPI.Model.extend({
+ initialize: function(options) {
+ options = _.extend({count: 1}, options);
+ this.count = options.count;
+ },
+
+ url: function() {
+ return app.host + "/_uuids?count=" + this.count;
+ },
+
+ next: function() {
+ return this.get("uuids").pop();
+ }
+ });
+
+ FauxtonAPI.Session = Backbone.Model.extend({
+ url: '/_session',
+
+ user: function () {
+ var userCtx = this.get('userCtx');
+
+ if (!userCtx || !userCtx.name) { return null; }
+
+ return {
+ name: userCtx.name,
+ roles: userCtx.roles
+ };
+ },
+
+ fetchOnce: function (opt) {
+ var options = _.extend({}, opt);
+
+ if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
+ this._deferred = this.fetch();
+ }
+
+ return this._deferred;
+ },
+
+ fetchUser: function (opt) {
+ var that = this,
+ currentUser = this.user();
+
+ return this.fetchOnce(opt).then(function () {
+ var user = that.user();
+
+ // Notify anyone listening on these events that either a user has changed
+ // or current user is the same
+ if (currentUser !== user) {
+ that.trigger('session:userChanged');
+ } else {
+ that.trigger('session:userFetched');
+ }
+
+ // this will return the user as a value to all function that calls done on this
+ // eg. session.fetchUser().done(user) { .. do something with user ..}
+ return user;
+ });
+ }
+ });
+
+ FauxtonAPI.setSession = function (newSession) {
+ app.session = FauxtonAPI.session = newSession;
+ return FauxtonAPI.session.fetchUser();
+ };
+
+ FauxtonAPI.setSession(new FauxtonAPI.Session());
+
+ // This is not exposed externally as it should not need to be accessed or overridden
+ var Auth = function (options) {
+ this._options = options;
+ this.initialize.apply(this, arguments);
+ };
+
+ // Piggy-back on Backbone's self-propagating extend function,
+ Auth.extend = Backbone.Model.extend;
+
+ _.extend(Auth.prototype, Backbone.Events, {
+ authDeniedCb: function() {},
+
+ initialize: function() {
+ var that = this;
+ },
+
+ authHandlerCb : function (roles) {
+ var deferred = $.Deferred();
+ deferred.resolve();
+ return deferred;
+ },
+
+ registerAuth: function (authHandlerCb) {
+ this.authHandlerCb = authHandlerCb;
+ },
+
+ registerAuthDenied: function (authDeniedCb) {
+ this.authDeniedCb = authDeniedCb;
+ },
+
+ checkAccess: function (roles) {
+ var requiredRoles = roles || [],
+ that = this;
+
+ return FauxtonAPI.session.fetchUser().then(function (user) {
+ return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
+ });
+ }
+ });
+
+ FauxtonAPI.auth = new Auth();
+
+ FauxtonAPI.RouteObject = function(options) {
+ this._options = options;
+
+ this._configure(options || {});
+ this.initialize.apply(this, arguments);
+ this.addEvents();
+ };
+
+ var broadcaster = {};
+ _.extend(broadcaster, Backbone.Events);
+
+ FauxtonAPI.RouteObject.on = function (eventName, fn) {
+ broadcaster.on(eventName, fn);
+ };
+
+ /* How Route Object events work
+ To listen to a specific route objects events:
+
+ myRouteObject = FauxtonAPI.RouteObject.extend({
+ events: {
+ "beforeRender": "beforeRenderEvent"
+ },
+
+ beforeRenderEvent: function (view, selector) {
+ console.log('Hey, beforeRenderEvent triggered',arguments);
+ },
+ });
+
+ It is also possible to listen to events triggered from all Routeobjects.
+ This is great for more general things like adding loaders, hooks.
+
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ console.log('hey, this will trigger when any routeobject renders a view');
+ });
+
+ Current Events to subscribe to:
+ * beforeFullRender -- before a full render is being done
+ * beforeEstablish -- before the routeobject calls establish
+ * AfterEstablish -- after the routeobject has run establish
+ * beforeRender -- before a view is rendered
+ * afterRender -- a view is finished being rendered
+ * renderComplete -- all rendering is complete
+
+ */
+
+ // Piggy-back on Backbone's self-propagating extend function
+ FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
+
+ var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
+
+ _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
+ // Should these be default vals or empty funcs?
+ views: {},
+ routes: {},
+ events: {},
+ crumbs: [],
+ layout: "with_sidebar",
+ apiUrl: null,
+ disableLoader: false,
+ loaderClassname: 'loader',
+ renderedState: false,
+ establish: function() {},
+ route: function() {},
+ roles: [],
+ initialize: function() {}
+ }, {
+
+ renderWith: function(route, masterLayout, args) {
+ var routeObject = this,
+ triggerBroadcast = _.bind(this.triggerBroadcast, this);
+
+ // Only want to redo the template if its a full render
+ if (!this.renderedState) {
+ masterLayout.setTemplate(this.layout);
+ triggerBroadcast('beforeFullRender');
+ $('#primary-navbar li').removeClass('active');
+
+ if (this.selectedHeader) {
+ app.selectedHeader = this.selectedHeader;
+ $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
+ }
+ }
+
+ masterLayout.clearBreadcrumbs();
+ var crumbs = this.get('crumbs');
+
+ if (crumbs.length) {
+ masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
+ crumbs: crumbs
+ }));
+ }
+
+ triggerBroadcast('beforeEstablish');
+ FauxtonAPI.when(this.establish()).then(function(resp) {
+ triggerBroadcast('afterEstablish');
+ _.each(routeObject.getViews(), function(view, selector) {
+ if(view.hasRendered) {
+ triggerBroadcast('viewHasRendered', view, selector);
+ return;
+ }
+
+ triggerBroadcast('beforeRender', view, selector);
+ FauxtonAPI.when(view.establish()).then(function(resp) {
+ masterLayout.setView(selector, view);
+
+ masterLayout.renderView(selector);
+ triggerBroadcast('afterRender', view, selector);
+ }, function(resp) {
+ view.establishError = {
+ error: true,
+ reason: resp
+ };
+
+ if (resp) {
+ var errorText = JSON.parse(resp.responseText).reason;
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred: ' + errorText,
+ type: 'error',
+ clear: true
+ });
+ }
+
+ masterLayout.renderView(selector);
+ });
+
+ });
+ }.bind(this), function (resp) {
+ if (!resp) { return; }
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
+ type: 'error',
+ clear: true
+ });
+ });
+
+ 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;
+ triggerBroadcast('renderComplete');
+ },
+
+ triggerBroadcast: function (eventName) {
+ var args = Array.prototype.slice.call(arguments);
+ this.trigger.apply(this, args);
+
+ args.splice(0,1, eventName, this);
+ broadcaster.trigger.apply(broadcaster, args);
+ },
+
+ get: function(key) {
+ return _.isFunction(this[key]) ? this[key]() : this[key];
+ },
+
+ addEvents: function(events) {
+ events = events || this.get('events');
+ _.each(events, function(method, event) {
+ if (!_.isFunction(method) && !_.isFunction(this[method])) {
+ throw new Error("Invalid method: "+method);
+ }
+ method = _.isFunction(method) ? method : this[method];
+
+ this.on(event, method);
+ }, this);
+ },
+
+ _configure: function(options) {
+ _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
+ this[key] = options[key];
+ }, this);
+ },
+
+ getView: function(selector) {
+ return this.views[selector];
+ },
+
+ setView: function(selector, view) {
+ this.views[selector] = view;
+ return view;
+ },
+
+ getViews: function() {
+ return this.views;
+ },
+
+ removeViews: function () {
+ _.each(this.views, function (view, selector) {
+ view.remove();
+ delete this.views[selector];
+ }, this);
+ },
+
+ getRouteUrls: function () {
+ return _.keys(this.get('routes'));
+ },
+
+ hasRoute: function (route) {
+ if (this.get('routes')[route]) {
+ return true;
+ }
+ return false;
+ },
+
+ routeCallback: function (route, args) {
+ var routes = this.get('routes'),
+ routeObj = routes[route],
+ routeCallback;
+
+ if (typeof routeObj === 'object') {
+ routeCallback = this[routeObj.route];
+ } else {
+ routeCallback = this[routeObj];
+ }
+
+ routeCallback.apply(this, args);
+ },
+
+ getRouteRoles: function (routeUrl) {
+ var route = this.get('routes')[routeUrl];
+
+ if ((typeof route === 'object') && route.roles) {
+ return route.roles;
+ }
+
+ return this.roles;
+ }
+
+ });
+
+ // We could look at moving the spinner code out to its own module
+ var routeObjectSpinner;
+ FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
+ if (!routeObject.disableLoader){
+ var opts = {
+ lines: 16, // The number of lines to draw
+ length: 8, // The length of each line
+ width: 4, // The line thickness
+ radius: 12, // The radius of the inner circle
+ color: '#333', // #rbg or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 10, // Afterglow percentage
+ shadow: false // Whether to render a shadow
+ };
+
+ if (!$('.spinner').length) {
+ $('<div class="spinner"></div>')
+ .appendTo('#app-container');
+ }
+
+ routeObjectSpinner = new Spinner(opts).spin();
+ $('.spinner').append(routeObjectSpinner.el);
+ }
+ });
+
+ var removeRouteObjectSpinner = function () {
+ if (routeObjectSpinner) {
+ routeObjectSpinner.stop();
+ $('.spinner').remove();
+ }
+ };
+
+ var removeViewSpinner = function () {
+ if (viewSpinner){
+ viewSpinner.stop();
+ $('.spinner').remove();
+ }
+ };
+
+ var viewSpinner;
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ removeRouteObjectSpinner();
+
+ if (!view.disableLoader){
+ var opts = {
+ lines: 16, // The number of lines to draw
+ length: 8, // The length of each line
+ width: 4, // The line thickness
+ radius: 12, // The radius of the inner circle
+ color: '#333', // #rbg or #rrggbb
+ speed: 1, // Rounds per second
+ trail: 10, // Afterglow percentage
+ shadow: false // Whether to render a shadow
+ };
+
+ viewSpinner = new Spinner(opts).spin();
+ $('<div class="spinner"></div>')
+ .appendTo(selector)
+ .append(viewSpinner.el);
+ }
+ });
+
+ FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
+ removeViewSpinner();
+ });
+
+ FauxtonAPI.RouteObject.on('viewHasRendered', function () {
+ removeViewSpinner();
+ removeRouteObjectSpinner();
+ });
+
+ var extensions = _.extend({}, Backbone.Events);
+ // Can look at a remove function later.
+ FauxtonAPI.registerExtension = function (name, view) {
+ if (!extensions[name]) {
+ extensions[name] = [];
+ }
+
+ extensions.trigger('add:' + name, view);
+ extensions[name].push(view);
+ };
+
+ FauxtonAPI.getExtensions = function (name) {
+ var views = extensions[name];
+
+ if (!views) {
+ views = [];
+ }
+
+ return views;
+ };
+
+ FauxtonAPI.extensions = extensions;
+
+ app.fauxtonAPI = FauxtonAPI;
+ return app.fauxtonAPI;
+});
+
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ccf1bb67/src/fauxton/app/core/base.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/base.js b/src/fauxton/app/core/base.js
new file mode 100644
index 0000000..20dea73
--- /dev/null
+++ b/src/fauxton/app/core/base.js
@@ -0,0 +1,52 @@
+// 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.
+
+define([
+],
+
+function() {
+ var FauxtonAPI = {};
+
+ FauxtonAPI.Deferred = function() {
+ return $.Deferred();
+ };
+
+ FauxtonAPI.when = function (deferreds) {
+ if (deferreds instanceof Array) {
+ return $.when.apply(null, deferreds);
+ }
+
+ return $.when(deferreds);
+ };
+
+ FauxtonAPI.View = Backbone.View.extend({
+ // This should return an array of promises, an empty array, or null
+ establish: function() {
+ return null;
+ },
+
+ loaderClassname: 'loader',
+
+ disableLoader: false,
+
+ forceRender: function () {
+ this.hasRendered = false;
+ }
+ });
+
+ FauxtonAPI.Model = Backbone.Model.extend({
+ //add fetchOnce
+ });
+
+ return FauxtonAPI;
+});
+
[18/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
use POSIX tar to support files length > 99
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/f04485f0
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/f04485f0
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/f04485f0
Branch: refs/heads/fauxton-file-reorder
Commit: f04485f04e2f02e86ca6316a0b19ce9a8d3cc5fd
Parents: 0b9bb15
Author: Benoit Chesneau <be...@apache.org>
Authored: Sun Jan 5 10:22:05 2014 +0100
Committer: Alexander Shorin <kx...@apache.org>
Committed: Thu Jan 16 01:41:58 2014 +0400
----------------------------------------------------------------------
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/f04485f0/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index 6c5ef5b..57a4268 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([src/snappy/google-snappy/config.h])
-AM_INIT_AUTOMAKE([1.6.3 foreign])
+AM_INIT_AUTOMAKE([1.6.3 foreign tar-ustar])
AC_USE_SYSTEM_EXTENSIONS
AC_ENABLE_SHARED
[25/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
Initial run
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/54241007
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/54241007
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/54241007
Branch: refs/heads/fauxton-file-reorder
Commit: 5424100714a5ea15d1cc3335f87b9b4036c8387a
Parents: ccf1bb6
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Jan 13 20:34:32 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Jan 20 10:07:39 2014 +0200
----------------------------------------------------------------------
src/fauxton/app/core/couchdb.js | 78 +++++++++
src/fauxton/app/core/resources.js | 301 +++++++++++++++++++++++++++++++++
2 files changed, 379 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/54241007/src/fauxton/app/core/couchdb.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/couchdb.js b/src/fauxton/app/core/couchdb.js
new file mode 100644
index 0000000..39cdc1a
--- /dev/null
+++ b/src/fauxton/app/core/couchdb.js
@@ -0,0 +1,78 @@
+// 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.
+
+define([
+ "app",
+ "core/base"
+],
+function (app, FauxtonAPI) {
+ //this later needs to be dynamically loaded
+
+ FauxtonAPI.UUID = FauxtonAPI.Model.extend({
+ initialize: function(options) {
+ options = _.extend({count: 1}, options);
+ this.count = options.count;
+ },
+
+ url: function() {
+ return app.host + "/_uuids?count=" + this.count;
+ },
+
+ next: function() {
+ return this.get("uuids").pop();
+ }
+ });
+
+ FauxtonAPI.Session = FauxtonAPI.Model.extend({
+ url: app.host + '/_session',
+
+ user: function () {
+ var userCtx = this.get('userCtx');
+
+ if (!userCtx || !userCtx.name) { return null; }
+
+ return {
+ name: userCtx.name,
+ roles: userCtx.roles
+ };
+ },
+
+ fetchUser: function (opt) {
+ var that = this,
+ currentUser = this.user();
+
+ return this.fetchOnce(opt).then(function () {
+ var user = that.user();
+
+ // Notify anyone listening on these events that either a user has changed
+ // or current user is the same
+ if (currentUser !== user) {
+ that.trigger('session:userChanged');
+ } else {
+ that.trigger('session:userFetched');
+ }
+
+ // this will return the user as a value to all function that calls done on this
+ // eg. session.fetchUser().done(user) { .. do something with user ..}
+ return user;
+ });
+ }
+ });
+
+ FauxtonAPI.setSession = function (newSession) {
+ app.session = FauxtonAPI.session = newSession;
+ return FauxtonAPI.session.fetchUser();
+ };
+
+ //set default session
+ FauxtonAPI.setSession(new FauxtonAPI.Session());
+
+ return FauxtonAPI;
+});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/54241007/src/fauxton/app/core/resources.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/core/resources.js b/src/fauxton/app/core/resources.js
new file mode 100644
index 0000000..83111c7
--- /dev/null
+++ b/src/fauxton/app/core/resources.js
@@ -0,0 +1,301 @@
+// 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.
+
+define([
+ "app",
+ "core/couchdb",
+ "addons/fauxton/base",
+ "backbone"
+],
+function(app, FauxtonAPI, Fauxton) {
+
+ // This is not exposed externally as it should not need to be accessed or overridden
+ var Auth = function (options) {
+ this._options = options;
+ this.initialize.apply(this, arguments);
+ };
+
+ // Piggy-back on Backbone's self-propagating extend function,
+ Auth.extend = Backbone.Model.extend;
+
+ _.extend(Auth.prototype, Backbone.Events, {
+ authDeniedCb: function() {},
+
+ initialize: function() {
+ var that = this;
+ },
+
+ authHandlerCb : function (roles) {
+ var deferred = $.Deferred();
+ deferred.resolve();
+ return deferred;
+ },
+
+ registerAuth: function (authHandlerCb) {
+ this.authHandlerCb = authHandlerCb;
+ },
+
+ registerAuthDenied: function (authDeniedCb) {
+ this.authDeniedCb = authDeniedCb;
+ },
+
+ checkAccess: function (roles) {
+ var requiredRoles = roles || [],
+ that = this;
+
+ if (!FauxtonAPI.session) {
+ throw new Error("Fauxton.session is not configured.");
+ }
+
+ return FauxtonAPI.session.fetchUser().then(function (user) {
+ return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
+ });
+ }
+ });
+
+ FauxtonAPI.auth = new Auth();
+
+ FauxtonAPI.RouteObject = function(options) {
+ this._options = options;
+
+ this._configure(options || {});
+ this.initialize.apply(this, arguments);
+ this.addEvents();
+ };
+
+ var broadcaster = {};
+ _.extend(broadcaster, Backbone.Events);
+
+ FauxtonAPI.RouteObject.on = function (eventName, fn) {
+ broadcaster.on(eventName, fn);
+ };
+
+ /* How Route Object events work
+ To listen to a specific route objects events:
+
+ myRouteObject = FauxtonAPI.RouteObject.extend({
+ events: {
+ "beforeRender": "beforeRenderEvent"
+ },
+
+ beforeRenderEvent: function (view, selector) {
+ console.log('Hey, beforeRenderEvent triggered',arguments);
+ },
+ });
+
+ It is also possible to listen to events triggered from all Routeobjects.
+ This is great for more general things like adding loaders, hooks.
+
+ FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
+ console.log('hey, this will trigger when any routeobject renders a view');
+ });
+
+ Current Events to subscribe to:
+ * beforeFullRender -- before a full render is being done
+ * beforeEstablish -- before the routeobject calls establish
+ * AfterEstablish -- after the routeobject has run establish
+ * beforeRender -- before a view is rendered
+ * afterRender -- a view is finished being rendered
+ * renderComplete -- all rendering is complete
+
+ */
+
+ // Piggy-back on Backbone's self-propagating extend function
+ FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
+
+ var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
+
+ _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
+ // Should these be default vals or empty funcs?
+ views: {},
+ routes: {},
+ events: {},
+ crumbs: [],
+ layout: "with_sidebar",
+ apiUrl: null,
+ disableLoader: false,
+ loaderClassname: 'loader',
+ renderedState: false,
+ establish: function() {},
+ route: function() {},
+ roles: [],
+ initialize: function() {}
+ }, {
+
+ renderWith: function(route, masterLayout, args) {
+ var routeObject = this,
+ triggerBroadcast = _.bind(this.triggerBroadcast, this);
+
+ // Only want to redo the template if its a full render
+ if (!this.renderedState) {
+ masterLayout.setTemplate(this.layout);
+ triggerBroadcast('beforeFullRender');
+ $('#primary-navbar li').removeClass('active');
+
+ if (this.selectedHeader) {
+ app.selectedHeader = this.selectedHeader;
+ $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
+ }
+ }
+
+ masterLayout.clearBreadcrumbs();
+ var crumbs = this.get('crumbs');
+
+ if (crumbs.length) {
+ masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
+ crumbs: crumbs
+ }));
+ }
+
+ triggerBroadcast('beforeEstablish');
+ FauxtonAPI.when(this.establish()).then(function(resp) {
+ triggerBroadcast('afterEstablish');
+ _.each(routeObject.getViews(), function(view, selector) {
+ if(view.hasRendered) {
+ triggerBroadcast('viewHasRendered', view, selector);
+ return;
+ }
+
+ triggerBroadcast('beforeRender', view, selector);
+ FauxtonAPI.when(view.establish()).then(function(resp) {
+ masterLayout.setView(selector, view);
+
+ masterLayout.renderView(selector);
+ triggerBroadcast('afterRender', view, selector);
+ }, function(resp) {
+ view.establishError = {
+ error: true,
+ reason: resp
+ };
+
+ if (resp) {
+ var errorText = JSON.parse(resp.responseText).reason;
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred: ' + errorText,
+ type: 'error',
+ clear: true
+ });
+ }
+
+ masterLayout.renderView(selector);
+ });
+
+ });
+ }.bind(this), function (resp) {
+ if (!resp) { return; }
+ FauxtonAPI.addNotification({
+ msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
+ type: 'error',
+ clear: true
+ });
+ });
+
+ 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;
+ triggerBroadcast('renderComplete');
+ },
+
+ triggerBroadcast: function (eventName) {
+ var args = Array.prototype.slice.call(arguments);
+ this.trigger.apply(this, args);
+
+ args.splice(0,1, eventName, this);
+ broadcaster.trigger.apply(broadcaster, args);
+ },
+
+ get: function(key) {
+ return _.isFunction(this[key]) ? this[key]() : this[key];
+ },
+
+ addEvents: function(events) {
+ events = events || this.get('events');
+ _.each(events, function(method, event) {
+ if (!_.isFunction(method) && !_.isFunction(this[method])) {
+ throw new Error("Invalid method: "+method);
+ }
+ method = _.isFunction(method) ? method : this[method];
+
+ this.on(event, method);
+ }, this);
+ },
+
+ _configure: function(options) {
+ _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
+ this[key] = options[key];
+ }, this);
+ },
+
+ getView: function(selector) {
+ return this.views[selector];
+ },
+
+ setView: function(selector, view) {
+ this.views[selector] = view;
+ return view;
+ },
+
+ getViews: function() {
+ return this.views;
+ },
+
+ removeViews: function () {
+ _.each(this.views, function (view, selector) {
+ view.remove();
+ delete this.views[selector];
+ }, this);
+ },
+
+ getRouteUrls: function () {
+ return _.keys(this.get('routes'));
+ },
+
+ hasRoute: function (route) {
+ if (this.get('routes')[route]) {
+ return true;
+ }
+ return false;
+ },
+
+ routeCallback: function (route, args) {
+ var routes = this.get('routes'),
+ routeObj = routes[route],
+ routeCallback;
+
+ if (typeof routeObj === 'object') {
+ routeCallback = this[routeObj.route];
+ } else {
+ routeCallback = this[routeObj];
+ }
+
+ routeCallback.apply(this, args);
+ },
+
+ getRouteRoles: function (routeUrl) {
+ var route = this.get('routes')[routeUrl];
+
+ if ((typeof route === 'object') && route.roles) {
+ return route.roles;
+ }
+
+ return this.roles;
+ }
+
+ });
+
+ return FauxtonAPI;
+});
[07/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
moving over post-addons refactor template changes
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/134dd40f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/134dd40f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/134dd40f
Branch: refs/heads/fauxton-file-reorder
Commit: 134dd40f259d0365b37db760e039f0873e81aa43
Parents: a37a3eb
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Mon Jan 13 13:45:22 2014 -0500
Committer: suelockwood <de...@apache.org>
Committed: Mon Jan 13 15:09:15 2014 -0500
----------------------------------------------------------------------
.../app/addons/documents/templates/advanced_options.html | 5 +++--
src/fauxton/app/addons/documents/templates/all_docs_layout.html | 2 +-
src/fauxton/app/addons/documents/templates/all_docs_number.html | 4 +++-
.../app/addons/documents/templates/duplicate_doc_modal.html | 2 +-
.../app/addons/documents/templates/index_row_docular.html | 5 +++--
5 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/advanced_options.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/advanced_options.html b/src/fauxton/app/addons/documents/templates/advanced_options.html
index 8e96574..e256325 100644
--- a/src/fauxton/app/addons/documents/templates/advanced_options.html
+++ b/src/fauxton/app/addons/documents/templates/advanced_options.html
@@ -67,8 +67,9 @@ the License.
Limit:
<select name="limit" class="input-small">
<option>5</option>
- <option selected="selected">10</option>
- <option>25</option>
+ <option>10</option>
+ <option selected="selected">20</option>
+ <option>30</option>
<option>50</option>
<option>100</option>
</select>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/all_docs_layout.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_layout.html b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
index 526c200..6b4a31b 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_layout.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_layout.html
@@ -12,7 +12,7 @@ License for the specific language governing permissions and limitations under
the License.
-->
<ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav">
- <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-toggle="tab">Query Options</a></li>
+ <li><a id="toggle-query" class="fonticon-plus fonticon" href="#query" data-bypass="true" data-toggle="tab">Query Options</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="query">
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/all_docs_number.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/all_docs_number.html b/src/fauxton/app/addons/documents/templates/all_docs_number.html
index c4ea8f6..df8fe07 100644
--- a/src/fauxton/app/addons/documents/templates/all_docs_number.html
+++ b/src/fauxton/app/addons/documents/templates/all_docs_number.html
@@ -13,8 +13,10 @@ the License.
-->
<% if (totalRows === "unknown"){ %>
Showing 0 documents. <a href="#/database/<%=database%>/new"> Create your first document.</a>
-<% } else { %>
+<% } else if (showNumbers) { %>
Showing <%=offset%> - <%= numModels %> of <%= totalRows %> rows
+<% } else { %>
+ Showing <%=pageStart%> - <%= pageEnd %>
<%}%>
<% if (updateSeq) { %>
-- Update Sequence: <%= updateSeq %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
index 3f374b6..dbb25bc 100644
--- a/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
+++ b/src/fauxton/app/addons/documents/templates/duplicate_doc_modal.html
@@ -19,7 +19,7 @@ the License.
</div>
<div class="modal-body">
<div id="modal-error" class="hide alert alert-error"/>
- <form id="file-upload" class="form" method="post">
+ <form id="doc-duplicate" class="form" method="post">
<p class="help-block">
Set new documents ID:
</p>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/134dd40f/src/fauxton/app/addons/documents/templates/index_row_docular.html
----------------------------------------------------------------------
diff --git a/src/fauxton/app/addons/documents/templates/index_row_docular.html b/src/fauxton/app/addons/documents/templates/index_row_docular.html
index 3835453..f1b2217 100644
--- a/src/fauxton/app/addons/documents/templates/index_row_docular.html
+++ b/src/fauxton/app/addons/documents/templates/index_row_docular.html
@@ -11,8 +11,9 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
-->
-
-<td class="select"><input type="checkbox"></td>
+<% if (doc.isEditable()) { %>
+ <td class="select"><input type="checkbox"></td>
+<% } %>
<td>
<div>
<pre class="prettyprint"><%- doc.prettyJSON() %></pre>
[15/29] couchdb commit: updated refs/heads/fauxton-file-reorder to
35d2ec1
Posted by ga...@apache.org.
made couchserver configurable via settings.json
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/ad3edf81
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/ad3edf81
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/ad3edf81
Branch: refs/heads/fauxton-file-reorder
Commit: ad3edf811182045b69d5e400be34b1f0133e3e3e
Parents: 42c4493
Author: BigBlueHat <by...@bigbluehat.com>
Authored: Tue Jan 14 14:27:27 2014 -0500
Committer: Garren Smith <ga...@gmail.com>
Committed: Wed Jan 15 09:01:19 2014 +0200
----------------------------------------------------------------------
src/fauxton/Gruntfile.js | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/ad3edf81/src/fauxton/Gruntfile.js
----------------------------------------------------------------------
diff --git a/src/fauxton/Gruntfile.js b/src/fauxton/Gruntfile.js
index 49b52a4..cf70440 100644
--- a/src/fauxton/Gruntfile.js
+++ b/src/fauxton/Gruntfile.js
@@ -112,6 +112,28 @@ module.exports = function(grunt) {
return settings.template || defaultSettings;
}();
+ var couchserver_config = function () {
+ // add a "couchserver" key to settings.json with JSON that matches the
+ // keys and values below (plus your customizations) to have Fauxton work
+ // against a remote CouchDB-compatible server.
+ var defaults = {
+ dist: './dist/debug/',
+ port: 8000,
+ proxy: {
+ target: {
+ host: 'localhost',
+ port: 5984,
+ https: false
+ },
+ // This sets the Host header in the proxy so that you can use external
+ // CouchDB instances and not have the Host set to 'localhost'
+ changeOrigin: true
+ }
+ };
+
+ return helper.readSettingsFile().couchserver || defaults;
+ }();
+
grunt.initConfig({
// The clean task ensures all files are removed from the dist/ directory so
@@ -223,20 +245,7 @@ module.exports = function(grunt) {
},
// Runs a proxy server for easier development, no need to keep deploying to couchdb
- couchserver: {
- dist: './dist/debug/',
- port: 8000,
- proxy: {
- target: {
- host: 'localhost',
- port: 5984,
- https: false
- },
- // This sets the Host header in the proxy so that you can use external
- // CouchDB instances and not have the Host set to 'localhost'
- changeOrigin: true
- }
- },
+ couchserver: couchserver_config,
watch: {
js: {