scaffy 0.5.0
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/LICENSE +20 -0
- data/README.textile +46 -0
- data/lib/generators/scaffy/USAGE +8 -0
- data/lib/generators/scaffy/scaffy_generator.rb +190 -0
- data/lib/generators/scaffy/templates/assets/images/alertbad_icon.gif +0 -0
- data/lib/generators/scaffy/templates/assets/images/alertgood_icon.gif +0 -0
- data/lib/generators/scaffy/templates/assets/images/glossy-error-icon.jpg +0 -0
- data/lib/generators/scaffy/templates/assets/stylesheets/scaffy.css +427 -0
- data/lib/generators/scaffy/templates/controller.rb +52 -0
- data/lib/generators/scaffy/templates/helper.rb +2 -0
- data/lib/generators/scaffy/templates/migration.rb +14 -0
- data/lib/generators/scaffy/templates/model.rb +2 -0
- data/lib/generators/scaffy/templates/test/factory_girl/factory.rb +5 -0
- data/lib/generators/scaffy/templates/test/shoulda/controller_test.rb +54 -0
- data/lib/generators/scaffy/templates/test/shoulda/model_test.rb +9 -0
- data/lib/generators/scaffy/templates/views/haml/_form.html.haml +16 -0
- data/lib/generators/scaffy/templates/views/haml/index.html.haml +24 -0
- data/lib/generators/scaffy/templates/views/haml/layout.html.haml +12 -0
- data/lib/generators/scaffy/templates/views/haml/new.html.haml +4 -0
- data/lib/generators/scaffy/templates/views/haml/show.html.haml +13 -0
- data/lib/scaffy/version.rb +3 -0
- metadata +87 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Alastair Brunton
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
!http://scoop.simplyexcited.co.uk/wp-content/uploads/2009/01/scaffy.jpg!
|
2
|
+
|
3
|
+
h2. Scaffy Generator
|
4
|
+
|
5
|
+
An opinionated cut down scaffold generator. This uses haml for templates and includes tests in shoulda with factory_girl as the object factory. Nothing fancy, nothing special. Just a really fast way to use scaffolding in an extendable manner.
|
6
|
+
|
7
|
+
!http://scoop.simplyexcited.co.uk/wp-content/uploads/2009/01/scaff.jpg (scaff)!
|
8
|
+
|
9
|
+
h2. Install
|
10
|
+
|
11
|
+
<pre lang="bash">rails plugin install git://github.com/pyrat/scaffy.git</pre>
|
12
|
+
|
13
|
+
h3. Usage
|
14
|
+
|
15
|
+
Simple scaffold
|
16
|
+
|
17
|
+
<pre>
|
18
|
+
rails g scaffy post title:string content:text
|
19
|
+
</pre>
|
20
|
+
|
21
|
+
Scaffold with added layout and flash messages.
|
22
|
+
|
23
|
+
<pre>
|
24
|
+
rails g scaffy post title:string content:text --layout=true
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
Scaffold with namespace
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
rails g car make:string model:string year:integer --namespace=admin
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
Then to install the dependent gems:
|
34
|
+
|
35
|
+
<pre>
|
36
|
+
bundle install
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
h3. Dependencies
|
40
|
+
|
41
|
+
h3. Credits
|
42
|
+
|
43
|
+
flutie
|
44
|
+
|
45
|
+
|
46
|
+
|
@@ -0,0 +1,190 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
class ScaffyGenerator < Rails::Generators::NamedBase
|
4
|
+
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
9
|
+
|
10
|
+
# make it a class option
|
11
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
12
|
+
class_option :namespace, :type => :string, :default => '', :desc => "Specify a namespace"
|
13
|
+
class_option :layout, :type => :string, :desc => "Generate a layout and styles"
|
14
|
+
|
15
|
+
|
16
|
+
def render_controller
|
17
|
+
template "controller.rb", "app/controllers" + namespace_directory + "/#{controller_filename}.rb"
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_views
|
21
|
+
%w(_form index new show).each do |t|
|
22
|
+
template "views/haml/#{t}.html.haml", "app/views" + namespace_directory + "/#{object_plural}/#{t}.html.haml"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def render_helper
|
27
|
+
template "helper.rb", "app/helpers/#{object_plural}_helper.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_routes
|
31
|
+
if namespace.present?
|
32
|
+
# add namespace route
|
33
|
+
route "namespace :#{namespace.downcase} do \n resources :#{object_plural} \nend"
|
34
|
+
else
|
35
|
+
# add standard route
|
36
|
+
route "resources :#{object_plural}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def render_migration
|
41
|
+
migration_template "migration.rb", "db/migrate/create_#{object_plural}.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_model
|
45
|
+
template "model.rb", "app/models/#{object_singular}.rb"
|
46
|
+
end
|
47
|
+
|
48
|
+
def render_tests
|
49
|
+
# need to create factories directory if it doesnt exist?
|
50
|
+
template "test/factory_girl/factory.rb", "test/factories/#{object_singular}.rb"
|
51
|
+
template "test/shoulda/model_test.rb", "test/unit/#{object_singular}_test.rb"
|
52
|
+
template "test/shoulda/controller_test.rb", "test/functional" + namespace_directory + "/#{object_plural}_controller_test.rb"
|
53
|
+
end
|
54
|
+
|
55
|
+
def render_layout
|
56
|
+
if options[:layout]
|
57
|
+
copy_file "views/haml/layout.html.haml", "app/views/layouts/application.html.haml"
|
58
|
+
copy_file "assets/stylesheets/scaffy.css", "public/stylesheets/scaffy.css"
|
59
|
+
copy_file "assets/images/alertbad_icon.gif", "public/images/scaffy/alertbad_icon.gif"
|
60
|
+
copy_file "assets/images/alertgood_icon.gif", "public/images/scaffy/alertgood_icon.gif"
|
61
|
+
copy_file "assets/images/glossy-error-icon.jpg", "public/images/scaffy/glossy-error-icon.gif"
|
62
|
+
|
63
|
+
inject_into_module "app/helpers/application_helper.rb", ApplicationHelper do
|
64
|
+
%(
|
65
|
+
# Returns a div for each key passed if there's a flash
|
66
|
+
# with that key
|
67
|
+
def flash_div *keys
|
68
|
+
divs = keys.select { |k| flash[k] }.collect do |k|
|
69
|
+
content_tag :div, flash[k], :class => "flash " + k.to_s
|
70
|
+
end
|
71
|
+
divs.join.html_safe
|
72
|
+
end
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def remove_index
|
80
|
+
remove_file "public/index.html"
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_gems
|
84
|
+
gem 'haml'
|
85
|
+
gem 'shoulda', :env => :test
|
86
|
+
gem 'factory_girl_rails', :env => :test
|
87
|
+
end
|
88
|
+
|
89
|
+
protected
|
90
|
+
|
91
|
+
class << self
|
92
|
+
|
93
|
+
def next_migration_number(dirname)
|
94
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def namespace
|
101
|
+
options[:namespace]
|
102
|
+
end
|
103
|
+
|
104
|
+
def controller_name
|
105
|
+
namespace_prefix + name.capitalize.pluralize
|
106
|
+
end
|
107
|
+
|
108
|
+
def namespace_prefix
|
109
|
+
unless options[:namespace].blank?
|
110
|
+
namespace.capitalize + "::"
|
111
|
+
else
|
112
|
+
''
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def namespace_directory
|
117
|
+
unless options[:namespace].blank?
|
118
|
+
"/" + namespace.downcase
|
119
|
+
else
|
120
|
+
''
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def object_singular
|
125
|
+
name.downcase
|
126
|
+
end
|
127
|
+
|
128
|
+
def object_plural
|
129
|
+
name.downcase.pluralize
|
130
|
+
end
|
131
|
+
|
132
|
+
def class_name
|
133
|
+
name.capitalize
|
134
|
+
end
|
135
|
+
|
136
|
+
def index_url
|
137
|
+
namespace_url_prefix + object_plural + "_url"
|
138
|
+
end
|
139
|
+
|
140
|
+
def namespace_url_prefix
|
141
|
+
if namespace.present?
|
142
|
+
namespace.downcase + "_"
|
143
|
+
else
|
144
|
+
''
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def controller_filename
|
149
|
+
object_plural + '_controller'
|
150
|
+
end
|
151
|
+
|
152
|
+
def show_url(options = {})
|
153
|
+
val = options[:instance] ? "@" : ''
|
154
|
+
if namespace.present?
|
155
|
+
"[:#{namespace.downcase}, #{val}#{object_singular}]"
|
156
|
+
else
|
157
|
+
val + object_singular
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
def new_url
|
163
|
+
if namespace.present?
|
164
|
+
"polymorphic_url([:#{namespace.downcase}, #{class_name}.new], :action => :new)"
|
165
|
+
else
|
166
|
+
"polymorphic_url(#{class_name}.new, :action => :new)"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def edit_url(options = {})
|
171
|
+
val = options[:instance] ? "@" : ''
|
172
|
+
if namespace.present?
|
173
|
+
"polymorphic_url([:#{namespace.downcase}, #{val}#{object_singular}], :action => :edit)"
|
174
|
+
else
|
175
|
+
"polymorphic_url(#{val}#{object_singular}, :action => :edit)"
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def human_name
|
180
|
+
name.capitalize.pluralize
|
181
|
+
end
|
182
|
+
|
183
|
+
def inject_into_module(path, mod, *args, &block)
|
184
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
185
|
+
config.merge!(:after => /module #{mod}\n|module #{mod} .*\n/)
|
186
|
+
inject_into_file(path, *(args << config), &block)
|
187
|
+
end
|
188
|
+
|
189
|
+
|
190
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,427 @@
|
|
1
|
+
/* This is a default stylesheet provided for scaffy scaffolding. Aim is to make it look OK initially. */
|
2
|
+
|
3
|
+
/* http://meyerweb.com/eric/tools/css/reset/ */
|
4
|
+
/* v1.0 | 20080212 */
|
5
|
+
|
6
|
+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p,
|
7
|
+
blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em,
|
8
|
+
font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var,
|
9
|
+
b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table,
|
10
|
+
caption, tbody, tfoot, thead, tr, th, td {
|
11
|
+
margin: 0;
|
12
|
+
padding: 0;
|
13
|
+
border: 0;
|
14
|
+
outline: 0;
|
15
|
+
font-size: 100%;
|
16
|
+
vertical-align: baseline;
|
17
|
+
background: transparent;
|
18
|
+
}
|
19
|
+
body {
|
20
|
+
line-height: 1;
|
21
|
+
}
|
22
|
+
ol, ul {
|
23
|
+
list-style: none;
|
24
|
+
}
|
25
|
+
blockquote, q {
|
26
|
+
quotes: none;
|
27
|
+
}
|
28
|
+
blockquote:before, blockquote:after,
|
29
|
+
q:before, q:after {
|
30
|
+
content: '';
|
31
|
+
content: none;
|
32
|
+
}
|
33
|
+
|
34
|
+
/* remember to define focus styles! */
|
35
|
+
:focus {
|
36
|
+
outline: 0;
|
37
|
+
}
|
38
|
+
|
39
|
+
/* remember to highlight inserts somehow! */
|
40
|
+
ins {
|
41
|
+
text-decoration: none;
|
42
|
+
}
|
43
|
+
del {
|
44
|
+
text-decoration: line-through;
|
45
|
+
}
|
46
|
+
|
47
|
+
/* tables still need 'cellspacing="0"' in the markup */
|
48
|
+
table {
|
49
|
+
border-collapse: collapse;
|
50
|
+
border-spacing: 0;
|
51
|
+
}
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
/*-------------------------------------------------
|
56
|
+
FLASHES
|
57
|
+
-------------------------------------------------*/
|
58
|
+
|
59
|
+
.flash {
|
60
|
+
text-align: left;
|
61
|
+
border: 1px solid #ccc;
|
62
|
+
padding: 5px 5px 5px 30px;
|
63
|
+
font-size: 14px;
|
64
|
+
margin: 12px auto;
|
65
|
+
margin-right: 7px;
|
66
|
+
margin-left : 7px;
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
.flash.message, .flash.notice {
|
71
|
+
border-color: #9c9;
|
72
|
+
color: #060;
|
73
|
+
background: url(../images/scaffy/alertgood_icon.gif) #E2F9E3 left no-repeat;
|
74
|
+
}
|
75
|
+
|
76
|
+
.flash.warning {
|
77
|
+
border-color: #c99;
|
78
|
+
color: #fff;
|
79
|
+
background: url(../images/scaffy/alertbad_icon.gif) #c00 left no-repeat;
|
80
|
+
}
|
81
|
+
|
82
|
+
/* General styles */
|
83
|
+
|
84
|
+
body {
|
85
|
+
color: #222;
|
86
|
+
font-size: 13px;
|
87
|
+
font-family: arial, "Helvetica Neue", "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
|
88
|
+
}
|
89
|
+
|
90
|
+
h1, h2, h3, h4, h5, h6 {
|
91
|
+
color: #111;
|
92
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
93
|
+
}
|
94
|
+
|
95
|
+
/* Use a .box to create a padded box inside a column. */
|
96
|
+
.box {
|
97
|
+
padding: 1.5em;
|
98
|
+
margin-bottom: 1.5em;
|
99
|
+
background: #eee;
|
100
|
+
}
|
101
|
+
|
102
|
+
/* Use this to create a horizontal ruler across a column. */
|
103
|
+
hr {
|
104
|
+
background: #ddd;
|
105
|
+
color: #ddd;
|
106
|
+
clear: both;
|
107
|
+
float: none;
|
108
|
+
width: 100%;
|
109
|
+
height: 1px;
|
110
|
+
margin: 0 0 1.4em;
|
111
|
+
border: none;
|
112
|
+
}
|
113
|
+
hr.space {
|
114
|
+
background: #fff;
|
115
|
+
color: #fff;
|
116
|
+
}
|
117
|
+
|
118
|
+
/* Clearfix hack I love you */
|
119
|
+
.clearfix:after {
|
120
|
+
content:".";
|
121
|
+
display:block;
|
122
|
+
height:0;
|
123
|
+
clear:both;
|
124
|
+
visibility:hidden;
|
125
|
+
}
|
126
|
+
|
127
|
+
.clearfix {display:inline-block;}
|
128
|
+
/* Hide from IE Mac \*/
|
129
|
+
.clearfix {display:block;}
|
130
|
+
/* End hide from IE Mac */
|
131
|
+
|
132
|
+
/* Forms */
|
133
|
+
|
134
|
+
input[type="submit"]::-moz-focus-inner {
|
135
|
+
border: none;
|
136
|
+
} /*removes dotted outline on submit buttons when clicking in firefox */
|
137
|
+
|
138
|
+
form ol {
|
139
|
+
list-style: none;
|
140
|
+
margin: 0 0 1em 0;
|
141
|
+
}
|
142
|
+
form ol ol { margin-left: 0; }
|
143
|
+
form ol li { margin: 0 0 1em 0; list-style-position: outside; }
|
144
|
+
form ol ol li { margin: 0 0 .25em 0; list-style-position: outside; } /*list-style-position fixes IE label margin bug*/
|
145
|
+
|
146
|
+
form ol li.error input { background: #FBE3E4; }
|
147
|
+
p.inline-errors { color: #D12F19; }
|
148
|
+
form ol li.file {
|
149
|
+
background: #e1e1e1;
|
150
|
+
border: 1px solid #c8c8c8;
|
151
|
+
padding: 10px;
|
152
|
+
}
|
153
|
+
|
154
|
+
form abbr { border-bottom: 0; }
|
155
|
+
|
156
|
+
label { display: block; }
|
157
|
+
.required label { font-weight: bold; }
|
158
|
+
.checkbox_field label, .radio_field label { font-weight: normal; }
|
159
|
+
|
160
|
+
a.cancel { color: #7d0d0d; }
|
161
|
+
.inline-hints {
|
162
|
+
font-size: 0.8em;
|
163
|
+
color: #666;
|
164
|
+
margin-bottom: 0.25em;
|
165
|
+
}
|
166
|
+
|
167
|
+
/* Fieldsets */
|
168
|
+
fieldset {
|
169
|
+
margin: 0 0 1.5em 0;
|
170
|
+
background: #f1f1f1;
|
171
|
+
padding: 1.5em 1.5em 1em 1.5em;
|
172
|
+
border: 1px solid #e3e3e3;
|
173
|
+
}
|
174
|
+
fieldset fieldset, fieldset fieldset fieldset {
|
175
|
+
padding: 0;
|
176
|
+
border: 0;
|
177
|
+
}
|
178
|
+
legend { font-weight: bold; }
|
179
|
+
fieldset.buttons {
|
180
|
+
background: inherit;
|
181
|
+
border: 0;
|
182
|
+
padding: 0;
|
183
|
+
}
|
184
|
+
fieldset.buttons li { display: inline; }
|
185
|
+
.radio fieldset {
|
186
|
+
padding: 0;
|
187
|
+
margin: 0;
|
188
|
+
}
|
189
|
+
|
190
|
+
/* Text fields */
|
191
|
+
input[type="text"], input[type="password"] {
|
192
|
+
width: 300px;
|
193
|
+
padding: 3px 2px;
|
194
|
+
font-size: inherit;
|
195
|
+
}
|
196
|
+
input[disabled='disabled'] {
|
197
|
+
background-color: #fcfcfc;
|
198
|
+
cursor:default;
|
199
|
+
}
|
200
|
+
input[type="checkbox"] {
|
201
|
+
margin: 0 3px 0 0;
|
202
|
+
vertical-align: middle;
|
203
|
+
position: relative;
|
204
|
+
top: -2px;
|
205
|
+
}
|
206
|
+
input[type="radio"] {
|
207
|
+
margin: 0 3px 0 0;
|
208
|
+
vertical-align: middle;
|
209
|
+
position: relative;
|
210
|
+
top: -2px;
|
211
|
+
}
|
212
|
+
.check_boxes label {
|
213
|
+
vertical-align: middle;
|
214
|
+
padding: 0;
|
215
|
+
display: inline;
|
216
|
+
}
|
217
|
+
.radio label { padding: 0; }
|
218
|
+
|
219
|
+
/* Textareas */
|
220
|
+
textarea {
|
221
|
+
width: 440px;
|
222
|
+
height: 200px;
|
223
|
+
margin: 0 0.5em 0.5em 0;
|
224
|
+
padding: 5px;
|
225
|
+
font-size: inherit;
|
226
|
+
}
|
227
|
+
|
228
|
+
/* Select fields */
|
229
|
+
fieldset .select select {
|
230
|
+
width:200px;
|
231
|
+
font-size: 0.9em;
|
232
|
+
}
|
233
|
+
optgroup { margin: 0 0 .5em 0; }
|
234
|
+
|
235
|
+
/* Date & Time */
|
236
|
+
form ol li.date ol li, form ol li.time ol li {
|
237
|
+
display: inline;
|
238
|
+
}
|
239
|
+
form ol li.datetime ol li {
|
240
|
+
display: inline-block;
|
241
|
+
}
|
242
|
+
form ol li.datetime select, form ol li.date select, form ol li.time select {
|
243
|
+
display: inline;
|
244
|
+
width: auto;
|
245
|
+
}
|
246
|
+
form ol li.date label, form ol li.time label {
|
247
|
+
display: none;
|
248
|
+
}
|
249
|
+
|
250
|
+
/* Lists */
|
251
|
+
|
252
|
+
ul, ol {
|
253
|
+
margin-bottom: 1.5em;
|
254
|
+
list-style-position: inside;
|
255
|
+
}
|
256
|
+
ul { list-style-type: disc; }
|
257
|
+
ol { list-style-type: decimal; }
|
258
|
+
|
259
|
+
dl {
|
260
|
+
margin-bottom: 1.5em;
|
261
|
+
line-height: 1.4;
|
262
|
+
}
|
263
|
+
dl dt {
|
264
|
+
font-weight: bold;
|
265
|
+
margin-top: 0.5em;
|
266
|
+
}
|
267
|
+
dl dd { margin-bottom: 0em;}
|
268
|
+
dd { margin-left: 0.5em; }
|
269
|
+
|
270
|
+
li { line-height: 1.4; }
|
271
|
+
|
272
|
+
ol ol, ol ul, ul ul, ul ol {
|
273
|
+
margin-left: 1em;
|
274
|
+
}
|
275
|
+
|
276
|
+
/* Tables */
|
277
|
+
|
278
|
+
table {
|
279
|
+
margin-bottom: 2em;
|
280
|
+
width: 100%;
|
281
|
+
}
|
282
|
+
th {
|
283
|
+
border-bottom: 2px solid #ccc;
|
284
|
+
font-weight: bold;
|
285
|
+
text-align: left;
|
286
|
+
}
|
287
|
+
td { border-bottom: 1px solid #ddd; }
|
288
|
+
caption, th, td {
|
289
|
+
padding: 4px 10px 4px 0;
|
290
|
+
}
|
291
|
+
caption {
|
292
|
+
background: #f1f1f1;
|
293
|
+
padding: 10px 0;
|
294
|
+
margin-bottom: 1em;
|
295
|
+
}
|
296
|
+
|
297
|
+
tr,td,th {
|
298
|
+
vertical-align: middle;
|
299
|
+
}
|
300
|
+
|
301
|
+
/* Use this if you use span-x classes on th/td. */
|
302
|
+
table .last { padding-right: 0; }
|
303
|
+
|
304
|
+
/* Headings */
|
305
|
+
|
306
|
+
h1, h2, h3, h4, h5, h6 { font-weight: bold; }
|
307
|
+
|
308
|
+
h1 {
|
309
|
+
font-size: 2.2em;
|
310
|
+
line-height: 1;
|
311
|
+
margin-bottom: 0.25em;
|
312
|
+
}
|
313
|
+
h2 {
|
314
|
+
font-size: 1.6em;
|
315
|
+
margin-bottom: 0.25em;
|
316
|
+
line-height: 1.1;
|
317
|
+
}
|
318
|
+
h3 {
|
319
|
+
font-size: 1.3em;
|
320
|
+
line-height: 1;
|
321
|
+
margin-bottom: 0.25em;
|
322
|
+
}
|
323
|
+
h4 {
|
324
|
+
font-size: 1.1em;
|
325
|
+
line-height: 1.25;
|
326
|
+
margin-bottom: 0.25em;
|
327
|
+
}
|
328
|
+
h5 {
|
329
|
+
font-size: 1em;
|
330
|
+
margin-bottom: 0.25em;
|
331
|
+
}
|
332
|
+
h6 {
|
333
|
+
font-size: 1em;
|
334
|
+
margin-bottom: 0.25em;
|
335
|
+
}
|
336
|
+
|
337
|
+
/* Text elements */
|
338
|
+
p { margin-bottom: 0.5em; }
|
339
|
+
p.last { margin-bottom: 0; }
|
340
|
+
p img {
|
341
|
+
float: left;
|
342
|
+
margin: 1.5em 1.5em 1.5em 0;
|
343
|
+
padding: 0;
|
344
|
+
}
|
345
|
+
p img.top { margin-top: 0; } /* Use this if the image is at the top of the <p>. */
|
346
|
+
img { margin: 0 0 1.5em; }
|
347
|
+
|
348
|
+
abbr, acronym {
|
349
|
+
border-bottom: 1px dotted #666;
|
350
|
+
cursor: help;
|
351
|
+
}
|
352
|
+
address {
|
353
|
+
margin-top: 1.5em;
|
354
|
+
font-style: italic;
|
355
|
+
}
|
356
|
+
del { color:#666; }
|
357
|
+
|
358
|
+
a, a:link {
|
359
|
+
color: #1a4882;
|
360
|
+
text-decoration: underline;
|
361
|
+
}
|
362
|
+
a:visited { color: #1a4882; }
|
363
|
+
a:hover { color: #052246; }
|
364
|
+
a:active, a:focus { color: #1a4882; }
|
365
|
+
|
366
|
+
blockquote {
|
367
|
+
margin: 1.5em 0;
|
368
|
+
color: #666;
|
369
|
+
font-style: italic;
|
370
|
+
padding-left: 1em;
|
371
|
+
border-left: 4px solid #d1d1d1;
|
372
|
+
}
|
373
|
+
strong { font-weight: bold; }
|
374
|
+
em, dfn { font-style: italic; }
|
375
|
+
dfn { font-weight: bold; }
|
376
|
+
pre, code {
|
377
|
+
margin: 1.5em 0;
|
378
|
+
white-space: pre;
|
379
|
+
}
|
380
|
+
pre, code, tt {
|
381
|
+
font: 1em 'andale mono', 'monotype.com', 'lucida console', monospace;
|
382
|
+
line-height: 1.5;
|
383
|
+
}
|
384
|
+
pre.code {
|
385
|
+
background: #000;
|
386
|
+
color: #fff;
|
387
|
+
padding: 20px;
|
388
|
+
}
|
389
|
+
tt {
|
390
|
+
display: block;
|
391
|
+
margin: 1.5em 0;
|
392
|
+
line-height: 1.5;
|
393
|
+
}
|
394
|
+
|
395
|
+
|
396
|
+
/* App Styles */
|
397
|
+
|
398
|
+
body {
|
399
|
+
background-color:#dadada;
|
400
|
+
}
|
401
|
+
|
402
|
+
.content {
|
403
|
+
background:#fff;
|
404
|
+
width:880px;
|
405
|
+
-moz-border-radius:24px;
|
406
|
+
-webkit-border-radius:24px;
|
407
|
+
border-radius: 24px;
|
408
|
+
margin:40px auto;
|
409
|
+
padding:40px;
|
410
|
+
}
|
411
|
+
|
412
|
+
|
413
|
+
label.inline {
|
414
|
+
display: inline;
|
415
|
+
font-weight: bold;
|
416
|
+
}
|
417
|
+
|
418
|
+
.errorExplanation {
|
419
|
+
border: red 2px solid;
|
420
|
+
padding: 15px;
|
421
|
+
margin: 10px 0;
|
422
|
+
}
|
423
|
+
|
424
|
+
p {
|
425
|
+
line-height: 18px;
|
426
|
+
}
|
427
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class <%= controller_name %>Controller < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@<%= object_plural %> = <%= class_name %>.all
|
5
|
+
end
|
6
|
+
|
7
|
+
def new
|
8
|
+
@<%= object_singular %> = <%= class_name %>.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def create
|
12
|
+
@<%= object_singular %> = <%= class_name %>.new(params[:<%= object_singular %>])
|
13
|
+
if @<%= object_singular %>.save
|
14
|
+
flash[:message] = "Successfully created <%= object_singular.humanize.downcase %>."
|
15
|
+
redirect_to <%= index_url %>
|
16
|
+
else
|
17
|
+
render :action => 'new'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def show
|
22
|
+
@<%= object_singular %> = <%= class_name %>.find(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def edit
|
27
|
+
@<%= object_singular %> = <%= class_name %>.find(params[:id])
|
28
|
+
render :action => :new
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
@<%= object_singular %> = <%= class_name %>.find(params[:id])
|
33
|
+
if @<%= object_singular %>.update_attributes(params[:<%= object_singular %>])
|
34
|
+
flash[:message] = "Successfully updated <%= object_singular.humanize.downcase %>."
|
35
|
+
redirect_to <%= index_url %>
|
36
|
+
else
|
37
|
+
render :action => :new
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
@<%= object_singular %> = <%= class_name %>.find(params[:id])
|
43
|
+
begin
|
44
|
+
@<%= object_singular %>.destroy
|
45
|
+
flash[:message] = "Successfully destroyed <%= object_singular.humanize.downcase %>."
|
46
|
+
rescue StandardError => msg
|
47
|
+
flash[:warning] = msg.to_s
|
48
|
+
end
|
49
|
+
redirect_to <%= index_url %>
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Create<%= human_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= object_plural %> do |t|
|
4
|
+
<%- for attribute in attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<%- end -%>
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :<%= object_plural %>
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class <%= controller_name %>ControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context "testing controller" do
|
6
|
+
|
7
|
+
# May want to add some login info here.
|
8
|
+
setup do
|
9
|
+
@<%= object_singular %> = Factory(:<%= object_singular %>)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
should "get index" do
|
14
|
+
get :index
|
15
|
+
assert_response :success, @response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
should "get new" do
|
19
|
+
get :new
|
20
|
+
assert_response :success, @response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
should "create successfully" do
|
24
|
+
post :create, Factory.attributes_for(:<%= object_singular %>)
|
25
|
+
assert_response :redirect, @response.body
|
26
|
+
assert_redirected_to <%= index_url %>
|
27
|
+
end
|
28
|
+
|
29
|
+
should "get edit" do
|
30
|
+
get :edit, :id => @<%= object_singular %>.id
|
31
|
+
assert_response :success, @response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
should "show successfully" do
|
35
|
+
get :show, :id => @<%= object_singular %>.id
|
36
|
+
assert_response :success, @response.body
|
37
|
+
end
|
38
|
+
|
39
|
+
should "update successfully" do
|
40
|
+
put :update, :id => @<%= object_singular %>.id, :<%= object_singular %> => Factory.attributes_for(:<%= object_singular %>)
|
41
|
+
assert_response :redirect, @response.body
|
42
|
+
assert_redirected_to <%= index_url %>
|
43
|
+
end
|
44
|
+
|
45
|
+
should "destroy successfully" do
|
46
|
+
delete :destroy, :id => @<%= object_singular %>.id
|
47
|
+
assert_response :redirect, @response.body
|
48
|
+
assert_redirected_to <%= index_url %>
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% unless namespace.blank? %>
|
2
|
+
= form_for [:<%= namespace.downcase %>, @<%= singular_name %>] do |f|
|
3
|
+
<% else %>
|
4
|
+
= form_for @<%= object_singular %> do |f|
|
5
|
+
<% end %>
|
6
|
+
%fieldset
|
7
|
+
= f.error_messages
|
8
|
+
<% attributes.each do |attribute| %>
|
9
|
+
%p
|
10
|
+
= f.label :<%= attribute.name %>
|
11
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
12
|
+
<% end %>
|
13
|
+
%p
|
14
|
+
= f.submit "Save"
|
15
|
+
or
|
16
|
+
= link_to "Cancel", <%= index_url %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%h1 <%= human_name %>
|
2
|
+
|
3
|
+
%table
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
<%- for attribute in attributes -%>
|
7
|
+
%th <%= attribute.human_name %>
|
8
|
+
<%- end -%>
|
9
|
+
%th Actions
|
10
|
+
%tbody
|
11
|
+
- for <%= object_singular %> in @<%= object_plural %>
|
12
|
+
%tr
|
13
|
+
<%- for attribute in attributes -%>
|
14
|
+
%td= <%= object_singular %>.<%= attribute.name %>
|
15
|
+
<%- end %>
|
16
|
+
%td
|
17
|
+
= link_to 'Show', <%= show_url %>
|
18
|
+
\|
|
19
|
+
= link_to 'Edit', <%= edit_url %>
|
20
|
+
\|
|
21
|
+
= link_to 'Destroy', <%= show_url %>, :confirm => 'Are you sure?', :method => :delete
|
22
|
+
|
23
|
+
%p= link_to "New <%= object_singular.titleize %>", <%= new_url %>
|
24
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
= link_to "< back to list", <%= index_url %>
|
2
|
+
|
3
|
+
%h1 View <%= human_name %>
|
4
|
+
|
5
|
+
<%- for attribute in attributes -%>
|
6
|
+
%p
|
7
|
+
%strong <%= attribute.human_name.titleize %>:
|
8
|
+
= @<%= object_singular %>.<%= attribute.name %>
|
9
|
+
<%- end -%>
|
10
|
+
|
11
|
+
%p
|
12
|
+
= link_to "Edit", <%= edit_url(:instance => true) %>
|
13
|
+
= link_to "Delete", <%= show_url(:instance => true) %>, :method => :delete, :confirm => "Are you sure?"
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scaffy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
- 0
|
9
|
+
version: 0.5.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Alastair Brunton
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-10-25 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Scaffy generates usable scaffolding for a model with tests, layout, namespacing and haml.
|
22
|
+
email:
|
23
|
+
- info@simplyexcited.co.uk
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- lib/generators/scaffy/scaffy_generator.rb
|
32
|
+
- lib/generators/scaffy/templates/assets/images/alertbad_icon.gif
|
33
|
+
- lib/generators/scaffy/templates/assets/images/alertgood_icon.gif
|
34
|
+
- lib/generators/scaffy/templates/assets/images/glossy-error-icon.jpg
|
35
|
+
- lib/generators/scaffy/templates/assets/stylesheets/scaffy.css
|
36
|
+
- lib/generators/scaffy/templates/controller.rb
|
37
|
+
- lib/generators/scaffy/templates/helper.rb
|
38
|
+
- lib/generators/scaffy/templates/migration.rb
|
39
|
+
- lib/generators/scaffy/templates/model.rb
|
40
|
+
- lib/generators/scaffy/templates/test/factory_girl/factory.rb
|
41
|
+
- lib/generators/scaffy/templates/test/shoulda/controller_test.rb
|
42
|
+
- lib/generators/scaffy/templates/test/shoulda/model_test.rb
|
43
|
+
- lib/generators/scaffy/templates/views/haml/_form.html.haml
|
44
|
+
- lib/generators/scaffy/templates/views/haml/index.html.haml
|
45
|
+
- lib/generators/scaffy/templates/views/haml/layout.html.haml
|
46
|
+
- lib/generators/scaffy/templates/views/haml/new.html.haml
|
47
|
+
- lib/generators/scaffy/templates/views/haml/show.html.haml
|
48
|
+
- lib/generators/scaffy/USAGE
|
49
|
+
- lib/scaffy/version.rb
|
50
|
+
- LICENSE
|
51
|
+
- README.textile
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: http://github.com/pyrat/scaffy
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 1
|
76
|
+
- 3
|
77
|
+
- 1
|
78
|
+
version: 1.3.1
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.7
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Opinionated scaffolding generator for rails 3.
|
86
|
+
test_files: []
|
87
|
+
|