papermill 1.0.5 → 1.0.6

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.5
1
+ 1.0.6
data/demo.txt ADDED
@@ -0,0 +1,113 @@
1
+ gem 'papermill'
2
+
3
+ generate :papermill_table, "PapermillMigration"
4
+ generate :papermill_assets
5
+ generate :papermill_initializer
6
+ generate :scaffold, "article title:string"
7
+ rake "db:migrate"
8
+
9
+ file "app/models/article.rb", <<-END
10
+ class Article < ActiveRecord::Base
11
+ validates_presence_of :title
12
+ papermill :thumbnail => {:width => 100, :height => 75} # catch-all for non-specified associations, will create assets/asset methods.
13
+ papermill :image_gallery, :class_name => ImageAsset, :images_only => true, :thumbnail => {:width => 75, :height => 100}
14
+ # image_gallery association (set with define_method)
15
+ end
16
+ END
17
+
18
+ file "app/models/image_asset.rb", <<-END
19
+ class ImageAsset < PapermillAsset
20
+ validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/gif']
21
+ end
22
+ END
23
+
24
+ file "app/views/articles/edit.html.erb", <<-END
25
+ <h1>Editing article</h1>
26
+ <%= render :partial => "form" %>
27
+ <%= link_to 'Show', @article %> |
28
+ <%= link_to 'Back', articles_path %>
29
+ END
30
+
31
+ file "app/views/articles/new.html.erb", <<-END
32
+ <h1>New article</h1>
33
+ <%= render :partial => "form" %>
34
+ <%= link_to 'Back', articles_path %>
35
+ END
36
+
37
+ file "app/views/articles/_form.html.erb", <<-END
38
+ <% form_for(@article) do |f| %>
39
+ <%= f.error_messages %><br /><br />
40
+ <%= f.label :title %><br />
41
+ <%= f.text_field :title %><br /><br />
42
+ <%= f.label :image_gallery %><br />
43
+ <%= f.images_upload(:image_gallery) %><br /><br />
44
+ <%= f.label :my_other_image %><br />
45
+ <%= f.image_upload(:my_other_image) %> <br /><br />
46
+ <%= f.label :my_assets %><br />
47
+ <%= f.assets_upload(:my_assets) %><br /><br />
48
+ <%= f.label :my_other_asset %><br />
49
+ <%= f.asset_upload(:my_other_asset) %><br /><br />
50
+ <%= f.submit 'Send' %>
51
+ <% end %>
52
+ END
53
+
54
+ file "app/views/articles/show.html.erb", <<-END
55
+ <p>
56
+ <b>Title:</b>
57
+ <%=h @article.title %>
58
+ </p>
59
+ <br /><br />
60
+ <b>@article.image_gallery.each :</b>
61
+ <p>
62
+ <% @article.image_gallery.each do |image| %>
63
+ <%= link_to(image_tag(image.url("100x100#")), image.url) %>
64
+ <% end %>
65
+ </p>
66
+ <br /><br />
67
+ <b>@article.assets(:my_other_image).first :</b>
68
+ <p>
69
+ <% image = @article.assets(:my_other_image).first %>
70
+ <%= link_to(image_tag(image.url("100x100#")), image.url) if image %>
71
+ </p>
72
+ <br /><br />
73
+ <b>@article.assets(:my_assets).each :</b>
74
+ <p>
75
+ <ul>
76
+ <% @article.assets(:my_assets).each do |asset| %>
77
+ <li><%= link_to asset.name, asset.url %></li>
78
+ <% end %>
79
+ </ul>
80
+ </p>
81
+ <br /><br />
82
+ <b>@article.assets(:my_other_asset).first :</b>
83
+ <p>
84
+ <% asset = @article.assets(:my_other_asset).first %>
85
+ <%= link_to(asset.name, asset.url) if asset %>
86
+ </p>
87
+
88
+ <%= link_to 'Edit', edit_article_path(@article) %> |
89
+ <%= link_to 'Back', articles_path %>
90
+ END
91
+
92
+
93
+ file "app/views/layouts/application.html.erb", <<-END
94
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
95
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
96
+
97
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
98
+ <head>
99
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
100
+ <title>Papermill Demo</title>
101
+ <%= stylesheet_link_tag 'scaffold' %>
102
+ <%= papermill_stylesheet_tag %>
103
+ </head>
104
+ <body>
105
+ <%= yield %>
106
+ <%= papermill_javascript_tag :with_jquery => true %>
107
+ </body>
108
+ </html>
109
+ END
110
+
111
+ run "rm app/views/layouts/articles.html.erb"
112
+ run "rm public/index.html"
113
+ route "map.root :controller => 'articles'"
@@ -41,7 +41,7 @@ module ActionView::Helpers::FormTagHelper
41
41
  end
