lucasefe-multi_helper 0.0.1

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.
Files changed (60) hide show
  1. data/README.rdoc +11 -0
  2. data/Rakefile +14 -0
  3. data/generators/full_layout/full_layout_generator.rb +47 -0
  4. data/generators/full_layout/templates/_flash_messages.html.haml +6 -0
  5. data/generators/full_layout/templates/_main_navigation.html.haml +6 -0
  6. data/generators/full_layout/templates/_secondary_navigation.html.haml +2 -0
  7. data/generators/full_layout/templates/_sidebar.html.haml +15 -0
  8. data/generators/full_layout/templates/_theme_switch.html.erb +29 -0
  9. data/generators/full_layout/templates/_user_navigation.html.erb +10 -0
  10. data/generators/full_layout/templates/javascripts/jquery-ui.js +273 -0
  11. data/generators/full_layout/templates/javascripts/jquery.corner.js +178 -0
  12. data/generators/full_layout/templates/javascripts/jquery.form.js +601 -0
  13. data/generators/full_layout/templates/javascripts/jquery.js +19 -0
  14. data/generators/full_layout/templates/javascripts/jquery.livequery.js +250 -0
  15. data/generators/full_layout/templates/javascripts/jquery.localscroll.js +104 -0
  16. data/generators/full_layout/templates/javascripts/jquery.scrollTo.js +150 -0
  17. data/generators/full_layout/templates/javascripts/layout.js +26 -0
  18. data/generators/full_layout/templates/layout.html.haml +36 -0
  19. data/generators/full_layout/templates/stylesheets/base.css +282 -0
  20. data/generators/full_layout/templates/stylesheets/overrides.css +11 -0
  21. data/generators/full_layout/templates/stylesheets/themes/bec/style.css +279 -0
  22. data/generators/full_layout/templates/stylesheets/themes/black-grey/style.css +171 -0
  23. data/generators/full_layout/templates/stylesheets/themes/default/style.css +233 -0
  24. data/generators/full_scaffold/README +11 -0
  25. data/generators/full_scaffold/full_scaffold_generator.rb +149 -0
  26. data/generators/full_scaffold/templates/controller.rb +13 -0
  27. data/generators/full_scaffold/templates/helper.rb +2 -0
  28. data/generators/full_scaffold/templates/migration.rb +15 -0
  29. data/generators/full_scaffold/templates/model.rb +2 -0
  30. data/generators/full_scaffold/templates/rspec/unit_spec.rb +11 -0
  31. data/generators/full_scaffold/templates/view__collection.haml +23 -0
  32. data/generators/full_scaffold/templates/view__form.haml +3 -0
  33. data/generators/full_scaffold/templates/view__search.haml +11 -0
  34. data/generators/full_scaffold/templates/view_edit.haml +9 -0
  35. data/generators/full_scaffold/templates/view_index.haml +8 -0
  36. data/generators/full_scaffold/templates/view_index.js.haml +1 -0
  37. data/generators/full_scaffold/templates/view_new.haml +7 -0
  38. data/generators/full_scaffold/templates/view_show.haml +10 -0
  39. data/icons/add.png +0 -0
  40. data/icons/arrow_undo.png +0 -0
  41. data/icons/cross.png +0 -0
  42. data/icons/error.png +0 -0
  43. data/icons/exclamation.png +0 -0
  44. data/icons/pencil.png +0 -0
  45. data/icons/tick.png +0 -0
  46. data/lib/multi_helper.rb +6 -0
  47. data/lib/multi_helper/form.rb +11 -0
  48. data/lib/multi_helper/form/README.markdown +119 -0
  49. data/lib/multi_helper/form/builder.rb +346 -0
  50. data/lib/multi_helper/form/helper.rb +41 -0
  51. data/lib/multi_helper/navigation.rb +6 -0
  52. data/lib/multi_helper/navigation/group.rb +36 -0
  53. data/lib/multi_helper/navigation/helper.rb +11 -0
  54. data/lib/multi_helper/navigation/item.rb +27 -0
  55. data/lib/multi_helper/navigation/renderer.rb +35 -0
  56. data/lib/multi_helper/vendor/validation_reflection.rb +73 -0
  57. data/lib/multi_helper/view.rb +49 -0
  58. data/multi_helper.gemspec +31 -0
  59. data/rails/init.rb +2 -0
  60. metadata +129 -0
