diff options
author | Russell Branca <chewbranca@gmail.com> | 2012-12-17 17:03:05 -0800 |
---|---|---|
committer | Russell Branca <chewbranca@gmail.com> | 2012-12-18 10:03:41 -0800 |
commit | b62b5d7dc5f1294d5c65d3bb9e0162cf11b74882 (patch) | |
tree | 72aff61faaf61c85603675d4eccfb85aaebf9e8b /src | |
parent | 4a85f0d319a29c84014f35e10ac7f4d600f6a331 (diff) | |
download | couchdb-b62b5d7dc5f1294d5c65d3bb9e0162cf11b74882.tar.gz |
Mostly working _config and _logs
Diffstat (limited to 'src')
-rw-r--r-- | src/fauxton/app/addons/config/resources.js | 20 | ||||
-rw-r--r-- | src/fauxton/app/addons/config/routes.js | 15 | ||||
-rw-r--r-- | src/fauxton/app/addons/demo/init.js | 2 | ||||
-rw-r--r-- | src/fauxton/app/addons/logs/resources.js | 18 | ||||
-rw-r--r-- | src/fauxton/app/addons/logs/routes.js | 8 | ||||
-rw-r--r-- | src/fauxton/app/addons/logs/views.js | 20 | ||||
-rw-r--r-- | src/fauxton/app/api.js | 12 | ||||
-rw-r--r-- | src/fauxton/app/load_addons.js | 16 | ||||
-rw-r--r-- | src/fauxton/app/modules/documents/routes.js | 1 | ||||
-rw-r--r-- | src/fauxton/app/router.js | 3 |
10 files changed, 48 insertions, 67 deletions
diff --git a/src/fauxton/app/addons/config/resources.js b/src/fauxton/app/addons/config/resources.js index 99e27aaf6..dc8011b2f 100644 --- a/src/fauxton/app/addons/config/resources.js +++ b/src/fauxton/app/addons/config/resources.js @@ -1,17 +1,11 @@ define([ "app", - - // Libs - "backbone", - - // Modules - "modules/fauxton/base" - + "api" ], -function (app, backbone, Fauxton) { +function (app, FauxtonAPI) { - var Config = app.module(); + var Config = FauxtonAPI.addon(); Config.Model = Backbone.Model.extend({}); Config.OptionModel = Backbone.Model.extend({ @@ -63,7 +57,7 @@ function (app, backbone, Fauxton) { } }); - Config.ViewItem = Backbone.View.extend({ + Config.ViewItem = FauxtonAPI.View.extend({ tagName: "tr", className: "config-item", template: "templates/config/item", @@ -105,7 +99,7 @@ function (app, backbone, Fauxton) { }); - Config.View = Backbone.View.extend({ + Config.View = FauxtonAPI.View.extend({ template: "templates/config/dashboard", events: { @@ -158,6 +152,10 @@ function (app, backbone, Fauxton) { })); }, this); }, this); + }, + + establish: function() { + return [this.collection.fetch()]; } }); diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js index db9be8e0c..f14f216b1 100644 --- a/src/fauxton/app/addons/config/routes.js +++ b/src/fauxton/app/addons/config/routes.js @@ -8,9 +8,8 @@ define([ ], function(app, FauxtonAPI, Config) { - var config = function () { + var configRoute = function () { var configs = new Config.Collection(); - var deferred = FauxtonAPI.Deferred(); return { layout: "one_pane", @@ -21,20 +20,14 @@ function(app, FauxtonAPI, Config) { views: { "#dashboard-content": new Config.View({collection: configs}) }, - apiUrl: configs.url(), - establish: function() { - configs.fetch().done(function(resp) { - deferred.resolve(); - }); - return [deferred]; - } + apiUrl: configs.url() }; }; Config.Routes = { - "_config": "config" + "_config": configRoute }; return Config; -});
\ No newline at end of file +}); diff --git a/src/fauxton/app/addons/demo/init.js b/src/fauxton/app/addons/demo/init.js index a3bef0645..7572650a8 100644 --- a/src/fauxton/app/addons/demo/init.js +++ b/src/fauxton/app/addons/demo/init.js @@ -5,7 +5,7 @@ define([ function(app, FauxtonAPI) { - var Demo = FauxtonAPI.module(); + var Demo = FauxtonAPI.addon(); Demo.initialize = function() { console.log("HELLO FROM DEMO LAND!!!!"); diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js index 97fb9bc73..7fa6b42f7 100644 --- a/src/fauxton/app/addons/logs/resources.js +++ b/src/fauxton/app/addons/logs/resources.js @@ -1,17 +1,11 @@ define([ "app", - - // Libs - "backbone", - - // Modules - "modules/fauxton/base" - + "api" ], -function (app, backbone, Fauxton) { +function (app, FauxtonAPI) { - var Log = app.module(); + var Log = FauxtonAPI.addon(); Log.Model = Backbone.Model.extend({ }); @@ -58,7 +52,7 @@ function (app, backbone, Fauxton) { Log.events = {}; _.extend(Log.events, Backbone.Events); - Log.View = Backbone.View.extend({ + Log.View = FauxtonAPI.View.extend({ template: "templates/log/dashboard", initialize: function (options) { @@ -140,7 +134,7 @@ function (app, backbone, Fauxton) { } }); - Log.FilterView = Backbone.View.extend({ + Log.FilterView = FauxtonAPI.View.extend({ template: "templates/log/sidebar", events: { @@ -163,7 +157,7 @@ function (app, backbone, Fauxton) { }); - Log.FilterItemView = Backbone.View.extend({ + Log.FilterItemView = FauxtonAPI.View.extend({ template: "templates/log/filterItem", tagName: "li", diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js index 2298c74df..77f870ade 100644 --- a/src/fauxton/app/addons/logs/routes.js +++ b/src/fauxton/app/addons/logs/routes.js @@ -12,7 +12,6 @@ function(app, FauxtonAPI, Log) { Log.Routes = { "_log": function() { var logs = new Log.Collection(); - var deferred = FauxtonAPI.Deferred(); return { layout: "one_pane", @@ -26,10 +25,7 @@ function(app, FauxtonAPI, Log) { }, apiUrl: logs.url(), establish: function() { - logs.fetch().done(function(resp) { - deferred.resolve(); - }); - return [deferred]; + return [logs.fetch()]; } }; } @@ -37,4 +33,4 @@ function(app, FauxtonAPI, Log) { return Log; -});
\ No newline at end of file +}); diff --git a/src/fauxton/app/addons/logs/views.js b/src/fauxton/app/addons/logs/views.js index 4e1adc540..9a74f863a 100644 --- a/src/fauxton/app/addons/logs/views.js +++ b/src/fauxton/app/addons/logs/views.js @@ -1,20 +1,12 @@ define([ "app", - - // Libs - "backbone", - "codemirror", - "jshint", - - // Plugins - "plugins/codemirror-javascript", - "plugins/prettify" + "api" ], -function(app, Backbone, Codemirror, JSHint) { +function(app, FauxtonAPI) { var Views = {}; - Views.View = Backbone.View.extend({ + Views.View = FauxtonAPI.View.extend({ template: "log/dashboard", initialize: function (options) { @@ -96,7 +88,7 @@ function(app, Backbone, Codemirror, JSHint) { } }); - Views.FilterView = Backbone.View.extend({ + Views.FilterView = FauxtonAPI.View.extend({ template: "log/sidebar", events: { @@ -119,7 +111,7 @@ function(app, Backbone, Codemirror, JSHint) { }); - Views.FilterItemView = Backbone.View.extend({ + Views.FilterItemView = FauxtonAPI.View.extend({ template: "log/filterItem", tagName: "li", @@ -147,4 +139,4 @@ function(app, Backbone, Codemirror, JSHint) { }); return Views; -});
\ No newline at end of file +}); diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js index bd1eaaf5c..7aebd372f 100644 --- a/src/fauxton/app/api.js +++ b/src/fauxton/app/api.js @@ -13,6 +13,10 @@ function(app, Fauxton) { } }; + FauxtonAPI.addonExtensions = { + initialize: function() {} + }; + FauxtonAPI.View = Backbone.View.extend({ // This should return an array of promises, an empty array, or null establish: function() { @@ -25,7 +29,7 @@ function(app, Fauxton) { }; FauxtonAPI.addHeaderLink = function(link) { - app.dashboard.navBar.addLink(link); + app.masterLayout.navBar.addLink(link); }; FauxtonAPI.Deferred = function() { @@ -37,7 +41,11 @@ function(app, Fauxton) { }; FauxtonAPI.module = function(extra) { - return app.module(FauxtonAPI.moduleExtensions, extra); + return app.module(_.extend(FauxtonAPI.moduleExtensions, extra)); + }; + + FauxtonAPI.addon = function(extra) { + return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra); }; FauxtonAPI.addNotification = function(options) { diff --git a/src/fauxton/app/load_addons.js b/src/fauxton/app/load_addons.js index ff7a3ca07..ef2b377ab 100644 --- a/src/fauxton/app/load_addons.js +++ b/src/fauxton/app/load_addons.js @@ -3,14 +3,18 @@ define([ "addons/logs/base", "addons/config/base" ], - function() { - var LoadAddons = {}; - - // TODO: template this or build from a file - LoadAddons.addons = [ - "addons/demo/init" + // TODO: figure out a way to have this outside for sharing in the + // define block above + var FauxtonLoadAddons = [ + "addons/demo/init", + "addons/logs/base", + "addons/config/base" ]; + var LoadAddons = { + addons: FauxtonLoadAddons + }; + return LoadAddons; }); diff --git a/src/fauxton/app/modules/documents/routes.js b/src/fauxton/app/modules/documents/routes.js index 2e0c6bfff..0a1e15320 100644 --- a/src/fauxton/app/modules/documents/routes.js +++ b/src/fauxton/app/modules/documents/routes.js @@ -4,7 +4,6 @@ define([ "api", // Modules - // TODO: rename to resources "modules/documents/resources", "modules/databases/base" ], diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js index 1179b84e9..764682dd7 100644 --- a/src/fauxton/app/router.js +++ b/src/fauxton/app/router.js @@ -69,8 +69,6 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents var Router = app.router = Backbone.Router.extend({ routes: { - "_log": "log", - "_config": "config" }, // These moduleRoutes functions are aguably better outside but @@ -85,7 +83,6 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents var that = this; _.each(modules, function(module) { - console.log(module); if (module){ _.each(module.Routes, addModuleRoute, this); } |