masterview 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -1
- data/Rakefile +201 -37
- metadata +23 -85
- data/generators/masterview/USAGE +0 -32
- data/generators/masterview/masterview_generator.rb +0 -277
- data/generators/masterview/templates/controller.rb +0 -50
- data/generators/masterview/templates/fields_scaffold.rhtml +0 -1
- data/generators/masterview/templates/form_scaffold.rhtml +0 -3
- data/generators/masterview/templates/functional_test.rb +0 -83
- data/generators/masterview/templates/helper.rb +0 -2
- data/generators/masterview/templates/layout.rhtml +0 -11
- data/generators/masterview/templates/list_head_scaffold.rhtml +0 -4
- data/generators/masterview/templates/list_line_scaffold.rhtml +0 -6
- data/generators/masterview/templates/masterview.rhtml +0 -182
- data/generators/masterview/templates/mvpreview.js +0 -31
- data/generators/masterview/templates/semantic.cache +0 -84
- data/generators/masterview/templates/show_scaffold.rhtml +0 -3
- data/generators/masterview/templates/style.css +0 -61
- data/generators/masterview_gem_plugin/masterview_gem_plugin_generator.rb +0 -21
- data/generators/masterview_gem_plugin/templates/init.rb +0 -43
- data/init.rb +0 -43
- data/lib/masterview/directive_base.rb +0 -163
- data/lib/masterview/directive_helpers.rb +0 -176
- data/lib/masterview/directives/block.rb +0 -30
- data/lib/masterview/directives/content.rb +0 -10
- data/lib/masterview/directives/else.rb +0 -25
- data/lib/masterview/directives/elsif.rb +0 -26
- data/lib/masterview/directives/form.rb +0 -19
- data/lib/masterview/directives/global_inline_erb.rb +0 -39
- data/lib/masterview/directives/hidden_field.rb +0 -31
- data/lib/masterview/directives/if.rb +0 -24
- data/lib/masterview/directives/insert_generated_comment.rb +0 -30
- data/lib/masterview/directives/javascript_include.rb +0 -15
- data/lib/masterview/directives/link_to.rb +0 -17
- data/lib/masterview/directives/link_to_if.rb +0 -21
- data/lib/masterview/directives/link_to_remote.rb +0 -17
- data/lib/masterview/directives/password_field.rb +0 -33
- data/lib/masterview/directives/preview.rb +0 -10
- data/lib/masterview/directives/replace.rb +0 -18
- data/lib/masterview/directives/stylesheet_link.rb +0 -14
- data/lib/masterview/directives/submit.rb +0 -14
- data/lib/masterview/directives/testfilter.rb +0 -55
- data/lib/masterview/directives/text_area.rb +0 -34
- data/lib/masterview/directives/text_field.rb +0 -33
- data/lib/masterview/extras/rails_init.rb +0 -67
- data/lib/masterview/extras/watcher.rb +0 -30
- data/lib/masterview/masterview_version.rb +0 -9
- data/lib/masterview/parser.rb +0 -585
- data/lib/masterview/plugin_load_tracking.rb +0 -41
- data/lib/masterview/runtime_helpers.rb +0 -9
- data/lib/masterview/string_extensions.rb +0 -15
- data/lib/masterview.rb +0 -130
- data/test/block_test.rb +0 -47
- data/test/content_test.rb +0 -26
- data/test/else_test.rb +0 -31
- data/test/elsif_test.rb +0 -31
- data/test/example_test.rb +0 -11
- data/test/filter_helpers_test.rb +0 -142
- data/test/form_test.rb +0 -66
- data/test/global_inline_erb_test.rb +0 -30
- data/test/hidden_field_test.rb +0 -62
- data/test/if_test.rb +0 -23
- data/test/javascript_include_test.rb +0 -26
- data/test/link_to_if_test.rb +0 -27
- data/test/link_to_test.rb +0 -52
- data/test/parser_test.rb +0 -166
- data/test/password_field_test.rb +0 -89
- data/test/replace_test.rb +0 -27
- data/test/run_parser_test.rb +0 -27
- data/test/stylesheet_link_test.rb +0 -26
- data/test/submit_test.rb +0 -54
- data/test/template_file_watcher_test.rb +0 -50
- data/test/template_test.rb +0 -181
- data/test/test_helper.rb +0 -24
- data/test/text_area_test.rb +0 -81
- data/test/text_field_test.rb +0 -89
@@ -1,277 +0,0 @@
|
|
1
|
-
class ScaffoldingSandbox
|
2
|
-
include ActionView::Helpers::ActiveRecordHelper
|
3
|
-
|
4
|
-
attr_accessor :singular_name, :suffix, :model_instance
|
5
|
-
|
6
|
-
def sandbox_binding
|
7
|
-
binding
|
8
|
-
end
|
9
|
-
|
10
|
-
def default_input_block
|
11
|
-
Proc.new { |record, column| "<tr><td class=\"label edit_label\"><label for=\"#{record}_#{column.name}\">#{column.human_name}:</label></td> <td class=\"field edit_field\">#{input(record, column.name)}</td></tr>" }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
class ListHeadScaffoldingSandbox < ScaffoldingSandbox
|
16
|
-
def default_input_block
|
17
|
-
Proc.new { |record, column| "<th>#{column.human_name}</th>" }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class ListLineScaffoldingSandbox < ScaffoldingSandbox
|
22
|
-
def default_input_block
|
23
|
-
Proc.new { |record, column| "<td class=\"field list_field\" mv:content=\"h #{record}.send(:#{column.name})\">#{record} #{column.human_name}</td>" }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
class ShowScaffoldingSandbox < ScaffoldingSandbox
|
28
|
-
def default_input_block
|
29
|
-
Proc.new { |record, column| "<tr><td class=\"label show_label\"><label>#{column.human_name}:</label></td> <td class=\"field show_field\"><span class=\"static\" mv:content=\"h @#{record}.send(:#{column.name})\">#{record} #{column.human_name}</span></td></tr>" }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
class ActionView::Helpers::InstanceTag
|
35
|
-
def to_input_field_tag(field_type, options={})
|
36
|
-
field_meth = "#{field_type}_field"
|
37
|
-
case field_meth
|
38
|
-
when 'text_field'
|
39
|
-
%Q[<input type="text" name="#{@object_name}_#{@method_name}" mv:text_field="'#{@object_name}', '#{@method_name}'#{options.empty? ? '' : ', '+options.inspect}"/>]
|
40
|
-
when 'hidden_field'
|
41
|
-
%Q[<input type="hidden" name="#{@object_name}_#{@method_name}" mv:hidden_field="'#{@object_name}', '#{@method_name}'#{options.empty? ? '' : ', '+options.inspect}"/>]
|
42
|
-
when 'password_field'
|
43
|
-
%Q[<input type="password" name="#{@object_name}_#{@method_name}" mv:password_field="'#{@object_name}', '#{@method_name}'#{options.empty? ? '' : ', '+options.inspect}"/>]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def to_text_area_tag(options = {})
|
48
|
-
%Q[<textarea name="#{@object_name}_#{@method_name}" rows="5" mv:text_area="'#{@object_name}', '#{@method_name}'#{options.empty? ? '' : ', '+options.inspect}"></textarea>]
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_date_select_tag(options = {})
|
52
|
-
%Q[<span mv:replace="date_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect}">todo render date select</span>]
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_datetime_select_tag(options = {})
|
56
|
-
%Q[<span mv:replace="datetime_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect}">todo render date select</span>]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
module Rails
|
61
|
-
module Generator
|
62
|
-
module Commands
|
63
|
-
class Create < Base
|
64
|
-
def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
|
65
|
-
options = template_options.dup
|
66
|
-
options[:assigns] ||= {}
|
67
|
-
multi_assign_options.each do |k,v|
|
68
|
-
options[:assigns][k] = render_template_part(v)
|
69
|
-
end
|
70
|
-
template(relative_source, relative_destination, options)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
class Destroy < RewindBase
|
75
|
-
def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
class List < Base
|
80
|
-
def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
|
81
|
-
str = ""
|
82
|
-
multi_assign_options.each do |k,v|
|
83
|
-
str << v[:insert] << ' '
|
84
|
-
end
|
85
|
-
logger.template "#{str} inside #{relative_destination}"
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class Update < Create
|
90
|
-
def multi_include_template(relative_source, relative_destination, template_options = {}, multi_assign_options = {})
|
91
|
-
begin
|
92
|
-
dest_file = destination_path(relative_destination)
|
93
|
-
source_to_update = File.readlines(dest_file).join
|
94
|
-
rescue Errno::ENOENT
|
95
|
-
logger.missing relative_destination
|
96
|
-
return
|
97
|
-
end
|
98
|
-
multi_assign_options.each do |k,v|
|
99
|
-
template_options = v
|
100
|
-
logger.refreshing "#{template_options[:insert].gsub(/\.rhtml/,'')} inside #{relative_destination}"
|
101
|
-
begin_mark = Regexp.quote(template_part_mark(template_options[:begin_mark], template_options[:mark_id]))
|
102
|
-
end_mark = Regexp.quote(template_part_mark(template_options[:end_mark], template_options[:mark_id]))
|
103
|
-
# Refreshing inner part of the template with freshly rendered part.
|
104
|
-
rendered_part = render_template_part(template_options)
|
105
|
-
source_to_update.gsub!(/#{begin_mark}.*?#{end_mark}/m, rendered_part)
|
106
|
-
end
|
107
|
-
File.open(dest_file, 'w') { |file| file.write(source_to_update) }
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
class MasterviewGenerator < Rails::Generator::NamedBase
|
115
|
-
attr_reader :controller_name,
|
116
|
-
:controller_class_path,
|
117
|
-
:controller_file_path,
|
118
|
-
:controller_class_nesting,
|
119
|
-
:controller_class_nesting_depth,
|
120
|
-
:controller_class_name,
|
121
|
-
:controller_singular_name,
|
122
|
-
:controller_plural_name
|
123
|
-
alias_method :controller_file_name, :controller_singular_name
|
124
|
-
alias_method :controller_view_dir_name, :controller_singular_name
|
125
|
-
alias_method :controller_masterview_name, :controller_singular_name
|
126
|
-
alias_method :controller_table_name, :controller_plural_name
|
127
|
-
|
128
|
-
def initialize(runtime_args, runtime_options = {})
|
129
|
-
super
|
130
|
-
@controller_name = args.shift || @name
|
131
|
-
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
132
|
-
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
133
|
-
if @controller_class_nesting.empty?
|
134
|
-
@controller_class_name = @controller_class_name_without_nesting
|
135
|
-
else
|
136
|
-
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def manifest
|
141
|
-
record do |m|
|
142
|
-
# Depend on model generator but skip if the model exists.
|
143
|
-
m.dependency 'model', [singular_name], :collision => :skip, :skip_migration => true
|
144
|
-
|
145
|
-
# Check for class naming collisions.
|
146
|
-
m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
|
147
|
-
|
148
|
-
# Controller, helper, views, and test directories.
|
149
|
-
m.directory File.join('app/controllers', controller_class_path)
|
150
|
-
m.directory File.join('app/helpers', controller_class_path)
|
151
|
-
m.directory File.join('app/views', controller_class_path, controller_view_dir_name)
|
152
|
-
m.directory 'app/views/masterview'
|
153
|
-
m.directory File.join('test/functional', controller_class_path)
|
154
|
-
|
155
|
-
# Controller class, functional test, helper, and views.
|
156
|
-
m.template 'controller.rb',
|
157
|
-
File.join('app/controllers',
|
158
|
-
controller_class_path,
|
159
|
-
"#{controller_file_name}_controller.rb")
|
160
|
-
|
161
|
-
m.template 'functional_test.rb',
|
162
|
-
File.join('test/functional',
|
163
|
-
controller_class_path,
|
164
|
-
"#{controller_file_name}_controller_test.rb")
|
165
|
-
|
166
|
-
m.template 'helper.rb',
|
167
|
-
File.join('app/helpers',
|
168
|
-
controller_class_path,
|
169
|
-
"#{controller_file_name}_helper.rb")
|
170
|
-
|
171
|
-
# MasterView
|
172
|
-
m.template 'mvpreview.js',
|
173
|
-
File.join('public/javascripts',
|
174
|
-
"mvpreview.js")
|
175
|
-
|
176
|
-
m.multi_include_template "masterview.rhtml","app/views/masterview/#{controller_masterview_name}.html", {},
|
177
|
-
{
|
178
|
-
'form_inclusion' =>
|
179
|
-
{ :insert => 'form_scaffold.rhtml',
|
180
|
-
:sandbox => lambda { create_multi_sandbox('ScaffoldingSandbox') },
|
181
|
-
:begin_mark => 'form',
|
182
|
-
:end_mark => 'eoform',
|
183
|
-
:mark_id => singular_name
|
184
|
-
},
|
185
|
-
'list_head_inclusion' =>
|
186
|
-
{ :insert => 'fields_scaffold.rhtml',
|
187
|
-
:sandbox => lambda { create_multi_sandbox('ListHeadScaffoldingSandbox') },
|
188
|
-
:begin_mark => 'listhead',
|
189
|
-
:end_mark => 'eolisthead',
|
190
|
-
:mark_id => singular_name
|
191
|
-
},
|
192
|
-
'list_line_inclusion' =>
|
193
|
-
{ :insert => 'list_line_scaffold.rhtml',
|
194
|
-
:sandbox => lambda { create_multi_sandbox('ListLineScaffoldingSandbox') },
|
195
|
-
:begin_mark => 'listline',
|
196
|
-
:end_mark => 'eolistline',
|
197
|
-
:mark_id => singular_name
|
198
|
-
},
|
199
|
-
'show_inclusion' =>
|
200
|
-
{ :insert => 'show_scaffold.rhtml',
|
201
|
-
:sandbox => lambda { create_multi_sandbox('ShowScaffoldingSandbox') },
|
202
|
-
:begin_mark => 'show',
|
203
|
-
:end_mark => 'eoshow',
|
204
|
-
:mark_id => singular_name
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
m.template 'style.css', 'public/stylesheets/scaffold.css'
|
209
|
-
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
protected
|
214
|
-
# Override with your own usage banner.
|
215
|
-
def banner
|
216
|
-
"Usage: #{$0} masterview ModelName [ControllerName] [action, ...]"
|
217
|
-
end
|
218
|
-
|
219
|
-
def scaffold_views
|
220
|
-
%w(list show new edit destroy)
|
221
|
-
end
|
222
|
-
|
223
|
-
def scaffold_actions
|
224
|
-
scaffold_views + %w(index)
|
225
|
-
end
|
226
|
-
|
227
|
-
def unscaffolded_actions
|
228
|
-
args - scaffold_actions
|
229
|
-
end
|
230
|
-
|
231
|
-
def suffix
|
232
|
-
"_#{singular_name}" if options[:suffix]
|
233
|
-
end
|
234
|
-
|
235
|
-
def model_name
|
236
|
-
class_name.demodulize
|
237
|
-
end
|
238
|
-
|
239
|
-
def create_sandbox
|
240
|
-
sandbox = ScaffoldingSandbox.new
|
241
|
-
sandbox.singular_name = singular_name
|
242
|
-
begin
|
243
|
-
sandbox.model_instance = model_instance
|
244
|
-
sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
|
245
|
-
rescue ActiveRecord::StatementInvalid => e
|
246
|
-
logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
|
247
|
-
raise SystemExit
|
248
|
-
end
|
249
|
-
sandbox.suffix = suffix
|
250
|
-
sandbox
|
251
|
-
end
|
252
|
-
|
253
|
-
def create_multi_sandbox( sandbox_class_name )
|
254
|
-
sandbox = eval("#{sandbox_class_name}.new")
|
255
|
-
sandbox.singular_name = singular_name
|
256
|
-
begin
|
257
|
-
sandbox.model_instance = model_instance
|
258
|
-
sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
|
259
|
-
rescue ActiveRecord::StatementInvalid => e
|
260
|
-
logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
|
261
|
-
raise SystemExit
|
262
|
-
end
|
263
|
-
sandbox.suffix = suffix
|
264
|
-
sandbox
|
265
|
-
end
|
266
|
-
|
267
|
-
def model_instance
|
268
|
-
base = class_nesting.split('::').inject(Object) do |base, nested|
|
269
|
-
break base.const_get(nested) if base.const_defined?(nested)
|
270
|
-
base.const_set(nested, Module.new)
|
271
|
-
end
|
272
|
-
unless base.const_defined?(@class_name_without_nesting)
|
273
|
-
base.const_set(@class_name_without_nesting, Class.new(ActiveRecord::Base))
|
274
|
-
end
|
275
|
-
class_name.constantize.new
|
276
|
-
end
|
277
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
|
3
|
-
<% unless suffix -%>
|
4
|
-
def index
|
5
|
-
list
|
6
|
-
render_action 'list'
|
7
|
-
end
|
8
|
-
<% end -%>
|
9
|
-
|
10
|
-
<% for action in unscaffolded_actions -%>
|
11
|
-
def <%= action %><%= suffix %>
|
12
|
-
end
|
13
|
-
|
14
|
-
<% end -%>
|
15
|
-
def list<%= suffix %>
|
16
|
-
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
|
17
|
-
end
|
18
|
-
|
19
|
-
def show<%= suffix %>
|
20
|
-
@<%= singular_name %> = <%= model_name %>.find(@params['id'])
|
21
|
-
end
|
22
|
-
|
23
|
-
def new<%= suffix %>
|
24
|
-
@<%= singular_name %> = <%= model_name %>.new(@params["<%= singular_name %>"])
|
25
|
-
|
26
|
-
if @request.post? and @<%= singular_name %>.save
|
27
|
-
flash[:notice] = '<%= model_name %> was successfully created.'
|
28
|
-
redirect_to :action => 'list<%= suffix %>'
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def edit<%= suffix %>
|
33
|
-
@<%= singular_name %> = <%= model_name %>.find(@params['id'])
|
34
|
-
@<%= singular_name %>.attributes = @params["<%= singular_name %>"]
|
35
|
-
if @request.post? and @<%= singular_name %>.save
|
36
|
-
flash[:notice] = '<%= model_name %> was successfully updated.'
|
37
|
-
redirect_to :action => 'list<%= suffix %>'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def destroy<%= suffix %>
|
42
|
-
@<%= singular_name %> = <%= model_name %>.find(@params['id'])
|
43
|
-
if @request.post?
|
44
|
-
@<%= singular_name %>.destroy
|
45
|
-
flash[:notice] = '<%= model_name %> was successfully deleted.'
|
46
|
-
redirect_to :action => 'list<%= suffix %>'
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
<%= all_input_tags(@model_instance, @singular_name, {}) %>
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '<%= "/.." * controller_class_nesting_depth %>/../test_helper'
|
2
|
-
require '<%= controller_file_path %>_controller'
|
3
|
-
|
4
|
-
# Re-raise errors caught by the controller.
|
5
|
-
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
|
6
|
-
|
7
|
-
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
8
|
-
fixtures :<%= table_name %>
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@controller = <%= controller_class_name %>Controller.new
|
12
|
-
@request = ActionController::TestRequest.new
|
13
|
-
@response = ActionController::TestResponse.new
|
14
|
-
end
|
15
|
-
|
16
|
-
<% for action in unscaffolded_actions -%>
|
17
|
-
def test_<%= action %>
|
18
|
-
get :<%= action %>
|
19
|
-
assert_rendered_file '<%= action %>'
|
20
|
-
end
|
21
|
-
|
22
|
-
<% end -%>
|
23
|
-
<% unless suffix -%>
|
24
|
-
def test_index
|
25
|
-
get :index
|
26
|
-
assert_rendered_file 'list'
|
27
|
-
end
|
28
|
-
|
29
|
-
<% end -%>
|
30
|
-
def test_list<%= suffix %>
|
31
|
-
get :list<%= suffix %>
|
32
|
-
assert_rendered_file 'list<%= suffix %>'
|
33
|
-
assert_template_has '<%= plural_name %>'
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_show<%= suffix %>
|
37
|
-
get :show<%= suffix %>, 'id' => 1
|
38
|
-
assert_rendered_file 'show'
|
39
|
-
assert_template_has '<%= singular_name %>'
|
40
|
-
assert_valid_record '<%= singular_name %>'
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_new<%= suffix %>
|
44
|
-
get :new<%= suffix %>
|
45
|
-
assert_rendered_file 'new<%= suffix %>'
|
46
|
-
assert_template_has '<%= singular_name %>'
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_create
|
50
|
-
num_<%= plural_name %> = <%= model_name %>.find_all.size
|
51
|
-
|
52
|
-
post :new<%= suffix %>, '<%= singular_name %>' => { }
|
53
|
-
assert_redirected_to :action => 'show<%= suffix %>'
|
54
|
-
|
55
|
-
assert_equal num_<%= plural_name %> + 1, <%= model_name %>.find_all.size
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_edit<%= suffix %>
|
59
|
-
get :edit<%= suffix %>, 'id' => 1
|
60
|
-
assert_rendered_file 'edit<%= suffix %>'
|
61
|
-
assert_template_has '<%= singular_name %>'
|
62
|
-
assert_valid_record '<%= singular_name %>'
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_update<%= suffix %>
|
66
|
-
post :edit<%= suffix %>, 'id' => 1
|
67
|
-
assert_redirected_to :action => 'show<%= suffix %>', :id => 1
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_destroy<%= suffix %>
|
71
|
-
assert_not_nil <%= model_name %>.find(1)
|
72
|
-
|
73
|
-
get :destroy, 'id' => 1
|
74
|
-
assert_success
|
75
|
-
|
76
|
-
post :destroy, 'id' => 1
|
77
|
-
assert_redirected_to :action => 'list<%= suffix %>'
|
78
|
-
|
79
|
-
assert_raise(ActiveRecord::RecordNotFound) {
|
80
|
-
<%= singular_name %> = <%= model_name %>.find(1)
|
81
|
-
}
|
82
|
-
end
|
83
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
|
2
|
-
<%= all_input_tags(@model_instance, @singular_name, {}) %>
|
3
|
-
<td class="operation"><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_show');" mv:link_to=":action => 'show<%= suffix %>', :id => <%= singular_name %>">Show</a></td>
|
4
|
-
<td class="operation"><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_edit');" mv:link_to=":action => 'edit<%= suffix %>', :id => <%= singular_name %>">Edit</a></td>
|
5
|
-
<td class="operation"><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_destroy');" mv:link_to=":action => 'destroy', :id => <%= singular_name %>">Destroy</a></td>
|
6
|
-
|
@@ -1,182 +0,0 @@
|
|
1
|
-
<html mv:generate="layouts/<%= singular_name %>.rhtml">
|
2
|
-
<head>
|
3
|
-
<title><%= controller_class_name %>: {{{= controller.action_name }}}</title>
|
4
|
-
<link rel="stylesheet" type="text/css" href="../../../public/stylesheets/scaffold.css" mv:stylesheet_link="scaffold"/>
|
5
|
-
<script type="text/javascript" src="../../../public/javascripts/prototype.js" mv:javascript_include=":defaults"></script>
|
6
|
-
<script type="text/javascript" src="../../../public/javascripts/effects.js" mv:replace=""></script>
|
7
|
-
<script type="text/javascript" src="../../../public/javascripts/dragdrop.js" mv:replace=""></script>
|
8
|
-
<script type="text/javascript" src="../../../public/javascripts/controls.js" mv:replace=""></script>
|
9
|
-
<script type="text/javascript" src="../../../public/javascripts/application.js" mv:replace=""></script>
|
10
|
-
</head>
|
11
|
-
<body>
|
12
|
-
|
13
|
-
<div class="messages" mv:if="@flash[:notice]" mv:content="@flash[:notice]">
|
14
|
-
messages
|
15
|
-
</div>
|
16
|
-
|
17
|
-
|
18
|
-
<div id="<%= singular_name %>_content" mv:replace="@content_for_layout">
|
19
|
-
<div id="<%= singular_name %>_new" mv:generate="<%= singular_name %>/new.rhtml" mv:preview="showOne">
|
20
|
-
<div class="<%= singular_name %>_new sidebar">
|
21
|
-
<h1>Tasks:</h1>
|
22
|
-
<ul>
|
23
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
24
|
-
</ul>
|
25
|
-
</div>
|
26
|
-
|
27
|
-
<div class="<%= singular_name %>_new content">
|
28
|
-
<h1><%= plural_name.capitalize %></h1>
|
29
|
-
|
30
|
-
<form mv:form=":action => 'new'">
|
31
|
-
|
32
|
-
<div class="form">
|
33
|
-
<h2>Creating <%= singular_name %></h2>
|
34
|
-
|
35
|
-
<div id="<%= singular_name %>_form" mv:gen_render=":partial => '<%= singular_name %>/form'">
|
36
|
-
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
37
|
-
error messages
|
38
|
-
</div>
|
39
|
-
<br/>
|
40
|
-
<%= form_inclusion %>
|
41
|
-
</div>
|
42
|
-
|
43
|
-
</div>
|
44
|
-
|
45
|
-
<br/>
|
46
|
-
<div class="<%= singular_name %>_new operations">
|
47
|
-
<input type="submit" value="OK" class="primary" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
48
|
-
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
49
|
-
</div>
|
50
|
-
|
51
|
-
</form>
|
52
|
-
</div>
|
53
|
-
</div>
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
<div id="<%= singular_name %>_edit" mv:generate="<%= singular_name %>/edit.rhtml" mv:preview="showOne">
|
59
|
-
<div class="<%= singular_name %>_edit sidebar">
|
60
|
-
<h1>Tasks:</h1>
|
61
|
-
<ul>
|
62
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
63
|
-
</ul>
|
64
|
-
</div>
|
65
|
-
|
66
|
-
<div class="<%= singular_name %>_edit content">
|
67
|
-
<h1><%= plural_name.capitalize %></h1>
|
68
|
-
|
69
|
-
<form mv:form=":action => 'edit', :id => @<%=singular_name%>.id">
|
70
|
-
|
71
|
-
<div class="form">
|
72
|
-
<h2>Editing <%= singular_name %></h2>
|
73
|
-
<div mv:replace="render :partial => 'form'" mv:preview="copyOf:<%= singular_name %>_form">
|
74
|
-
copyOf:<%= singular_name %>_form
|
75
|
-
</div>
|
76
|
-
</div>
|
77
|
-
|
78
|
-
<br/>
|
79
|
-
<div class="<%= singular_name %>_edit operations">
|
80
|
-
<input type="submit" value="OK" class="primary" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
81
|
-
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" /> </div>
|
82
|
-
|
83
|
-
</form>
|
84
|
-
</div>
|
85
|
-
</div>
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
<div id="<%= singular_name %>_list" mv:generate="<%= singular_name %>/list.rhtml" mv:preview="showOne">
|
90
|
-
<div class="<%= singular_name %>_list sidebar">
|
91
|
-
<h1>Tasks:</h1>
|
92
|
-
<ul>
|
93
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_new');" mv:link_to=":action => 'new<%= suffix %>'">Create new <%= singular_name %></a></li>
|
94
|
-
</ul>
|
95
|
-
</div>
|
96
|
-
|
97
|
-
<div class="<%= singular_name %>_list content">
|
98
|
-
<h1><%= plural_name.capitalize %></h1>
|
99
|
-
|
100
|
-
<div class="list">
|
101
|
-
<table border="1" class="<%= singular_name %>_list_table" cellpadding="5">
|
102
|
-
<tr>
|
103
|
-
<%= list_head_inclusion %>
|
104
|
-
</tr>
|
105
|
-
<tr mv:gen_render=":partial => '<%= singular_name %>/<%= singular_name %>', :collection => @<%= plural_name %>">
|
106
|
-
<%= list_line_inclusion %>
|
107
|
-
</tr>
|
108
|
-
</table>
|
109
|
-
|
110
|
-
<a mv:if="@<%= singular_name %>_pages.current.previous" mv:link_to=":page => @<%= singular_name %>_pages.current.previous">Previous page</a>
|
111
|
-
<a mv:if="@<%= singular_name %>_pages.current.next" mv:link_to=":page => @<%= singular_name %>_pages.current.next">Next page</a>
|
112
|
-
|
113
|
-
</div>
|
114
|
-
</div>
|
115
|
-
</div>
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<div id="<%= singular_name %>_show" mv:generate="<%= singular_name %>/show.rhtml" mv:preview="showOne">
|
120
|
-
<div class="<%= singular_name %>_show sidebar">
|
121
|
-
<h1>Tasks:</h1>
|
122
|
-
<ul>
|
123
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
124
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_edit');" mv:link_to=":action => 'edit<%= suffix %>', :id => @<%= singular_name %>.id">Edit this <%= singular_name %></a></li>
|
125
|
-
</ul>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
<div class="<%= singular_name %>_show content">
|
129
|
-
<h1><%= plural_name.capitalize %></h1>
|
130
|
-
|
131
|
-
<div id="<%= singular_name %>_show_partial" class="form" mv:gen_render=":partial => '<%= singular_name %>/show'">
|
132
|
-
<%= show_inclusion %>
|
133
|
-
</div>
|
134
|
-
|
135
|
-
</div>
|
136
|
-
</div>
|
137
|
-
|
138
|
-
<div id="<%= singular_name %>_destroy" mv:generate="<%= singular_name %>/destroy.rhtml" mv:preview="showOne">
|
139
|
-
<div class="<%= singular_name %>_destroy sidebar">
|
140
|
-
<h1>Tasks:</h1>
|
141
|
-
<ul>
|
142
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_list');" mv:link_to=":action => 'list<%= suffix %>'">Back to overview</a></li>
|
143
|
-
<li><a href="javascript:mvpreview.showOneSection('<%= singular_name %>_show');" mv:link_to=":action => 'show<%= suffix %>', :id => @<%= singular_name %>.id">Show this <%= singular_name %></a></li>
|
144
|
-
</ul>
|
145
|
-
</div>
|
146
|
-
|
147
|
-
<div class="<%= singular_name %>_destroy content">
|
148
|
-
<h1><%= plural_name.capitalize %></h1>
|
149
|
-
|
150
|
-
<div class="error_messages" mv:replace="error_messages_for :<%= singular_name %>">
|
151
|
-
error messages
|
152
|
-
</div>
|
153
|
-
|
154
|
-
<div class="messages">Are you sure you want to delete this item?</div>
|
155
|
-
<br/>
|
156
|
-
<form mv:form=":action => 'destroy', :id => @<%= singular_name %>.id">
|
157
|
-
<div mv:replace="render :partial => 'show'" mv:preview="copyOf:<%= singular_name %>_show_partial">
|
158
|
-
copyOf:<%= singular_name %>_show_partial
|
159
|
-
</div>
|
160
|
-
|
161
|
-
<br/>
|
162
|
-
<div class="<%= singular_name %>_edit operations">
|
163
|
-
<input type="submit" value="Delete" mv:submit="" onclick="javascript:mvpreview.showOneSection('<%= singular_name %>_list');return false;"/>
|
164
|
-
<input type="button" value="Cancel" style="width: auto;" onclick="window.location.href = '{{{= url_for :action => %q{list} }}}';" />
|
165
|
-
</div>
|
166
|
-
</form>
|
167
|
-
</div>
|
168
|
-
</div>
|
169
|
-
</div>
|
170
|
-
|
171
|
-
<script type="text/javascript" mv:replace="" src="../../../public/javascripts/mvpreview.js"></script>
|
172
|
-
<script type="text/javascript" mv:replace="">
|
173
|
-
mvpreview.copySections();
|
174
|
-
mvpreview.showOneSection('<%= singular_name %>_list');
|
175
|
-
</script>
|
176
|
-
|
177
|
-
</body>
|
178
|
-
</html>
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
@@ -1,31 +0,0 @@
|
|
1
|
-
var mvpreview = new Object();
|
2
|
-
|
3
|
-
mvpreview.preview_divs = $A( document.getElementsByTagName('div') ).findAll( function(elem){ return (elem.getAttribute('mv:preview') != null); });
|
4
|
-
|
5
|
-
mvpreview.copySections = function(){
|
6
|
-
var mv_sections_needing_copy = this.preview_divs.findAll( function(elem){
|
7
|
-
var prevAttr = elem.getAttribute('mv:preview');
|
8
|
-
return (prevAttr.substring(0,7) == 'copyOf:');
|
9
|
-
});
|
10
|
-
|
11
|
-
//copy sections
|
12
|
-
mv_sections_needing_copy.each( function(e){
|
13
|
-
var id = e.getAttribute('mv:preview').split(':')[1];
|
14
|
-
e.innerHTML = $(id).innerHTML;
|
15
|
-
} );
|
16
|
-
};
|
17
|
-
|
18
|
-
mvpreview.sections = mvpreview.preview_divs.findAll( function(elem){ return (elem.getAttribute('mv:preview') == 'showOne'); });
|
19
|
-
|
20
|
-
mvpreview.hideSections = function(){
|
21
|
-
this.sections.each( function(elem){ window.Element.hide(elem); } );
|
22
|
-
}
|
23
|
-
|
24
|
-
mvpreview.findSectionToShow = function(id){
|
25
|
-
return this.sections.find( function(e){ return (e.id == id); } );
|
26
|
-
}
|
27
|
-
|
28
|
-
mvpreview.showOneSection = function(id){
|
29
|
-
this.hideSections();
|
30
|
-
window.Element.show( this.findSectionToShow(id) );
|
31
|
-
}
|