radiant-page_attachments-extension 1.0.0 → 1.0.2
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/HELP.md +27 -0
- data/README.md +34 -11
- data/VERSION +1 -1
- data/app/controllers/admin/page_attachments_controller.rb +46 -0
- data/app/helpers/admin/page_attachments_helper.rb +11 -0
- data/app/models/page_attachment_tags.rb +13 -6
- data/app/models/page_attachments_interface.rb +1 -0
- data/app/views/admin/page_attachments/edit.html.haml +21 -0
- data/app/views/admin/page_attachments/grid.html.haml +20 -0
- data/app/views/admin/page_attachments/index.html.haml +24 -0
- data/app/views/admin/pages/_attachment.html.erb +19 -0
- data/app/views/admin/pages/_attachment.html.haml +1 -1
- data/lib/tasks/page_attachments_extension_tasks.rake +3 -0
- data/page_attachments_extension.rb +17 -3
- data/public/images/admin/page_attachments/move_higher.png +0 -0
- data/public/images/admin/page_attachments/move_lower.png +0 -0
- data/public/images/admin/page_attachments/pdf-icon.png +0 -0
- data/public/javascripts/admin/lowpro.js +338 -0
- data/public/javascripts/admin/page_attachments.js +1 -1
- data/public/stylesheets/page_attachments.css +98 -0
- data/radiant-page_attachments-extension.gemspec +16 -5
- data/vendor/plugins/attachment_fu/README +7 -14
- data/vendor/plugins/attachment_fu/amazon_s3.yml.tpl +0 -3
- data/vendor/plugins/attachment_fu/install.rb +0 -2
- data/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb +9 -18
- data/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb +8 -33
- data/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb +15 -55
- data/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb +9 -0
- data/vendor/plugins/attachment_fu/test/backends/file_system_test.rb +1 -64
- data/vendor/plugins/attachment_fu/test/basic_test.rb +3 -3
- data/vendor/plugins/attachment_fu/test/fixtures/attachment.rb +0 -43
- data/vendor/plugins/attachment_fu/test/schema.rb +1 -27
- metadata +25 -5
- data/app/models/observe_page_attachments.rb +0 -5
data/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb
CHANGED
@@ -45,6 +45,15 @@ module Technoweenie # :nodoc:
|
|
45
45
|
elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75
|
46
46
|
dimensions = size[1..size.size].split("x")
|
47
47
|
img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)
|
48
|
+
elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75
|
49
|
+
dimensions = size[1..size.size].split("x")
|
50
|
+
img.change_geometry(dimensions.join("x")) do |cols, rows, image|
|
51
|
+
image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows )
|
52
|
+
end
|
53
|
+
img.background_color = "black"
|
54
|
+
x_offset = (img.columns - dimensions[0].to_i) / 2
|
55
|
+
y_offset = (img.rows - dimensions[1].to_i) / 2
|
56
|
+
img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)
|
48
57
|
else
|
49
58
|
img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }
|
50
59
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper'))
|
2
|
-
require 'digest/sha2'
|
3
2
|
|
4
3
|
class FileSystemTest < Test::Unit::TestCase
|
5
4
|
include BaseAttachmentTests
|
@@ -78,66 +77,4 @@ class FileSystemTest < Test::Unit::TestCase
|
|
78
77
|
end
|
79
78
|
|
80
79
|
test_against_subclass :test_should_delete_old_file_when_renaming, FileAttachment
|
81
|
-
|
82
|
-
def test_path_partitioning_works_on_integer_id(klass = FileAttachment)
|
83
|
-
attachment_model klass
|
84
|
-
|
85
|
-
# Create a random attachment object, doesn't matter what.
|
86
|
-
attachment = upload_file :filename => '/files/rails.png'
|
87
|
-
old_id = attachment.id
|
88
|
-
attachment.id = 1
|
89
|
-
|
90
|
-
begin
|
91
|
-
assert_equal ["0000", "0001", "bar.txt"], attachment.send(:partitioned_path, "bar.txt")
|
92
|
-
ensure
|
93
|
-
attachment.id = old_id
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
test_against_subclass :test_path_partitioning_works_on_integer_id, FileAttachment
|
98
|
-
|
99
|
-
def test_path_partitioning_with_string_id_works_by_generating_hash(klass = FileAttachmentWithStringId)
|
100
|
-
attachment_model klass
|
101
|
-
|
102
|
-
# Create a random attachment object, doesn't matter what.
|
103
|
-
attachment = upload_file :filename => '/files/rails.png'
|
104
|
-
old_id = attachment.id
|
105
|
-
attachment.id = "hello world some long string"
|
106
|
-
hash = Digest::SHA512.hexdigest("hello world some long string")
|
107
|
-
|
108
|
-
begin
|
109
|
-
assert_equal [
|
110
|
-
hash[0..31],
|
111
|
-
hash[32..63],
|
112
|
-
hash[64..95],
|
113
|
-
hash[96..127],
|
114
|
-
"bar.txt"
|
115
|
-
], attachment.send(:partitioned_path, "bar.txt")
|
116
|
-
ensure
|
117
|
-
attachment.id = old_id
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
test_against_subclass :test_path_partitioning_with_string_id_works_by_generating_hash, FileAttachmentWithStringId
|
122
|
-
|
123
|
-
def test_path_partition_string_id_hashing_is_turned_off_if_id_is_uuid(klass = FileAttachmentWithUuid)
|
124
|
-
attachment_model klass
|
125
|
-
|
126
|
-
# Create a random attachment object, doesn't matter what.
|
127
|
-
attachment = upload_file :filename => '/files/rails.png'
|
128
|
-
old_id = attachment.id
|
129
|
-
attachment.id = "0c0743b698483569dc65909a8cdb3bf9"
|
130
|
-
|
131
|
-
begin
|
132
|
-
assert_equal [
|
133
|
-
"0c0743b698483569",
|
134
|
-
"dc65909a8cdb3bf9",
|
135
|
-
"bar.txt"
|
136
|
-
], attachment.send(:partitioned_path, "bar.txt")
|
137
|
-
ensure
|
138
|
-
attachment.id = old_id
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
test_against_subclass :test_path_partition_string_id_hashing_is_turned_off_if_id_is_uuid, FileAttachmentWithUuid
|
143
|
-
end
|
80
|
+
end
|
@@ -24,8 +24,8 @@ class BasicTest < Test::Unit::TestCase
|
|
24
24
|
def test_should_normalize_content_types_to_array
|
25
25
|
assert_equal %w(pdf), PdfAttachment.attachment_options[:content_type]
|
26
26
|
assert_equal %w(pdf doc txt), DocAttachment.attachment_options[:content_type]
|
27
|
-
assert_equal
|
28
|
-
assert_equal ['pdf'
|
27
|
+
assert_equal ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'], ImageAttachment.attachment_options[:content_type]
|
28
|
+
assert_equal ['pdf', 'image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png', 'image/jpg'], ImageOrPdfAttachment.attachment_options[:content_type]
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_should_sanitize_content_type
|
@@ -67,4 +67,4 @@ class BasicTest < Test::Unit::TestCase
|
|
67
67
|
klass.has_attachment :thumbnails => []
|
68
68
|
end
|
69
69
|
end
|
70
|
-
end
|
70
|
+
end
|
@@ -44,38 +44,6 @@ class FileAttachment < ActiveRecord::Base
|
|
44
44
|
validates_as_attachment
|
45
45
|
end
|
46
46
|
|
47
|
-
class FileAttachmentWithStringId < ActiveRecord::Base
|
48
|
-
set_table_name 'file_attachments_with_string_id'
|
49
|
-
has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick
|
50
|
-
validates_as_attachment
|
51
|
-
|
52
|
-
before_validation :auto_generate_id
|
53
|
-
before_save :auto_generate_id
|
54
|
-
@@last_id = 0
|
55
|
-
|
56
|
-
private
|
57
|
-
def auto_generate_id
|
58
|
-
@@last_id += 1
|
59
|
-
self.id = "id_#{@@last_id}"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class FileAttachmentWithUuid < ActiveRecord::Base
|
64
|
-
set_table_name 'file_attachments_with_string_id'
|
65
|
-
has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files', :processor => :rmagick, :uuid_primary_key => true
|
66
|
-
validates_as_attachment
|
67
|
-
|
68
|
-
before_validation :auto_generate_id
|
69
|
-
before_save :auto_generate_id
|
70
|
-
@@last_id = 0
|
71
|
-
|
72
|
-
private
|
73
|
-
def auto_generate_id
|
74
|
-
@@last_id += 1
|
75
|
-
self.id = "%0127dx" % @@last_id
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
47
|
class ImageFileAttachment < FileAttachment
|
80
48
|
has_attachment :path_prefix => 'vendor/plugins/attachment_fu/test/files',
|
81
49
|
:content_type => :image, :resize_to => [50,50]
|
@@ -205,22 +173,11 @@ begin
|
|
205
173
|
has_attachment :storage => :s3, :processor => :rmagick, :s3_config_path => File.join(File.dirname(__FILE__), '../amazon_s3.yml')
|
206
174
|
validates_as_attachment
|
207
175
|
end
|
208
|
-
|
209
|
-
class CloudFilesAttachment < ActiveRecord::Base
|
210
|
-
has_attachment :storage => :cloud_files, :processor => :rmagick, :cloudfiles_config_path => File.join(File.dirname(__FILE__), '../rackspace_cloudfiles.yml')
|
211
|
-
validates_as_attachment
|
212
|
-
end
|
213
176
|
|
214
177
|
class S3WithPathPrefixAttachment < S3Attachment
|
215
178
|
has_attachment :storage => :s3, :path_prefix => 'some/custom/path/prefix', :processor => :rmagick
|
216
179
|
validates_as_attachment
|
217
180
|
end
|
218
|
-
|
219
|
-
class CloudFilesWithPathPrefixAttachment < CloudFilesAttachment
|
220
|
-
has_attachment :storage => :cloud_files, :path_prefix => 'some/custom/path/prefix', :processor => :rmagick
|
221
|
-
validates_as_attachment
|
222
|
-
end
|
223
|
-
|
224
181
|
rescue
|
225
182
|
puts "S3 error: #{$!}"
|
226
183
|
end
|
@@ -22,19 +22,6 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
22
22
|
t.column :type, :string
|
23
23
|
t.column :aspect_ratio, :float
|
24
24
|
end
|
25
|
-
|
26
|
-
create_table :file_attachments_with_string_id, :id => false, :force => true do |t|
|
27
|
-
t.column :id, :string
|
28
|
-
t.column :parent_id, :string
|
29
|
-
t.column :thumbnail, :string
|
30
|
-
t.column :filename, :string, :limit => 255
|
31
|
-
t.column :content_type, :string, :limit => 255
|
32
|
-
t.column :size, :integer
|
33
|
-
t.column :width, :integer
|
34
|
-
t.column :height, :integer
|
35
|
-
t.column :type, :string
|
36
|
-
t.column :aspect_ratio, :float
|
37
|
-
end
|
38
25
|
|
39
26
|
create_table :gd2_attachments, :force => true do |t|
|
40
27
|
t.column :parent_id, :integer
|
@@ -118,17 +105,4 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
118
105
|
t.column :type, :string
|
119
106
|
t.column :aspect_ratio, :float
|
120
107
|
end
|
121
|
-
|
122
|
-
create_table :cloud_files_attachments, :force => true do |t|
|
123
|
-
t.column :parent_id, :integer
|
124
|
-
t.column :thumbnail, :string
|
125
|
-
t.column :filename, :string, :limit => 255
|
126
|
-
t.column :content_type, :string, :limit => 255
|
127
|
-
t.column :size, :integer
|
128
|
-
t.column :width, :integer
|
129
|
-
t.column :height, :integer
|
130
|
-
t.column :type, :string
|
131
|
-
t.column :aspect_ratio, :float
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
108
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-page_attachments-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Sean Cribbs
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-06-28 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
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: cucumber
|
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"
|
@@ -52,15 +57,21 @@ extra_rdoc_files:
|
|
52
57
|
- README.md
|
53
58
|
files:
|
54
59
|
- .gitignore
|
60
|
+
- HELP.md
|
55
61
|
- LICENSE
|
56
62
|
- README.md
|
57
63
|
- Rakefile
|
58
64
|
- VERSION
|
59
|
-
- app/
|
65
|
+
- app/controllers/admin/page_attachments_controller.rb
|
66
|
+
- app/helpers/admin/page_attachments_helper.rb
|
60
67
|
- app/models/page_attachment.rb
|
61
68
|
- app/models/page_attachment_associations.rb
|
62
69
|
- app/models/page_attachment_tags.rb
|
63
70
|
- app/models/page_attachments_interface.rb
|
71
|
+
- app/views/admin/page_attachments/edit.html.haml
|
72
|
+
- app/views/admin/page_attachments/grid.html.haml
|
73
|
+
- app/views/admin/page_attachments/index.html.haml
|
74
|
+
- app/views/admin/pages/_attachment.html.erb
|
64
75
|
- app/views/admin/pages/_attachment.html.haml
|
65
76
|
- app/views/admin/pages/_attachments_box.html.haml
|
66
77
|
- db/migrate/001_create_page_attachments_extension_schema.rb
|
@@ -74,8 +85,13 @@ files:
|
|
74
85
|
- lib/tasks/page_attachments_extension_tasks.rake
|
75
86
|
- page_attachments_extension.rb
|
76
87
|
- public/images/admin/drag_order.png
|
88
|
+
- public/images/admin/page_attachments/move_higher.png
|
89
|
+
- public/images/admin/page_attachments/move_lower.png
|
90
|
+
- public/images/admin/page_attachments/pdf-icon.png
|
91
|
+
- public/javascripts/admin/lowpro.js
|
77
92
|
- public/javascripts/admin/page_attachments.js
|
78
93
|
- public/stylesheets/admin/page_attachments.css
|
94
|
+
- public/stylesheets/page_attachments.css
|
79
95
|
- radiant-page_attachments-extension.gemspec
|
80
96
|
- spec/controllers/pages_controller_spec.rb
|
81
97
|
- spec/datasets/page_attachments_dataset.rb
|
@@ -148,23 +164,27 @@ rdoc_options:
|
|
148
164
|
require_paths:
|
149
165
|
- lib
|
150
166
|
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
none: false
|
151
168
|
requirements:
|
152
169
|
- - ">="
|
153
170
|
- !ruby/object:Gem::Version
|
171
|
+
hash: 3
|
154
172
|
segments:
|
155
173
|
- 0
|
156
174
|
version: "0"
|
157
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
+
none: false
|
158
177
|
requirements:
|
159
178
|
- - ">="
|
160
179
|
- !ruby/object:Gem::Version
|
180
|
+
hash: 3
|
161
181
|
segments:
|
162
182
|
- 0
|
163
183
|
version: "0"
|
164
184
|
requirements: []
|
165
185
|
|
166
186
|
rubyforge_project:
|
167
|
-
rubygems_version: 1.3.
|
187
|
+
rubygems_version: 1.3.7
|
168
188
|
signing_key:
|
169
189
|
specification_version: 3
|
170
190
|
summary: Adds page-attachment-style asset management.
|