papermill 1.3.3 → 1.3.4
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 +1 -1
- data/app/controllers/papermill_controller.rb +9 -3
- data/app/views/papermill/_asset.html.erb +1 -1
- data/app/views/papermill/crop.html.erb +23 -10
- data/app/views/papermill/edit.html.erb +11 -2
- data/config/locales/papermill.yml +4 -0
- data/config/routes.rb +1 -1
- data/generators/papermill_table/templates/migrate/papermill_migration.rb.erb +1 -1
- data/lib/papermill/form_builder.rb +7 -5
- data/lib/papermill/papermill.rb +1 -6
- data/lib/papermill/papermill_asset.rb +1 -1
- data/lib/papermill/papermill_initializer.rb +54 -15
- data/lib/papermill/papermill_options.rb +2 -1
- data/lib/papermill/papermill_paperclip_processor.rb +10 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.4
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class PapermillController < ApplicationController
|
2
|
-
prepend_before_filter :load_asset, :only => [ "show", "destroy", "update", "edit", "crop" ]
|
2
|
+
prepend_before_filter :load_asset, :only => [ "show", "destroy", "update", "edit", "crop", "receive_from_pixlr" ]
|
3
3
|
prepend_before_filter :load_assets, :only => [ "sort", "mass_delete", "mass_edit", "mass_thumbnail_reset" ]
|
4
4
|
|
5
5
|
skip_before_filter :verify_authenticity_token, :only => [:create] # not needed (Flash same origin policy)
|
6
6
|
|
7
7
|
def show
|
8
8
|
# first escaping is done by rails prior to route recognition, need to do a second one on MSWIN systems to get original one.
|
9
|
-
params[:style] = CGI::unescape(params[:style]) if
|
9
|
+
params[:style] = CGI::unescape(params[:style]) if Papermill::MSWIN
|
10
10
|
if @asset.has_valid_url_key?(params[:url_key], params[:style]) && @asset.create_thumb_file(params[:style])
|
11
11
|
redirect_to @asset.url(params[:style])
|
12
12
|
else
|
@@ -20,7 +20,7 @@ class PapermillController < ApplicationController
|
|
20
20
|
PapermillAsset.find(:all, :conditions => { :assetable_id => @asset.assetable_id, :assetable_type => @asset.assetable_type, :assetable_key => @asset.assetable_key }).each do |asset|
|
21
21
|
asset.destroy unless asset == @asset
|
22
22
|
end if !params[:gallery]
|
23
|
-
render :partial => "papermill/asset", :object => @asset, :locals => { :gallery => params[:gallery], :thumbnail_style => params[:thumbnail_style] }
|
23
|
+
render :partial => "papermill/asset", :object => @asset, :locals => { :gallery => params[:gallery], :thumbnail_style => params[:thumbnail_style], :targetted_geometry => params[:targetted_geometry] }
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -32,6 +32,12 @@ class PapermillController < ApplicationController
|
|
32
32
|
render :action => "crop", :layout => false
|
33
33
|
end
|
34
34
|
|
35
|
+
def receive_from_pixlr
|
36
|
+
@asset.file = params[:image]
|
37
|
+
@asset.destroy_thumbnails
|
38
|
+
render :nothing => true
|
39
|
+
end
|
40
|
+
|
35
41
|
def update
|
36
42
|
@asset.create_thumb_file(params[:target], params[:papermill_asset].merge({ :geometry => "#{params[:target]}#" })) if params[:target]
|
37
43
|
render :update do |page|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%- dom_id = "papermill_asset_#{asset.id}" -%>
|
2
2
|
<%- delete_link = %{<a onclick="if(confirm('#{escape_javascript t("papermill.delete-confirmation", :resource => asset.name)}')){ jQuery.ajax({async:true, beforeSend:function(request){jQuery('##{dom_id}').hide();}, dataType:'script', error:function(request){jQuery('##{dom_id}').show();}, type:'delete', url:'#{papermill_url(asset)}'})}; return false;" href="#" class="delete"><img title="#{escape_javascript t("papermill.delete", :resource => asset.name)}" src="/papermill/images/delete.png" alt="delete"/></a>} %>
|
3
3
|
|
4
|
-
<div id="<%= dom_id %>" class="asset" title="<%= t("papermill.#{(thumbnail_style) ? "thumbnail-" : ""}edit-title", :resource => asset.name) %>" onDblClick="popup(jQuery(this).attr('rel')); return false;" rel="<%= edit_papermill_url(asset) %>">
|
4
|
+
<div id="<%= dom_id %>" class="asset" title="<%= t("papermill.#{(thumbnail_style) ? "thumbnail-" : ""}edit-title", :resource => asset.name) %>" onDblClick="popup(jQuery(this).attr('rel')); return false;" rel="<%= edit_papermill_url(asset, :targetted_geometry => targetted_geometry) %>">
|
5
5
|
<%= delete_link %>
|
6
6
|
<%- if thumbnail_style -%>
|
7
7
|
<%= render :partial => "papermill/thumbnail_asset", :object => asset, :locals => {:thumbnail_style => thumbnail_style} %>
|
@@ -22,17 +22,26 @@
|
|
22
22
|
}
|
23
23
|
</style>
|
24
24
|
|
25
|
+
<%
|
26
|
+
unless (@size = params[:targetted_geometry]).blank?
|
27
|
+
@target_w, @target_h = @size.split("x").map(&:to_i)
|
28
|
+
@init_x = (@asset.width - @target_w.to_i) / 2
|
29
|
+
@init_y = (@asset.height - @target_h.to_i) / 2
|
30
|
+
end
|
31
|
+
%>
|
32
|
+
|
33
|
+
|
25
34
|
<div class="jc_coords">
|
26
35
|
<form onsubmit="jQuery.ajax({data:jQuery.param(jQuery(this).serializeArray()), dataType:'script', type:'post', url:'/papermill/<%= @asset.id %>'}); return false;" method="post">
|
27
36
|
<input type="hidden" value="put" name="_method"/>
|
28
37
|
<input type="hidden" value="<%= params[:target] %>" name="target"/>
|
29
38
|
<% fields_for :papermill_asset, @asset do |f| %>
|
30
|
-
<label>W <%= f.text_field :crop_w, :id => :crop_w, :size => 4, :readonly => "readonly" %></label>
|
31
|
-
<label>H <%= f.text_field :crop_h, :id => :crop_h, :size => 4, :readonly => "readonly" %></label>
|
39
|
+
<label>W: <%= f.text_field :crop_w, :id => :crop_w, :size => 4, :readonly => "readonly" %><%= " /" + @target_w.to_s if @size %></label>
|
40
|
+
<label>H: <%= f.text_field :crop_h, :id => :crop_h, :size => 4, :readonly => "readonly" %><%= " /" + @target_h.to_s if @size %></label>
|
32
41
|
<%= f.hidden_field :crop_x, :id => :crop_x %>
|
33
42
|
<%= f.hidden_field :crop_y, :id => :crop_y %>
|
34
43
|
<%= f.submit I18n.t('papermill.save'), :class => "submit" %>
|
35
|
-
<%= link_to_function I18n.t("papermill.back"), "popup('#{edit_papermill_path(@asset)}')" %>
|
44
|
+
<%= link_to_function I18n.t("papermill.back"), "popup('#{edit_papermill_path(@asset, :targetted_geometry => params[:targetted_geometry])}')" %>
|
36
45
|
<% end -%>
|
37
46
|
</form>
|
38
47
|
</div>
|
@@ -41,27 +50,31 @@
|
|
41
50
|
|
42
51
|
|
43
52
|
<script type="text/javascript" charset="utf-8">
|
53
|
+
|
44
54
|
jQuery(function() {
|
45
55
|
jQuery('#cropbox').Jcrop({
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
56
|
+
<% unless @size %>
|
57
|
+
setSelect: [0,0,100,100]
|
58
|
+
<% else %>
|
59
|
+
setSelect: <%= %{[#{@init_x}, #{@init_y}, #{@target_w + @init_x}, #{@target_h + @init_y}]} %>
|
60
|
+
<% end -%>
|
61
|
+
,onChange: update_crop
|
62
|
+
,onSelect: update_crop
|
63
|
+
<%= ",aspectRatio: #{@target_w} / #{@target_h}" unless @size.blank? %>
|
50
64
|
});
|
51
65
|
});
|
52
|
-
|
66
|
+
|
53
67
|
function update_crop(coords) {
|
54
68
|
jQuery("#crop_x").val(coords.x);
|
55
69
|
jQuery("#crop_y").val(coords.y);
|
56
70
|
jQuery("#crop_w").val(coords.w);
|
57
71
|
jQuery("#crop_h").val(coords.h);
|
58
|
-
|
59
72
|
};
|
60
73
|
|
61
74
|
/* browser don't know about windows content size when loading facebox if image not in cache, fixing facebox left */
|
62
75
|
jQuery(document).bind('reveal.facebox', function() {
|
63
76
|
jQuery(document).unbind('reveal.facebox'); /* clear self (one-shot binding) */
|
64
|
-
jQuery('#facebox').css('left', jQuery(window).width()
|
77
|
+
jQuery('#facebox').css('left', (jQuery(window).width() - <%= @asset.width %>) / 2);
|
65
78
|
});
|
66
79
|
|
67
80
|
</script>
|
@@ -1,12 +1,21 @@
|
|
1
1
|
<div id="papermill-box">
|
2
2
|
<div id="left">
|
3
3
|
<% if @asset.image? %>
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
<%# image_tag(@asset.url("400x400>"), :onDblClick => %{$.facebox( $('<iframe src="#{crop_papermill_path(@asset, :target => "original", :targetted_geometry => params[:targetted_geometry])}" />')); return false;}, :title => I18n.t("papermill.crop", :resource => @asset.name)) %>
|
6
|
+
|
7
|
+
|
8
|
+
<%= image_tag(@asset.url("400x400>"), :onDblClick => "popup('#{crop_papermill_path(@asset, :target => "original", :targetted_geometry => params[:targetted_geometry])}'); return false;", :title => I18n.t("papermill.crop", :resource => @asset.name)) %>
|
9
|
+
|
10
|
+
|
11
|
+
<%# @test = "webonrails.com/wp-content/uploads/2008/11/hosting-rails-app-and-wordpress-on-same-domainas-folder-instead-of-subdomain-webonrails_1225783508773.png" %>
|
12
|
+
<%# link_to I18n.t("papermill.edit-with-pixlr", :resource => @asset.name), "http://www.pixlr.com/editor/?image=http://#{@test || request.env["HTTP_HOST"] + @asset.url}&target=http://#{receive_from_pixlr_papermill_path(@asset)}&method=POST", :target => "_blank" %>
|
6
13
|
<div style="clear:both;"></div>
|
7
14
|
<% else %>
|
8
15
|
<%= link_to t("file_type", :type => @asset.content_type, :scope => 'papermill'), @asset.url, :popup => true %>
|
9
16
|
<% end -%>
|
17
|
+
|
18
|
+
|
10
19
|
</div>
|
11
20
|
<div id="right">
|
12
21
|
<div id="read-only">
|
@@ -4,6 +4,8 @@ en:
|
|
4
4
|
updated: "'{{resource}}' updated"
|
5
5
|
not-found: "'#{{resource}}' not found"
|
6
6
|
edit-title: "Click to edit '{{resource}}'"
|
7
|
+
crop: "Double-click to crop '{{resource}}'"
|
8
|
+
edit-with-pixlr: "Edit '{{resource}}' online @ pixlr.com"
|
7
9
|
thumbnail-edit-title: "Double-click to edit '{{resource}}'"
|
8
10
|
upload-button-wording: "Upload..."
|
9
11
|
delete: "Remove {{resource}}"
|
@@ -37,6 +39,8 @@ fr:
|
|
37
39
|
updated: "'{{resource}}' modifiés(s)"
|
38
40
|
not-found: "'{{resource}}' non trouvé"
|
39
41
|
edit-title: "Cliquer pour éditer '{{resource}}'"
|
42
|
+
crop: "Double-cliquer pour retailler '{{resource}}'"
|
43
|
+
edit-with-pixlr: "Éditer '{{resource}}' en-ligne sur pixlr.com"
|
40
44
|
thumbnail-edit-title: "Double-cliquer pour éditer '{{resource}}'"
|
41
45
|
upload-button-wording: "Charger.."
|
42
46
|
delete: "Supprimer {{resource}}"
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
|
-
map.resources :papermill, :collection => { :sort => :post, :mass_edit => :post, :mass_delete => :post, :mass_thumbnail_reset => :post }, :member => { :crop => :get }
|
2
|
+
map.resources :papermill, :collection => { :sort => :post, :mass_edit => :post, :mass_delete => :post, :mass_thumbnail_reset => :post }, :member => { :crop => :get, :receive_from_pixlr => :post }
|
3
3
|
map.connect "#{Papermill::options[:papermill_url_prefix]}/#{Papermill::compute_paperclip_path.gsub(":id_partition", ":id0/:id1/:id2")}", :controller => "papermill", :action => "show", :requirements => { :style => /.*/ }
|
4
4
|
end
|
@@ -24,7 +24,7 @@ class <%= migration_name %> < ActiveRecord::Migration
|
|
24
24
|
end
|
25
25
|
|
26
26
|
change_table :papermill_assets do |t|
|
27
|
-
t.index [:
|
27
|
+
t.index [:assetable_id, :assetable_type, :assetable_key, :position], { :name => "papermill_index" }
|
28
28
|
t.index [:assetable_key, :position] # for non assetable assets
|
29
29
|
end
|
30
30
|
end
|
@@ -50,23 +50,25 @@ module ActionView::Helpers::FormTagHelper
|
|
50
50
|
assetable_type = assetable && assetable.class.base_class.name || nil
|
51
51
|
|
52
52
|
options = PapermillAsset.papermill_options(assetable && assetable.class.name, key).deep_merge(options)
|
53
|
+
|
53
54
|
dom_id = "papermill_#{assetable_type}_#{assetable_id}_#{key}"
|
54
55
|
|
55
56
|
if ot = options[:thumbnail]
|
56
57
|
w = ot[:width] || ot[:height] && ot[:aspect_ratio] && (ot[:height] * ot[:aspect_ratio]).to_i || nil
|
57
58
|
h = ot[:height] || ot[:width] && ot[:aspect_ratio] && (ot[:width] / ot[:aspect_ratio]).to_i || nil
|
58
|
-
|
59
|
+
|
60
|
+
computed_style = ot[:style] || (w || h) && "#{w}x#{h}>" || "original"
|
59
61
|
set_papermill_inline_css(dom_id, w, h, options)
|
60
62
|
end
|
61
63
|
|
62
|
-
set_papermill_inline_js(dom_id, compute_papermill_create_url(assetable_id, assetable_type, key, options), options)
|
64
|
+
set_papermill_inline_js(dom_id, compute_papermill_create_url(assetable_id, assetable_type, key, computed_style, options), options)
|
63
65
|
|
64
66
|
html = {}
|
65
67
|
html[:upload_button] = %{<div id="#{dom_id}-button-wrapper" class="papermill-button-wrapper" style="height: #{options[:swfupload][:button_height]}px;"><span id="browse_for_#{dom_id}" class="swf_button"></span></div>}
|
66
68
|
html[:container] = @template.content_tag(:div, :id => dom_id, :class => "papermill-#{key.to_s} #{(options[:thumbnail] ? "papermill-thumb-container" : "papermill-asset-container")} #{(options[:gallery] ? "papermill-multiple-items" : "papermill-unique-item")}") do
|
67
69
|
conditions = {:assetable_type => assetable_type, :assetable_id => assetable_id}
|
68
70
|
conditions.merge!({:assetable_key => key.to_s}) if key
|
69
|
-
@template.render :partial => "papermill/asset", :collection => PapermillAsset.all(:conditions => conditions), :locals => { :thumbnail_style =>
|
71
|
+
@template.render :partial => "papermill/asset", :collection => PapermillAsset.all(:conditions => conditions), :locals => { :thumbnail_style => computed_style, :targetted_geometry => options[:targetted_geometry] }
|
70
72
|
end
|
71
73
|
|
72
74
|
if options[:gallery]
|
@@ -88,11 +90,11 @@ module ActionView::Helpers::FormTagHelper
|
|
88
90
|
end
|
89
91
|
|
90
92
|
|
91
|
-
def compute_papermill_create_url(assetable_id, assetable_type, key, options)
|
93
|
+
def compute_papermill_create_url(assetable_id, assetable_type, key, computed_style, options)
|
92
94
|
create_url_options = {
|
93
95
|
:escape => false, :controller => "/papermill", :action => "create",
|
94
96
|
:asset_class => (options[:class_name] || PapermillAsset).to_s,
|
95
|
-
:gallery => !!options[:gallery], :thumbnail_style =>
|
97
|
+
:gallery => !!options[:gallery], :thumbnail_style => computed_style, :targetted_geometry => options[:targetted_geometry]
|
96
98
|
}
|
97
99
|
create_url_options.merge!({ :assetable_id => assetable_id, :assetable_type => assetable_type }) if assetable_id
|
98
100
|
create_url_options.merge!({ :assetable_key => key }) if key
|
data/lib/papermill/papermill.rb
CHANGED
@@ -29,9 +29,8 @@ module Papermill
|
|
29
29
|
(@papermill_associations ||= {}).merge!( assoc_name => Papermill::options.deep_merge(local_options) )
|
30
30
|
|
31
31
|
include Papermill::InstanceMethods
|
32
|
-
before_destroy :destroy_assets
|
33
32
|
after_create :rebase_assets
|
34
|
-
has_many :papermill_assets, :as => "
|
33
|
+
has_many :papermill_assets, :as => "assetable", :dependent => :destroy
|
35
34
|
|
36
35
|
[assoc_name, Papermill::options[:base_association_name].to_sym].uniq.each do |assoc|
|
37
36
|
define_method assoc do |*options|
|
@@ -63,10 +62,6 @@ module Papermill
|
|
63
62
|
|
64
63
|
private
|
65
64
|
|
66
|
-
def destroy_assets
|
67
|
-
papermill_assets.each &:destroy
|
68
|
-
end
|
69
|
-
|
70
65
|
def rebase_assets
|
71
66
|
PapermillAsset.all(:conditions => { :assetable_id => self.timestamp, :assetable_type => self.class.base_class.name }).each do |asset|
|
72
67
|
asset.created_at < 2.hours.ago ? asset.destroy : asset.update_attribute(:assetable_id, self.id)
|
@@ -13,7 +13,7 @@ class PapermillAsset < ActiveRecord::Base
|
|
13
13
|
validates_attachment_presence :file
|
14
14
|
|
15
15
|
belongs_to :assetable, :polymorphic => true
|
16
|
-
default_scope :order => '
|
16
|
+
default_scope :order => 'position'
|
17
17
|
|
18
18
|
named_scope :key, lambda { |assetable_key| { :conditions => ['assetable_key = ?', assetable_key.to_s] }}
|
19
19
|
|
@@ -9,37 +9,47 @@ module Papermill
|
|
9
9
|
|
10
10
|
OPTIONS = {
|
11
11
|
|
12
|
-
|
12
|
+
|
13
|
+
#@@@@@@@@@@@@@@ Papermill association parameters @@@@@@@@@@@@@@@@@@
|
13
14
|
|
14
15
|
# You can override these parameters here, or in your papermill associations definition.
|
15
16
|
|
16
|
-
# Associated PapermillAsset subclass (must be STI subclass of PapermillAsset)
|
17
|
+
# Associated PapermillAsset subclass (must be an STI subclass of PapermillAsset)
|
17
18
|
# :class_name => "PapermillAsset",
|
18
19
|
|
20
|
+
|
21
|
+
|
22
|
+
|
19
23
|
#@@@@@@@@@@@@@@@@@@@ form-helper parameters @@@@@@@@@@@@@@@@@@@@@@@
|
20
24
|
|
21
25
|
# You can override all these parameters here, or in your papermill associations definition, or in form-helper calls.
|
22
26
|
|
23
27
|
# Helper can generates inline css styling that adapt to your gallery/images placeholder. You can use it to scaffold, then copy the lines you need in your application css and set it to false.
|
28
|
+
|
24
29
|
# :inline_css => true,
|
25
30
|
|
26
31
|
# SwfUpload will only let the user upload images.
|
32
|
+
|
27
33
|
# :images_only => false,
|
28
34
|
|
29
35
|
# Dashboard is only for galleries
|
30
36
|
# You can remove/change order of HTML elements.
|
31
37
|
# See below for dashboard
|
38
|
+
|
32
39
|
# :form_helper_elements => [:upload_button, :container, :dashboard],
|
33
40
|
|
34
41
|
# Dashboard elements
|
35
42
|
# You can remove/change order of HTML elements. You can add :mass_thumbnail_reset to add a link to reset all thumbnails, although you shouldn't need it.
|
43
|
+
|
36
44
|
# :dashboard => [:mass_edit, :mass_delete ],
|
37
45
|
|
38
46
|
# Attributes editable at once for all assets in a gallery
|
47
|
+
|
39
48
|
# :mass_editable_fields => ["title", "copyright", "description"],
|
40
49
|
|
41
50
|
# Attributes you can edit in the form. You can use :type (string or text) and :label (any string)
|
42
51
|
# if you have more complex needs, you should override app/views/papermill/_form.html.erb in your application.
|
52
|
+
|
43
53
|
# :editable_fields => [
|
44
54
|
# {:title => {:type => "string"}},
|
45
55
|
# {:alt => {:type => "string"}},
|
@@ -52,19 +62,29 @@ module Papermill
|
|
52
62
|
# Great for quick admin scaffolding.
|
53
63
|
|
54
64
|
:gallery => {
|
65
|
+
|
55
66
|
# override calculated gallery width. Ex: "auto"
|
67
|
+
|
56
68
|
# :width => nil,
|
69
|
+
|
57
70
|
# override calculated gallery height
|
71
|
+
|
58
72
|
# :height => nil,
|
73
|
+
|
59
74
|
# Number of columns and lines in a gallery
|
75
|
+
|
60
76
|
# :columns => 8,
|
61
77
|
# :lines => 2,
|
78
|
+
|
62
79
|
# vertical/horizontal padding/margin around each thumbnails
|
80
|
+
|
63
81
|
# :vpadding => 0,
|
64
82
|
# :hpadding => 0,
|
65
83
|
# :vmargin => 1,
|
66
84
|
# :hmargin => 1,
|
85
|
+
|
67
86
|
# border around thumbnails
|
87
|
+
|
68
88
|
# :border_thickness => 2
|
69
89
|
},
|
70
90
|
|
@@ -74,12 +94,19 @@ module Papermill
|
|
74
94
|
# Needed if you set :aliases_only to true
|
75
95
|
|
76
96
|
:thumbnail => {
|
97
|
+
|
77
98
|
# :width => 100,
|
78
99
|
# :height => 100,
|
79
100
|
# :aspect_ratio => nil,
|
80
101
|
# :style => nil
|
81
102
|
},
|
82
|
-
|
103
|
+
|
104
|
+
# If you plan to use the original images in one place in one specific size, you can pass targetted_geometry,
|
105
|
+
# to incitate the user to crop the image himself (double-click on the image when editing) with the right parameters,
|
106
|
+
# instead of letting ImageMagick do his magick bluntly at render-time.
|
107
|
+
|
108
|
+
# :targetted_geometry => nil,
|
109
|
+
|
83
110
|
# Options passed on to SWFUpload.
|
84
111
|
# To remove an option when overriding, set it to nil.
|
85
112
|
|
@@ -97,24 +124,26 @@ module Papermill
|
|
97
124
|
# :file_size_limit => "'10 MB'"
|
98
125
|
},
|
99
126
|
|
100
|
-
|
127
|
+
#@@@@@@@@@@@@@@@@@ thumbnails style parameters @@@@@@@@@@@@@@@@@@@@
|
101
128
|
|
102
129
|
# You can override all these parameters here, or in your papermill associations definition, or in thumbnail styling hashes.
|
103
130
|
|
104
131
|
# 1. COPYRIGHT WATERMARKING
|
105
132
|
|
106
|
-
# Activate with '©' at the end of your geometry string or pass :copyright => "my_copyright" in alias definition
|
133
|
+
# Activate with '©' at the end of your geometry string or pass :copyright => true|"my_copyright" in alias definition or geometry hash
|
107
134
|
# Papermill will use, in that order of priority :
|
108
135
|
# * copyright found in geometry string AFTER the @
|
109
|
-
# * alternatively :copyright in alias/
|
136
|
+
# * alternatively :copyright in alias/definition hash
|
110
137
|
# * asset's copyright column (if found)
|
111
138
|
# * associated :copyright definition in your Assetable association definition
|
112
|
-
# * below :copyright definition
|
139
|
+
# * below's :copyright definition
|
113
140
|
|
114
|
-
# Set this definition to
|
115
|
-
|
141
|
+
# Set this definition to a default copyright name if you want one (You'll still need to postfix your geometry string with © or pass {:watermark => true} in your alias/geometry hash to use it)
|
142
|
+
|
143
|
+
# :copyright => nil,
|
144
|
+
|
145
|
+
# Textilize, truncate, transform... your copyright before its ImageMagick integration
|
116
146
|
|
117
|
-
# Textilize, truncate, transform... your copyright before integration
|
118
147
|
# :copyright_text_transform => Proc.new {|c| c },
|
119
148
|
|
120
149
|
# Watermark ImageMagick command string.
|
@@ -122,7 +151,7 @@ module Papermill
|
|
122
151
|
# * DO NOT change the background color!, change the bordercolor instead. (because background color adds to bordercolor I set it to totally transparent)
|
123
152
|
# * for both fill (=foreground color) and bordercolor (=background color), the last two octals control alpha (transparency). FF is opaque, 00 is transparent.
|
124
153
|
# * remove -bordercolor if you don't want any background
|
125
|
-
# * +antialias to REMOVE antialiasing
|
154
|
+
# * add +antialias to REMOVE antialiasing (after '-font Arial-Bold', for example)
|
126
155
|
# * font-size is pointsize
|
127
156
|
# * type 'identify -list font' to get a list of the fonts you can use (ImageMagick will default to Arial/Times if it can't find it)
|
128
157
|
# * use -gravity and -geometry for positionning, -geometry +x+y is relative to -gravity's corner/zone
|
@@ -137,21 +166,29 @@ module Papermill
|
|
137
166
|
# If you pass an image_path to :watermark, it will override below :
|
138
167
|
|
139
168
|
# you can use a relative path from your public directory (see :public_root), a complete path, or an URI
|
169
|
+
|
140
170
|
# :watermark => "/images/rails.png",
|
141
171
|
|
142
172
|
# default :watermarking command for image_magick. %s gets interpolated with above image path.
|
173
|
+
|
143
174
|
# :watermark_im_command => %{- | composite \\( %s -resize 100% \\) - -dissolve 20% -gravity center -geometry +0+0 },
|
144
175
|
|
145
|
-
|
146
|
-
|
176
|
+
|
177
|
+
|
178
|
+
#@@@@@@@@@@@@@@@@@ Application-wide parameters @@@@@@@@@@@@@@@@@@@@
|
179
|
+
|
147
180
|
# Default named_scope name for catch-all :papermill declaration
|
181
|
+
|
148
182
|
# :base_association_name => :assets,
|
149
183
|
|
150
|
-
# Set to true to require aliases in all url/path
|
184
|
+
# Set to true to require aliases in all url/path, disabling the
|
151
185
|
# Don't forget to give an alias value to options[:thumbnail][:style] if true!
|
186
|
+
|
152
187
|
# :alias_only => false,
|
153
188
|
|
154
189
|
# Needed if :alias_only
|
190
|
+
# Aliases are available application wide for all your assets. You can pass them instead of a geometry_string or a geometry hash
|
191
|
+
|
155
192
|
:aliases => {
|
156
193
|
# :mini_crop => "100x100#",
|
157
194
|
# :cant_touch_this => {
|
@@ -165,9 +202,11 @@ module Papermill
|
|
165
202
|
# e.g. if you want to protect access to non-copyrighted original files,
|
166
203
|
# or don't want users to browse images by guessing the sequence of ids,
|
167
204
|
# an encrypted hash can be generated for each geometry string/alias and added to path/url.
|
205
|
+
# Use your imagination for :url_key_generator, really.
|
168
206
|
# Please note that all previous assets paths will be lost if you add/remove or change the :url_key generation.
|
207
|
+
|
169
208
|
# :use_url_key => false,
|
170
|
-
# :url_key_salt => "change-me-to-your-favorite-pet-name",
|
209
|
+
# :url_key_salt => "change-me-to-your-favorite-pet's-name",
|
171
210
|
# :url_key_generator => Proc.new { |style, asset| Digest::SHA512.hexdigest("#{style}#{asset.id}#{Papermill::options[:url_key_salt]}")[0..10] },
|
172
211
|
|
173
212
|
# added before path/url. Your front webserver will need to be able to find your assets
|
@@ -12,6 +12,7 @@ module Papermill
|
|
12
12
|
{:copyright => {:type => "string"}},
|
13
13
|
{:description => {:type => "text" }}
|
14
14
|
],
|
15
|
+
:targetted_geometry => nil,
|
15
16
|
:gallery => {
|
16
17
|
:width => nil,
|
17
18
|
:height => nil,
|
@@ -42,7 +43,7 @@ module Papermill
|
|
42
43
|
:prevent_swf_caching => true,
|
43
44
|
:file_size_limit => "'10 MB'"
|
44
45
|
},
|
45
|
-
:copyright =>
|
46
|
+
:copyright => nil,
|
46
47
|
:copyright_text_transform => Proc.new {|c| c },
|
47
48
|
:copyright_im_command => %{\\( -font Arial-Bold -pointsize 9 -fill '#FFFFFFE0' -border 3 -bordercolor '#50550080' -background '#00000000' label:' %s ' \\) -gravity South-West -geometry +0+0 -composite},
|
48
49
|
:watermark => "/images/rails.png",
|
@@ -13,8 +13,16 @@ module Paperclip
|
|
13
13
|
# copyright extraction
|
14
14
|
if options[:geometry] =~ /©/ || options[:copyright]
|
15
15
|
options[:geometry], *@copyright = options[:geometry].split("©", -1)
|
16
|
-
|
17
|
-
@copyright = (
|
16
|
+
|
17
|
+
@copyright = (
|
18
|
+
(options[:copyright] != true && options[:copyright]) ||
|
19
|
+
@copyright.join("©").nie ||
|
20
|
+
file.instance.respond_to?(:copyright) && file.instance.copyright.nie ||
|
21
|
+
file.instance.papermill_options[:copyright].nie)
|
22
|
+
|
23
|
+
if @copyright
|
24
|
+
@copyright = (options[:copyright_text_transform] || file.instance.papermill_options[:copyright_text_transform]).try(:call, @copyright) || @copyright
|
25
|
+
end
|
18
26
|
end
|
19
27
|
|
20
28
|
# watermark extraction
|
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.3.
|
4
|
+
version: 1.3.4
|
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: 2010-
|
12
|
+
date: 2010-02-09 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|