papermill 1.0.1 → 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/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
@@ -8,14 +8,14 @@ class <%= migration_name %> < ActiveRecord::Migration
|
|
8
8
|
t.integer :file_file_size
|
9
9
|
|
10
10
|
# Papermill fields (required)
|
11
|
-
t.integer :position
|
12
|
-
t.integer :assetable_id
|
13
|
-
t.string :assetable_type
|
14
|
-
t.string :assetable_key
|
15
|
-
t.string :type
|
11
|
+
t.integer :position # sets are ordered by position
|
12
|
+
t.integer :assetable_id # Assetable
|
13
|
+
t.string :assetable_type # Assetable
|
14
|
+
t.string :assetable_key # Assetable sets
|
15
|
+
t.string :type # STI
|
16
|
+
t.string :title # raw filename, without file extension, for your own use
|
16
17
|
|
17
18
|
# Custom fields (optionnals)
|
18
|
-
t.string :title
|
19
19
|
t.string :alt
|
20
20
|
t.string :copyright
|
21
21
|
t.text :description
|
data/lib/papermill/papermill.rb
CHANGED
@@ -7,11 +7,7 @@ class PapermillAsset < ActiveRecord::Base
|
|
7
7
|
:path => "#{Papermill::options[:public_root]}/#{Papermill::options[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}",
|
8
8
|
:url => "/#{Papermill::options[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}"
|
9
9
|
|
10
|
-
before_post_process :
|
11
|
-
|
12
|
-
Paperclip.interpolates :escaped_basename do |attachment, style|
|
13
|
-
Paperclip::Interpolations[:basename].call(attachment, style).to_url
|
14
|
-
end
|
10
|
+
before_post_process :set_file_name
|
15
11
|
|
16
12
|
validates_attachment_presence :file
|
17
13
|
|
@@ -95,8 +91,10 @@ class PapermillAsset < ActiveRecord::Base
|
|
95
91
|
|
96
92
|
private
|
97
93
|
|
98
|
-
def
|
99
|
-
|
94
|
+
def set_file_name
|
95
|
+
return if @real_file_name.blank?
|
96
|
+
self.title = (basename = @real_file_name.gsub(/#{extension = File.extname(@real_file_name)}$/, ""))
|
97
|
+
self.file.instance_write(:file_name, "#{basename.to_url}#{extension}")
|
100
98
|
end
|
101
99
|
|
102
100
|
def set_position
|