uploader 0.1.7 → 0.1.8
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/Rakefile +3 -2
- data/VERSION +1 -1
- data/rdoc/classes/ActiveRecord/Acts/UploaderUpload/ClassMethods.html +19 -21
- data/rdoc/classes/ActiveRecord/Acts/UploaderUpload/InstanceMethods.html +162 -162
- data/rdoc/created.rid +1 -1
- data/rdoc/files/README_rdoc.html +108 -34
- data/rdoc/files/lib/active_record/acts/uploader_upload_rb.html +1 -1
- data/rdoc/files/lib/uploader/tasks_rb.html +1 -1
- data/rdoc/fr_file_index.html +1 -0
- data/uploader.gemspec +4 -1
- metadata +12 -3
data/Rakefile
CHANGED
@@ -32,7 +32,8 @@ begin
|
|
32
32
|
gemspec.description = "Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload and Paperclip"
|
33
33
|
gemspec.authors = ["Justin Ball", "David South"]
|
34
34
|
#gemspec.files.include %w( tasks/rails.rake lib/uploader/*.rb lib/uploader/middleware/*.rb db/migrate/*.rb public/images/file_icons/* app/views/uploads/* )
|
35
|
-
gemspec.rubyforge_project = 'uploader'
|
35
|
+
gemspec.rubyforge_project = 'uploader'
|
36
|
+
gemspec.add_dependency "mime-types"
|
36
37
|
end
|
37
38
|
rescue LoadError
|
38
39
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
@@ -54,7 +55,7 @@ begin
|
|
54
55
|
)
|
55
56
|
|
56
57
|
host = "#{config['username']}@rubyforge.org"
|
57
|
-
remote_dir = "/var/www/gforge-projects/
|
58
|
+
remote_dir = "/var/www/gforge-projects/uploader/"
|
58
59
|
local_dir = 'rdoc'
|
59
60
|
|
60
61
|
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
@@ -147,27 +147,25 @@ href="ClassMethods.html#M000005">acts_as_uploader</a> :has_attached_file
|
|
147
147
|
26: <span class="ruby-identifier">named_scope</span> <span class="ruby-identifier">:documents</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">></span> <span class="ruby-node">"local_content_type IN (#{(Uploader::MimeTypeGroups::WORD_TYPES + Uploader::MimeTypeGroups::EXCEL_TYPES + Uploader::MimeTypeGroups::PDF_TYPES).collect{|type| "'#{type}'"}.join(',')})"</span>
|
148
148
|
27: <span class="ruby-identifier">named_scope</span> <span class="ruby-identifier">:files</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">></span> <span class="ruby-node">"local_content_type NOT IN (#{Uploader::MimeTypeGroups::IMAGE_TYPES.collect{|type| "'#{type}'"}.join(',')})"</span>
|
149
149
|
28: <span class="ruby-identifier">named_scope</span> <span class="ruby-identifier">:since</span>, <span class="ruby-identifier">lambda</span> { <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span> { <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">></span> [<span class="ruby-value str">"created_at > ?"</span>, (<span class="ruby-identifier">args</span>.<span class="ruby-identifier">first</span> <span class="ruby-operator">||</span> <span class="ruby-value">7</span>.<span class="ruby-identifier">days</span>.<span class="ruby-identifier">ago</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">:db</span>)) ]} }
|
150
|
-
29: <span class="ruby-identifier">named_scope</span> <span class="ruby-identifier">:pending_s3_migration</span>, <span class="ruby-identifier">lambda</span> {
|
151
|
-
30:
|
152
|
-
31:
|
153
|
-
32:
|
154
|
-
33:
|
155
|
-
34:
|
156
|
-
35:
|
157
|
-
36:
|
158
|
-
37: <span class="ruby-keyword kw">
|
159
|
-
38:
|
160
|
-
39:
|
161
|
-
40:
|
162
|
-
41:
|
163
|
-
42:
|
164
|
-
43: <span class="ruby-identifier">
|
165
|
-
44:
|
166
|
-
45: <span class="ruby-identifier">
|
167
|
-
46:
|
168
|
-
47:
|
169
|
-
48: <span class="ruby-identifier">extend</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Acts</span><span class="ruby-operator">::</span><span class="ruby-constant">UploaderUpload</span><span class="ruby-operator">::</span><span class="ruby-constant">SingletonMethods</span>
|
170
|
-
49: <span class="ruby-keyword kw">end</span>
|
150
|
+
29: <span class="ruby-identifier">named_scope</span> <span class="ruby-identifier">:pending_s3_migration</span>, <span class="ruby-identifier">lambda</span> { { <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">></span> [<span class="ruby-value str">"remote_file_name IS NULL AND created_at <= ?"</span>, <span class="ruby-value">20</span>.<span class="ruby-identifier">minutes</span>.<span class="ruby-identifier">ago</span>.<span class="ruby-identifier">to_s</span>(<span class="ruby-identifier">:db</span>)], <span class="ruby-identifier">:order</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'created_at DESC'</span> } }
|
151
|
+
30:
|
152
|
+
31: <span class="ruby-comment cmt"># Paperclip</span>
|
153
|
+
32: <span class="ruby-identifier">has_attached_file</span> <span class="ruby-identifier">:local</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_attached_file</span>].<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:storage</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:filesystem</span>) <span class="ruby-comment cmt"># Override any storage settings. This one has to be local.</span>
|
154
|
+
33: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:enable_s3</span>] <span class="ruby-operator">==</span> <span class="ruby-keyword kw">true</span>
|
155
|
+
34: <span class="ruby-identifier">has_attached_file</span> <span class="ruby-identifier">:remote</span>, <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:has_attached_file</span>].<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">:url</span> =<span class="ruby-operator">></span> <span class="ruby-value str">':s3_alias_url'</span>,
|
156
|
+
35: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:s3_path</span>],
|
157
|
+
36: <span class="ruby-identifier">:storage</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:s3</span>)
|
158
|
+
37: <span class="ruby-keyword kw">end</span>
|
159
|
+
38:
|
160
|
+
39:
|
161
|
+
40: <span class="ruby-identifier">belongs_to</span> <span class="ruby-identifier">:uploadable</span>, <span class="ruby-identifier">:polymorphic</span> =<span class="ruby-operator">></span> <span class="ruby-keyword kw">true</span>
|
162
|
+
41: <span class="ruby-identifier">belongs_to</span> <span class="ruby-identifier">:creator</span>, <span class="ruby-identifier">:class_name</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'User'</span>, <span class="ruby-identifier">:foreign_key</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'creator_id'</span>
|
163
|
+
42:
|
164
|
+
43: <span class="ruby-identifier">class_eval</span> <span class="ruby-value str">"validates_attachment_size :local, :less_than => 10.megabytes\n\nbefore_post_process :transliterate_file_name\nbefore_create :add_width_and_height\n\n# prevents a user from submitting a crafted form that bypasses activation\nattr_protected :creator_id, :uploadable_id, :uploadable_type\n"</span>
|
165
|
+
44:
|
166
|
+
45: <span class="ruby-identifier">include</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Acts</span><span class="ruby-operator">::</span><span class="ruby-constant">UploaderUpload</span><span class="ruby-operator">::</span><span class="ruby-constant">InstanceMethods</span>
|
167
|
+
46: <span class="ruby-identifier">extend</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Acts</span><span class="ruby-operator">::</span><span class="ruby-constant">UploaderUpload</span><span class="ruby-operator">::</span><span class="ruby-constant">SingletonMethods</span>
|
168
|
+
47: <span class="ruby-keyword kw">end</span>
|
171
169
|
</pre>
|
172
170
|
</div>
|
173
171
|
</div>
|
@@ -145,17 +145,17 @@ All the methods available to a record that has had
|
|
145
145
|
onclick="toggleCode('M000025-source');return false;">[Source]</a></p>
|
146
146
|
<div class="method-source-code" id="M000025-source">
|
147
147
|
<pre>
|
148
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
148
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 192</span>
|
149
|
+
192: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>)
|
150
|
+
193: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">image_ratio</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
151
|
+
194: <span class="ruby-ivar">@image_width</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">width</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">width</span>
|
152
|
+
195: <span class="ruby-ivar">@image_height</span> <span class="ruby-operator">||=</span> (<span class="ruby-ivar">@image_width</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">image_ratio</span>).<span class="ruby-identifier">round</span>
|
153
|
+
196: <span class="ruby-keyword kw">else</span>
|
154
|
+
197: <span class="ruby-ivar">@image_height</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">></span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">height</span>
|
155
|
+
198: <span class="ruby-ivar">@image_width</span> <span class="ruby-operator">||=</span> (<span class="ruby-ivar">@image_height</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">image_ratio</span>).<span class="ruby-identifier">round</span>
|
156
|
+
199: <span class="ruby-keyword kw">end</span>
|
157
|
+
200: <span class="ruby-ivar">@image_size</span> <span class="ruby-operator">||=</span> <span class="ruby-node">"#{@image_width.to_i}x#{@image_height.to_i}"</span>
|
158
|
+
201: <span class="ruby-keyword kw">end</span>
|
159
159
|
</pre>
|
160
160
|
</div>
|
161
161
|
</div>
|
@@ -175,11 +175,11 @@ All the methods available to a record that has had
|
|
175
175
|
onclick="toggleCode('M000019-source');return false;">[Source]</a></p>
|
176
176
|
<div class="method-source-code" id="M000019-source">
|
177
177
|
<pre>
|
178
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
178
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 156</span>
|
179
|
+
156: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_edit?</span>(<span class="ruby-identifier">check_user</span>)
|
180
|
+
157: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">check_user</span>.<span class="ruby-identifier">blank?</span>
|
181
|
+
158: <span class="ruby-identifier">check_user</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">creator</span>
|
182
|
+
159: <span class="ruby-keyword kw">end</span>
|
183
183
|
</pre>
|
184
184
|
</div>
|
185
185
|
</div>
|
@@ -199,10 +199,10 @@ All the methods available to a record that has had
|
|
199
199
|
onclick="toggleCode('M000018-source');return false;">[Source]</a></p>
|
200
200
|
<div class="method-source-code" id="M000018-source">
|
201
201
|
<pre>
|
202
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
203
|
-
|
204
|
-
|
205
|
-
|
202
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 152</span>
|
203
|
+
152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_name</span>
|
204
|
+
153: <span class="ruby-constant">CGI</span><span class="ruby-operator">::</span><span class="ruby-identifier">escapeHTML</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_file_name</span>)
|
205
|
+
154: <span class="ruby-keyword kw">end</span>
|
206
206
|
</pre>
|
207
207
|
</div>
|
208
208
|
</div>
|
@@ -222,10 +222,10 @@ All the methods available to a record that has had
|
|
222
222
|
onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
|
223
223
|
<div class="method-source-code" id="M000006-source">
|
224
224
|
<pre>
|
225
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
226
|
-
|
227
|
-
|
228
|
-
|
225
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 67</span>
|
226
|
+
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file</span>
|
227
|
+
68: <span class="ruby-identifier">local_file_name</span> <span class="ruby-value">? </span><span class="ruby-identifier">local</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">remote</span>
|
228
|
+
69: <span class="ruby-keyword kw">end</span>
|
229
229
|
</pre>
|
230
230
|
</div>
|
231
231
|
</div>
|
@@ -245,10 +245,10 @@ All the methods available to a record that has had
|
|
245
245
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
246
246
|
<div class="method-source-code" id="M000007-source">
|
247
247
|
<pre>
|
248
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
249
|
-
|
250
|
-
|
251
|
-
|
248
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 71</span>
|
249
|
+
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_name</span>
|
250
|
+
72: <span class="ruby-identifier">remote_file_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">local_file_name</span>
|
251
|
+
73: <span class="ruby-keyword kw">end</span>
|
252
252
|
</pre>
|
253
253
|
</div>
|
254
254
|
</div>
|
@@ -268,13 +268,13 @@ All the methods available to a record that has had
|
|
268
268
|
onclick="toggleCode('M000021-source');return false;">[Source]</a></p>
|
269
269
|
<div class="method-source-code" id="M000021-source">
|
270
270
|
<pre>
|
271
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
271
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 170</span>
|
272
|
+
170: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">height</span>(<span class="ruby-identifier">style</span> = <span class="ruby-identifier">:default</span>)
|
273
|
+
171: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:height</span>]
|
274
|
+
172: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:height</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">style</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:default</span>
|
275
|
+
173: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
276
|
+
174: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_height</span>.<span class="ruby-identifier">to_i</span>
|
277
|
+
175: <span class="ruby-keyword kw">end</span>
|
278
278
|
</pre>
|
279
279
|
</div>
|
280
280
|
</div>
|
@@ -294,24 +294,24 @@ All the methods available to a record that has had
|
|
294
294
|
onclick="toggleCode('M000017-source');return false;">[Source]</a></p>
|
295
295
|
<div class="method-source-code" id="M000017-source">
|
296
296
|
<pre>
|
297
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
297
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 134</span>
|
298
|
+
134: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">icon</span>
|
299
|
+
135: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_pdf?</span>
|
300
|
+
136: <span class="ruby-value str">'/images/file_icons/file_pdf.gif'</span>
|
301
|
+
137: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_word?</span>
|
302
|
+
138: <span class="ruby-value str">'/images/file_icons/file_doc.gif'</span>
|
303
|
+
139: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_image?</span>
|
304
|
+
140: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">file</span>.<span class="ruby-identifier">url</span>(<span class="ruby-identifier">:icon</span>)
|
305
|
+
141: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_mp3?</span>
|
306
|
+
142: <span class="ruby-value str">'/images/file_icons/file_mp3.gif'</span>
|
307
|
+
143: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_excel?</span>
|
308
|
+
144: <span class="ruby-value str">'/images/file_icons/file_xls.gif'</span>
|
309
|
+
145: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_text?</span>
|
310
|
+
146: <span class="ruby-value str">'/images/file_icons/file_txt.gif'</span>
|
311
|
+
147: <span class="ruby-keyword kw">else</span>
|
312
|
+
148: <span class="ruby-value str">'/images/file_icons/file_raw.gif'</span>
|
313
|
+
149: <span class="ruby-keyword kw">end</span>
|
314
|
+
150: <span class="ruby-keyword kw">end</span>
|
315
315
|
</pre>
|
316
316
|
</div>
|
317
317
|
</div>
|
@@ -331,10 +331,10 @@ All the methods available to a record that has had
|
|
331
331
|
onclick="toggleCode('M000024-source');return false;">[Source]</a></p>
|
332
332
|
<div class="method-source-code" id="M000024-source">
|
333
333
|
<pre>
|
334
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
335
|
-
|
336
|
-
|
337
|
-
|
334
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 188</span>
|
335
|
+
188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_ratio</span>
|
336
|
+
189: <span class="ruby-ivar">@image_ratio</span> <span class="ruby-operator">||=</span> <span class="ruby-identifier">width</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">height</span>.<span class="ruby-identifier">to_f</span>
|
337
|
+
190: <span class="ruby-keyword kw">end</span>
|
338
338
|
</pre>
|
339
339
|
</div>
|
340
340
|
</div>
|
@@ -354,10 +354,10 @@ All the methods available to a record that has had
|
|
354
354
|
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
355
355
|
<div class="method-source-code" id="M000012-source">
|
356
356
|
<pre>
|
357
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
358
|
-
|
359
|
-
|
360
|
-
|
357
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 100</span>
|
358
|
+
100: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_excel?</span>
|
359
|
+
101: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">EXCEL_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
360
|
+
102: <span class="ruby-keyword kw">end</span>
|
361
361
|
</pre>
|
362
362
|
</div>
|
363
363
|
</div>
|
@@ -377,10 +377,10 @@ All the methods available to a record that has had
|
|
377
377
|
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
378
378
|
<div class="method-source-code" id="M000010-source">
|
379
379
|
<pre>
|
380
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
381
|
-
|
382
|
-
|
383
|
-
|
380
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 92</span>
|
381
|
+
92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_image?</span>
|
382
|
+
93: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">IMAGE_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
383
|
+
94: <span class="ruby-keyword kw">end</span>
|
384
384
|
</pre>
|
385
385
|
</div>
|
386
386
|
</div>
|
@@ -400,10 +400,10 @@ All the methods available to a record that has had
|
|
400
400
|
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
401
401
|
<div class="method-source-code" id="M000011-source">
|
402
402
|
<pre>
|
403
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
404
|
-
|
405
|
-
|
406
|
-
|
403
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 96</span>
|
404
|
+
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_mp3?</span>
|
405
|
+
97: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">MP3_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
406
|
+
98: <span class="ruby-keyword kw">end</span>
|
407
407
|
</pre>
|
408
408
|
</div>
|
409
409
|
</div>
|
@@ -423,10 +423,10 @@ All the methods available to a record that has had
|
|
423
423
|
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|
424
424
|
<div class="method-source-code" id="M000013-source">
|
425
425
|
<pre>
|
426
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
427
|
-
|
428
|
-
|
429
|
-
|
426
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 104</span>
|
427
|
+
104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_pdf?</span>
|
428
|
+
105: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">PDF_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
429
|
+
106: <span class="ruby-keyword kw">end</span>
|
430
430
|
</pre>
|
431
431
|
</div>
|
432
432
|
</div>
|
@@ -446,10 +446,10 @@ All the methods available to a record that has had
|
|
446
446
|
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
447
447
|
<div class="method-source-code" id="M000015-source">
|
448
448
|
<pre>
|
449
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
450
|
-
|
451
|
-
|
452
|
-
|
449
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 112</span>
|
450
|
+
112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_text?</span>
|
451
|
+
113: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">TEXT_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
452
|
+
114: <span class="ruby-keyword kw">end</span>
|
453
453
|
</pre>
|
454
454
|
</div>
|
455
455
|
</div>
|
@@ -469,10 +469,10 @@ All the methods available to a record that has had
|
|
469
469
|
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
470
470
|
<div class="method-source-code" id="M000014-source">
|
471
471
|
<pre>
|
472
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
473
|
-
|
474
|
-
|
475
|
-
|
472
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 108</span>
|
473
|
+
108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_word?</span>
|
474
|
+
109: <span class="ruby-constant">Uploader</span><span class="ruby-operator">::</span><span class="ruby-constant">MimeTypeGroups</span><span class="ruby-operator">::</span><span class="ruby-constant">WORD_TYPES</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local_content_type</span>)
|
475
|
+
110: <span class="ruby-keyword kw">end</span>
|
476
476
|
</pre>
|
477
477
|
</div>
|
478
478
|
</div>
|
@@ -492,10 +492,10 @@ All the methods available to a record that has had
|
|
492
492
|
onclick="toggleCode('M000023-source');return false;">[Source]</a></p>
|
493
493
|
<div class="method-source-code" id="M000023-source">
|
494
494
|
<pre>
|
495
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
496
|
-
|
497
|
-
|
498
|
-
|
495
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 184</span>
|
496
|
+
184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>)
|
497
|
+
185: <span class="ruby-ivar">@max_dimension</span> <span class="ruby-operator">||=</span> <span class="ruby-constant">Paperclip</span><span class="ruby-operator">::</span><span class="ruby-constant">Geometry</span>.<span class="ruby-identifier">parse</span>(<span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span>.<span class="ruby-identifier">styles</span>[<span class="ruby-identifier">style</span>][<span class="ruby-identifier">:geometry</span>]).<span class="ruby-identifier">width</span>.<span class="ruby-identifier">to_f</span>
|
498
|
+
186: <span class="ruby-keyword kw">end</span>
|
499
499
|
</pre>
|
500
500
|
</div>
|
501
501
|
</div>
|
@@ -515,18 +515,18 @@ All the methods available to a record that has had
|
|
515
515
|
onclick="toggleCode('M000008-source');return false;">[Source]</a></p>
|
516
516
|
<div class="method-source-code" id="M000008-source">
|
517
517
|
<pre>
|
518
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
518
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 75</span>
|
519
|
+
75: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_remote</span>
|
520
|
+
76: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">local_file_name</span>
|
521
|
+
77: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">remote</span> = <span class="ruby-identifier">local</span>.<span class="ruby-identifier">to_file</span>
|
522
|
+
78: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">save</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">remote</span>.<span class="ruby-identifier">original_filename</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">remote</span>.<span class="ruby-identifier">exists?</span>
|
523
|
+
79: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span> = <span class="ruby-keyword kw">nil</span>
|
524
|
+
80: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">save</span>
|
525
|
+
81: <span class="ruby-keyword kw">else</span>
|
526
|
+
82: <span class="ruby-keyword kw">false</span>
|
527
|
+
83: <span class="ruby-keyword kw">end</span>
|
528
|
+
84: <span class="ruby-keyword kw">end</span>
|
529
|
+
85: <span class="ruby-keyword kw">end</span>
|
530
530
|
</pre>
|
531
531
|
</div>
|
532
532
|
</div>
|
@@ -546,13 +546,13 @@ All the methods available to a record that has had
|
|
546
546
|
onclick="toggleCode('M000022-source');return false;">[Source]</a></p>
|
547
547
|
<div class="method-source-code" id="M000022-source">
|
548
548
|
<pre>
|
549
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
549
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 177</span>
|
550
|
+
177: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span>(<span class="ruby-identifier">style</span> = <span class="ruby-identifier">:default</span>)
|
551
|
+
178: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">width</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">height</span>
|
552
|
+
179: <span class="ruby-keyword kw">return</span> <span class="ruby-node">"#{width}x#{height}"</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">style</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:default</span>
|
553
|
+
180: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
554
|
+
181: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_size</span>
|
555
|
+
182: <span class="ruby-keyword kw">end</span>
|
556
556
|
</pre>
|
557
557
|
</div>
|
558
558
|
</div>
|
@@ -572,11 +572,11 @@ All the methods available to a record that has had
|
|
572
572
|
onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
|
573
573
|
<div class="method-source-code" id="M000009-source">
|
574
574
|
<pre>
|
575
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
575
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 87</span>
|
576
|
+
87: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">swfupload_local=</span>(<span class="ruby-identifier">filedata</span>)
|
577
|
+
88: <span class="ruby-identifier">filedata</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-constant">MIME</span><span class="ruby-operator">::</span><span class="ruby-constant">Types</span>.<span class="ruby-identifier">type_for</span>(<span class="ruby-identifier">filedata</span>.<span class="ruby-identifier">original_filename</span>)[<span class="ruby-value">0</span>].<span class="ruby-identifier">to_s</span>
|
578
|
+
89: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span> = <span class="ruby-identifier">filedata</span>
|
579
|
+
90: <span class="ruby-keyword kw">end</span>
|
580
580
|
</pre>
|
581
581
|
</div>
|
582
582
|
</div>
|
@@ -596,24 +596,24 @@ All the methods available to a record that has had
|
|
596
596
|
onclick="toggleCode('M000016-source');return false;">[Source]</a></p>
|
597
597
|
<div class="method-source-code" id="M000016-source">
|
598
598
|
<pre>
|
599
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
599
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 116</span>
|
600
|
+
116: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upload_type</span>
|
601
|
+
117: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_pdf?</span>
|
602
|
+
118: <span class="ruby-value str">'Adobe pdf file'</span>
|
603
|
+
119: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_word?</span>
|
604
|
+
120: <span class="ruby-value str">'Word document'</span>
|
605
|
+
121: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_image?</span>
|
606
|
+
122: <span class="ruby-value str">'photo'</span>
|
607
|
+
123: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_mp3?</span>
|
608
|
+
124: <span class="ruby-value str">'mp3'</span>
|
609
|
+
125: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_excel?</span>
|
610
|
+
126: <span class="ruby-value str">'Excel document'</span>
|
611
|
+
127: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_text?</span>
|
612
|
+
128: <span class="ruby-value str">'text file'</span>
|
613
|
+
129: <span class="ruby-keyword kw">else</span>
|
614
|
+
130: <span class="ruby-value str">'file'</span>
|
615
|
+
131: <span class="ruby-keyword kw">end</span>
|
616
|
+
132: <span class="ruby-keyword kw">end</span>
|
617
617
|
</pre>
|
618
618
|
</div>
|
619
619
|
</div>
|
@@ -636,13 +636,13 @@ Image dimension calculations
|
|
636
636
|
onclick="toggleCode('M000020-source');return false;">[Source]</a></p>
|
637
637
|
<div class="method-source-code" id="M000020-source">
|
638
638
|
<pre>
|
639
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
639
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 163</span>
|
640
|
+
163: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">width</span>(<span class="ruby-identifier">style</span> = <span class="ruby-identifier">:default</span>)
|
641
|
+
164: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:width</span>]
|
642
|
+
165: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:width</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">style</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:default</span>
|
643
|
+
166: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
644
|
+
167: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_width</span>.<span class="ruby-identifier">to_i</span>
|
645
|
+
168: <span class="ruby-keyword kw">end</span>
|
646
646
|
</pre>
|
647
647
|
</div>
|
648
648
|
</div>
|
@@ -664,15 +664,15 @@ Image dimension calculations
|
|
664
664
|
onclick="toggleCode('M000028-source');return false;">[Source]</a></p>
|
665
665
|
<div class="method-source-code" id="M000028-source">
|
666
666
|
<pre>
|
667
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
667
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 223</span>
|
668
|
+
223: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_width_and_height</span>
|
669
|
+
224: <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_image?</span>
|
670
|
+
225: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span>.<span class="ruby-identifier">to_file</span>
|
671
|
+
226: <span class="ruby-identifier">geometry</span> = <span class="ruby-constant">Paperclip</span><span class="ruby-operator">::</span><span class="ruby-constant">Geometry</span>.<span class="ruby-identifier">from_file</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span>.<span class="ruby-identifier">to_file</span>
|
672
|
+
227: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:width</span>] = <span class="ruby-identifier">geometry</span>.<span class="ruby-identifier">width</span>.<span class="ruby-identifier">to_i</span>
|
673
|
+
228: <span class="ruby-keyword kw">self</span>[<span class="ruby-identifier">:height</span>] = <span class="ruby-identifier">geometry</span>.<span class="ruby-identifier">height</span>.<span class="ruby-identifier">to_i</span>
|
674
|
+
229: <span class="ruby-keyword kw">end</span>
|
675
|
+
230: <span class="ruby-keyword kw">end</span>
|
676
676
|
</pre>
|
677
677
|
</div>
|
678
678
|
</div>
|
@@ -692,19 +692,19 @@ Image dimension calculations
|
|
692
692
|
onclick="toggleCode('M000027-source');return false;">[Source]</a></p>
|
693
693
|
<div class="method-source-code" id="M000027-source">
|
694
694
|
<pre>
|
695
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
695
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 210</span>
|
696
|
+
210: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transliterate</span>(<span class="ruby-identifier">str</span>)
|
697
|
+
211: <span class="ruby-comment cmt"># Lifted from permalink_fu by Rick Olsen</span>
|
698
|
+
212: <span class="ruby-comment cmt"># Escape str by transliterating to UTF-8 with Iconv,</span>
|
699
|
+
213: <span class="ruby-comment cmt"># downcasing, then removing illegal characters and replacing them with ’-’</span>
|
700
|
+
214: <span class="ruby-identifier">s</span> = <span class="ruby-constant">Iconv</span>.<span class="ruby-identifier">iconv</span>(<span class="ruby-value str">'ascii//ignore//translit'</span>, <span class="ruby-value str">'utf-8'</span>, <span class="ruby-identifier">str</span>).<span class="ruby-identifier">to_s</span>
|
701
|
+
215: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">downcase!</span>
|
702
|
+
216: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\'/</span>, <span class="ruby-value str">''</span>)
|
703
|
+
217: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/[^A-Za-z0-9]+/</span>, <span class="ruby-value str">' '</span>)
|
704
|
+
218: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">strip!</span>
|
705
|
+
219: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">gsub!</span>(<span class="ruby-regexp re">/\ +/</span>, <span class="ruby-value str">'-'</span>) <span class="ruby-comment cmt"># set single or multiple spaces to a single dash</span>
|
706
|
+
220: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
707
|
+
221: <span class="ruby-keyword kw">end</span>
|
708
708
|
</pre>
|
709
709
|
</div>
|
710
710
|
</div>
|
@@ -724,12 +724,12 @@ Image dimension calculations
|
|
724
724
|
onclick="toggleCode('M000026-source');return false;">[Source]</a></p>
|
725
725
|
<div class="method-source-code" id="M000026-source">
|
726
726
|
<pre>
|
727
|
-
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
727
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 204</span>
|
728
|
+
204: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transliterate_file_name</span>
|
729
|
+
205: <span class="ruby-identifier">extension</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">extname</span>(<span class="ruby-identifier">local_file_name</span>).<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/^\.+/</span>, <span class="ruby-value str">''</span>)
|
730
|
+
206: <span class="ruby-identifier">filename</span> = <span class="ruby-identifier">local_file_name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-node">/\.#{extension}$/</span>, <span class="ruby-value str">''</span>)
|
731
|
+
207: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span>.<span class="ruby-identifier">instance_write</span>(<span class="ruby-identifier">:file_name</span>, <span class="ruby-node">"#{transliterate(filename)}.#{transliterate(extension)}"</span>)
|
732
|
+
208: <span class="ruby-keyword kw">end</span>
|
733
733
|
</pre>
|
734
734
|
</div>
|
735
735
|
</div>
|
data/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Sat, 30 May 2009 09:55:43 -0600
|
data/rdoc/files/README_rdoc.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Thu May 28 19:40:14 -0600 2009</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -87,6 +87,21 @@ sudo gem install uploader
|
|
87
87
|
<p>
|
88
88
|
config.gem ‘uploader‘
|
89
89
|
</p>
|
90
|
+
<h3>Install jQuery</h3>
|
91
|
+
<p>
|
92
|
+
uploader uses jQuery. You‘ll need to include it in your application.
|
93
|
+
Download it here: <a href="http://jquery.com">jquery.com</a>/
|
94
|
+
</p>
|
95
|
+
<p>
|
96
|
+
Then include it in your layout:
|
97
|
+
</p>
|
98
|
+
<pre>
|
99
|
+
<%= javascript_include_tag 'jquery/jquery.js' %>
|
100
|
+
</pre>
|
101
|
+
<p>
|
102
|
+
Another option is to use jRails <a
|
103
|
+
href="http://ennerchi.com/projects/jrails">ennerchi.com/projects/jrails</a>
|
104
|
+
</p>
|
90
105
|
<h3>Create a model for uploads.</h3>
|
91
106
|
<p>
|
92
107
|
We recommend creating a model called upload.rb. acts_as_uploader accepts
|
@@ -94,23 +109,26 @@ all valid options for paperclip via :has_attached_file => {}
|
|
94
109
|
</p>
|
95
110
|
<pre>
|
96
111
|
class Upload < ActiveRecord::Base
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
|
113
|
+
acts_as_uploader :enable_s3 => false,
|
114
|
+
:has_attached_file => {
|
115
|
+
:url => "/system/:attachment/:id_partition/:style/:basename.:extension",
|
116
|
+
:path => ":rails_root/public/system/:attachment/:id_partition/:style/:basename.:extension",
|
117
|
+
:styles => { :icon => "30x30!",
|
118
|
+
:thumb => "100>",
|
119
|
+
:small => "150>",
|
120
|
+
:medium => "300>",
|
121
|
+
:large => "660>" },
|
122
|
+
:default_url => "/images/profile_default.jpg",
|
123
|
+
:storage => :s3,
|
124
|
+
:s3_credentials => AMAZON_S3_CREDENTIALS,
|
125
|
+
:bucket => "assets.example.com",
|
126
|
+
:s3_host_alias => "assets.example.com",
|
127
|
+
:convert_options => {
|
128
|
+
:all => '-quality 80'
|
129
|
+
}
|
130
|
+
},
|
131
|
+
:s3_path => ':id_partition/:style/:basename.:extension'
|
114
132
|
|
115
133
|
# only allow images:
|
116
134
|
# validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg']
|
@@ -183,7 +201,7 @@ the one inside the gem:
|
|
183
201
|
|
184
202
|
class UploadsController < Uploader::UploadsController
|
185
203
|
|
186
|
-
|
204
|
+
prepend_before_filter :login_required
|
187
205
|
|
188
206
|
protected
|
189
207
|
|
@@ -209,6 +227,7 @@ the one inside the gem:
|
|
209
227
|
|
210
228
|
# Simply attempts to redirect to the parent object. You might want to build something more sophisticated that
|
211
229
|
# redirect to different areas of you site depending on the type of object that was uploaded or on based on the parent.
|
230
|
+
# source can be :destroy_success, :create_success, :create_failure, :permission_denied
|
212
231
|
def get_redirect
|
213
232
|
@parent
|
214
233
|
end
|
@@ -228,20 +247,6 @@ the one inside the gem:
|
|
228
247
|
|
229
248
|
end
|
230
249
|
</pre>
|
231
|
-
<h3>Other Methods</h3>
|
232
|
-
<p>
|
233
|
-
uploader assumes that you have a method called
|
234
|
-
‘redirect_back_or_default’ which is common in many Rails
|
235
|
-
projects. This method is called upon completion of destroy or created when
|
236
|
-
the requested format is ‘html’. A simple implementation of this
|
237
|
-
method is listed below:
|
238
|
-
</p>
|
239
|
-
<pre>
|
240
|
-
def redirect_back_or_default(default)
|
241
|
-
redirect_to(session[:return_to] || default)
|
242
|
-
session[:return_to] = nil
|
243
|
-
end
|
244
|
-
</pre>
|
245
250
|
<h3>Configure your views.</h3>
|
246
251
|
<p>
|
247
252
|
You‘ll need something like this in your layout so that uploader can
|
@@ -322,7 +327,76 @@ following lines:
|
|
322
327
|
There are a number of timing issues that you will run into if you attempt
|
323
328
|
to upload files directly to s3. To overcome that problem uploader includes
|
324
329
|
a daemon process which will send the files to Amazon asynchronously. Note
|
325
|
-
that the uploader will leave your local copy in place.
|
330
|
+
that the uploader will leave your local copy in place.
|
331
|
+
</p>
|
332
|
+
<p>
|
333
|
+
Add the daemons gem and plugin:
|
334
|
+
</p>
|
335
|
+
<pre>
|
336
|
+
sudo gem install daemons
|
337
|
+
</pre>
|
338
|
+
<p>
|
339
|
+
Then inside your Rails project:
|
340
|
+
</p>
|
341
|
+
<pre>
|
342
|
+
script/plugin install git://github.com/dougal/daemon_generator.git
|
343
|
+
script/generate daemon amazonaws
|
344
|
+
|
345
|
+
RAILS_ENV=development lib/daemons/mailer_ctl start
|
346
|
+
</pre>
|
347
|
+
<p>
|
348
|
+
Learn more about the custom daemon gem with Ryan Bates screencast:
|
349
|
+
</p>
|
350
|
+
<pre>
|
351
|
+
http://railscasts.com/episodes/129-custom-daemon
|
352
|
+
</pre>
|
353
|
+
<h2>Use Rake to send files to s3</h2>
|
354
|
+
<p>
|
355
|
+
uploader includes a task capable of sending files to s3 but it makes an
|
356
|
+
assumption that the model you are interacting with is named
|
357
|
+
‘Upload’.
|
358
|
+
</p>
|
359
|
+
<pre>
|
360
|
+
rake uploader:upload_to_s3
|
361
|
+
</pre>
|
362
|
+
<p>
|
363
|
+
If you want to use a different model or several models just add a rake task
|
364
|
+
to your project:
|
365
|
+
</p>
|
366
|
+
<pre>
|
367
|
+
desc 'Send all uploads to S3. (Will only send uploads from a model named Upload)'
|
368
|
+
task :upload_to_s3 do
|
369
|
+
|
370
|
+
uploads = Upload.pending_s3_migration
|
371
|
+
uploads.each do |upload|
|
372
|
+
upload.remote = upload.local
|
373
|
+
upload.save!
|
374
|
+
end
|
375
|
+
|
376
|
+
photos = Photo.pending_s3_migration
|
377
|
+
photos.each do |photo|
|
378
|
+
photo.remote = photo.local
|
379
|
+
photo.save!
|
380
|
+
end
|
381
|
+
|
382
|
+
end
|
383
|
+
</pre>
|
384
|
+
<h2>Setup Domains</h2>
|
385
|
+
<p>
|
386
|
+
If you use Amazon‘s S3 service you can setup a cname to clean up your
|
387
|
+
urls. Configure your s3 bucket as above:
|
388
|
+
</p>
|
389
|
+
<pre>
|
390
|
+
:bucket => "assets.example.com"
|
391
|
+
:s3_host_alias => "assets.example.com"
|
392
|
+
</pre>
|
393
|
+
<p>
|
394
|
+
Your assets will be available at assets.example.com.s3.amazon.com. You can
|
395
|
+
then create a CNAME in your DNS entries to point
|
396
|
+
"assets.example.com" to
|
397
|
+
"assets.example.com.s3.amazon.com". Your assets will then appear
|
398
|
+
to be be served from assets.example.com even though they are loaded from
|
399
|
+
Amazon.
|
326
400
|
</p>
|
327
401
|
<h2>Other Stuff</h2>
|
328
402
|
<p>
|
data/rdoc/fr_file_index.html
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
<div id="index-entries">
|
23
23
|
<a href="files/README_rdoc.html">README.rdoc</a><br />
|
24
24
|
<a href="files/lib/active_record/acts/uploader_upload_rb.html">lib/active_record/acts/uploader_upload.rb</a><br />
|
25
|
+
<a href="files/lib/daemons/amazonaws_rb.html">lib/daemons/amazonaws.rb</a><br />
|
25
26
|
<a href="files/lib/uploader_rb.html">lib/uploader.rb</a><br />
|
26
27
|
<a href="files/lib/uploader/exceptions_rb.html">lib/uploader/exceptions.rb</a><br />
|
27
28
|
<a href="files/lib/uploader/initialize_routes_rb.html">lib/uploader/initialize_routes.rb</a><br />
|
data/uploader.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{uploader}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.8"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Justin Ball", "David South"]
|
@@ -172,8 +172,11 @@ Gem::Specification.new do |s|
|
|
172
172
|
s.specification_version = 2
|
173
173
|
|
174
174
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
175
|
+
s.add_runtime_dependency(%q<mime-types>, [">= 0"])
|
175
176
|
else
|
177
|
+
s.add_dependency(%q<mime-types>, [">= 0"])
|
176
178
|
end
|
177
179
|
else
|
180
|
+
s.add_dependency(%q<mime-types>, [">= 0"])
|
178
181
|
end
|
179
182
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -12,8 +12,17 @@ cert_chain: []
|
|
12
12
|
|
13
13
|
date: 2009-05-30 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
|
-
dependencies:
|
16
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: mime-types
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
version:
|
17
26
|
description: Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload and Paperclip
|
18
27
|
email: justinball@gmail.com
|
19
28
|
executables: []
|