42
42
 
43
43
  assetable = options[:assetable] || @template.instance_variable_get("@#{@object_name}")
44
- options = PapermillAsset.assetable_papermill_options(assetable.class.name, key)
44
+ options = PapermillAsset.assetable_papermill_options(assetable.class.name, key).deep_merge(options)
45
45
 
46
46
  assetable_id = assetable && (assetable.id || assetable.timestamp) || nil
47
47
  assetable_type = assetable && assetable.class.base_class.name || nil
@@ -22,7 +22,7 @@ module Papermill
22
22
  include Papermill::InstanceMethods
23
23
  before_destroy :destroy_assets
24
24
  after_create :rebase_assets
25
- has_many :papermill_assets, :as => "Assetable", :dependent => :destroy, :order => 'assetable_key ASC, position ASC'
25
+ has_many :papermill_assets, :as => "Assetable", :dependent => :destroy
26
26
 
27
27
  define_method assoc_name do |*options|
28
28
  scope = PapermillAsset.scoped(:conditions => {:assetable_id => self.id, :assetable_type => self.class.base_class.name})
@@ -14,7 +14,7 @@ class PapermillAsset < ActiveRecord::Base
14
14
  belongs_to :assetable, :polymorphic => true
15
15
  default_scope :order => 'assetable_key ASC, position ASC'
16
16
 
17
- named_scope :key, lambda { |assetable_key| { :conditions => ['assetable_key = ?', assetable_key] }
17
+ named_scope :key, lambda { |assetable_key| { :conditions => ['assetable_key = ?', assetable_key] }}
18
18
 
19
19
  def Filedata=(data)
20
20
  data.content_type = data.get_content_type # SWFUpload content-type fix
@@ -100,7 +100,7 @@ class PapermillAsset < ActiveRecord::Base
100
100
  end
101
101
 
102
102
  def set_position
103
- self.position ||= PapermillAsset.first(:conditions => {:assetable_key => assetable_key, :assetable_type => assetable_type, :assetable_id => assetable_id}, :order => "position DESC" ).try(:position).to_i + 1
103
+ self.position ||= PapermillAsset.first(:conditions => { :assetable_key => assetable_key, :assetable_type => assetable_type, :assetable_id => assetable_id } ).try(:position).to_i + 1
104
104
  end
105
105
 
106
106
  def destroy_files
@@ -109,6 +109,6 @@ class PapermillAsset < ActiveRecord::Base
109
109
 
110
110
  def self.compute_style(style)
111
111
  style = Papermill::options[:aliases][style.to_sym] || Papermill::options[:aliases][style.to_s] || !Papermill::options[:alias_only] && style
112
- [Symbol, String].include?(style.class) ? {:geometry => style.to_s} : style
113
- end
114
- end
112
+ [Symbol, String].include?(style.class) ? { :geometry => style.to_s } : style
113
+ end
114
+ end
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: 1.0.5
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Benoit B\xC3\xA9n\xC3\xA9zech"
@@ -45,6 +45,7 @@ files:
45
45
  - app/views/papermill/edit.html.erb
46
46
  - config/locales/papermill.yml
47
47
  - config/routes.rb
48
+ - demo.txt
48
49
  - generators/papermill_assets/USAGE
49
50
  - generators/papermill_assets/papermill_assets_generator.rb
50
51
  - generators/papermill_initializer/USAGE