papermill 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 0.7.0
@@ -1,25 +1,25 @@
1
- class ActionView::Helpers::FormBuilder
1
+ module ActionView::Helpers::FormTagHelper
2
2
 
3
- def assets_upload(key = nil, options = {})
4
- papermill_upload_field key, { :thumbnail => false }.update(options)
3
+ def assets_upload_tag(assetable, key = nil, options = {})
4
+ papermill_upload_field_tag key, { :thumbnail => false, :assetable => assetable }.update(options)
5
5
  end
6
- def asset_upload(key = nil, options = {})
7
- papermill_upload_field key, { :gallery => false, :thumbnail => false }.update(options)
6
+ def asset_upload_tag(assetable, key = nil, options = {})
7
+ papermill_upload_field_tag key, { :gallery => false, :thumbnail => false, :assetable => assetable }.update(options)
8
8
  end
9
- def images_upload(key = nil, options = {})
10
- papermill_upload_field key, options
9
+ def images_upload_tag(assetable, key = nil, options = {})
10
+ papermill_upload_field_tag key, { :assetable => assetable }.update(options)
11
11
  end
12
- def image_upload(key = nil, options = {})
13
- papermill_upload_field key, { :gallery => false }.update(options)
12
+ def image_upload_tag(assetable, key = nil, options = {})
13
+ papermill_upload_field_tag key, { :gallery => false, :assetable => assetable }.update(options)
14
14
  end
15
-
15
+
16
16
  private
17
- def papermill_upload_field(key, options = {})
17
+ def papermill_upload_field_tag(key, options)
18
18
  if key.is_a? Hash
19
19
  options = key
20
20
  key = nil
21
21
  end
22
- assetable = @template.instance_variable_get("@#{@object_name}")
22
+ assetable = options[:assetable] || @template.instance_variable_get("@#{@object_name}")
23
23
  options = if assetable && (association = (assetable.class.papermill_associations[key] || assetable.class.papermill_associations[:papermill_assets]))
24
24
  association[:options].deep_merge(options)
25
25
  else
@@ -64,7 +64,7 @@ class ActionView::Helpers::FormBuilder
64
64
  asset_class = options[:class_name] && options[:class_name].to_s.constantize || association && association[:class] || PapermillAsset
65
65
  create_url = @template.url_for(:controller => "/papermill", :action => "create", :escape => false, :asset_class => asset_class.to_s, :assetable_key => key, :assetable_id => assetable_id, :assetable_type => assetable_type, :gallery => (options[:gallery] != false), :thumbnail_style => (options[:thumbnail] && options[:thumbnail][:style]))
66
66
  if assetable && assetable.new_record? && !@timestamped
67
- html << self.hidden_field(:timestamp, :value => assetable.timestamp)
67
+ html << @template.hidden_field(assetable.class.to_s.underscore, :timestamp, :value => assetable.timestamp)
68
68
  @timestamped = true
69
69
  end
70
70
  collection = asset_class.find(:all, :conditions => conditions, :order => "position")
@@ -98,4 +98,22 @@ class ActionView::Helpers::FormBuilder
98
98
  html.reverse! if options[:button_after_container]
99
99
  html.join("\n")
100
100
  end
101
+ end
102
+
103
+
104
+ class ActionView::Helpers::FormBuilder
105
+ include ActionView::Helpers::FormTagHelper
106
+
107
+ def assets_upload(key = nil, options = {})
108
+ papermill_upload_field_tag key, { :thumbnail => false }.update(options)
109
+ end
110
+ def asset_upload(key = nil, options = {})
111
+ papermill_upload_field_tag key, { :gallery => false, :thumbnail => false }.update(options)
112
+ end
113
+ def images_upload(key = nil, options = {})
114
+ papermill_upload_field_tag key, options
115
+ end
116
+ def image_upload(key = nil, options = {})
117
+ papermill_upload_field_tag key, { :gallery => false }.update(options)
118
+ end
101
119
  end
data/papermill.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{papermill}
8
- s.version = "0.6.1"
8
+ s.version = "0.7.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Benoit B\303\251n\303\251zech"]
12
- s.date = %q{2009-09-16}
12
+ s.date = %q{2009-09-17}
13
13
  s.description = %q{Paperclip Swfupload UploadHelper wrapper}
14
14
  s.email = %q{benoit.benezech@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papermill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Benoit B\xC3\xA9n\xC3\xA9zech"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-16 00:00:00 +02:00
12
+ date: 2009-09-17 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency