rid 0.5.2 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/LICENSE +1 -1
  2. data/README +14 -0
  3. data/Rakefile +18 -33
  4. data/VERSION +1 -0
  5. data/bin/rid +3 -6
  6. data/lib/rid/app.rb +49 -0
  7. data/lib/rid/attachments.rb +6 -2
  8. data/lib/rid/commands.rb +61 -39
  9. data/lib/rid/core_ext/hash.rb +1 -1
  10. data/lib/rid/database.rb +69 -0
  11. data/lib/rid/document.rb +99 -0
  12. data/lib/rid.rb +14 -41
  13. data/rid.gemspec +49 -78
  14. data/spec/mock_app/_database +1 -0
  15. data/spec/rid/app_spec.rb +59 -0
  16. data/spec/rid/attachments_spec.rb +2 -2
  17. data/spec/rid/commands_spec.rb +14 -0
  18. data/spec/rid/database_spec.rb +25 -0
  19. data/spec/rid/document_spec.rb +36 -0
  20. data/spec/spec_helper.rb +6 -0
  21. metadata +127 -86
  22. data/.gitmodules +0 -3
  23. data/README.rdoc +0 -92
  24. data/lib/rid/actions/base.rb +0 -15
  25. data/lib/rid/actions/pull.rb +0 -28
  26. data/lib/rid/actions/push.rb +0 -53
  27. data/lib/rid/actions/routes.rb +0 -44
  28. data/lib/rid/commands/destroy.rb +0 -9
  29. data/lib/rid/commands/generate.rb +0 -9
  30. data/lib/rid/commands/pull.rb +0 -4
  31. data/lib/rid/commands/push.rb +0 -4
  32. data/lib/rid/commands/routes.rb +0 -4
  33. data/lib/rid/design_document.rb +0 -149
  34. data/lib/rid/generators/application/USAGE +0 -10
  35. data/lib/rid/generators/application/application_generator.rb +0 -56
  36. data/lib/rid/generators/application/templates/README +0 -1
  37. data/lib/rid/generators/application/templates/_attachments/index.html +0 -11
  38. data/lib/rid/generators/application/templates/_attachments/stylesheets/application.css +0 -25
  39. data/lib/rid/generators/application/templates/_id +0 -1
  40. data/lib/rid/generators/application/templates/gitignore +0 -0
  41. data/lib/rid/generators/application/templates/lib/mustache.js +0 -305
  42. data/lib/rid/generators/application/templates/lib/path.js +0 -5
  43. data/lib/rid/generators/application/templates/lib/templates/layout.mustache +0 -14
  44. data/lib/rid/generators/application/templates/ridrc +0 -1
  45. data/lib/rid/generators/application/templates/validate_doc_update.js +0 -3
  46. data/lib/rid/generators/base.rb +0 -66
  47. data/lib/rid/generators/list/USAGE +0 -8
  48. data/lib/rid/generators/list/list_generator.rb +0 -10
  49. data/lib/rid/generators/list/templates/index.mustache +0 -23
  50. data/lib/rid/generators/list/templates/list.js +0 -34
  51. data/lib/rid/generators/named_base.rb +0 -22
  52. data/lib/rid/generators/scaffold/USAGE +0 -10
  53. data/lib/rid/generators/scaffold/scaffold_generator.rb +0 -32
  54. data/lib/rid/generators/show/USAGE +0 -8
  55. data/lib/rid/generators/show/show_generator.rb +0 -13
  56. data/lib/rid/generators/show/templates/delete.mustache +0 -20
  57. data/lib/rid/generators/show/templates/deleted.mustache +0 -3
  58. data/lib/rid/generators/show/templates/form.mustache +0 -22
  59. data/lib/rid/generators/show/templates/show.js +0 -48
  60. data/lib/rid/generators/show/templates/show.mustache +0 -13
  61. data/lib/rid/generators/update/USAGE +0 -8
  62. data/lib/rid/generators/update/templates/update.js +0 -48
  63. data/lib/rid/generators/update/update_generator.rb +0 -9
  64. data/lib/rid/generators/validation/USAGE +0 -9
  65. data/lib/rid/generators/validation/templates/validate_doc_update.js +0 -3
  66. data/lib/rid/generators/validation/validation_generator.rb +0 -34
  67. data/lib/rid/generators/view/USAGE +0 -8
  68. data/lib/rid/generators/view/templates/map.js +0 -5
  69. data/lib/rid/generators/view/view_generator.rb +0 -17
  70. data/lib/rid/generators.rb +0 -63
  71. data/lib/rid/makros.rb +0 -114
  72. data/lib/rid/version.rb +0 -3
  73. data/spec/rid/design_document_spec.rb +0 -220
  74. data/spec/rid/makros_spec.rb +0 -94
  75. data/spec/rid_spec.rb +0 -7
@@ -1,305 +0,0 @@
1
- /*
2
- Shameless port of http://github.com/defunkt/mustache
3
- by Jan Lehnardt <jan@apache.org>,
4
- Alexander Lang <alex@upstream-berlin.com>,
5
- Sebastian Cohnen <sebastian.cohnen@googlemail.com>
6
-
7
- Thanks @defunkt for the awesome code.
8
-
9
- See http://github.com/defunkt/mustache for more info.
10
- */
11
-
12
- var Mustache = function() {
13
- var Renderer = function() {};
14
-
15
- Renderer.prototype = {
16
- otag: "{{",
17
- ctag: "}}",
18
- pragmas: {},
19
- buffer: [],
20
- pragmas_parsed: false,
21
- pragmas_implemented: {
22
- "IMPLICIT-ITERATOR": true
23
- },
24
-
25
- render: function(template, context, partials, in_recursion) {
26
- // fail fast
27
- if(template.indexOf(this.otag) == -1) {
28
- if(in_recursion) {
29
- return template;
30
- } else {
31
- this.send(template);
32
- return;
33
- }
34
- }
35
-
36
- if(!in_recursion) {
37
- this.buffer = [];
38
- }
39
-
40
- if(!this.pragmas_parsed) {
41
- template = this.render_pragmas(template);
42
- }
43
- var html = this.render_section(template, context, partials);
44
- if(in_recursion) {
45
- return this.render_tags(html, context, partials, in_recursion);
46
- }
47
-
48
- this.render_tags(html, context, partials, in_recursion);
49
- },
50
-
51
- /*
52
- Sends parsed lines
53
- */
54
- send: function(line) {
55
- if(line != "") {
56
- this.buffer.push(line);
57
- }
58
- },
59
-
60
- /*
61
- Looks for %PRAGMAS
62
- */
63
- render_pragmas: function(template) {
64
- this.pragmas_parsed = true;
65
- // no pragmas
66
- if(template.indexOf(this.otag + "%") == -1) {
67
- return template;
68
- }
69
-
70
- var that = this;
71
- var regex = new RegExp(this.otag + "%([\\w_-]+) ?([\\w]+=[\\w]+)?"
72
- + this.ctag);
73
- return template.replace(regex, function(match, pragma, options) {
74
- if(!that.pragmas_implemented[pragma]) {
75
- throw({message: "This implementation of mustache doesn't understand the '"
76
- + pragma + "' pragma"});
77
- }
78
- that.pragmas[pragma] = {};
79
- if(options) {
80
- var opts = options.split("=");
81
- that.pragmas[pragma][opts[0]] = opts[1];
82
- }
83
- return "";
84
- // ignore unknown pragmas silently
85
- });
86
- },
87
-
88
- /*
89
- Tries to find a partial in the global scope and render it
90
- */
91
- render_partial: function(name, context, partials) {
92
- if(typeof(context[name]) != "object") {
93
- throw({message: "subcontext for '" + name + "' is not an object"});
94
- }
95
- if(!partials || !partials[name]) {
96
- throw({message: "unknown_partial '" + name + "'"});
97
- }
98
- return this.render(partials[name], context[name], partials, true);
99
- },
100
-
101
- /*
102
- Renders boolean and enumerable sections
103
- */
104
- render_section: function(template, context, partials) {
105
- if(template.indexOf(this.otag + "#") == -1) {
106
- return template;
107
- }
108
- var that = this;
109
- // CSW - Added "+?" so it finds the tighest bound, not the widest
110
- var regex = new RegExp(this.otag + "\\#(.+)" + this.ctag +
111
- "\\s*([\\s\\S]+?)" + this.otag + "\\/\\1" + this.ctag + "\\s*", "mg");
112
-
113
- // for each {{#foo}}{{/foo}} section do...
114
- return template.replace(regex, function(match, name, content) {
115
- var value = that.find(name, context);
116
- if(that.is_array(value)) { // Enumerable, Let's loop!
117
- return that.map(value, function(row) {
118
- return that.render(content, that.merge(context,
119
- that.create_context(row)), partials, true);
120
- }).join("");
121
- } else if(value) { // boolean section
122
- return that.render(content, context, partials, true);
123
- } else {
124
- return "";
125
- }
126
- });
127
- },
128
-
129
- /*
130
- Replace {{foo}} and friends with values from our view
131
- */
132
- render_tags: function(template, context, partials, in_recursion) {
133
- // tit for tat
134
- var that = this;
135
-
136
- var new_regex = function() {
137
- return new RegExp(that.otag + "(=|!|>|\\{|%)?([^\/#]+?)\\1?" +
138
- that.ctag + "+", "g");
139
- };
140
-
141
- var regex = new_regex();
142
- var lines = template.split("\n");
143
- for (var i=0; i < lines.length; i++) {
144
- lines[i] = lines[i].replace(regex, function(match, operator, name) {
145
- switch(operator) {
146
- case "!": // ignore comments
147
- return match;
148
- case "=": // set new delimiters, rebuild the replace regexp
149
- that.set_delimiters(name);
150
- regex = new_regex();
151
- return "";
152
- case ">": // render partial
153
- return that.render_partial(name, context, partials);
154
- case "{": // the triple mustache is unescaped
155
- return that.find(name, context);
156
- default: // escape the value
157
- return that.escape(that.find(name, context));
158
- }
159
- }, this);
160
- if(!in_recursion) {
161
- this.send(lines[i]);
162
- }
163
- }
164
-
165
- if(in_recursion) {
166
- return lines.join("\n");
167
- }
168
- },
169
-
170
- set_delimiters: function(delimiters) {
171
- var dels = delimiters.split(" ");
172
- this.otag = this.escape_regex(dels[0]);
173
- this.ctag = this.escape_regex(dels[1]);
174
- },
175
-
176
- escape_regex: function(text) {
177
- // thank you Simon Willison
178
- if(!arguments.callee.sRE) {
179
- var specials = [
180
- '/', '.', '*', '+', '?', '|',
181
- '(', ')', '[', ']', '{', '}', '\\'
182
- ];
183
- arguments.callee.sRE = new RegExp(
184
- '(\\' + specials.join('|\\') + ')', 'g'
185
- );
186
- }
187
- return text.replace(arguments.callee.sRE, '\\$1');
188
- },
189
-
190
- /*
191
- find `name` in current `context`. That is find me a value
192
- from the view object
193
- */
194
- find: function(name, context) {
195
- name = this.trim(name);
196
- if(typeof context[name] === "function") {
197
- return context[name].apply(context);
198
- }
199
- if(context[name] !== undefined) {
200
- return context[name];
201
- }
202
- // silently ignore unkown variables
203
- return "";
204
- },
205
-
206
- // Utility methods
207
-
208
- /*
209
- Does away with nasty characters
210
- */
211
- escape: function(s) {
212
- return ((s == null) ? "" : s).toString().replace(/[&"<>\\]/g, function(s) {
213
- switch(s) {
214
- case "&": return "&amp;";
215
- case "\\": return "\\\\";;
216
- case '"': return '\"';;
217
- case "<": return "&lt;";
218
- case ">": return "&gt;";
219
- default: return s;
220
- }
221
- });
222
- },
223
-
224
- /*
225
- Merges all properties of object `b` into object `a`.
226
- `b.property` overwrites a.property`
227
- */
228
- merge: function(a, b) {
229
- var _new = {};
230
- for(var name in a) {
231
- if(a.hasOwnProperty(name)) {
232
- _new[name] = a[name];
233
- }
234
- };
235
- for(var name in b) {
236
- if(b.hasOwnProperty(name)) {
237
- _new[name] = b[name];
238
- }
239
- };
240
- return _new;
241
- },
242
-
243
- // by @langalex, support for arrays of strings
244
- create_context: function(_context) {
245
- if(this.is_object(_context)) {
246
- return _context;
247
- } else if(this.pragmas["IMPLICIT-ITERATOR"]) {
248
- var iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator || ".";
249
- var ctx = {};
250
- ctx[iterator] = _context
251
- return ctx;
252
- }
253
- },
254
-
255
- is_object: function(a) {
256
- return a && typeof a == "object";
257
- },
258
-
259
- is_array: function(a) {
260
- return Object.prototype.toString.call(a) === '[object Array]';
261
- },
262
-
263
- /*
264
- Gets rid of leading and trailing whitespace
265
- */
266
- trim: function(s) {
267
- return s.replace(/^\s*|\s*$/g, "");
268
- },
269
-
270
- /*
271
- Why, why, why? Because IE. Cry, cry cry.
272
- */
273
- map: function(array, fn) {
274
- if (typeof array.map == "function") {
275
- return array.map(fn)
276
- } else {
277
- var r = [];
278
- var l = array.length;
279
- for(i=0;i<l;i++) {
280
- r.push(fn(array[i]));
281
- }
282
- return r;
283
- }
284
- }
285
- };
286
-
287
- return({
288
- name: "mustache.js",
289
- version: "0.2.3-dev",
290
-
291
- /*
292
- Turns a template and view into HTML
293
- */
294
- to_html: function(template, view, partials, send_fun) {
295
- var renderer = new Renderer();
296
- if(send_fun) {
297
- renderer.send = send_fun;
298
- }
299
- renderer.render(template, view, partials);
300
- if(!send_fun) {
301
- return renderer.buffer.join("\n");
302
- }
303
- }
304
- });
305
- }();
@@ -1,5 +0,0 @@
1
- // returns the path of the design document
2
- function path() {
3
- var p = req.path, parts = ['', p[0], p[1] , p[2]];
4
- return parts.join('/');
5
- };
@@ -1,14 +0,0 @@
1
- <!DOCTYPE HTML>
2
- <html>
3
- <head>
4
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
5
- <title><%= app_title %>: {{title}}</title>
6
- <link rel="stylesheet" href="{{path}}/stylesheets/application.css" type="text/css" media="screen" charset="utf-8">
7
- </head>
8
- <body>
9
- <h1><%= app_title %></h1>
10
- <h2>{{title}}</h2>
11
- <p class="notice">{{notice}}</p>
12
- {{>body}}
13
- </body>
14
- </html>
@@ -1 +0,0 @@
1
- database: "http://127.0.0.1:5984/<%= app_name %>"
@@ -1,3 +0,0 @@
1
- function (newDoc, oldDoc, userCtx) {
2
- // validation code goes here
3
- }
@@ -1,66 +0,0 @@
1
- require 'thor/group'
2
- require 'active_support/inflector'
3
-
4
- module Rid
5
- module Generators
6
- class Error < Thor::Error
7
- end
8
-
9
- class Base < Thor::Group
10
- include Thor::Actions
11
-
12
- add_runtime_options!
13
-
14
- class_option :skip_git, :type => :boolean, :aliases => "-G", :default => false,
15
- :desc => "Skip Git ignores and keeps"
16
-
17
- # Automatically sets the source root based on the class name.
18
- #
19
- def self.source_root
20
- @_rid_source_root ||= begin
21
- if generator_name
22
- File.expand_path(File.join("../generators", generator_name, 'templates'), File.dirname(__FILE__))
23
- end
24
- end
25
- end
26
-
27
- # Tries to get the description from a USAGE file one folder above the source
28
- # root otherwise uses a default description.
29
- #
30
- def self.desc(description=nil)
31
- return super if description
32
- usage = File.expand_path(File.join(source_root, "..", "USAGE"))
33
-
34
- @desc ||= if File.exist?(usage)
35
- File.read(usage)
36
- else
37
- "Description:\n Create files for #{generator_name} generator."
38
- end
39
- end
40
-
41
- def self.info
42
- desc.split(/\n+/)[1].strip
43
- end
44
-
45
- protected
46
-
47
- # Use Rid default banner.
48
- #
49
- def self.banner
50
- "rid generate|destroy #{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
51
- end
52
-
53
- # Removes the namespaces and get the generator name. For example,
54
- # Rid::Generators::MetalGenerator will return "metal" as generator name.
55
- #
56
- def self.generator_name
57
- @generator_name ||= begin
58
- if generator = name.to_s.split('::').last
59
- generator.sub!(/Generator$/, '')
60
- generator.underscore
61
- end
62
- end
63
- end
64
- end
65
- end
66
- end
@@ -1,8 +0,0 @@
1
- Description:
2
- The 'list' generator creates a scaffold list function
3
- for the name and attributes you specify
4
-
5
- Example:
6
- rid generate list post title body
7
-
8
- This generates a skeletal posts list function
@@ -1,10 +0,0 @@
1
- require 'rid/generators/named_base'
2
-
3
- module Rid::Generators
4
- class ListGenerator < NamedBase
5
- def create_templates
6
- template "list.js", "lists/#{pluralized_model_name}.js"
7
- template "index.mustache", "lib/templates/#{pluralized_model_name}/index.mustache"
8
- end
9
- end
10
- end
@@ -1,23 +0,0 @@
1
- <p><a href="{{path}}/_show/<%= model_name %>/">New <%= model_name.humanize %></a></p>
2
- <table>
3
- <tr>
4
- <th>ID</th>
5
- <% attributes.each do |attribute| -%>
6
- <th><%= attribute.humanize %></th>
7
- <% end -%>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
- {{#rows}}
13
- <tr>
14
- <td>{{id}}</td>
15
- <% attributes.each do |attribute| -%>
16
- <td>{{<%= attribute %>}}</td>
17
- <% end -%>
18
- <td><a href="{{path}}/_show/<%= model_name %>/{{id}}">Show</a></td>
19
- <td><a href="{{path}}/_show/<%= model_name %>/{{id}}?edit">Edit</a></td>
20
- <td><a href="{{path}}/_show/<%= model_name %>/{{id}}?delete">Delete</a></td>
21
- </tr>
22
- {{/rows}}
23
- </table>
@@ -1,34 +0,0 @@
1
- function(head, req) {
2
- // !code path.js
3
- // !code mustache.js
4
- // !json templates/layout.mustache
5
- // !json templates/<%= pluralized_model_name %>/index.mustache
6
-
7
- provides("html", function() {
8
- var view = {
9
- path: path(),
10
- title: "Listing <%= pluralized_model_name.humanize %>",
11
- body: {
12
- path: path(),
13
- rows: function() {
14
- var rows = [];
15
- var row;
16
- while (row = getRow()) {
17
- rows.push({
18
- <% attributes.each do |attribute| -%>
19
- <%= attribute %>: row.value['<%= attribute %>'],
20
- <% end -%>
21
- id: row.id
22
- });
23
- }
24
-
25
- return rows;
26
- }
27
- }
28
- };
29
-
30
- Mustache.to_html(templates.layout, view, { body: templates.<%= pluralized_model_name %>.index }, function(line) {
31
- send(line + "\n");
32
- });
33
- });
34
- }
@@ -1,22 +0,0 @@
1
- require 'thor/group'
2
- require 'active_support/inflector'
3
-
4
- module Rid
5
- module Generators
6
- class NamedBase < Base
7
- argument :name, :type => :string
8
- argument :attributes, :type => :array, :default => []
9
-
10
- protected
11
-
12
- # force underscored and singularized model name
13
- def model_name
14
- @model_name ||= name.underscore.singularize
15
- end
16
-
17
- def pluralized_model_name
18
- model_name.pluralize
19
- end
20
- end
21
- end
22
- end
@@ -1,10 +0,0 @@
1
- Description:
2
- The 'scaffold' generator creates a scaffold skelet
3
- with a default show function, list function
4
- of the name and attributes you specify
5
-
6
- Example:
7
- rid generate scaffold post title body
8
-
9
- This generates a skeletal model post with a posts list view,
10
- post show function and validation.
@@ -1,32 +0,0 @@
1
- require 'rid/generators/named_base'
2
-
3
- module Rid::Generators
4
- class ScaffoldGenerator < NamedBase
5
- def create_view_function
6
- Rid::Generators.invoke :view, *invokation_options
7
- end
8
-
9
- def inject_validations
10
- Rid::Generators.invoke :validation, *invokation_options
11
- end
12
-
13
- def create_list_function
14
- Rid::Generators.invoke :list, *invokation_options
15
- end
16
-
17
- def create_show_function
18
- Rid::Generators.invoke :show, *invokation_options
19
- end
20
-
21
- def create_update_function
22
- Rid::Generators.invoke :update, *invokation_options
23
- end
24
-
25
- protected
26
-
27
- # TODO: add default options, like --help, --force etc
28
- def invokation_options
29
- [[name] + attributes, { :behavior => behavior }]
30
- end
31
- end
32
- end
@@ -1,8 +0,0 @@
1
- Description:
2
- The 'show' generator creates a scaffold show function
3
- for the name and attributes you specify
4
-
5
- Example:
6
- rid generate show post title body
7
-
8
- This generates a skeletal post show function with title and body
@@ -1,13 +0,0 @@
1
- require 'rid/generators/named_base'
2
-
3
- module Rid::Generators
4
- class ShowGenerator < NamedBase
5
- def create_show_function
6
- template "show.js", "shows/#{model_name}.js"
7
- template "show.mustache", "lib/templates/#{pluralized_model_name}/show.mustache"
8
- template "form.mustache", "lib/templates/#{pluralized_model_name}/form.mustache"
9
- template "delete.mustache", "lib/templates/#{pluralized_model_name}/delete.mustache"
10
- template "deleted.mustache", "lib/templates/#{pluralized_model_name}/deleted.mustache"
11
- end
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- <p>
2
- <a href="{{path}}/_list/<%= pluralized_model_name %>/<%= pluralized_model_name %>">List <%= pluralized_model_name.humanize %></a> |
3
- <a href="{{path}}/_show/<%= model_name %>/{{id}}">Show <%= model_name.humanize %></a> |
4
- <a href="{{path}}/_show/<%= model_name %>/{{id}}?edit">Edit <%= model_name.humanize %></a>
5
- </p>
6
- <h3>Are you sure you want to delete that <%= model_name.humanize %>?</h3>
7
- <dl>
8
- <dt>ID</dt>
9
- <dd>{{id}}</dd>
10
- <% attributes.each do |attribute| -%>
11
- <dt><%= attribute.humanize %></dt>
12
- <dd>{{<%= attribute %>}}</dd>
13
- <% end -%>
14
- </dl>
15
- <form action="{{path}}/_update/<%= pluralized_model_name %>" method="post" accept-charset="utf-8">
16
- <input type="hidden" name="rev" value="{{rev}}" id="rev" />
17
- <input type="hidden" name="id" value="{{id}}" id="id" />
18
- <input type="hidden" name="delete" value="true" id="delete" />
19
- <p><input type="submit" value="Yes, delete <%= model_name.humanize %>"></p>
20
- </form>
@@ -1,3 +0,0 @@
1
- <p>
2
- <a href="{{path}}/_list/<%= pluralized_model_name %>/<%= pluralized_model_name %>">Back to the list of <%= pluralized_model_name.humanize %></a>
3
- </p>
@@ -1,22 +0,0 @@
1
- <p>
2
- <a href="{{path}}/_list/<%= pluralized_model_name %>/<%= pluralized_model_name %>">List <%= pluralized_model_name.humanize %></a>
3
- {{#rev}}
4
- | <a href="{{path}}/_show/<%= model_name %>/{{id}}">Show <%= model_name.humanize %></a>
5
- {{/rev}}
6
- </p>
7
- <form action="{{path}}/_update/<%= pluralized_model_name %>" method="post" accept-charset="utf-8">
8
- {{#rev}}
9
- <input type="hidden" name="rev" value="{{rev}}" id="rev" />
10
- {{/rev}}
11
- <p>
12
- <label for="id">ID</label><br/>
13
- <input type="text" name="id" value="{{id}}" id="id" />
14
- </p>
15
- <% attributes.each do |attribute| -%>
16
- <p>
17
- <label for="<%= attribute %>"><%= attribute.humanize %></label><br/>
18
- <input type="text" name="<%= attribute %>" value="{{<%= attribute %>}}" id="<%= attribute %>" />
19
- </p>
20
- <% end -%>
21
- <p><input type="submit" value="Save <%= model_name.humanize %>"></p>
22
- </form>
@@ -1,48 +0,0 @@
1
- function(doc, req) {
2
- // !code path.js
3
- // !code mustache.js
4
- // !json templates/layout.mustache
5
- // !json templates/<%= pluralized_model_name %>/show.mustache
6
- // !json templates/<%= pluralized_model_name %>/form.mustache
7
- // !json templates/<%= pluralized_model_name %>/delete.mustache
8
-
9
- provides("html", function() {
10
- var view = {
11
- path: path(),
12
- body: {
13
- path: path()
14
- }
15
- };
16
- var partial;
17
-
18
- if(doc) {
19
- <% attributes.each do |attribute| -%>
20
- view.body['<%= attribute %>'] = doc['<%= attribute %>'];
21
- <% end -%>
22
- view.body.id = doc._id;
23
-
24
- if (req.query.edit != undefined) {
25
- // edit
26
- view.title = "Editing <%= model_name.humanize %>";
27
- partial = "form";
28
- } else {
29
- view.body.rev = doc._rev;
30
- if (req.query['delete'] != undefined) {
31
- // delete
32
- view.title = "Deleting <%= model_name.humanize %>";
33
- partial = "delete";
34
- } else {
35
- // show
36
- view.title = "Showing <%= model_name.humanize %>";
37
- partial = "show";
38
- }
39
- }
40
- } else {
41
- // new
42
- view.title = "New <%= model_name.humanize %>";
43
- partial = "form";
44
- }
45
-
46
- return Mustache.to_html(templates.layout, view, { body: templates.<%= pluralized_model_name %>[partial] });
47
- });
48
- }