brick_layer 0.9.2 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -41,7 +41,7 @@ Also in your 'app/assets/stylesheets' directory add:
41
41
  == Associated Gems
42
42
 
43
43
  This gem can work with other code that can server as clients.
44
- - Brick House ( http://github.com/rmcafee/brick_house )
44
+ - Brick House ( http://github.com/rmcafee/brick_house[http://github.com/rmcafee/brick_house] )
45
45
 
46
46
  == Data Sets
47
47
 
@@ -133,12 +133,31 @@ Now, I know what you are thinking - what about when I want to have a file field
133
133
 
134
134
  All you have to do is say 'custom_field_type' with whatever mapping that is supported by simple form.
135
135
 
136
+ == File and Image Uploads
137
+
138
+ Brick Layer is using a combo of dragonfly[http://github.com/markevans/dragonfly] and carrierwave[http://github.com/jnicklas/carrierwave] to allow resizing support of images by passing dimension variables into your data set for custom_fields with the 'image' type.
139
+
140
+ class Employee < BrickLayer::DataSet
141
+ custom_field :avatar, :image, { :sizes => { :small => "50x50>", :large => "400x400#" } }
142
+ custom_field :badge, :image, { :sizes => { :small => "50x50>", :large => "400x400#" } }
143
+
144
+ custom_field :resume, :file
145
+ end
146
+
147
+ The uploaded file will be located at: "/files/[filename]"
148
+ The uploaded image will be located at: "/media/[app_generated_path]/[image_name]"
149
+
150
+ Note this data will then be available in your JSON data load and that the fields "avatar_small" and "avatar_large" will be in different paths.
151
+
152
+ == Enable Supported WYSIWYG for Text Fields
153
+
136
154
  You can pass simple form supported options into your custom field to enable the built in WYSIWYG editor or whatever else you want to pass to the view.
137
155
 
138
156
  class Product < BrickLayer::DataSet
139
157
  custom_field :description, :text, { :input_html => { :class => "withEditor" } }
140
158
  end
141
159
 
160
+ == Relationships
142
161
 
143
162
  Relationships are also supported so you can add those and the fields should automatically show up.
144
163
 
@@ -87,4 +87,13 @@ small {
87
87
  .sub_routes {
88
88
  margin: 8px 0px 8px 10px;
89
89
  }
90
- }
90
+ }
91
+
92
+ ul.image-links {
93
+ margin:0px;
94
+ }
95
+
96
+ .image-links li {
97
+ display: inline;
98
+ margin-right: 10px;
99
+ }
@@ -2,7 +2,8 @@ module BrickLayer::DataSetHelper
2
2
  # This method grabs the attributes based on a class, allowing control of displaying and hiding certain fields
3
3
  def attributes_for(klass,options={})
4
4
  ignored_fields = ["_type","updated_at","created_at","route_id","_id"]
5
-
5
+ ignored_fields += ["title","meta_keywords","meta_description"] unless klass.name.include?("PageDataSet")
6
+
6
7
  if klass.respond_to?("relations")
7
8
  ignored_fields += klass.relations.keys.map { |r| "#{r}_id" }
8
9
  ignored_fields += klass.relations.keys.map { |r| "#{r.singularize}_ids" }
@@ -0,0 +1,14 @@
1
+ module BrickLayer::ViewHelper
2
+ def list_of_sizes_for(data_set, image_attribute)
3
+ if data_set.class.custom_field_options && data_set.class.custom_field_options[image_attribute.to_sym]
4
+ sizes = data_set.class.custom_field_options[image_attribute.to_sym][:sizes]
5
+ if !sizes.blank?
6
+ html = ""
7
+ sizes.each do |k,v|
8
+ html += content_tag(:li, link_to("#{k.to_s.titlecase} #{image_attribute.titlecase}", data_set.send(image_attribute).thumb(v).url, { :target => "_blank"}))
9
+ end
10
+ content_tag(:ul, raw(html), { :class => "image-links"} )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -122,10 +122,11 @@ class BrickLayer::DataSet
122
122
 
123
123
  mount_uploader field_name.to_sym, BrickLayer::FileUploader, :mount_on => "#{field_name}_filename".to_sym
124
124
  else
125
- @custom_field_options[field_name.to_sym] = options unless options.blank?
126
125
  @custom_fields[field_name.to_sym] = field_type
127
126
  field field_name, type: String
128
127
  end
128
+
129
+ @custom_field_options[field_name.to_sym] = options unless options.blank?
129
130
  end
130
131
 
131
132
  # convert an array of ids to an array of objects
@@ -1,14 +1,17 @@
1
1
  - attributes_for(@model_constant, :added_only => true).each do |attribute|
2
2
  = form_field_formatter(f, attribute)
3
+
3
4
  - if f.object.send(attribute).respond_to?("image?") && !f.object.send("#{attribute}_uid").blank?
4
5
  %p
5
6
  = image_tag(f.object.send(attribute).thumb('100x100#').url)
7
+ = list_of_sizes_for(f.object, attribute)
8
+ %br
6
9
  = f.check_box("remove_#{attribute}")
7
10
  = f.label "Remove #{attribute.titlecase}"
8
11
 
9
12
  - if f.object.send(attribute).to_s.try(:include?, "/files/")
10
13
  %p
11
- = link_to "Current #{attribute} File", f.object.send(attribute).to_s
14
+ = link_to "Current #{attribute.titlecase} File", f.object.send(attribute).to_s
12
15
  = f.check_box("remove_#{attribute}")
13
16
  = f.label "Remove #{attribute.titlecase}"
14
17
 
@@ -10,6 +10,9 @@
10
10
  %dt== #{attribute.titlecase}:
11
11
  - if @data_set.send(attribute).respond_to?("image?")
12
12
  = image_tag(@data_set.send(attribute).thumb('100x100#').url)
13
+ %br
14
+ = list_of_sizes_for(@data_set, attribute)
15
+ %br
13
16
  - elsif @data_set.send(attribute).to_s.try(:include?,"/files/")
14
17
  - uploaded_file = @data_set.send(attribute)
15
18
  = link_to (uploaded_file.model.send("#{attribute}_filename") || uploaded_file.to_s), uploaded_file.url, :target => "_blank"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick_layer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-20 00:00:00.000000000 Z
12
+ date: 2012-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bson_ext
16
- requirement: &70160111426820 !ruby/object:Gem::Requirement
16
+ requirement: &70208963386900 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.3.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70160111426820
24
+ version_requirements: *70208963386900
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mongoid
27
- requirement: &70160111426180 !ruby/object:Gem::Requirement
27
+ requirement: &70208963386200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.1.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70160111426180
35
+ version_requirements: *70208963386200
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: haml
38
- requirement: &70160111425000 !ruby/object:Gem::Requirement
38
+ requirement: &70208963385440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - =
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.1.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70160111425000
46
+ version_requirements: *70208963385440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: kaminari
49
- requirement: &70160111424320 !ruby/object:Gem::Requirement
49
+ requirement: &70208963384260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - =
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.12.4
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70160111424320
57
+ version_requirements: *70208963384260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mongoid_nested_set
60
- requirement: &70160111423760 !ruby/object:Gem::Requirement
60
+ requirement: &70208963383740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.1.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70160111423760
68
+ version_requirements: *70208963383740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: mongoid-ancestry
71
- requirement: &70160108109620 !ruby/object:Gem::Requirement
71
+ requirement: &70208963383060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.2.2
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70160108109620
79
+ version_requirements: *70208963383060
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: mongoid_fulltext
82
- requirement: &70160108108820 !ruby/object:Gem::Requirement
82
+ requirement: &70208963376420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.3.6
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70160108108820
90
+ version_requirements: *70208963376420
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: simple_form
93
- requirement: &70160108107980 !ruby/object:Gem::Requirement
93
+ requirement: &70208963375680 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - =
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 1.4.2
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *70160108107980
101
+ version_requirements: *70208963375680
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rack-cache
104
- requirement: &70160108107320 !ruby/object:Gem::Requirement
104
+ requirement: &70208963374900 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.0.3
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *70160108107320
112
+ version_requirements: *70208963374900
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: dragonfly
115
- requirement: &70160108106340 !ruby/object:Gem::Requirement
115
+ requirement: &70208963373840 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - =
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 0.9.5
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *70160108106340
123
+ version_requirements: *70208963373840
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: carrierwave
126
- requirement: &70160108104920 !ruby/object:Gem::Requirement
126
+ requirement: &70208963373100 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - =
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 0.5.4
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *70160108104920
134
+ version_requirements: *70208963373100
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: turn
137
- requirement: &70160108103820 !ruby/object:Gem::Requirement
137
+ requirement: &70208963372020 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70160108103820
145
+ version_requirements: *70208963372020
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: ruby-debug19
148
- requirement: &70160108103060 !ruby/object:Gem::Requirement
148
+ requirement: &70208963371080 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70160108103060
156
+ version_requirements: *70208963371080
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rspec-rails
159
- requirement: &70160108098760 !ruby/object:Gem::Requirement
159
+ requirement: &70208963369840 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '2.4'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *70160108098760
167
+ version_requirements: *70208963369840
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: autotest
170
- requirement: &70160108098300 !ruby/object:Gem::Requirement
170
+ requirement: &70208963368760 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *70160108098300
178
+ version_requirements: *70208963368760
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: webrat
181
- requirement: &70160108097680 !ruby/object:Gem::Requirement
181
+ requirement: &70208966627120 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ! '>='
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: '0'
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *70160108097680
189
+ version_requirements: *70208966627120
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: capybara
192
- requirement: &70160108097000 !ruby/object:Gem::Requirement
192
+ requirement: &70208966626420 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ! '>='
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: '0'
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *70160108097000
200
+ version_requirements: *70208966626420
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: shoulda
203
- requirement: &70160108096540 !ruby/object:Gem::Requirement
203
+ requirement: &70208966625940 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ! '>='
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: '0'
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *70160108096540
211
+ version_requirements: *70208966625940
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: hirb
214
- requirement: &70160108096100 !ruby/object:Gem::Requirement
214
+ requirement: &70208966625480 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ! '>='
@@ -219,10 +219,10 @@ dependencies:
219
219
  version: '0'
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *70160108096100
222
+ version_requirements: *70208966625480
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: wirble
225
- requirement: &70160108095580 !ruby/object:Gem::Requirement
225
+ requirement: &70208966624960 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
228
228
  - - ! '>='
@@ -230,10 +230,10 @@ dependencies:
230
230
  version: '0'
231
231
  type: :development
232
232
  prerelease: false
233
- version_requirements: *70160108095580
233
+ version_requirements: *70208966624960
234
234
  - !ruby/object:Gem::Dependency
235
235
  name: looksee
236
- requirement: &70160108095120 !ruby/object:Gem::Requirement
236
+ requirement: &70208966624500 !ruby/object:Gem::Requirement
237
237
  none: false
238
238
  requirements:
239
239
  - - ! '>='
@@ -241,7 +241,7 @@ dependencies:
241
241
  version: '0'
242
242
  type: :development
243
243
  prerelease: false
244
- version_requirements: *70160108095120
244
+ version_requirements: *70208966624500
245
245
  description: Content Management and Endpoint Rails Service Engine
246
246
  email:
247
247
  executables: []
@@ -524,6 +524,7 @@ files:
524
524
  - app/helpers/brick_layer/data_set_helper.rb
525
525
  - app/helpers/brick_layer/layout_helper.rb
526
526
  - app/helpers/brick_layer/site_helper.rb
527
+ - app/helpers/brick_layer/view_helper.rb
527
528
  - app/models/brick_layer/data_set.rb
528
529
  - app/models/brick_layer/file_uploader.rb
529
530
  - app/models/brick_layer/route.rb