diff options
author | Garren Smith <garren.smith@gmail.com> | 2013-03-09 10:49:01 +0200 |
---|---|---|
committer | Garren Smith <garren.smith@gmail.com> | 2013-03-09 10:49:01 +0200 |
commit | 44232ccb1b3f35d467bae04e91eff655cb589ab7 (patch) | |
tree | 8a2fc55b939a198dc89cd6ce6529a4700d0e1ebc | |
parent | c09e3cc76f0e19ef1c2da624b57d67ec09a52b16 (diff) | |
download | couchdb-44232ccb1b3f35d467bae04e91eff655cb589ab7.tar.gz |
move addon templates into own file and better addon file defaults
-rw-r--r-- | src/fauxton/tasks/fauxton.js | 9 | ||||
-rw-r--r-- | src/fauxton/tasks/templates/base.js.underscore | 21 | ||||
-rw-r--r-- | src/fauxton/tasks/templates/resources.js.underscore | 21 | ||||
-rw-r--r-- | src/fauxton/tasks/templates/route.js.underscore | 21 | ||||
-rw-r--r-- | src/fauxton/writing_addons.md | 3 |
5 files changed, 71 insertions, 4 deletions
diff --git a/src/fauxton/tasks/fauxton.js b/src/fauxton/tasks/fauxton.js index 78b50f377..ee365a20b 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 +}; diff --git a/src/fauxton/tasks/templates/base.js.underscore b/src/fauxton/tasks/templates/base.js.underscore new file mode 100644 index 000000000..cf7afa7ee --- /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 %>; +}); diff --git a/src/fauxton/tasks/templates/resources.js.underscore b/src/fauxton/tasks/templates/resources.js.underscore new file mode 100644 index 000000000..0aa37f8bc --- /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 %>; +}); diff --git a/src/fauxton/tasks/templates/route.js.underscore b/src/fauxton/tasks/templates/route.js.underscore new file mode 100644 index 000000000..9256766d3 --- /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 %>; +}); diff --git a/src/fauxton/writing_addons.md b/src/fauxton/writing_addons.md index 6d3f87bc0..ccd09af3c 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. |