upload_juicer 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -48,7 +48,7 @@ API key) to the `info` method. The return hash would look exactly like the
|
|
48
48
|
hash you got back from `submit`, but hopefully the status will now be
|
49
49
|
"finished" rather than "queued" (or "failed").
|
50
50
|
|
51
|
-
# Using Juicer with Rails
|
51
|
+
# Using Juicer with Rails
|
52
52
|
|
53
53
|
The intended usage is to have your users upload files directly to S3 via
|
54
54
|
swfupload, create an UploadJuicer::Upload record via ajax once the upload is
|
@@ -118,6 +118,8 @@ the form is submitted to associated the UploadJuicer::Upload with the Person.
|
|
118
118
|
The Uploads helper provides the `swfupload_params` method, which does all the
|
119
119
|
request signing, etc. that S3 requires.
|
120
120
|
|
121
|
+
By the way, for Rails 2 change that `<%= form_for` to `<% form_for`.
|
122
|
+
|
121
123
|
### app/models/person.rb
|
122
124
|
|
123
125
|
class Person < ActiveRecord::Base
|
@@ -144,7 +146,7 @@ partitioned paths for the files in your S3 bucket like so:
|
|
144
146
|
Avatar: http://s3.amazonaws.com/your_bucket/34j/e8r/9fu/avatar/file_name.jpg
|
145
147
|
Thumb: http://s3.amazonaws.com/your_bucket/34j/e8r/9fu/thumb/file_name.jpg
|
146
148
|
|
147
|
-
### app/views/
|
149
|
+
### app/views/people/show.html.erb
|
148
150
|
|
149
151
|
<h1><%= @person.name %></h1>
|
150
152
|
<p>Avatar: <%= image_tag(@person.image.url(:avatar)) %></p>
|
@@ -153,3 +155,42 @@ partitioned paths for the files in your S3 bucket like so:
|
|
153
155
|
|
154
156
|
This view shows how to get the publicly-readable S3 URLs from the
|
155
157
|
UploadJuicer::Upload record associated with the Person.
|
158
|
+
|
159
|
+
Just for completeness' sake, here's a minimal People controller, and a sample
|
160
|
+
layout that includes jquery and the two yields the new view needs:
|
161
|
+
|
162
|
+
### app/controllers/people\_controller.rb
|
163
|
+
|
164
|
+
|
165
|
+
class PeopleController < ApplicationController
|
166
|
+
before_filter :build_person, :only => [ :new, :create ]
|
167
|
+
helper :uploads
|
168
|
+
|
169
|
+
def create
|
170
|
+
@person.save
|
171
|
+
redirect_to :action => "show", :id => @person
|
172
|
+
end
|
173
|
+
|
174
|
+
def show
|
175
|
+
@person = Person.find(params[:id])
|
176
|
+
end
|
177
|
+
|
178
|
+
protected
|
179
|
+
|
180
|
+
def build_person
|
181
|
+
@person = Person.new(params[:person])
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
### app/views/layouts/application.html.erb
|
186
|
+
|
187
|
+
<html>
|
188
|
+
<head>
|
189
|
+
<%= yield :head %>
|
190
|
+
</head>
|
191
|
+
<body>
|
192
|
+
<%= yield %>
|
193
|
+
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' %>
|
194
|
+
<%= yield :foot %>
|
195
|
+
</body>
|
196
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -14,7 +14,7 @@ class UploadJuicerGenerator < Rails::Generators::Base
|
|
14
14
|
class_option :heroku, :type => :boolean, :desc => "Use the Heroku addon to provide your Juicer API key"
|
15
15
|
|
16
16
|
def self.source_root
|
17
|
-
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
17
|
+
@source_root ||= File.join(File.dirname(__FILE__), '..', '..', '..', 'generators', 'upload_juicer', 'templates')
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.next_migration_number(dirname)
|
data/lib/upload_juicer.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: upload_juicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 61
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
9
|
+
- 3
|
10
|
+
version: 0.9.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Benjamin Curtis
|
@@ -21,9 +22,11 @@ dependencies:
|
|
21
22
|
name: rest-client
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
27
30
|
segments:
|
28
31
|
- 0
|
29
32
|
version: "0"
|
@@ -33,9 +36,11 @@ dependencies:
|
|
33
36
|
name: json
|
34
37
|
prerelease: false
|
35
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
41
|
- - ">="
|
38
42
|
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
39
44
|
segments:
|
40
45
|
- 0
|
41
46
|
version: "0"
|
@@ -51,8 +56,6 @@ extensions: []
|
|
51
56
|
extra_rdoc_files: []
|
52
57
|
|
53
58
|
files:
|
54
|
-
- lib/generators/upload_juicer/templates/initializer.rb
|
55
|
-
- lib/generators/upload_juicer/templates/migration.rb
|
56
59
|
- lib/generators/upload_juicer/upload_juicer_generator.rb
|
57
60
|
- lib/upload_juicer/engine.rb
|
58
61
|
- lib/upload_juicer/extensions/string.rb
|
@@ -75,16 +78,20 @@ rdoc_options: []
|
|
75
78
|
require_paths:
|
76
79
|
- lib
|
77
80
|
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
78
82
|
requirements:
|
79
83
|
- - ">="
|
80
84
|
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
81
86
|
segments:
|
82
87
|
- 0
|
83
88
|
version: "0"
|
84
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
85
91
|
requirements:
|
86
92
|
- - ">="
|
87
93
|
- !ruby/object:Gem::Version
|
94
|
+
hash: 23
|
88
95
|
segments:
|
89
96
|
- 1
|
90
97
|
- 3
|
@@ -93,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
100
|
requirements: []
|
94
101
|
|
95
102
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.3.
|
103
|
+
rubygems_version: 1.3.7
|
97
104
|
signing_key:
|
98
105
|
specification_version: 3
|
99
106
|
summary: UploadJuicer juices up your images!
|
@@ -1 +0,0 @@
|
|
1
|
-
UploadJuicer::Config.api_key = <%= api_key_fetcher %>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class CreateUploadTables < ActiveRecord::Migration
|
2
|
-
def self.up
|
3
|
-
create_table :upload_juicer_uploads do |t|
|
4
|
-
t.string :file_name
|
5
|
-
t.string :key
|
6
|
-
t.integer :size
|
7
|
-
t.integer :uploadable_id
|
8
|
-
t.string :uploadable_type
|
9
|
-
|
10
|
-
t.timestamps
|
11
|
-
end
|
12
|
-
|
13
|
-
add_index :upload_juicer_uploads, :key
|
14
|
-
add_index :upload_juicer_uploads, [:uploadable_id, :uploadable_type]
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.down
|
18
|
-
drop_table :upload_juicer_uploads
|
19
|
-
end
|
20
|
-
end
|