Updated Branches: refs/heads/fauxton c09e3cc76 -> 44232ccb1
move addon templates into own file and better addon file defaults Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/44232ccb Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/44232ccb Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/44232ccb Branch: refs/heads/fauxton Commit: 44232ccb1b3f35d467bae04e91eff655cb589ab7 Parents: c09e3cc Author: Garren Smith <[email protected]> Authored: Sat Mar 9 10:49:01 2013 +0200 Committer: Garren Smith <[email protected]> Committed: Sat Mar 9 10:49:01 2013 +0200 ---------------------------------------------------------------------- src/fauxton/tasks/fauxton.js | 9 +++--- src/fauxton/tasks/templates/base.js.underscore | 21 +++++++++++++++ .../tasks/templates/resources.js.underscore | 21 +++++++++++++++ src/fauxton/tasks/templates/route.js.underscore | 21 +++++++++++++++ src/fauxton/writing_addons.md | 3 ++ 5 files changed, 71 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/44232ccb/src/fauxton/tasks/fauxton.js ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js index 78b50f3..ee365a2 100644 --- a/src/fauxton/tasks/fauxton.js +++ b/src/fauxton/tasks/fauxton.js @@ -37,17 +37,17 @@ module.exports = function(grunt) { { name: 'base', filename: 'base.js', - template: 'define([\n "app",\n "api",\n "addons/<%= module.toLowerCase() %>/routes"\n],\n\nfunction(app, FauxtonAPI, <%= module %>Routes) {\n\tvar <%= module %> = new FauxtonAPI.addon();\n\treturn <%= module %>;\n});\n' + template: grunt.file.read('./tasks/templates/base.js.underscore') }, { name: 'resources', filename: 'resources.js', - template: 'define([\n "app",\n "backbone",\n "modules/fauxton/base"\n],\n\nfunction (app, backbone, FauxtonAPI) {\n\tvar <%= module %> = {};\n\treturn <%= module %>;\n});\n' + template: grunt.file.read('./tasks/templates/resources.js.underscore') }, { name: 'routes', filename: 'routes.js', - template: 'define([\n "app",\n "api",\n "addons/<%= module.toLowerCase() %>/resources"\n],\n\nfunction(app, FauxtonAPI, <%= module %>) {\n\treturn <%= module %>;\n});\n' + template: grunt.file.read('./tasks/templates/route.js.underscore') } ] @@ -81,6 +81,7 @@ module.exports = function(grunt) { grunt.file.write(filepath + '/' + file.filename, content); }); grunt.log.writeln('Created addon ' + result.name + ' in ' + result.path); + grunt.log.writeln('\n\nAdd ' + result.name + ' to settings.json for it to be compiled and deployed'); done(); }); function onErr(err) { @@ -166,4 +167,4 @@ module.exports = function(grunt) { grunt.file.write(dest, tmpl({deps: deps})); }); -}; \ No newline at end of file +}; http://git-wip-us.apache.org/repos/asf/couchdb/blob/44232ccb/src/fauxton/tasks/templates/base.js.underscore ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/templates/base.js.underscore b/src/fauxton/tasks/templates/base.js.underscore new file mode 100644 index 0000000..cf7afa7 --- /dev/null +++ b/src/fauxton/tasks/templates/base.js.underscore @@ -0,0 +1,21 @@ +// 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", + "api", + "addons/<%= module.toLowerCase() %>/routes" +], + +function(app, FauxtonAPI, <%= module %>) { + return <%= module %>; +}); http://git-wip-us.apache.org/repos/asf/couchdb/blob/44232ccb/src/fauxton/tasks/templates/resources.js.underscore ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/templates/resources.js.underscore b/src/fauxton/tasks/templates/resources.js.underscore new file mode 100644 index 0000000..0aa37f8 --- /dev/null +++ b/src/fauxton/tasks/templates/resources.js.underscore @@ -0,0 +1,21 @@ +// 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", + "api" +], + +function (app, FauxtonAPI) { + var <%= module %> = FauxtonAPI.addon(); + return <%= module %>; +}); http://git-wip-us.apache.org/repos/asf/couchdb/blob/44232ccb/src/fauxton/tasks/templates/route.js.underscore ---------------------------------------------------------------------- diff --git a/src/fauxton/tasks/templates/route.js.underscore b/src/fauxton/tasks/templates/route.js.underscore new file mode 100644 index 0000000..9256766 --- /dev/null +++ b/src/fauxton/tasks/templates/route.js.underscore @@ -0,0 +1,21 @@ +// 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", + "api", + "addons/<%= module.toLowerCase() %>/resources" +], +function(app, FauxtonAPI, <%= module %>) { + <%= module %>.Routes = {}; + return <%= module %>; +}); http://git-wip-us.apache.org/repos/asf/couchdb/blob/44232ccb/src/fauxton/writing_addons.md ---------------------------------------------------------------------- diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md index 6d3f87b..ccd09af 100644 --- a/src/fauxton/writing_addons.md +++ b/src/fauxton/writing_addons.md @@ -32,6 +32,9 @@ an addon: Done, without errors. +Once the addon is created add the name to the settings.json file to get it compiled +and added on the next install. + ## Routes and hooks An addon can insert itself into fauxton in two ways; via a route or via a hook.
