masterview_generator 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 -0
- data/MIT-LICENSE +20 -0
- data/README +574 -0
- data/Rakefile +313 -0
- data/generators/masterview/USAGE +32 -0
- data/generators/masterview/masterview_generator.rb +277 -0
- data/generators/masterview/templates/controller.rb +50 -0
- data/generators/masterview/templates/fields_scaffold.rhtml +1 -0
- data/generators/masterview/templates/form_scaffold.rhtml +3 -0
- data/generators/masterview/templates/functional_test.rb +83 -0
- data/generators/masterview/templates/helper.rb +2 -0
- data/generators/masterview/templates/layout.rhtml +11 -0
- data/generators/masterview/templates/list_head_scaffold.rhtml +4 -0
- data/generators/masterview/templates/list_line_scaffold.rhtml +6 -0
- data/generators/masterview/templates/masterview.rhtml +182 -0
- data/generators/masterview/templates/mvpreview.js +31 -0
- data/generators/masterview/templates/show_scaffold.rhtml +3 -0
- data/generators/masterview/templates/style.css +61 -0
- metadata +71 -0
@@ -0,0 +1,83 @@
|
|
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
|
@@ -0,0 +1,6 @@
|
|
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
|
+
|
@@ -0,0 +1,182 @@
|
|
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
|
+
|
@@ -0,0 +1,31 @@
|
|
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
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
.fieldWithErrors {
|
20
|
+
padding: 2px;
|
21
|
+
background-color: red;
|
22
|
+
display: table;
|
23
|
+
}
|
24
|
+
|
25
|
+
.messages {
|
26
|
+
color: green;
|
27
|
+
}
|
28
|
+
|
29
|
+
.label {
|
30
|
+
text-align: right;
|
31
|
+
}
|
32
|
+
|
33
|
+
#ErrorExplanation {
|
34
|
+
width: 400px;
|
35
|
+
border: 2px solid #red;
|
36
|
+
padding: 7px;
|
37
|
+
padding-bottom: 12px;
|
38
|
+
margin-bottom: 20px;
|
39
|
+
background-color: #f0f0f0;
|
40
|
+
}
|
41
|
+
|
42
|
+
#ErrorExplanation h2 {
|
43
|
+
text-align: left;
|
44
|
+
font-weight: bold;
|
45
|
+
padding: 5px 5px 5px 15px;
|
46
|
+
font-size: 12px;
|
47
|
+
margin: -7px;
|
48
|
+
background-color: #c00;
|
49
|
+
color: #fff;
|
50
|
+
}
|
51
|
+
|
52
|
+
#ErrorExplanation p {
|
53
|
+
color: #333;
|
54
|
+
margin-bottom: 0;
|
55
|
+
padding: 5px;
|
56
|
+
}
|
57
|
+
|
58
|
+
#ErrorExplanation ul li {
|
59
|
+
font-size: 12px;
|
60
|
+
list-style: square;
|
61
|
+
}
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: masterview_generator
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2006-04-18 00:00:00 -05:00
|
8
|
+
summary: A (x)html friendly template engine for rails with the power of layouts, and partials. MasterView Generator for GEM
|
9
|
+
require_paths:
|
10
|
+
- generators/masterview
|
11
|
+
email: jeff.barczewski@gmail.com
|
12
|
+
homepage: http://masterview.org/
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Jeff Barczewski
|
30
|
+
files:
|
31
|
+
- generators/masterview/masterview_generator.rb
|
32
|
+
- generators/masterview/templates
|
33
|
+
- generators/masterview/USAGE
|
34
|
+
- generators/masterview/templates/controller.rb
|
35
|
+
- generators/masterview/templates/fields_scaffold.rhtml
|
36
|
+
- generators/masterview/templates/form_scaffold.rhtml
|
37
|
+
- generators/masterview/templates/functional_test.rb
|
38
|
+
- generators/masterview/templates/helper.rb
|
39
|
+
- generators/masterview/templates/layout.rhtml
|
40
|
+
- generators/masterview/templates/list_head_scaffold.rhtml
|
41
|
+
- generators/masterview/templates/list_line_scaffold.rhtml
|
42
|
+
- generators/masterview/templates/masterview.rhtml
|
43
|
+
- generators/masterview/templates/mvpreview.js
|
44
|
+
- generators/masterview/templates/show_scaffold.rhtml
|
45
|
+
- generators/masterview/templates/style.css
|
46
|
+
- CHANGELOG
|
47
|
+
- MIT-LICENSE
|
48
|
+
- Rakefile
|
49
|
+
- README
|
50
|
+
test_files: []
|
51
|
+
|
52
|
+
rdoc_options: []
|
53
|
+
|
54
|
+
extra_rdoc_files: []
|
55
|
+
|
56
|
+
executables: []
|
57
|
+
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
dependencies:
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: masterview_parser
|
65
|
+
version_requirement:
|
66
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 0.0.0
|
71
|
+
version:
|