@@ -0,0 +1,171 @@
1
+ a:link, a:visited, a:hover, a:active, h1, h2, h3 { color: #000; }
2
+
3
+ body {
4
+ color: #222;
5
+ background: #f0f0ee;
6
+ text-align: center;
7
+ }
8
+
9
+ hr {
10
+ background: #f0f0ee;
11
+ color: #f0f0ee;
12
+ }
13
+
14
+ #container {
15
+ width: 960px;
16
+ margin: 0 auto;
17
+ text-align: left;
18
+ }
19
+
20
+ #header {
21
+ background: #000;
22
+ padding: 20px 0 0 0;
23
+ }
24
+
25
+ #header h1 {
26
+ font-size: 20px;
27
+ margin: 0 0 0 10px;
28
+ padding: 0;
29
+ float: left;
30
+ }
31
+
32
+ #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited {
33
+ color: #FFF;
34
+ }
35
+
36
+ #wrapper {
37
+ padding: 20px 0 0 0;
38
+ }
39
+
40
+ #main {
41
+ float: right;
42
+ width: 755px;
43
+ }
44
+
45
+ #main-navigation {
46
+ margin: 0 0 0 205px;
47
+ }
48
+
49
+ #main .block {
50
+ background: #FFF;
51
+ padding-bottom: 20px;
52
+ }
53
+
54
+ #main .block h2.title {
55
+ margin-left: 15px;
56
+ }
57
+
58
+
59
+ #sidebar {
60
+ float: left;
61
+ width: 180px;
62
+ padding: 0 10px
63
+ }
64
+
65
+ #sidebar h3 {
66
+ background: #f0f0ee;
67
+ padding: 0 0 10px 0;
68
+ font-weight: bold;
69
+ font-size: 15px;
70
+ }
71
+
72
+ #sidebar ul.navigation li a:link, #sidebar ul.navigation li a:visited {
73
+ padding: 5px;
74
+ }
75
+
76
+ #sidebar ul li a:link, #sidebar ul li a:visited {
77
+ border-bottom-color: #F0F0EE;
78
+ }
79
+
80
+ #sidebar ul li a:hover, #sidebar ul li a:active {
81
+ background: #444;
82
+ color: #FFF;
83
+ }
84
+
85
+ #sidebar .block .sidebar-block, #sidebar .notice {
86
+ padding: 0;
87
+ }
88
+
89
+ #main-navigation ul li {
90
+ background: #444;
91
+ }
92
+
93
+ #main-navigation ul li.active {
94
+ background: #f0f0ee;
95
+ }
96
+
97
+ #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active,
98
+ .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active,
99
+ #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active {
100
+ text-decoration: none;
101
+ color: #FFF;
102
+ }
103
+
104
+ #main-navigation ul li.active a:link, #main-navigation ul li.active a:visited, #main-navigation ul li.active a:hover, #main-navigation ul li.active a:active {
105
+ color: #444;
106
+ }
107
+
108
+ .secondary-navigation {
109
+ background: #000;
110
+ border-bottom-color: #444;
111
+ }
112
+
113
+ .secondary-navigation ul li.active {
114
+ background-color: #444;
115
+ }
116
+
117
+ #footer {
118
+ padding: 0 0 10px 205px;
119
+ }
120
+
121
+ /* pagination */
122
+
123
+ .pagination span.current {
124
+ background: #444;
125
+ color: #FFF;
126
+ border-color: #444;
127
+ }
128
+
129
+ .pagination a {
130
+ color: #444;
131
+ border-color: #444;
132
+ }
133
+
134
+ .pagination a:hover {
135
+ color: #FFF;
136
+ background: #444;
137
+ }
138
+
139
+ /* tables */
140
+
141
+ .table th {
142
+ background: #444;
143
+ color: #FFF;
144
+ }
145
+
146
+ .table th.first {
147
+ width: 30px;
148
+ text-align: center;
149
+ }
150
+
151
+ .table td {
152
+ border-bottom-color: #F0F0EE;
153
+ }
154
+
155
+ /* forms */
156
+
157
+ .form input[type="text"], .form textarea {
158
+ width: 100%;
159
+ border: 1px solid #444;
160
+ }
161
+
162
+
163
+ /* lists */
164
+
165
+ ul.list li {
166
+ border-bottom-color: #F0F0EE;
167
+ }
168
+
169
+ ul.list li .item .avatar {
170
+ border-color: #F0F0EE;
171
+ }
@@ -0,0 +1,233 @@
1
+ .small { font-size:11px; }
2
+ .gray { color:#999999; }
3
+ .hightlight { background-color:#FFFFCC; }
4
+
5
+ a:link, a:visited, a:hover, a:active, h1, h2, h3 { color: #7A1818; }
6
+
7
+ body {
8
+ color: #222;
9
+ background: #f0f0ee;
10
+ font-family: helvetica, arial, sans-serif;
11
+ }
12
+
13
+ hr {
14
+ background: #f0f0ee;
15
+ color: #f0f0ee;
16
+ }
17
+
18
+ #header {
19
+ background: #7A1818;
20
+ }
21
+
22
+ #header h1 {
23
+ padding: 0;
24
+ }
25
+
26
+ #header h1 a:link, #header h1 a:active, #header h1 a:hover, #header h1 a:visited {
27
+ color: #FFF;
28
+ }
29
+
30
+ #user-navigation {
31
+ top: auto;
32
+ bottom: 5px;
33
+ right: 25px;
34
+ }
35
+
36
+ #main .block {
37
+ background: #FFF;
38
+ padding-bottom: 20px;
39
+ }
40
+
41
+ #main .block h2.title {
42
+ margin-left: 15px;
43
+ }
44
+
45
+ #sidebar .block {
46
+ background: #FFF;
47
+ }
48
+
49
+ #sidebar h3 {
50
+ background: #7A1818;
51
+ color: #FFF;
52
+ border-bottom: 10px solid #262626;
53
+ }
54
+
55
+ #sidebar ul li a:link, #sidebar ul li a:visited {
56
+ background: #FFF;
57
+ border-bottom: 1px solid #F0F0EE;
58
+ text-decoration: none;
59
+ }
60
+
61
+ #sidebar ul li a:hover, #sidebar ul li a:active {
62
+ background: #470E0E;
63
+ color: #FFF;
64
+ }
65
+
66
+ #main-navigation {
67
+ background: #262626;
68
+ }
69
+
70
+ #main-navigation ul li {
71
+ background: #262626;
72
+ margin-right: 0;
73
+ }
74
+
75
+ #main-navigation ul li.active {
76
+ background: #f0f0ee;
77
+ }
78
+
79
+ #main-navigation ul li a:link, #main-navigation ul li a:visited, #main-navigation ul li a:hover, #main-navigation ul li a:active,
80
+ .secondary-navigation ul li a:link, .secondary-navigation ul li a:visited, .secondary-navigation ul li a:hover, .secondary-navigation ul li a:active,
81
+ #user-navigation ul li a:link, #user-navigation ul li a:visited, #user-navigation ul li a:hover, #user-navigation ul li a:active {
82
+ text-decoration: none;
83
+ color: #FFF;
84
+ }
85
+
86
+ .secondary-navigation li a:hover {
87
+ background: #470E0E;
88
+ }
89
+
90
+ #main-navigation ul li.active a:link, #main-navigation ul li.active a:visited, #main-navigation ul li.active a:hover, #main-navigation ul li.active a:active {
91
+ color: #262626;
92
+ }
93
+
94
+ .secondary-navigation {
95
+ background: #7A1818;
96
+ border-bottom-color: #262626;
97
+ }
98
+
99
+ .secondary-navigation ul li.active, .secondary-navigation ul li.active a:hover {
100
+ background-color: #262626;
101
+ }
102
+
103
+ #footer .block {
104
+ color: #FFF;
105
+ background: #262626;
106
+ width: 70%;
107
+ }
108
+
109
+ #footer .block p {
110
+ margin: 0;
111
+ padding: 10px;
112
+ }
113
+
114
+ /* pagination */
115
+
116
+ .pagination span.current {
117
+ background: #262626;
118
+ color: #FFF;
119
+ border-color: #262626;
120
+ }
121
+
122
+ .pagination a {
123
+ color: #262626;
124
+ border-color: #262626;
125
+ }
126
+
127
+ .pagination a:hover {
128
+ color: #FFF;
129
+ background: #262626;
130
+ }
131
+
132
+ /* tables */
133
+
134
+ .table th {
135
+ background: #262626;
136
+ color: #FFF;
137
+ }
138
+
139
+ .table td {
140
+ border-bottom:1px solid #F0F0EE;
141
+ }
142
+
143
+ /* forms */
144
+
145
+ .form input[type="text"], .form textarea {
146
+ width: 100%;
147
+ border: 1px solid #262626;
148
+ }
149
+
150
+ .form input.button {
151
+ background: #EEE;
152
+ color: #262626;
153
+ padding: 2px 5px;
154
+ border: 1px solid #262626;
155
+ cursor: pointer;
156
+ }
157
+
158
+ .form .description {
159
+ font-style: italic;
160
+ color: #8C8C8C;
161
+ font-size: .9em;
162
+ }
163
+
164
+ /* flash-messages */
165
+ .flash-messages {
166
+ -moz-border-radius: 3px;
167
+ -webkit-border-radius: 3px;
168
+ text-align:center;
169
+ margin:0 auto 5px;
170
+
171
+ }
172
+ .flash-messages p {
173
+ margin:8px;
174
+ }
175
+ .flash-messages.error {
176
+ border: 1px solid #fbb;
177
+ background-color: #fdd;
178
+ }
179
+ .flash-messages.warning {
180
+ border: 1px solid #fffaaa;
181
+ background-color: #ffffcc;
182
+ }
183
+ .flash-messages.notice {
184
+ border: 1px solid #1FDF00;
185
+ background-color: #BBFFB6;
186
+ }
187
+
188
+ /* lists */
189
+
190
+ ul.list li {
191
+ border-bottom-color: #F0F0EE;
192
+ border-bottom-width: 1px;
193
+ border-bottom-style: solid;
194
+ }
195
+
196
+ ul.list li .item .avatar {
197
+ border-color: #F0F0EE;
198
+ border-width: 1px;
199
+ border-style: solid;
200
+ padding: 2px;
201
+ }
202
+
203
+ /* rounded borders */
204
+
205
+ #main, #main-navigation, #main-navigation li, .secondary-navigation, #main .block, #sidebar .block, #sidebar h3, ul.list li, #footer .block, .form input.button {
206
+ -moz-border-radius-topleft: 4px;
207
+ -webkit-border-top-left-radius: 4px;
208
+ -moz-border-radius-topright: 4px;
209
+ -webkit-border-top-right-radius: 4px;
210
+ }
211
+
212
+ .secondary-navigation li.first a, .secondary-navigation ul li.first, .table th.first, .table th.first {
213
+ -moz-border-radius-topleft: 4px;
214
+ -webkit-border-top-left-radius: 4px;
215
+ }
216
+
217
+ .table th.last {
218
+ -moz-border-radius-topright: 4px;
219
+ -webkit-border-top-right-radius: 4px;
220
+ }
221
+
222
+
223
+ .secondary-navigation ul li.first {
224
+ -moz-border-radius-topleft: 4px;
225
+ -webkit-border-top-left-radius: 4px;
226
+ }
227
+
228
+ #sidebar, #sidebar .block, #main .block, #sidebar ul.navigation, ul.list li, #footer .block, .form input.button {
229
+ -moz-border-radius-bottomleft: 4px;
230
+ -webkit-border-bottom-left-radius: 4px;
231
+ -moz-border-radius-bottomright: 4px;
232
+ -webkit-border-bottom-right-radius: 4px;
233
+ }
@@ -0,0 +1,11 @@
1
+ == Serious Scaffold ==
2
+
3
+ Usage:
4
+ ./script/generate full_scaffold Product name:string price:decimal enabled:boolean published_at:datetime
5
+
6
+ Features:
7
+
8
+ * Formtastic
9
+ * Search capability with searchlogic's gem.
10
+ * Pagination.
11
+ * Ordering.
@@ -0,0 +1,149 @@
1
+ # Basado en el scaffold generator de Resource Controller.
2
+ class FullScaffoldGenerator < Rails::Generator::NamedBase
3
+ attr_reader :controller_name,
4
+ :controller_class_path,
5
+ :controller_file_path,
6
+ :controller_class_nesting,
7
+ :controller_class_nesting_depth,
8
+ :controller_class_name,
9
+ :controller_singular_name,
10
+ :controller_plural_name,
11
+ :resource_edit_path,
12
+ :default_file_extension,
13
+ :generator_default_file_extension
14
+ alias_method :controller_file_name, :controller_singular_name
15
+ alias_method :controller_table_name, :controller_plural_name
16
+
17
+ def initialize(runtime_args, runtime_options = {})
18
+ super
19
+ if @rspec = has_rspec?
20
+ @resource_edit_path = "/edit"
21
+ end
22
+ raise "Instalar Haml" unless defined?Haml
23
+ @generator_default_file_extension = "haml"
24
+ @default_file_extension = "html.#{@generator_default_file_extension}"
25
+ @controller_name = @name.pluralize
26
+
27
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
28
+ @controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
29
+
30
+ if @controller_class_nesting.empty?
31
+ @controller_class_name = @controller_class_name_without_nesting
32
+ else
33
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
34
+ end
35
+ end
36
+
37
+ def manifest
38
+ record do |m|
39
+ # Check for class naming collisions.
40
+ # m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper")
41
+ m.class_collisions(class_path, "#{class_name}")
42
+
43
+ # Controller, helper, views, and test directories.
44
+ m.directory(File.join('app/models', class_path))
45
+ m.directory(File.join('app/controllers', controller_class_path))
46
+ m.directory(File.join('app/helpers', controller_class_path))
47
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
48
+
49
+ if @rspec
50
+ m.directory(File.join('spec/models', class_path))
51
+ end
52
+
53
+ scaffold_views.each do |action|
54
+ m.template(
55
+ "view_#{action}.#{generator_default_file_extension}",
56
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.#{default_file_extension}")
57
+ )
58
+ end
59
+ m.template("view__collection.#{generator_default_file_extension}",
60
+ File.join('app/views', controller_class_path, controller_file_name, "_#{plural_name}.#{default_file_extension}" ))
61
+ m.template("view_index.js.#{generator_default_file_extension}",
62
+ File.join('app/views', controller_class_path, controller_file_name, "index.js.haml" ))
63
+
64
+
65
+ m.template('model.rb', File.join('app/models', class_path, "#{file_name}.rb"))
66
+ m.template('controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb"))
67
+ m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
68
+
69
+ if @rspec
70
+ m.template('rspec/unit_spec.rb', File.join('spec/models', class_path, "#{file_name}_spec.rb"))
71
+ end
72
+
73
+
74
+ unless options[:skip_migration]
75
+ migration_template = 'migration.rb'
76
+
77
+ m.migration_template(
78
+ migration_template, 'db/migrate',
79
+ :assigns => {
80
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}",
81
+ :attributes => attributes
82
+ },
83
+ :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
84
+ )
85
+ end
86
+
87
+ m.route_resources controller_file_name
88
+ end
89
+ end
90
+
91
+ # Lifted from Rick Olson's restful_authentication
92
+ def has_rspec?
93
+ options[:rspec] || (File.exist?('spec') && File.directory?('spec'))
94
+ end
95
+
96
+ protected
97
+ # Override with your own usage banner.
98
+ def banner
99
+ "Usage: #{$0} serious_scaffold ModelName [field:type, field:type]"
100
+ end
101
+
102
+ def rspec_views
103
+ %w[ index show new edit ]
104
+ end
105
+
106
+ def scaffold_views
107
+ rspec_views + %w[ _form _search ]
108
+ end
109
+
110
+ def model_name
111
+ class_name.demodulize
112
+ end
113
+
114
+ def add_options!(opt)
115
+ opt.separator ''
116
+ opt.separator 'Options:'
117
+ opt.on("--rspec", "Force rspec mode (checks for RAILS_ROOT/spec by default)") { |v| options[:rspec] = true }
118
+ end
119
+ end
120
+
121
+ module Rails
122
+ module Generator
123
+ class GeneratedAttribute
124
+ def default_value
125
+ @default_value ||= case type
126
+ when :int, :integer then "\"1\""
127
+ when :float then "\"1.5\""
128
+ when :decimal then "\"9.99\""
129
+ when :datetime, :timestamp, :time then "Time.now"
130
+ when :date then "Date.today"
131
+ when :string then "\"MyString\""
132
+ when :text then "\"MyText\""
133
+ when :boolean then "false"
134
+ else
135
+ ""
136
+ end
137
+ end
138
+
139
+ def input_type
140
+ @input_type ||= case type
141
+ when :text then "textarea"
142
+ when :boolean then "check_box"
143
+ else
144
+ "input"
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end