radiant-assets-extension 0.0.7 → 0.0.10
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/README.rdoc +58 -5
- data/app/models/asset.rb +6 -1
- data/app/models/asset_tags.rb +129 -43
- data/app/models/attachment.rb +13 -5
- data/app/views/admin/assets/_attachments.html.erb +32 -23
- data/app/views/admin/assets/edit.html.erb +4 -4
- data/app/views/admin/assets/remove.html.erb +4 -4
- data/assets_extension.rb +9 -3
- data/db/migrate/20110321005357_make_attachments_polymorphic.rb +17 -0
- data/lib/radiant-assets-extension.rb +2 -1
- data/lib/radiant-assets-extension/s3_store.rb +1 -1
- data/public/stylesheets/admin/extensions/assets/assets.css +8 -0
- data/radiant-assets-extension.gemspec +1 -1
- metadata +6 -6
- data/lib/radiant-assets-extension/version.rb +0 -3
data/README.rdoc
CHANGED
@@ -1,22 +1,75 @@
|
|
1
1
|
= Assets
|
2
2
|
|
3
|
-
Provides simple image handling
|
3
|
+
Provides simple image/attachment handling. Intended as a
|
4
4
|
replacement for paperclipped in the long run, but very barebones right now.
|
5
5
|
|
6
|
-
|
6
|
+
Features:
|
7
7
|
|
8
|
-
|
8
|
+
* Supports uploading of images as well as other files.
|
9
|
+
* Uploading of multiple files at once
|
10
|
+
* On-the-fly resizing of images to arbitrary sizes
|
11
|
+
* Easy Attachment of assets to pages (and reordering them)
|
9
12
|
|
10
|
-
|
13
|
+
== Example Radius Tags
|
14
|
+
|
15
|
+
<r:image size="300x" />
|
11
16
|
|
12
17
|
Proportionally resizes an image to 300px width. Supports imagemagick geometry
|
13
18
|
strings to do advanced resizing straight in Radius tags. Resized images are
|
14
19
|
cached in Radiant's built-in cache so they don't have to be re-created on every
|
15
20
|
request.
|
16
21
|
|
22
|
+
<r:assets:caption />
|
23
|
+
|
24
|
+
Renders the current asset’s caption
|
25
|
+
|
26
|
+
<r:attachments:each />
|
27
|
+
|
28
|
+
Cycles through all assets that are attached to the current page
|
29
|
+
|
30
|
+
== Configuration
|
31
|
+
|
32
|
+
You can change the behaviour of this extension using a number of Radiant settings.
|
33
|
+
|
34
|
+
===assets.host
|
35
|
+
|
36
|
+
If this is set (defaults to not being set), the hostname given will be
|
37
|
+
inserted into all URLs generated by the assets extension. If you set up a
|
38
|
+
CNAME record in DNS that points to the Radiant app itself, this can improve
|
39
|
+
performance of the site by enabling browser to download assets in parallel. It
|
40
|
+
can also be used to configure a CDN such as Amazon’s CloudFront.
|
41
|
+
|
42
|
+
You will need to make sure this hostname points to the right content yourself.
|
43
|
+
|
44
|
+
Example:
|
45
|
+
|
46
|
+
Radiant::Config['assets.host'] = 'cdn.example.com'
|
47
|
+
|
48
|
+
===assets.storage
|
49
|
+
|
50
|
+
This defaults to 'file'. Set this to 's3' to store all uploads in Amazon's S3
|
51
|
+
service. You will need to supply your Amazon AWS credentials as +s3.key+ and
|
52
|
+
+s3.secret+
|
53
|
+
|
54
|
+
Example:
|
55
|
+
|
56
|
+
Radiant::Config['assets.storage'] = 's3'
|
57
|
+
Radiant::Config['s3.key'] = 'asd123asdklj'
|
58
|
+
Radiant::Config['s3.secret'] = 'a1678123bcd123123efasdc'
|
59
|
+
|
60
|
+
===s3.bucket
|
61
|
+
|
62
|
+
Set this to the s3 bucket name you want to use. If you don't set this, a
|
63
|
+
bucket named "radiant-assets-extension" will be created and used.
|
64
|
+
|
65
|
+
===s3.host
|
66
|
+
|
67
|
+
If your bucket is located in a region other than the Amazon default of
|
68
|
+
us-east-1, set this to the appropriate host, e.g. +s3-eu-west-1.amazonaws.com+
|
69
|
+
for the EU (Ireland) region.
|
70
|
+
|
17
71
|
== Todo
|
18
72
|
|
19
|
-
- Attaching Assets to Pages
|
20
73
|
- Easy/Automatic migration from paperclipped (currently this extension should
|
21
74
|
only be used on “fresh” radiant sites w/o an asset management solution
|
22
75
|
already in place)
|
data/app/models/asset.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class Asset < ActiveRecord::Base
|
2
|
-
has_many :attachments, :
|
2
|
+
has_many :attachments, :as => :attachable, :dependent => :destroy
|
3
|
+
|
3
4
|
# HACK: incomplete
|
4
5
|
AUDIO_FORMATS = [:wav, :mp3, :m4a, :ogg]
|
5
6
|
VIDEO_FORMATS = [:mp4, :avi]
|
@@ -8,6 +9,10 @@ class Asset < ActiveRecord::Base
|
|
8
9
|
validates_presence_of :upload
|
9
10
|
delegate :url, :width, :height, :landscape, :portrait, :to => :upload
|
10
11
|
|
12
|
+
def page_attachments
|
13
|
+
attachments.select(&:attached_to_page?)
|
14
|
+
end
|
15
|
+
|
11
16
|
def uploads
|
12
17
|
[]
|
13
18
|
end
|
data/app/models/asset_tags.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module AssetTags
|
2
2
|
include Radiant::Taggable
|
3
|
-
|
4
3
|
class TagError < StandardError;end
|
5
4
|
|
6
5
|
desc %{
|
7
|
-
Renders an image tag
|
6
|
+
Renders an image tag for the current asset (if it’s an image)
|
7
|
+
|
8
|
+
You can resize the image using the @width@, @height@ and @size@ attributes.
|
9
|
+
|
10
|
+
Using @width@ and/or @height@ will resize the image to the specified
|
11
|
+
width/height maintaining the aspect ratio. For more complex resizing operations
|
12
|
+
you can use the @size@ attribute which will override any supplied
|
13
|
+
width/height attributes.
|
8
14
|
|
9
15
|
Examples of possible values for the @size@ attribute
|
10
16
|
|
@@ -22,77 +28,102 @@ module AssetTags
|
|
22
28
|
'400x300se' crop, with south-east gravity
|
23
29
|
'400x300+50+100' crop from the point 50,100 with width, height 400,300
|
24
30
|
|
25
|
-
|
31
|
+
*Usage:*
|
32
|
+
|
33
|
+
<pre><code><r:image id="2" [width="200"] [height="400"] [size="400x200"] /></code></pre>
|
26
34
|
}
|
27
|
-
# TODO: accept width/height attributes and do something sensible like
|
28
|
-
# resizing proportionally
|
29
35
|
tag 'image' do |tag|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
36
|
+
assign_asset_and_upload!(tag)
|
37
|
+
if tag.locals.asset.image?
|
38
|
+
img = (tag.locals.asset_upload ||= tag.locals.asset.upload)
|
39
|
+
fill_dimension_attributes!(tag)
|
40
|
+
%{<img src="#{img.url}"#{html_attr_string(tag.attr.except('size'))}>}
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
44
|
desc %{
|
37
45
|
Selects an asset. Does not render anything itself but gives access to the
|
38
|
-
asset's attributes such as
|
46
|
+
asset's attributes such as @caption@, @url@ and @width@/@height@
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
tag.locals.asset = find_asset(tag)
|
44
|
-
tag.expand
|
45
|
-
end
|
46
|
-
|
47
|
-
desc %{
|
48
|
-
Renders the URL of an asset
|
48
|
+
Accepts optional @size@ parameter in which case, if the asset is an image,
|
49
|
+
the asset is resized and any child @url@, @width@ and @height@ tags will refer
|
50
|
+
to the resized image.
|
49
51
|
|
50
|
-
|
51
|
-
the URL to a resized version of the image will be returned
|
52
|
+
*Usage:*
|
52
53
|
|
53
|
-
<r:asset
|
54
|
+
<pre><code><r:asset id="22" [size="200x200"]>...</r:asset></code></pre>
|
55
|
+
|
56
|
+
*Examples:*
|
57
|
+
|
58
|
+
Will render URL to original uploaded file
|
59
|
+
<pre><code><r:asset id="66"><r:url /></r:asset></code></pre>
|
60
|
+
|
61
|
+
Will render render height of resized image (500)
|
62
|
+
<pre><code><r:asset id="66" size="x500">New Height: <r:height />px</r:asset></code></pre>
|
54
63
|
}
|
55
|
-
tag 'asset
|
56
|
-
|
57
|
-
|
64
|
+
tag 'asset' do |tag|
|
65
|
+
assign_asset_and_upload!(tag)
|
66
|
+
tag.expand
|
58
67
|
end
|
59
68
|
|
60
|
-
|
69
|
+
# NOTE: width/height tags require analysing the image if you resized it
|
70
|
+
# this can be quite slow. Avoid using with resized images.
|
71
|
+
%w[url width height].each do |attribute|
|
61
72
|
desc %{
|
62
73
|
Renders the #{attribute} of the current asset
|
74
|
+
|
75
|
+
Accepts optional size parameter in which case, if the asset is an image,
|
76
|
+
the #{attribute} to a resized version of the image will be returned.
|
77
|
+
|
78
|
+
*Usage:*
|
79
|
+
|
80
|
+
<pre><code><r:asset:#{attribute} [size="200x200"] id="22" /></code></pre>
|
63
81
|
}
|
64
82
|
tag "asset:#{attribute}" do |tag|
|
65
|
-
tag
|
83
|
+
assign_asset_and_upload!(tag)
|
84
|
+
(tag.locals.asset_upload ||= tag.locals.asset.upload).send(attribute.to_sym)
|
66
85
|
end
|
67
86
|
end
|
87
|
+
|
88
|
+
desc %{
|
89
|
+
Renders the caption of the current asset
|
90
|
+
}
|
91
|
+
tag 'asset:caption' do |tag|
|
92
|
+
assign_asset_and_upload!(tag)
|
93
|
+
tag.locals.asset.caption
|
94
|
+
end
|
68
95
|
|
69
96
|
desc %{
|
70
|
-
Renders contents if the current asset is an image
|
97
|
+
Renders its contents if the current asset is an image
|
71
98
|
}
|
72
99
|
tag 'asset:if_image' do |tag|
|
100
|
+
assign_asset_and_upload!(tag)
|
73
101
|
tag.expand if tag.locals.asset.image?
|
74
102
|
end
|
75
103
|
|
76
104
|
desc %{
|
77
|
-
Renders contents if the current asset isn't an image
|
105
|
+
Renders its contents if the current asset isn't an image
|
78
106
|
}
|
79
107
|
tag 'asset:unless_image' do |tag|
|
108
|
+
assign_asset_and_upload!(tag)
|
80
109
|
tag.expand unless tag.locals.asset.image?
|
81
110
|
end
|
82
111
|
|
83
112
|
%w[landscape portrait].each do |orientation|
|
84
113
|
desc %{
|
85
|
-
Renders contents if the current image is in #{orientation} orientation
|
114
|
+
Renders its contents if the current image is in #{orientation} orientation
|
86
115
|
}
|
87
116
|
tag "asset:if_#{orientation}" do |tag|
|
88
|
-
tag
|
117
|
+
assign_asset_and_upload!(tag)
|
118
|
+
tag.expand if (tag.locals.asset_upload ||= tag.locals.asset.upload).send "#{orientation}?".to_sym
|
89
119
|
end
|
90
120
|
|
91
121
|
desc %{
|
92
|
-
Renders contents if the current image isn't in #{orientation} orientation
|
122
|
+
Renders its contents if the current image isn't in #{orientation} orientation
|
93
123
|
}
|
94
124
|
tag "asset:unless_#{orientation}" do |tag|
|
95
|
-
tag
|
125
|
+
assign_asset_and_upload!(tag)
|
126
|
+
tag.expand unless (tag.locals.asset_upload ||= tag.locals.asset.upload).send "#{orientation}?".to_sym
|
96
127
|
end
|
97
128
|
end
|
98
129
|
|
@@ -102,16 +133,39 @@ module AssetTags
|
|
102
133
|
end
|
103
134
|
|
104
135
|
desc %{
|
105
|
-
|
136
|
+
Renders the tag’s contents if the page has any assets attached.
|
137
|
+
}
|
138
|
+
tag 'if_attachments' do |tag|
|
139
|
+
tag.expand if tag.locals.page.attachments.any?
|
140
|
+
end
|
141
|
+
|
142
|
+
desc %{
|
143
|
+
Renders the tag’s contents if the page has no assets attached.
|
144
|
+
}
|
145
|
+
tag 'unless_attachments' do |tag|
|
146
|
+
tag.expand unless tag.locals.page.attachments.any?
|
147
|
+
end
|
148
|
+
|
149
|
+
desc %{
|
150
|
+
Renders the tag‘s contents with the first attached asset of the current
|
151
|
+
page selected.
|
152
|
+
|
106
153
|
If there are no assets on the page, nothing is rendered.
|
107
154
|
}
|
108
155
|
tag 'attachments:first' do |tag|
|
109
156
|
if attachment = tag.locals.page.attachments.first
|
157
|
+
tag.locals.attachment = attachment
|
110
158
|
tag.locals.asset = attachment.asset
|
111
159
|
tag.expand
|
112
160
|
end
|
113
161
|
end
|
114
162
|
|
163
|
+
|
164
|
+
desc %{
|
165
|
+
Cycles through the attachments of the current page and renders the tag’s
|
166
|
+
contents for each of them.
|
167
|
+
}
|
168
|
+
# TODO: arbitrary ordering and limiting
|
115
169
|
tag 'attachments:each' do |tag|
|
116
170
|
tag.locals.page.attachments.collect do |attachment|
|
117
171
|
tag.locals.attachment = attachment
|
@@ -121,20 +175,52 @@ module AssetTags
|
|
121
175
|
end
|
122
176
|
|
123
177
|
private
|
124
|
-
def
|
125
|
-
|
126
|
-
|
127
|
-
|
178
|
+
def assign_asset_and_upload!(tag)
|
179
|
+
assign_asset!(tag)
|
180
|
+
assign_upload!(tag)
|
181
|
+
end
|
182
|
+
|
183
|
+
def assign_asset!(tag)
|
184
|
+
if tag.attr['id']
|
185
|
+
tag.locals.asset = Asset.find(tag.attr['id'])
|
186
|
+
else
|
187
|
+
tag.locals.asset || raise(TagError, 'Please supply an id attribute')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def fill_dimension_attributes!(tag)
|
192
|
+
# Can't use aspect_ratio here because it's not cached on the model
|
193
|
+
# Using it would require analysing the image which we want to postpone
|
194
|
+
# The original height/width are cached on upload though
|
195
|
+
aspect_ratio = tag.locals.asset.width.to_f / tag.locals.asset.height.to_f
|
196
|
+
if tag.attr['width'] && tag.attr['height']
|
197
|
+
return
|
198
|
+
elsif tag.attr['width']
|
199
|
+
tag.attr['height'] = (tag.attr['width'].to_i / aspect_ratio).to_i
|
200
|
+
elsif h = tag.attr['height']
|
201
|
+
tag.attr['width'] = (tag.attr['height'].to_i * aspect_ratio).to_i
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
def assign_upload!(tag)
|
206
|
+
tag.attr['size'] ||= build_geometry_string(tag.attr['width'], tag.attr['height'])
|
207
|
+
tag.locals.asset_upload = if tag.attr['size']
|
208
|
+
tag.locals.asset.upload.process(:resize, tag.attr['size'])
|
209
|
+
end
|
128
210
|
end
|
129
211
|
|
130
|
-
def
|
131
|
-
if
|
132
|
-
|
212
|
+
def build_geometry_string(width, height)
|
213
|
+
if width && height
|
214
|
+
"#{width}x#{height}"
|
215
|
+
elsif width
|
216
|
+
"#{width}x"
|
217
|
+
elsif height
|
218
|
+
"x#{height}"
|
133
219
|
end
|
134
220
|
end
|
135
221
|
|
136
|
-
def
|
137
|
-
attributes =
|
222
|
+
def html_attr_string(hash)
|
223
|
+
attributes = hash.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
|
138
224
|
" #{attributes}" unless attributes.empty?
|
139
225
|
end
|
140
226
|
end
|
data/app/models/attachment.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'acts_as_list'
|
2
2
|
|
3
3
|
class Attachment < ActiveRecord::Base
|
4
|
-
belongs_to :
|
5
|
-
belongs_to :
|
4
|
+
belongs_to :attachable, :polymorphic => true, :autosave => true
|
5
|
+
belongs_to :parent, :polymorphic => true
|
6
6
|
|
7
|
-
acts_as_list :scope => :
|
7
|
+
acts_as_list :scope => :parent_id
|
8
8
|
|
9
9
|
def self.reorder(new_order)
|
10
10
|
new_order.each_with_index do |id, index|
|
@@ -13,11 +13,19 @@ class Attachment < ActiveRecord::Base
|
|
13
13
|
new_order
|
14
14
|
end
|
15
15
|
|
16
|
+
def attached_to_page?
|
17
|
+
parent_type == 'Page'
|
18
|
+
end
|
19
|
+
|
20
|
+
def asset
|
21
|
+
attachable if attachable_type == 'Asset'
|
22
|
+
end
|
23
|
+
|
16
24
|
def uploads=(new_uploads)
|
17
|
-
(
|
25
|
+
(self.attachable ||= Asset.new).uploads=new_uploads
|
18
26
|
end
|
19
27
|
|
20
28
|
def uploads
|
21
|
-
(
|
29
|
+
(self.attachable ||= Asset.new).uploads
|
22
30
|
end
|
23
31
|
end
|
@@ -1,23 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
</
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
<%#
|
2
|
+
HACK: when page isn't saved there isnt a way to associate uploaded images
|
3
|
+
saving uploads temporarily and associating them on save is messy, but
|
4
|
+
should be the way to go
|
5
|
+
%>
|
6
|
+
<% unless @page.new_record? %>
|
7
|
+
<h2>Attachments</h2>
|
8
|
+
|
9
|
+
<%= render :partial => 'admin/assets/upload', :locals => {:record => @page.attachments.build, :url => admin_page_attachments_path(@page)} %>
|
10
|
+
|
11
|
+
<ul id="assets">
|
12
|
+
<%= render :partial => 'admin/assets/attachment', :collection => @page.attachments.reject(&:new_record?) %>
|
13
|
+
</ul>
|
14
|
+
|
15
|
+
<script type="text/javascript">
|
16
|
+
(function($) {
|
17
|
+
$(function() {
|
18
|
+
$('#assets').sortable({
|
19
|
+
update: function(event, ui) {
|
20
|
+
$.ajax({
|
21
|
+
type: "POST",
|
22
|
+
url: '<%= positions_admin_page_attachments_path(@page) %>',
|
23
|
+
data: '_method=PUT&'+$(this).sortable('serialize'),
|
24
|
+
});
|
25
|
+
}
|
26
|
+
}).disableSelection();
|
27
|
+
});
|
28
|
+
}(jQuery));
|
29
|
+
</script>
|
30
|
+
<% else %>
|
31
|
+
<p>Please save page first before uploading attachments.</p>
|
32
|
+
<% end %>
|
@@ -18,11 +18,11 @@
|
|
18
18
|
</table>
|
19
19
|
<%= f.file_field :upload %>
|
20
20
|
<%= display(@asset) %>
|
21
|
-
<%- if @asset.
|
22
|
-
<h2>Included on <%= pluralize(@asset.
|
21
|
+
<%- if @asset.page_attachments.any? -%>
|
22
|
+
<h2>Included on <%= pluralize(@asset.page_attachments.size, 'this page', 'these pages') %>:</h2>
|
23
23
|
<ul>
|
24
|
-
<%- @asset.
|
25
|
-
<li><%= link_to attachment.
|
24
|
+
<%- @asset.page_attachments.each do |attachment| -%>
|
25
|
+
<li><%= link_to attachment.parent.title, edit_admin_page_path(attachment.parent) %></li>
|
26
26
|
<%- end -%>
|
27
27
|
</ul>
|
28
28
|
<%- end -%>
|
@@ -8,16 +8,16 @@
|
|
8
8
|
|
9
9
|
<table class="index" id="assets">
|
10
10
|
<tr><td class="name"><%= asset_listing(@asset) %></td></tr>
|
11
|
-
<% if @asset.
|
11
|
+
<% if @asset.page_attachments.any? %>
|
12
12
|
<tr>
|
13
13
|
<th>
|
14
14
|
It's being used on the following
|
15
|
-
<%= pluralize(@asset.
|
15
|
+
<%= pluralize(@asset.page_attachments.size, 'page') %> and will be removed from
|
16
16
|
there as well:
|
17
17
|
</th>
|
18
18
|
</tr>
|
19
|
-
<% @asset.
|
20
|
-
<tr><td><%= attachment.
|
19
|
+
<% @asset.page_attachments.each do |attachment| %>
|
20
|
+
<tr><td><%= attachment.parent.title %></td></tr>
|
21
21
|
<% end %>
|
22
22
|
<% end %>
|
23
23
|
</table>
|
data/assets_extension.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Uncomment this if you reference any of your controllers in activate
|
2
2
|
# require_dependency 'application_controller'
|
3
|
-
require 'radiant-assets-extension
|
3
|
+
require 'radiant-assets-extension'
|
4
4
|
require 'radiant-assets-extension/s3_store'
|
5
5
|
|
6
6
|
class AssetsExtension < Radiant::Extension
|
@@ -10,11 +10,17 @@ class AssetsExtension < Radiant::Extension
|
|
10
10
|
|
11
11
|
extension_config do |config|
|
12
12
|
path = '/assets'
|
13
|
+
|
13
14
|
dragonfly = Dragonfly[:assets]
|
14
15
|
dragonfly.configure_with(:imagemagick)
|
16
|
+
# Overriding command to strip metadata from resized/converted images
|
17
|
+
# see https://github.com/markevans/dragonfly/pull/61#issuecomment-1037694
|
18
|
+
Dragonfly::ImageMagickUtils.convert_command = 'convert -strip'
|
15
19
|
dragonfly.configure_with(:rails)
|
16
|
-
dragonfly.define_macro(ActiveRecord::Base, :image_accessor)
|
20
|
+
dragonfly.define_macro(ActiveRecord::Base, :image_accessor)
|
17
21
|
dragonfly.url_path_prefix = path
|
22
|
+
# TODO: optional SSL support for url_host. could protocol-relative urls be used?
|
23
|
+
dragonfly.url_host = 'http://' + Radiant::Config['assets.host'] if Radiant::Config['assets.host']
|
18
24
|
if RadiantAssetsExtension::S3Store.enabled?
|
19
25
|
dragonfly.datastore = RadiantAssetsExtension::S3Store.new
|
20
26
|
dragonfly.datastore.configure do |c|
|
@@ -33,7 +39,7 @@ class AssetsExtension < Radiant::Extension
|
|
33
39
|
ApplicationController.helper(:assets)
|
34
40
|
Page.class_eval do
|
35
41
|
include AssetTags
|
36
|
-
has_many :attachments, :
|
42
|
+
has_many :attachments, :as => :parent, :order => :position, :dependent => :destroy
|
37
43
|
end
|
38
44
|
end
|
39
45
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class MakeAttachmentsPolymorphic < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
rename_column :attachments, :page_id, :parent_id
|
4
|
+
add_column :attachments, :parent_type, :string
|
5
|
+
Attachment.update_all 'parent_type = "Page"'
|
6
|
+
|
7
|
+
rename_column :attachments, :asset_id, :attachable_id
|
8
|
+
add_column :attachments, :attachable_type, :string
|
9
|
+
Attachment.update_all 'attachable_type = "Asset"'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
warn 'This will delete all Attachments that aren’t attached to pages'
|
14
|
+
remove_column :attachments, :parent_type
|
15
|
+
rename_column :attachments, :parent_id, :page_id
|
16
|
+
end
|
17
|
+
end
|
@@ -23,7 +23,7 @@ module RadiantAssetsExtension
|
|
23
23
|
# HACK: AWS::S3 doesn't support S3 international regions properly
|
24
24
|
# https://github.com/marcel/aws-s3/issues#issue/4/comment/411302
|
25
25
|
# we monkey-patch the default host
|
26
|
-
AWS::S3::DEFAULT_HOST.replace Radiant::Config['s3.host']
|
26
|
+
AWS::S3::DEFAULT_HOST.replace Radiant::Config['s3.host'] if Radiant::Config['s3.host']
|
27
27
|
super({
|
28
28
|
:bucket_name => Radiant::Config['s3.bucket'] || DEFAULT_BUCKET_NAME,
|
29
29
|
:access_key_id => Radiant::Config['s3.key'],
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-assets-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 10
|
10
|
+
version: 0.0.10
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Gerrit Kaiser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-21 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -108,11 +108,11 @@ files:
|
|
108
108
|
- db/migrate/20110225210821_add_attachment_to_pages.rb
|
109
109
|
- db/migrate/20110225210912_add_timestamps_and_locking_to_assets.rb
|
110
110
|
- db/migrate/20110320152044_add_position_to_attachments.rb
|
111
|
+
- db/migrate/20110321005357_make_attachments_polymorphic.rb
|
111
112
|
- features/support/env.rb
|
112
113
|
- features/support/paths.rb
|
113
114
|
- lib/radiant-assets-extension.rb
|
114
115
|
- lib/radiant-assets-extension/s3_store.rb
|
115
|
-
- lib/radiant-assets-extension/version.rb
|
116
116
|
- lib/tasks/assets_extension_tasks.rake
|
117
117
|
- public/jquery.fileupload/.gitignore
|
118
118
|
- public/jquery.fileupload/jquery.fileupload-ui.css
|
@@ -127,7 +127,7 @@ has_rdoc: true
|
|
127
127
|
homepage: http://ext.radiantcms.org/extensions/269-assets
|
128
128
|
licenses: []
|
129
129
|
|
130
|
-
post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.
|
130
|
+
post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.10'\n "
|
131
131
|
rdoc_options: []
|
132
132
|
|
133
133
|
require_paths:
|