aslon_scaffold 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/README +26 -0
- data/Rakefile +2 -0
- data/aslon_scaffold.gemspec +33 -0
- data/config/locales/aslon_scaffold.fr.yml +14 -0
- data/init.rb +1 -0
- data/install.rb +1 -0
- data/lib/app/controllers/articles_controller.rb +7 -0
- data/lib/app/helpers/application_helper.rb +410 -0
- data/lib/app/views/aslon_scaffolds/_search.haml +1 -0
- data/lib/app/views/aslon_scaffolds/index.haml +4 -0
- data/lib/app/views/aslon_scaffolds/new_edit.haml +8 -0
- data/lib/app/views/aslon_scaffolds/show.haml +9 -0
- data/lib/aslon_scaffold.rb +34 -0
- data/lib/aslon_scaffold/aslon_scaffold.rb +237 -0
- data/lib/aslon_scaffold/version.rb +4 -0
- data/lib/generators/haml.rb +11 -0
- data/lib/generators/haml/scaffold/scaffold_generator.rb +25 -0
- data/lib/generators/haml/scaffold/templates/_new_edit.haml.erb +6 -0
- data/lib/generators/haml/scaffold/templates/_search.haml.erb +6 -0
- data/lib/generators/haml/scaffold/templates/edit.haml.erb +5 -0
- data/lib/generators/haml/scaffold/templates/index.haml.erb +10 -0
- data/lib/generators/haml/scaffold/templates/layout.haml.erb +17 -0
- data/lib/generators/haml/scaffold/templates/new.haml.erb +6 -0
- data/lib/generators/haml/scaffold/templates/new_edit.haml.erb +13 -0
- data/lib/generators/haml/scaffold/templates/show.haml.erb +14 -0
- data/lib/generators/nifty.rb +28 -0
- data/lib/generators/nifty/aslon/USAGE +51 -0
- data/lib/generators/nifty/aslon/aslon_generator.rb +320 -0
- data/lib/generators/nifty/aslon/templates/actions/create.rb +8 -0
- data/lib/generators/nifty/aslon/templates/actions/destroy.rb +5 -0
- data/lib/generators/nifty/aslon/templates/actions/edit.rb +3 -0
- data/lib/generators/nifty/aslon/templates/actions/index.rb +3 -0
- data/lib/generators/nifty/aslon/templates/actions/new.rb +3 -0
- data/lib/generators/nifty/aslon/templates/actions/show.rb +3 -0
- data/lib/generators/nifty/aslon/templates/actions/update.rb +8 -0
- data/lib/generators/nifty/aslon/templates/controller.rb +10 -0
- data/lib/generators/nifty/aslon/templates/fixtures.yml +9 -0
- data/lib/generators/nifty/aslon/templates/helper.rb +2 -0
- data/lib/generators/nifty/aslon/templates/migration.rb +16 -0
- data/lib/generators/nifty/aslon/templates/model.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/create.rb +11 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/destroy.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/edit.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/index.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/new.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/show.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/actions/update.rb +11 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/controller.rb +8 -0
- data/lib/generators/nifty/aslon/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/create.rb +13 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/edit.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/index.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/new.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/show.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/actions/update.rb +13 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/controller.rb +5 -0
- data/lib/generators/nifty/aslon/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/create.rb +11 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/destroy.rb +6 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/edit.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/index.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/new.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/show.rb +4 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/actions/update.rb +11 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/controller.rb +5 -0
- data/lib/generators/nifty/aslon/templates/tests/testunit/model.rb +7 -0
- data/lib/generators/nifty/aslon/templates/views/haml/_new_edit.html.haml +6 -0
- data/lib/generators/nifty/aslon/templates/views/haml/_search.html.haml +6 -0
- data/lib/generators/nifty/aslon/templates/views/haml/index.html.haml +10 -0
- data/lib/generators/nifty/aslon/templates/views/haml/layout.haml.erb +17 -0
- data/lib/generators/nifty/aslon/templates/views/haml/new_edit.html.haml +13 -0
- data/lib/generators/nifty/aslon/templates/views/haml/show.html.haml +14 -0
- data/lib/generators/nifty/layout/USAGE +25 -0
- data/lib/generators/nifty/layout/layout_generator.rb +42 -0
- data/lib/generators/nifty/layout/templates/_default.html.haml +9 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/add.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/delete.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/edit.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/folder.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid-blue-hd.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid-split.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/grid3-hrow.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/indicator.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/magnifier.png +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/sort_asc.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/images/aslon_scaffold/sort_desc.gif +0 -0
- data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/base.css.sass +263 -0
- data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/formtastic.css.sass +176 -0
- data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/formtastic_changes.css.sass +31 -0
- data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/table_coffee_with_milk.css.sass +94 -0
- data/lib/generators/nifty/layout/templates/error_messages_helper.rb +23 -0
- data/lib/generators/nifty/layout/templates/layout.html.haml +13 -0
- data/lib/generators/nifty/layout/templates/layout_helper.rb +22 -0
- data/lib/generators/nifty/layout/templates/locales/aslon_scaffold.fr.yml +14 -0
- data/lib/generators/nifty/scaffold/USAGE +51 -0
- data/lib/generators/nifty/scaffold/scaffold_generator.rb +319 -0
- data/lib/generators/nifty/scaffold/templates/actions/create.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/actions/destroy.rb +5 -0
- data/lib/generators/nifty/scaffold/templates/actions/edit.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/index.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/new.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/show.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/actions/update.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/controller.rb +3 -0
- data/lib/generators/nifty/scaffold/templates/fixtures.yml +9 -0
- data/lib/generators/nifty/scaffold/templates/helper.rb +2 -0
- data/lib/generators/nifty/scaffold/templates/migration.rb +16 -0
- data/lib/generators/nifty/scaffold/templates/model.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/create.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/edit.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/index.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/new.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/show.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/actions/update.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/controller.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/create.rb +13 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/index.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/new.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/show.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/actions/update.rb +13 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/controller.rb +5 -0
- data/lib/generators/nifty/scaffold/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/create.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/edit.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/index.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/new.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/show.rb +4 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/actions/update.rb +11 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/controller.rb +5 -0
- data/lib/generators/nifty/scaffold/templates/tests/testunit/model.rb +7 -0
- data/lib/generators/nifty/scaffold/templates/views/erb/_form.html.erb +10 -0
- data/lib/generators/nifty/scaffold/templates/views/erb/edit.html.erb +14 -0
- data/lib/generators/nifty/scaffold/templates/views/erb/index.html.erb +29 -0
- data/lib/generators/nifty/scaffold/templates/views/erb/new.html.erb +7 -0
- data/lib/generators/nifty/scaffold/templates/views/erb/show.html.erb +20 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/_new_edit.html.haml +6 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/_search.html.haml +6 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml +10 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/layout.haml.erb +17 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/new_edit.haml.erb +13 -0
- data/lib/generators/nifty/scaffold/templates/views/haml/show.haml.erb +14 -0
- data/lib/generators/templates/rails/scaffold_controller/controller.rb +11 -0
- data/lib/tasks/aslon_scaffold_tasks.rake +91 -0
- data/lib/tasks/task.rake +113 -0
- data/test/articles_controller_test.rb +24 -0
- data/test/database.yml +8 -0
- data/test/schema.rb +6 -0
- data/test/test_helper.rb +39 -0
- data/test/undeletable_plugin.sqlite.db +0 -0
- data/test/undeletable_plugin2.sqlite3.db +0 -0
- data/uninstall.rb +1 -0
- data/vendor/assets/images/aslon_scaffold/add.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/delete.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/edit.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/folder.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/grid-blue-hd.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/grid-split.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/grid3-hrow.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/indicator.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/magnifier.png +0 -0
- data/vendor/assets/images/aslon_scaffold/sort_asc.gif +0 -0
- data/vendor/assets/images/aslon_scaffold/sort_desc.gif +0 -0
- data/vendor/assets/stylesheets/aslon_scaffold_base.css.sass +116 -0
- data/vendor/assets/stylesheets/aslon_scaffold_base.css.sass.old +263 -0
- data/vendor/assets/stylesheets/aslon_scaffold_table.css.sass +94 -0
- data/vendor/assets/stylesheets/formtastic_changes.css.sass +31 -0
- metadata +185 -4
data/lib/generators/nifty/layout/templates/assets/stylesheets/aslon_scaffold/formtastic.css.sass
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
form.formtastic
|
2
|
+
margin: 0
|
3
|
+
padding: 0
|
4
|
+
|
5
|
+
ul, ol, li, fieldset, legend, input, textarea, select, p
|
6
|
+
margin: 0
|
7
|
+
padding: 0
|
8
|
+
|
9
|
+
fieldset
|
10
|
+
border: 0
|
11
|
+
|
12
|
+
em, strong
|
13
|
+
font-style: normal
|
14
|
+
font-weight: normal
|
15
|
+
|
16
|
+
ol, ul
|
17
|
+
list-style: none
|
18
|
+
|
19
|
+
abbr, acronym
|
20
|
+
border: 0
|
21
|
+
font-variant: normal
|
22
|
+
|
23
|
+
input, textarea, select
|
24
|
+
font-family: inherit
|
25
|
+
font-size: inherit
|
26
|
+
font-weight: inherit
|
27
|
+
|
28
|
+
input, textarea, select
|
29
|
+
font-size: 100%
|
30
|
+
|
31
|
+
legend
|
32
|
+
color: #000
|
33
|
+
|
34
|
+
fieldset
|
35
|
+
display: inline-block
|
36
|
+
|
37
|
+
&.inputs
|
38
|
+
&.buttons
|
39
|
+
padding-left: 25%
|
40
|
+
|
41
|
+
ol
|
42
|
+
&.buttons li
|
43
|
+
float: left
|
44
|
+
padding-right: 0.5em
|
45
|
+
|
46
|
+
&:after
|
47
|
+
content: "."
|
48
|
+
display: block
|
49
|
+
height: 0
|
50
|
+
clear: both
|
51
|
+
visibility: hidden
|
52
|
+
|
53
|
+
|
54
|
+
html[xmlns] form.formtastic fieldset
|
55
|
+
display: block
|
56
|
+
|
57
|
+
|
58
|
+
* html form.formtastic fieldset
|
59
|
+
height: 1%
|
60
|
+
|
61
|
+
|
62
|
+
form.formtastic fieldset ol li
|
63
|
+
margin-bottom: 1.5em
|
64
|
+
display: inline-block
|
65
|
+
|
66
|
+
&:after
|
67
|
+
content: "."
|
68
|
+
display: block
|
69
|
+
height: 0
|
70
|
+
clear: both
|
71
|
+
visibility: hidden
|
72
|
+
|
73
|
+
|
74
|
+
html[xmlns] form.formtastic fieldset ol li
|
75
|
+
display: block
|
76
|
+
|
77
|
+
|
78
|
+
* html form.formtastic fieldset ol li
|
79
|
+
height: 1%
|
80
|
+
|
81
|
+
|
82
|
+
form.formtastic fieldset ol li
|
83
|
+
&.required, &.optional, &.error
|
84
|
+
label
|
85
|
+
display: block
|
86
|
+
width: 25%
|
87
|
+
float: left
|
88
|
+
padding-top: .2em
|
89
|
+
|
90
|
+
li label
|
91
|
+
line-height: 100%
|
92
|
+
padding-top: 0
|
93
|
+
|
94
|
+
input
|
95
|
+
line-height: 100%
|
96
|
+
vertical-align: middle
|
97
|
+
margin-top: -0.1em
|
98
|
+
|
99
|
+
fieldset
|
100
|
+
position: relative
|
101
|
+
|
102
|
+
legend
|
103
|
+
position: absolute
|
104
|
+
width: 25%
|
105
|
+
padding-top: 0.1em
|
106
|
+
|
107
|
+
span
|
108
|
+
position: absolute
|
109
|
+
|
110
|
+
ol
|
111
|
+
float: left
|
112
|
+
width: 74%
|
113
|
+
margin: 0
|
114
|
+
padding: 0 0 0 25%
|
115
|
+
|
116
|
+
li
|
117
|
+
padding: 0
|
118
|
+
border: 0
|
119
|
+
|
120
|
+
p
|
121
|
+
&.inline-hints
|
122
|
+
color: #666
|
123
|
+
margin: 0.5em 0 0 25%
|
124
|
+
|
125
|
+
&.inline-errors
|
126
|
+
color: #cc0000
|
127
|
+
margin: 0.5em 0 0 25%
|
128
|
+
|
129
|
+
ul.errors
|
130
|
+
color: #cc0000
|
131
|
+
margin: 0.5em 0 0 25%
|
132
|
+
list-style: square
|
133
|
+
|
134
|
+
li
|
135
|
+
padding: 0
|
136
|
+
border: none
|
137
|
+
display: list-item
|
138
|
+
|
139
|
+
&.string input, &.password input, &.numeric input, &.text textarea
|
140
|
+
width: 74%
|
141
|
+
|
142
|
+
&.hidden
|
143
|
+
display: none
|
144
|
+
|
145
|
+
&.boolean label
|
146
|
+
padding-left: 25%
|
147
|
+
width: auto
|
148
|
+
|
149
|
+
input
|
150
|
+
margin: 0 0.5em 0 0.2em
|
151
|
+
|
152
|
+
&.radio fieldset ol, &.check_boxes fieldset ol
|
153
|
+
margin-bottom: -0.6em
|
154
|
+
|
155
|
+
li
|
156
|
+
margin: 0.1em 0 0.5em 0
|
157
|
+
|
158
|
+
label
|
159
|
+
float: none
|
160
|
+
width: 100%
|
161
|
+
|
162
|
+
input
|
163
|
+
margin-right: 0.2em
|
164
|
+
|
165
|
+
&.date fieldset ol li, &.time fieldset ol li, &.datetime fieldset ol li
|
166
|
+
float: left
|
167
|
+
width: auto
|
168
|
+
margin: 0 .3em 0 0
|
169
|
+
|
170
|
+
&.date fieldset ol li label, &.time fieldset ol li label, &.datetime fieldset ol li label
|
171
|
+
display: none
|
172
|
+
|
173
|
+
&.date fieldset ol li label input, &.time fieldset ol li label input, &.datetime fieldset ol li label input
|
174
|
+
display: inline
|
175
|
+
margin: 0
|
176
|
+
padding: 0
|
@@ -0,0 +1,31 @@
|
|
1
|
+
form.formtastic
|
2
|
+
ul, ol, li, fieldset, legend, input, textarea, select, p
|
3
|
+
margin: 0.5px
|
4
|
+
padding: 1px
|
5
|
+
legend
|
6
|
+
color: darkblue
|
7
|
+
padding: 1pt
|
8
|
+
width: 95%
|
9
|
+
float: left
|
10
|
+
margin-left: 10px
|
11
|
+
|
12
|
+
fieldset.inputs
|
13
|
+
border: 1px solid
|
14
|
+
border-style: dotted
|
15
|
+
background-color: white
|
16
|
+
|
17
|
+
form.formtastic fieldset ol li
|
18
|
+
margin-bottom: 0.3em
|
19
|
+
|
20
|
+
form.formtastic fieldset ol li
|
21
|
+
&.required, &.optional, &.error
|
22
|
+
label
|
23
|
+
width: 15%
|
24
|
+
padding-top: .2em
|
25
|
+
&.string input, &.password input, &.numeric input, &.text textarea
|
26
|
+
width: 50%
|
27
|
+
&.numeric input
|
28
|
+
width: 15%
|
29
|
+
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
table#titreliste
|
2
|
+
padding: 4px 4px
|
3
|
+
font-size: 1em
|
4
|
+
background: #EBE5D9
|
5
|
+
text-align: left
|
6
|
+
cursor: default
|
7
|
+
border-top: 1px solid grey
|
8
|
+
border-bottom: 1px solid grey
|
9
|
+
width: 100%
|
10
|
+
|
11
|
+
|
12
|
+
table#liste
|
13
|
+
font: normal 0.7em/1.5em "Lucida Grande", "Lucida Sans Unicode", Verdana, Arial, Helvetica, sans-serif
|
14
|
+
border-collapse: separate
|
15
|
+
border-spacing: 0
|
16
|
+
margin: 0 0 1em
|
17
|
+
color: #000
|
18
|
+
width: 100%
|
19
|
+
a
|
20
|
+
color: #523A0B
|
21
|
+
text-decoration: none
|
22
|
+
// border-bottom: 1px dotted
|
23
|
+
|
24
|
+
&:visited
|
25
|
+
color: #444
|
26
|
+
font-weight: normal
|
27
|
+
|
28
|
+
// &:after
|
29
|
+
// content: "\00A0\221A"
|
30
|
+
|
31
|
+
// &:hover
|
32
|
+
// border-bottom-style: solid
|
33
|
+
|
34
|
+
|
35
|
+
thead
|
36
|
+
th, td
|
37
|
+
font:
|
38
|
+
size: 1.1em
|
39
|
+
border: 1px solid #523A0B
|
40
|
+
border-width: 1px 0
|
41
|
+
background: #EBE5D9
|
42
|
+
|
43
|
+
|
44
|
+
tfoot
|
45
|
+
th, td
|
46
|
+
border: 1px solid #523A0B
|
47
|
+
border-width: 1px 0
|
48
|
+
background: #EBE5D9
|
49
|
+
|
50
|
+
th
|
51
|
+
font-weight: bold
|
52
|
+
line-height: normal
|
53
|
+
padding: 0.25em 0.5em
|
54
|
+
text-align: left
|
55
|
+
|
56
|
+
|
57
|
+
tbody th, td
|
58
|
+
padding: 0.25em 0.5em
|
59
|
+
text-align: left
|
60
|
+
vertical-align: top
|
61
|
+
|
62
|
+
|
63
|
+
tbody
|
64
|
+
th
|
65
|
+
font-weight: normal
|
66
|
+
white-space: nowrap
|
67
|
+
|
68
|
+
a
|
69
|
+
&:link, &:visited
|
70
|
+
font-weight: bold
|
71
|
+
|
72
|
+
td, th
|
73
|
+
border: 1px solid #fff
|
74
|
+
border-width: 1px 0
|
75
|
+
|
76
|
+
tr
|
77
|
+
&.odd
|
78
|
+
th, td
|
79
|
+
border-color: #EBE5D9
|
80
|
+
background: #F7F4EE
|
81
|
+
|
82
|
+
&:hover
|
83
|
+
td, th
|
84
|
+
background: #ffffee
|
85
|
+
border-color: #523A0B
|
86
|
+
|
87
|
+
|
88
|
+
caption
|
89
|
+
font-family: Georgia,Times,serif
|
90
|
+
font-weight: normal
|
91
|
+
font-size: 1.4em
|
92
|
+
text-align: left
|
93
|
+
margin: 0
|
94
|
+
padding: 0.5em 0.25em
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ErrorMessagesHelper
|
2
|
+
# Render error messages for the given objects. The :message and :header_message options are allowed.
|
3
|
+
def error_messages_for(*objects)
|
4
|
+
options = objects.extract_options!
|
5
|
+
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
|
6
|
+
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
|
7
|
+
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
|
8
|
+
unless messages.empty?
|
9
|
+
content_tag(:div, :class => "error_messages") do
|
10
|
+
list_items = messages.map { |msg| content_tag(:li, msg.html_safe) }
|
11
|
+
content_tag(:h2, options[:header_message].html_safe) + content_tag(:p, options[:message].html_safe) + content_tag(:ul, list_items.join.html_safe)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module FormBuilderAdditions
|
17
|
+
def error_messages(options = {})
|
18
|
+
@template.error_messages_for(@object, options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
=# encoding: utf-8
|
2
|
+
= render "layouts/default"
|
3
|
+
%body
|
4
|
+
= image_tag("aslon_scaffold/indicator.gif",:style=>"vertical-align:middle",:border => 0, :id => "spiner", :style => "display:none; position:absolute; top:5px;left:350px; " )
|
5
|
+
|
6
|
+
#container
|
7
|
+
- flash.each do |name, msg|
|
8
|
+
= content_tag :div, msg, :id => "flash_#{name}"
|
9
|
+
|
10
|
+
- if show_title?
|
11
|
+
%h1= yield(:title)
|
12
|
+
|
13
|
+
= yield
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# These helper methods can be called in your template to set variables to be used in the layout
|
2
|
+
# This module should be included in all views globally,
|
3
|
+
# to do so you may need to add this line to your ApplicationController
|
4
|
+
# helper :layout
|
5
|
+
module LayoutHelper
|
6
|
+
def title(page_title, show_title = true)
|
7
|
+
content_for(:title) { h(page_title.to_s) }
|
8
|
+
@show_title = show_title
|
9
|
+
end
|
10
|
+
|
11
|
+
def show_title?
|
12
|
+
@show_title
|
13
|
+
end
|
14
|
+
|
15
|
+
def stylesheet(*args)
|
16
|
+
content_for(:head) { stylesheet_link_tag(*args) }
|
17
|
+
end
|
18
|
+
|
19
|
+
def javascript(*args)
|
20
|
+
content_for(:head) { javascript_include_tag(*args) }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
fr:
|
3
|
+
views:
|
4
|
+
generic:
|
5
|
+
edit: "Edition : %{model}"
|
6
|
+
new: "Nouveau : %{model}"
|
7
|
+
index: "Liste : %{model}"
|
8
|
+
messages:
|
9
|
+
ok_created: "%{model} : OK création"
|
10
|
+
ok_deleted: "OK suppression"
|
11
|
+
ko_deleted: "KO suppression"
|
12
|
+
ok_updated: "OK mise à jour"
|
13
|
+
mise_a_jour: "Mise à jour"
|
14
|
+
model: "Modèle"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire resource, from model and migration to controller and
|
3
|
+
views. The resource is ready to use as a starting point for your restful,
|
4
|
+
resource-oriented application. Tests or specs are also generated depending
|
5
|
+
on if you have a "spec" directory or not.
|
6
|
+
|
7
|
+
IMPORTANT: This generator uses the "title" helper method which is generated
|
8
|
+
by the nifty_layout generator. You may want to run that generator first.
|
9
|
+
|
10
|
+
Usage:
|
11
|
+
Pass the name of the model, either CamelCased or under_scored, as the first
|
12
|
+
argument along with an optional list of attribute pairs and controller actions.
|
13
|
+
|
14
|
+
If no controller actions are specified, they will default to index, show,
|
15
|
+
new, create, edit, update, and destroy.
|
16
|
+
|
17
|
+
IMPORTANT: If no attribute pairs are specified, no model will be generated.
|
18
|
+
It will try to determine the attributes from an existing model.
|
19
|
+
|
20
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
21
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
22
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
23
|
+
|
24
|
+
For example, `nifty:scaffold post name:string content:text hidden:boolean`
|
25
|
+
gives you a model with those three attributes, a controller that handles
|
26
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
27
|
+
an index that lists them all, as well as a map.resources :posts
|
28
|
+
declaration in config/routes.rb.
|
29
|
+
|
30
|
+
Adding an "!" in the mix of arguments will invert the passed controller
|
31
|
+
actions. This will include all 7 controller actitons except the ones
|
32
|
+
mentioned. This option doesn't affect model attributes.
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
rails generate nifty:scaffold post
|
36
|
+
|
37
|
+
Will create a controller called "posts" it will contain all seven
|
38
|
+
CRUD actions along with the views. A model will NOT be created,
|
39
|
+
instead it will look for an existing model and use those attributes.
|
40
|
+
|
41
|
+
rails generate nifty:scaffold post name:string content:text index new edit
|
42
|
+
|
43
|
+
Will create a Post model and migration file with the name and content
|
44
|
+
attributes. It will also create a controller with index, new, create,
|
45
|
+
edit, and update actions. Notice the create and update actions are
|
46
|
+
added automatically with new and edit.
|
47
|
+
|
48
|
+
rails generate nifty:scaffold post ! show new
|
49
|
+
|
50
|
+
Creates a posts controller (no model) with index, edit, update, and
|
51
|
+
destroy actions.
|
@@ -0,0 +1,319 @@
|
|
1
|
+
require 'generators/nifty'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails/generators/generated_attribute'
|
4
|
+
|
5
|
+
module Nifty
|
6
|
+
module Generators
|
7
|
+
class ScaffoldGenerator < Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
no_tasks { attr_accessor :scaffold_name, :model_attributes, :controller_actions }
|
10
|
+
|
11
|
+
argument :scaffold_name, :type => :string, :required => true, :banner => 'ModelName'
|
12
|
+
argument :args_for_c_m, :type => :array, :default => [], :banner => 'controller_actions and model:attributes'
|
13
|
+
|
14
|
+
class_option :skip_model, :desc => 'Don\'t generate a model or migration file.', :type => :boolean
|
15
|
+
class_option :skip_migration, :desc => 'Dont generate migration file for model.', :type => :boolean
|
16
|
+
class_option :skip_timestamps, :desc => 'Don\'t add timestamps to migration file.', :type => :boolean
|
17
|
+
class_option :skip_controller, :desc => 'Don\'t generate controller, helper, or views.', :type => :boolean
|
18
|
+
class_option :invert, :desc => 'Generate all controller actions except these mentioned.', :type => :boolean
|
19
|
+
class_option :namespace_model, :desc => 'If the resource is namespaced, include the model in the namespace.', :type => :boolean
|
20
|
+
class_option :haml, :desc => 'Generate HAML views instead of ERB.', :type => :boolean
|
21
|
+
|
22
|
+
class_option :testunit, :desc => 'Use test/unit for test files.', :group => 'Test framework', :type => :boolean
|
23
|
+
class_option :rspec, :desc => 'Use RSpec for test files.', :group => 'Test framework', :type => :boolean
|
24
|
+
class_option :shoulda, :desc => 'Use shoulda for test files.', :group => 'Test framework', :type => :boolean
|
25
|
+
|
26
|
+
def initialize(*args, &block)
|
27
|
+
super
|
28
|
+
|
29
|
+
print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/
|
30
|
+
|
31
|
+
@controller_actions = []
|
32
|
+
@model_attributes = []
|
33
|
+
@skip_model = options.skip_model?
|
34
|
+
@namespace_model = options.namespace_model?
|
35
|
+
@invert_actions = options.invert?
|
36
|
+
|
37
|
+
args_for_c_m.each do |arg|
|
38
|
+
if arg == '!'
|
39
|
+
@invert_actions = true
|
40
|
+
elsif arg.include?(':')
|
41
|
+
@model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
|
42
|
+
else
|
43
|
+
@controller_actions << arg
|
44
|
+
@controller_actions << 'create' if arg == 'new'
|
45
|
+
@controller_actions << 'update' if arg == 'edit'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
@controller_actions.uniq!
|
50
|
+
@model_attributes.uniq!
|
51
|
+
|
52
|
+
if @invert_actions || @controller_actions.empty?
|
53
|
+
@controller_actions = all_actions - @controller_actions
|
54
|
+
end
|
55
|
+
|
56
|
+
if @model_attributes.empty?
|
57
|
+
@skip_model = true # skip model if no attributes
|
58
|
+
if model_exists?
|
59
|
+
model_columns_for_attributes.each do |column|
|
60
|
+
@model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
|
61
|
+
end
|
62
|
+
else
|
63
|
+
@model_attributes << Rails::Generators::GeneratedAttribute.new('name', 'string')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_gems
|
69
|
+
add_gem "mocha", :group => :test
|
70
|
+
end
|
71
|
+
|
72
|
+
def create_model
|
73
|
+
unless @skip_model
|
74
|
+
template 'model.rb', "app/models/#{model_path}.rb"
|
75
|
+
if test_framework == :rspec
|
76
|
+
template "tests/rspec/model.rb", "spec/models/#{model_path}_spec.rb"
|
77
|
+
template 'fixtures.yml', "spec/fixtures/#{model_path.pluralize}.yml"
|
78
|
+
else
|
79
|
+
template "tests/#{test_framework}/model.rb", "test/unit/#{model_path}_test.rb"
|
80
|
+
template 'fixtures.yml', "test/fixtures/#{model_path.pluralize}.yml"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def create_migration
|
86
|
+
unless @skip_model || options.skip_migration?
|
87
|
+
migration_template 'migration.rb', "db/migrate/create_#{model_path.pluralize.gsub('/', '_')}.rb"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_controller
|
92
|
+
unless options.skip_controller?
|
93
|
+
template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
|
94
|
+
|
95
|
+
template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
|
96
|
+
|
97
|
+
controller_actions.each do |action|
|
98
|
+
if %w[index show new edit].include?(action) # Actions with templates
|
99
|
+
template "views/#{view_language}/#{action}.html.#{view_language}", "app/views/#{plural_name}/#{action}.html.#{view_language}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
if form_partial?
|
104
|
+
template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
|
105
|
+
end
|
106
|
+
|
107
|
+
namespaces = plural_name.split('/')
|
108
|
+
resource = namespaces.pop
|
109
|
+
route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
|
110
|
+
"namespace(:#{namespace}){ #{acc} }"
|
111
|
+
}
|
112
|
+
|
113
|
+
if test_framework == :rspec
|
114
|
+
template "tests/#{test_framework}/controller.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
|
115
|
+
else
|
116
|
+
template "tests/#{test_framework}/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def form_partial?
|
124
|
+
actions? :new, :edit
|
125
|
+
end
|
126
|
+
|
127
|
+
def all_actions
|
128
|
+
%w[index show new create edit update destroy]
|
129
|
+
end
|
130
|
+
|
131
|
+
def action?(name)
|
132
|
+
controller_actions.include? name.to_s
|
133
|
+
end
|
134
|
+
|
135
|
+
def actions?(*names)
|
136
|
+
names.all? { |name| action? name }
|
137
|
+
end
|
138
|
+
|
139
|
+
def singular_name
|
140
|
+
scaffold_name.underscore
|
141
|
+
end
|
142
|
+
|
143
|
+
def plural_name
|
144
|
+
scaffold_name.underscore.pluralize
|
145
|
+
end
|
146
|
+
|
147
|
+
def table_name
|
148
|
+
if scaffold_name.include?('::') && @namespace_model
|
149
|
+
plural_name.gsub('/', '_')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def class_name
|
154
|
+
if @namespace_model
|
155
|
+
scaffold_name.camelize
|
156
|
+
else
|
157
|
+
scaffold_name.split('::').last.camelize
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def model_path
|
162
|
+
class_name.underscore
|
163
|
+
end
|
164
|
+
|
165
|
+
def plural_class_name
|
166
|
+
plural_name.camelize
|
167
|
+
end
|
168
|
+
|
169
|
+
def instance_name
|
170
|
+
if @namespace_model
|
171
|
+
singular_name.gsub('/','_')
|
172
|
+
else
|
173
|
+
singular_name.split('/').last
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def instances_name
|
178
|
+
instance_name.pluralize
|
179
|
+
end
|
180
|
+
|
181
|
+
def controller_methods(dir_name)
|
182
|
+
controller_actions.map do |action|
|
183
|
+
read_template("#{dir_name}/#{action}.rb")
|
184
|
+
end.join("\n").strip
|
185
|
+
end
|
186
|
+
|
187
|
+
def render_form
|
188
|
+
if form_partial?
|
189
|
+
if options.haml?
|
190
|
+
"= render \"form\""
|
191
|
+
else
|
192
|
+
"<%= render \"form\" %>"
|
193
|
+
end
|
194
|
+
else
|
195
|
+
read_template("views/#{view_language}/_form.html.#{view_language}")
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def item_resource
|
200
|
+
scaffold_name.underscore.gsub('/','_')
|
201
|
+
end
|
202
|
+
|
203
|
+
def items_path
|
204
|
+
if action? :index
|
205
|
+
"#{item_resource.pluralize}_path"
|
206
|
+
else
|
207
|
+
"root_path"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def item_path(options = {})
|
212
|
+
name = options[:instance_variable] ? "@#{instance_name}" : instance_name
|
213
|
+
suffix = options[:full_url] ? "url" : "path"
|
214
|
+
if options[:action].to_s == "new"
|
215
|
+
"new_#{item_resource}_#{suffix}"
|
216
|
+
elsif options[:action].to_s == "edit"
|
217
|
+
"edit_#{item_resource}_#{suffix}(#{name})"
|
218
|
+
else
|
219
|
+
if scaffold_name.include?('::') && !@namespace_model
|
220
|
+
namespace = singular_name.split('/')[0..-2]
|
221
|
+
"[:#{namespace.join(', :')}, #{name}]"
|
222
|
+
else
|
223
|
+
name
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def item_url
|
229
|
+
if action? :show
|
230
|
+
item_path(:full_url => true, :instance_variable => true)
|
231
|
+
else
|
232
|
+
items_url
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
def items_url
|
237
|
+
if action? :index
|
238
|
+
item_resource.pluralize + '_url'
|
239
|
+
else
|
240
|
+
"root_url"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
def item_path_for_spec(suffix = 'path')
|
245
|
+
if action? :show
|
246
|
+
"#{item_resource}_#{suffix}(assigns[:#{instance_name}])"
|
247
|
+
else
|
248
|
+
if suffix == 'path'
|
249
|
+
items_path
|
250
|
+
else
|
251
|
+
items_url
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def item_path_for_test(suffix = 'path')
|
257
|
+
if action? :show
|
258
|
+
"#{item_resource}_#{suffix}(assigns(:#{instance_name}))"
|
259
|
+
else
|
260
|
+
if suffix == 'path'
|
261
|
+
items_path
|
262
|
+
else
|
263
|
+
items_url
|
264
|
+
end
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def model_columns_for_attributes
|
269
|
+
class_name.constantize.columns.reject do |column|
|
270
|
+
column.name.to_s =~ /^(id|created_at|updated_at)$/
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def view_language
|
275
|
+
# options.haml? ? 'haml' : 'erb'
|
276
|
+
'haml'
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_framework
|
280
|
+
return @test_framework if defined?(@test_framework)
|
281
|
+
if options.testunit?
|
282
|
+
return @test_framework = :testunit
|
283
|
+
elsif options.rspec?
|
284
|
+
return @test_framework = :rspec
|
285
|
+
elsif options.shoulda?
|
286
|
+
return @test_framework = :shoulda
|
287
|
+
else
|
288
|
+
return @test_framework = default_test_framework
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
def default_test_framework
|
293
|
+
File.exist?(destination_path("spec")) ? :rspec : :testunit
|
294
|
+
end
|
295
|
+
|
296
|
+
def model_exists?
|
297
|
+
File.exist? destination_path("app/models/#{singular_name}.rb")
|
298
|
+
end
|
299
|
+
|
300
|
+
def read_template(relative_path)
|
301
|
+
ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
|
302
|
+
end
|
303
|
+
|
304
|
+
def destination_path(path)
|
305
|
+
File.join(destination_root, path)
|
306
|
+
end
|
307
|
+
|
308
|
+
# FIXME: Should be proxied to ActiveRecord::Generators::Base
|
309
|
+
# Implement the required interface for Rails::Generators::Migration.
|
310
|
+
def self.next_migration_number(dirname) #:nodoc:
|
311
|
+
if ActiveRecord::Base.timestamped_migrations
|
312
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
313
|
+
else
|
314
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
318
|
+
end
|
319
|
+
end
|