uploader 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -1
- data/Rakefile +7 -1
- data/TODO +0 -1
- data/VERSION +1 -1
- data/app/helpers/uploader_helper.rb +2 -2
- data/lib/uploader/middleware/flash_session_cookie_middleware.rb +0 -1
- data/locales/ca.yml +1 -1
- data/locales/de.yml +2 -2
- data/locales/ko.yml +1 -1
- data/locales/lt.yml +1 -1
- data/locales/zh-TW.yml +1 -1
- data/rdoc/classes/ActiveRecord/Acts/UploaderUpload/ClassMethods.html +13 -16
- data/rdoc/classes/ActiveRecord/Acts/UploaderUpload/InstanceMethods.html +162 -162
- data/rdoc/created.rid +1 -1
- data/rdoc/files/README_rdoc.html +14 -1
- data/rdoc/files/lib/active_record/acts/uploader_upload_rb.html +1 -1
- data/test/rails_root/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG +0 -0
- data/uploader.gemspec +3 -4
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -221,7 +221,16 @@ Then inside your Rails project:
|
|
221
221
|
script/plugin install git://github.com/dougal/daemon_generator.git
|
222
222
|
script/generate daemon amazonaws
|
223
223
|
|
224
|
-
|
224
|
+
If you have already run rake uploader:sync it will have already copied a file called amazonaws.rb into lib/daemons. Running
|
225
|
+
script/generate daemon amazonaws will create the other files required to support that process. You will get a prompt "overwrite lib/daemons/amazonaws.rb?".
|
226
|
+
Answer 'n'o as the file is already setup.
|
227
|
+
|
228
|
+
To start the daemon locally:
|
229
|
+
RAILS_ENV=development lib/daemons/amazonaws_ctl start
|
230
|
+
|
231
|
+
|
232
|
+
There is also an app wide control script that you can add to capistrano:
|
233
|
+
./script/daemons [start|stop|restart]
|
225
234
|
|
226
235
|
Learn more about the custom daemon gem with Ryan Bates screencast:
|
227
236
|
http://railscasts.com/episodes/129-custom-daemon
|
data/Rakefile
CHANGED
@@ -22,6 +22,12 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
22
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
23
|
end
|
24
24
|
|
25
|
+
desc 'Translate this gem'
|
26
|
+
task :translate do
|
27
|
+
file = File.join(File.dirname(__FILE__), 'locales', 'en.yml')
|
28
|
+
system("babelphish -o -y #{file}")
|
29
|
+
end
|
30
|
+
|
25
31
|
begin
|
26
32
|
require 'jeweler'
|
27
33
|
Jeweler::Tasks.new do |gemspec|
|
@@ -31,7 +37,7 @@ begin
|
|
31
37
|
gemspec.homepage = "http://github.com/jbasdf/uploader"
|
32
38
|
gemspec.description = "Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload and Paperclip"
|
33
39
|
gemspec.authors = ["Justin Ball", "David South"]
|
34
|
-
gemspec.files.include %w( test/rails_root/db
|
40
|
+
gemspec.files.include %w( test/rails_root/db/schema.rb )
|
35
41
|
gemspec.rubyforge_project = 'uploader'
|
36
42
|
gemspec.add_dependency "mime-types"
|
37
43
|
gemspec.add_dependency "rack"
|
data/TODO
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
@@ -5,9 +5,9 @@ module UploaderHelper
|
|
5
5
|
render :partial => 'uploads/swf_upload', :locals => {:parent => parent, :display_upload_indicators => display_upload_indicators}
|
6
6
|
end
|
7
7
|
|
8
|
-
def new_upload_path_with_session_information(upload_parent)
|
8
|
+
def new_upload_path_with_session_information(upload_parent, format = 'js')
|
9
9
|
session_key = ActionController::Base.session_options[:key]
|
10
|
-
swfupload_uploads_path({session_key => cookies[session_key], request_forgery_protection_token => form_authenticity_token}.merge(make_parent_params(upload_parent)))
|
10
|
+
swfupload_uploads_path({:format => format, session_key => cookies[session_key], request_forgery_protection_token => form_authenticity_token}.merge(make_parent_params(upload_parent)))
|
11
11
|
end
|
12
12
|
|
13
13
|
def make_parent_params(parent)
|
data/locales/ca.yml
CHANGED
@@ -8,7 +8,7 @@ ca:
|
|
8
8
|
javascript_not_enabled: "Ho sentim. SWFUpload no ha pogut carregar. Vostè ha d'activar Javascript per poder gaudir de SWFUpload."
|
9
9
|
missing_parent_id_error: "Si us plau, especifiqueu un objecte pare"
|
10
10
|
permission_denied: "Vostè no té permís per completar aquesta acció."
|
11
|
-
standard_file_upload_error: "
|
11
|
+
standard_file_upload_error: "Ha fallat carregant fitxer {{error}}. Si us plau, assegureu-vos que el fitxer és vàlid. Assegureu-vos que l'arxiu no està buit. Torneu a intentar-ho."
|
12
12
|
successful_upload: "Arxiu pujat amb èxit."
|
13
13
|
swf_loading: "SWFUpload s'està carregant. Si us plau, espereu un moment ..."
|
14
14
|
swf_not_loading: "Ho sentim. SWFUpload no ha pogut carregar. És possible que necessiteu instal lar o actualitzar Flash Player. Visiteu el {{url}} per obtenir el Flash Player."
|
data/locales/de.yml
CHANGED
@@ -5,13 +5,13 @@ de:
|
|
5
5
|
file_delete_permission_denied: "Sie haben keine Berechtigung zum Löschen der Datei."
|
6
6
|
file_deleted: "Gelöschte Datei"
|
7
7
|
file_upload_error: "Fehler beim Hochladen der Datei."
|
8
|
-
javascript_not_enabled: "Es tut uns leid. SWFUpload
|
8
|
+
javascript_not_enabled: "Es tut uns leid. SWFUpload nicht geladen werden konnte. Sie müssen Javascript aktivieren, damit Sie SWFUpload."
|
9
9
|
missing_parent_id_error: "Bitte geben Sie ein Objekt"
|
10
10
|
permission_denied: "Sie haben keine Berechtigung, um diese Aktion."
|
11
11
|
standard_file_upload_error: "Fehler beim Hochladen der Datei: {{error}}. Bitte stellen Sie sicher, dass die Datei gültig ist. Überprüfen Sie, ob Sie die Datei nicht leer ist. Dann versuchen Sie es erneut."
|
12
12
|
successful_upload: "Erfolgreich hochgeladenen Datei."
|
13
13
|
swf_loading: "SWFUpload wird geladen. Bitte einen Moment warten ..."
|
14
|
-
swf_not_loading: "Es tut uns leid. SWFUpload
|
14
|
+
swf_not_loading: "Es tut uns leid. SWFUpload nicht geladen werden konnte. Möglicherweise müssen Sie installieren oder aktualisieren Flash Player. Besuchen Sie die {{url}}, um den Flash Player."
|
15
15
|
swf_taking_to_long: "SWFUpload ist eine lange Zeit zu laden oder die Kraft hat. Bitte stellen Sie sicher, dass das Flash-Plugin aktiviert ist, und dass eine funktionierende Version des Adobe Flash Player installiert ist."
|
16
16
|
upload_file: "Upload File"
|
17
17
|
upload_files: "Dateien hochladen"
|
data/locales/ko.yml
CHANGED
@@ -8,7 +8,7 @@ ko:
|
|
8
8
|
javascript_not_enabled: "죄송합니다. SWFUpload를 로드할 수없습니다. 자바 스크립트를 즐길 수 SWFUpload를 활성화해야합니다."
|
9
9
|
missing_parent_id_error: "부모 개체를 지정하여주십시오"
|
10
10
|
permission_denied: "권한이 작업을 완료하는 데 필요가없습니다."
|
11
|
-
standard_file_upload_error: "파일을 업로드하는 동안 오류가 발생했습니다 : {{error}}. 그 파일이 유효한지 확인하시기 바랍니다. 확인 파일이 비어 있지 않은지 확인합니다.
|
11
|
+
standard_file_upload_error: "파일을 업로드하는 동안 오류가 발생했습니다 : {{error}}. 그 파일이 유효한지 확인하시기 바랍니다. 확인 파일이 비어 있지 않은지 확인합니다. 그런 다음 다시 시도해보십시오."
|
12
12
|
successful_upload: "성공적으로 업로드된 파일입니다."
|
13
13
|
swf_loading: "SWFUpload로드하는 것입니다. 잠시 기다려주십시오 ..."
|
14
14
|
swf_not_loading: "죄송합니다. SWFUpload를 로드할 수없습니다. 플래시 플레이어를 설치하거나 업그레이 드해야 할 수도있습니다. Flash Player를 얻기 위해 {{url}}를 방문하십시오."
|
data/locales/lt.yml
CHANGED
@@ -5,7 +5,7 @@ lt:
|
|
5
5
|
file_delete_permission_denied: "Jūs neturite leidimo, jei norite ištrinti šį failą."
|
6
6
|
file_deleted: "Išbraukta failą"
|
7
7
|
file_upload_error: "Įvyko klaida įkeliant failą."
|
8
|
-
javascript_not_enabled: "Apgailestaujame. SWFUpload nepavyko įkelti. Jūs
|
8
|
+
javascript_not_enabled: "Apgailestaujame. SWFUpload nepavyko įkelti. Jūs turite turėti Javascript, kad galėtumėte mėgautis SWFUpload."
|
9
9
|
missing_parent_id_error: "Nurodykite patronuojanti objektą"
|
10
10
|
permission_denied: "Jūs neturite leidimo atlikti šį veiksmą."
|
11
11
|
standard_file_upload_error: "Įvyko klaida įkeliant failą: {{error}}. Prašome įsitikinti, kad failas yra svarbūs. Įsitikinkite, kad failo nėra tuščias. Tada bandykite dar kartą."
|
data/locales/zh-TW.yml
CHANGED
@@ -10,7 +10,7 @@ zh-TW:
|
|
10
10
|
permission_denied: 您沒有權限,以完成這個動作。
|
11
11
|
standard_file_upload_error: "時發生錯誤的文件上傳: {{error}}.請確保該文件是有效的。檢查以確定該文件不是空的。然後再試一次。"
|
12
12
|
successful_upload: 成功上載文件。
|
13
|
-
swf_loading: SWFUpload
|
13
|
+
swf_loading: SWFUpload是載入中。一會兒請稍候...
|
14
14
|
swf_not_loading: "我們深表歉意。 SWFUpload無法加載。您可能需要安裝或升級的Flash Player 。訪問{{url}}讓Flash Player的。"
|
15
15
|
swf_taking_to_long: "SWFUpload花費很長的時間來加載或加載失敗。請確保啟用Flash插件和一個工作版本的Adobe Flash Player的安裝。"
|
16
16
|
upload_file: 上傳文件
|
@@ -148,24 +148,21 @@ href="ClassMethods.html#M000005">acts_as_uploader</a> :has_attached_file
|
|
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
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:
|
151
|
+
30:
|
152
152
|
31: <span class="ruby-comment cmt"># Paperclip</span>
|
153
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-
|
155
|
-
34:
|
156
|
-
35:
|
157
|
-
36:
|
158
|
-
37: <span class="ruby-keyword kw">
|
159
|
-
38:
|
160
|
-
39:
|
161
|
-
40: <span class="ruby-identifier">
|
162
|
-
41:
|
163
|
-
42:
|
164
|
-
43: <span class="ruby-identifier">
|
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>
|
154
|
+
33: <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>,
|
155
|
+
34: <span class="ruby-identifier">:path</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:s3_path</span>],
|
156
|
+
35: <span class="ruby-identifier">:storage</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">:s3</span>)
|
157
|
+
36:
|
158
|
+
37: <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>
|
159
|
+
38: <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>
|
160
|
+
39:
|
161
|
+
40: <span class="ruby-identifier">class_eval</span> <span class="ruby-value str">"\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>
|
162
|
+
41:
|
163
|
+
42: <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>
|
164
|
+
43: <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>
|
165
|
+
44: <span class="ruby-keyword kw">end</span>
|
169
166
|
</pre>
|
170
167
|
</div>
|
171
168
|
</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 188</span>
|
149
|
+
188: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>)
|
150
|
+
189: <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
|
+
190: <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
|
+
191: <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
|
+
192: <span class="ruby-keyword kw">else</span>
|
154
|
+
193: <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
|
+
194: <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
|
+
195: <span class="ruby-keyword kw">end</span>
|
157
|
+
196: <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
|
+
197: <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 152</span>
|
179
|
+
152: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">can_edit?</span>(<span class="ruby-identifier">check_user</span>)
|
180
|
+
153: <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
|
+
154: <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
|
+
155: <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 148</span>
|
203
|
+
148: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">display_name</span>
|
204
|
+
149: <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
|
+
150: <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 63</span>
|
226
|
+
63: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file</span>
|
227
|
+
64: <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
|
+
65: <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 67</span>
|
249
|
+
67: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">file_name</span>
|
250
|
+
68: <span class="ruby-identifier">remote_file_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">local_file_name</span>
|
251
|
+
69: <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 166</span>
|
272
|
+
166: <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
|
+
167: <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
|
+
168: <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
|
+
169: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
276
|
+
170: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_height</span>.<span class="ruby-identifier">to_i</span>
|
277
|
+
171: <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 130</span>
|
298
|
+
130: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">icon</span>
|
299
|
+
131: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_pdf?</span>
|
300
|
+
132: <span class="ruby-value str">'/images/file_icons/file_pdf.gif'</span>
|
301
|
+
133: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_word?</span>
|
302
|
+
134: <span class="ruby-value str">'/images/file_icons/file_doc.gif'</span>
|
303
|
+
135: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_image?</span>
|
304
|
+
136: <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
|
+
137: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_mp3?</span>
|
306
|
+
138: <span class="ruby-value str">'/images/file_icons/file_mp3.gif'</span>
|
307
|
+
139: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_excel?</span>
|
308
|
+
140: <span class="ruby-value str">'/images/file_icons/file_xls.gif'</span>
|
309
|
+
141: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_text?</span>
|
310
|
+
142: <span class="ruby-value str">'/images/file_icons/file_txt.gif'</span>
|
311
|
+
143: <span class="ruby-keyword kw">else</span>
|
312
|
+
144: <span class="ruby-value str">'/images/file_icons/file_raw.gif'</span>
|
313
|
+
145: <span class="ruby-keyword kw">end</span>
|
314
|
+
146: <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 184</span>
|
335
|
+
184: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_ratio</span>
|
336
|
+
185: <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
|
+
186: <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
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
357
|
+
<span class="ruby-comment cmt"># File lib/active_record/acts/uploader_upload.rb, line 96</span>
|
358
|
+
96: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_excel?</span>
|
359
|
+
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">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
|
+
98: <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 88</span>
|
381
|
+
88: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_image?</span>
|
382
|
+
89: <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
|
+
90: <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 92</span>
|
404
|
+
92: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_mp3?</span>
|
405
|
+
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">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
|
+
94: <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 100</span>
|
427
|
+
100: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_pdf?</span>
|
428
|
+
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">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
|
+
102: <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 108</span>
|
450
|
+
108: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_text?</span>
|
451
|
+
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">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
|
+
110: <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 104</span>
|
473
|
+
104: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_word?</span>
|
474
|
+
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">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
|
+
106: <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 180</span>
|
496
|
+
180: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">max_dimension</span>(<span class="ruby-identifier">style</span>)
|
497
|
+
181: <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
|
+
182: <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 71</span>
|
519
|
+
71: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">send_to_remote</span>
|
520
|
+
72: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">local_file_name</span>
|
521
|
+
73: <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
|
+
74: <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
|
+
75: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span> = <span class="ruby-keyword kw">nil</span>
|
524
|
+
76: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">save</span>
|
525
|
+
77: <span class="ruby-keyword kw">else</span>
|
526
|
+
78: <span class="ruby-keyword kw">false</span>
|
527
|
+
79: <span class="ruby-keyword kw">end</span>
|
528
|
+
80: <span class="ruby-keyword kw">end</span>
|
529
|
+
81: <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 173</span>
|
550
|
+
173: <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
|
+
174: <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
|
+
175: <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
|
+
176: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
554
|
+
177: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_size</span>
|
555
|
+
178: <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 83</span>
|
576
|
+
83: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">swfupload_local=</span>(<span class="ruby-identifier">filedata</span>)
|
577
|
+
84: <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
|
+
85: <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">local</span> = <span class="ruby-identifier">filedata</span>
|
579
|
+
86: <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 112</span>
|
600
|
+
112: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">upload_type</span>
|
601
|
+
113: <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_pdf?</span>
|
602
|
+
114: <span class="ruby-value str">'Adobe pdf file'</span>
|
603
|
+
115: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_word?</span>
|
604
|
+
116: <span class="ruby-value str">'Word document'</span>
|
605
|
+
117: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_image?</span>
|
606
|
+
118: <span class="ruby-value str">'photo'</span>
|
607
|
+
119: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_mp3?</span>
|
608
|
+
120: <span class="ruby-value str">'mp3'</span>
|
609
|
+
121: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_excel?</span>
|
610
|
+
122: <span class="ruby-value str">'Excel document'</span>
|
611
|
+
123: <span class="ruby-keyword kw">elsif</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">is_text?</span>
|
612
|
+
124: <span class="ruby-value str">'text file'</span>
|
613
|
+
125: <span class="ruby-keyword kw">else</span>
|
614
|
+
126: <span class="ruby-value str">'file'</span>
|
615
|
+
127: <span class="ruby-keyword kw">end</span>
|
616
|
+
128: <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 159</span>
|
640
|
+
159: <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
|
+
160: <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
|
+
161: <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
|
+
162: <span class="ruby-identifier">calculate_sizes</span>(<span class="ruby-identifier">style</span>.<span class="ruby-identifier">to_sym</span>)
|
644
|
+
163: <span class="ruby-keyword kw">return</span> <span class="ruby-ivar">@image_width</span>.<span class="ruby-identifier">to_i</span>
|
645
|
+
164: <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 219</span>
|
668
|
+
219: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_width_and_height</span>
|
669
|
+
220: <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
|
+
221: <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
|
+
222: <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
|
+
223: <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
|
+
224: <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
|
+
225: <span class="ruby-keyword kw">end</span>
|
675
|
+
226: <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 206</span>
|
696
|
+
206: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transliterate</span>(<span class="ruby-identifier">str</span>)
|
697
|
+
207: <span class="ruby-comment cmt"># Lifted from permalink_fu by Rick Olsen</span>
|
698
|
+
208: <span class="ruby-comment cmt"># Escape str by transliterating to UTF-8 with Iconv,</span>
|
699
|
+
209: <span class="ruby-comment cmt"># downcasing, then removing illegal characters and replacing them with ’-’</span>
|
700
|
+
210: <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
|
+
211: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">downcase!</span>
|
702
|
+
212: <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
|
+
213: <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
|
+
214: <span class="ruby-identifier">s</span>.<span class="ruby-identifier">strip!</span>
|
705
|
+
215: <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
|
+
216: <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">s</span>
|
707
|
+
217: <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 200</span>
|
728
|
+
200: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">transliterate_file_name</span>
|
729
|
+
201: <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
|
+
202: <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
|
+
203: <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
|
+
204: <span class="ruby-keyword kw">end</span>
|
733
733
|
</pre>
|
734
734
|
</div>
|
735
735
|
</div>
|
data/rdoc/created.rid
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Thu, 04 Jun 2009
|
1
|
+
Thu, 04 Jun 2009 15:46:42 -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 Jun 04 15:26:03 -0600 2009</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -134,6 +134,9 @@ all valid options for paperclip via :has_attached_file => {}
|
|
134
134
|
# only allow images:
|
135
135
|
# validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg']
|
136
136
|
|
137
|
+
# limit uploads to 10 MB
|
138
|
+
# validates_attachment_size :local, :less_than => 10.megabytes
|
139
|
+
|
137
140
|
# The following method is implemented in 'acts_as_uploader'. This is the method destroy will check to see if
|
138
141
|
# the user has permission to delete the object. Add additional logic as needed or if the existing logic
|
139
142
|
# looks fine then feel free to delete this comment and the can_edit? method.
|
@@ -464,6 +467,16 @@ The following jQuery code will do an ajax delete for you
|
|
464
467
|
});
|
465
468
|
}
|
466
469
|
</pre>
|
470
|
+
<h3>Testing</h3>
|
471
|
+
<p>
|
472
|
+
If you intend to develop code and wish to run the tests you may do so using
|
473
|
+
rake test. However, note that you will need to install the gem first using
|
474
|
+
rake install since the embedded test application will use the gem that is
|
475
|
+
install and not the current code from the project. This is a limitation I
|
476
|
+
attempted to overcome using a special initializer in
|
477
|
+
rails_root/config/initializers/uploader.rb but I didn‘t have any
|
478
|
+
success getting it working.
|
479
|
+
</p>
|
467
480
|
<p>
|
468
481
|
Copyright (c) 2009 Justin Ball, released under the MIT license
|
469
482
|
</p>
|
Binary file
|
data/uploader.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
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.16"
|
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"]
|
9
|
-
s.date = %q{2009-06-
|
9
|
+
s.date = %q{2009-06-20}
|
10
10
|
s.description = %q{Uploader gem that makes it simple add multiple file uploads to your Rails project using SWFUpload and Paperclip}
|
11
11
|
s.email = %q{justinball@gmail.com}
|
12
12
|
s.extra_rdoc_files = [
|
@@ -178,12 +178,10 @@ Gem::Specification.new do |s|
|
|
178
178
|
"test/rails_root/config/routes.rb",
|
179
179
|
"test/rails_root/db/.keep",
|
180
180
|
"test/rails_root/db/development.sqlite3",
|
181
|
-
"test/rails_root/db/development.sqlite3",
|
182
181
|
"test/rails_root/db/migrate/20090517040220_create_uploads.rb",
|
183
182
|
"test/rails_root/db/migrate/20090602041838_create_users.rb",
|
184
183
|
"test/rails_root/db/schema.rb",
|
185
184
|
"test/rails_root/db/test.sqlite3",
|
186
|
-
"test/rails_root/db/test.sqlite3",
|
187
185
|
"test/rails_root/features/step_definitions/webrat_steps.rb",
|
188
186
|
"test/rails_root/features/support/env.rb",
|
189
187
|
"test/rails_root/public/.htaccess",
|
@@ -223,6 +221,7 @@ Gem::Specification.new do |s|
|
|
223
221
|
"test/rails_root/script/server",
|
224
222
|
"test/rails_root/test/factories.rb",
|
225
223
|
"test/rails_root/test/fixtures/files/5k.png",
|
224
|
+
"test/rails_root/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG",
|
226
225
|
"test/rails_root/test/functional/.keep",
|
227
226
|
"test/rails_root/test/functional/uploads_controller_test.rb",
|
228
227
|
"test/rails_root/test/integration/.keep",
|
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.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-06-
|
13
|
+
date: 2009-06-20 00:00:00 -06:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- test/rails_root/script/server
|
251
251
|
- test/rails_root/test/factories.rb
|
252
252
|
- test/rails_root/test/fixtures/files/5k.png
|
253
|
+
- test/rails_root/test/fixtures/files/IT'sUPPERCASE!AND WeIRD.JPG
|
253
254
|
- test/rails_root/test/functional/.keep
|
254
255
|
- test/rails_root/test/functional/uploads_controller_test.rb
|
255
256
|
- test/rails_root/test/integration/.keep
|