papermill 0.13.2 → 0.14.0

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/README.rdoc CHANGED
@@ -21,6 +21,7 @@ Asset management made easy.
21
21
 
22
22
  papermill my_option_hash # in your papermilled assetable model
23
23
  assets_upload(:my_key, my_option_hash) # form helper call
24
+ f.input :my_key, :as => :assets_upload, my_option_hash # if you are using formtastic
24
25
  @assetable.assets(:my_key) # data access in your view
25
26
 
26
27
  === Association specific declaration
@@ -64,7 +65,7 @@ See papermill_module.rb for the complete list of options.
64
65
  :height => 100
65
66
  },
66
67
  :aliases => {
67
- :big => "500x500>"
68
+ :big => "500x500>",
68
69
  :small => "100x100>"
69
70
  },
70
71
  :public_root => ":rails_root/public", # already a default
data/TODO.txt CHANGED
@@ -1,6 +1,5 @@
1
1
  * non-regression tests
2
+ * write rake task to delete all forgotten images.
2
3
  Edit views :
3
- * better CSS
4
- * use forms
5
4
  * use Jcrop
6
5
  * try Picnic API
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.2
1
+ 0.14.0
@@ -1,24 +1,28 @@
1
1
  class PapermillController < ApplicationController
2
2
  # Create is protected because of the Ajax same origin policy.
3
- # Yet SwfUpload doesn't send the right header for request.xhr? to be true and thus failed to disable verify_authenticity_token automatically.
3
+ # Yet SwfUpload doesn't send the right header for request.xhr? to be true and thus fails to disable verify_authenticity_token automatically.
4
4
  skip_before_filter :verify_authenticity_token, :only => [:create]
5
5
 
6
6
  def show
7
- complete_id = (params[:id0] + params[:id1] + params[:id2]).to_i
8
- asset = PapermillAsset.find(complete_id)
9
- raise if asset.nil? || params[:style] == "original"
10
- style = Papermill::PAPERMILL_DEFAULTS[:aliases][params[:style]] || !Papermill::PAPERMILL_DEFAULTS[:alias_only] && params[:style]
11
- raise unless style
12
- style = {:geometry => style} unless style.is_a? Hash # new Paperclip API
7
+ begin
8
+ complete_id = (params[:id0] + params[:id1] + params[:id2]).to_i
9
+ asset = PapermillAsset.find(complete_id)
10
+ raise if asset.nil? || params[:style] == "original"
11
+ style = Papermill::PAPERMILL_DEFAULTS[:aliases][params[:style]] || !Papermill::PAPERMILL_DEFAULTS[:alias_only] && params[:style]
12
+ raise unless style
13
+ style = {:geometry => style} unless style.is_a? Hash
13
14
 
14
- if asset.image?
15
- temp_thumbnail = Paperclip::Thumbnail.make(asset_file = asset.file, style)
16
- new_parent_folder_path = File.dirname(new_image_path = asset_file.path(params[:style]))
17
- FileUtils.mkdir_p new_parent_folder_path unless File.exists? new_parent_folder_path
18
- FileUtils.cp temp_thumbnail.path, new_image_path
19
- redirect_to asset.url(params[:style])
20
- else
21
- redirect_to asset.url
15
+ if asset.image?
16
+ temp_thumbnail = Paperclip::Thumbnail.make(asset_file = asset.file, style)
17
+ new_parent_folder_path = File.dirname(new_image_path = asset_file.path(params[:style]))
18
+ FileUtils.mkdir_p new_parent_folder_path unless File.exists? new_parent_folder_path
19
+ FileUtils.cp temp_thumbnail.path, new_image_path
20
+ redirect_to asset.url(params[:style])
21
+ else
22
+ redirect_to asset.url
23
+ end
24
+ rescue
25
+ render :text => t('papermill.not-found'), :status => "404"
22
26
  end
23
27
  end
24
28
 
@@ -29,7 +33,7 @@ class PapermillController < ApplicationController
29
33
  page << "jQuery('#papermill_asset_#{params[:id]}').remove()"
30
34
  else
31
35
  page << "jQuery('#papermill_asset_#{params[:id]}').show()"
32
- page << %{ notify("#{t((@asset && "not-deleted" || "not-found"), :ressource => @asset.name, :scope => "papermill")}", "error") }
36
+ page << %{ notify("#{t((@asset && "papermill.not-deleted" || "papermill.not-found"), :ressource => @asset.name)}", "error") }
33
37
  end
34
38
  end
35
39
  end
@@ -38,9 +42,9 @@ class PapermillController < ApplicationController
38
42
  @asset = PapermillAsset.find_by_id(params[:id])
39
43
  render :update do |page|
40
44
  if @asset && @asset.update_attributes(params[:papermill_asset])
41
- page << %{ notify("#{t("updated", :ressource => @asset.name, :scope => "papermill")}", "notice") }
45
+ page << %{ notify("#{t("papermill.updated", :ressource => @asset.name)}", "notice") }
42
46
  else
43
- page << %{ notify("#{@asset && @asset.errors.full_messages.to_sentence || t("not-found", :ressource => params[:id].to_s, :scope => "papermill")}", "warning") }
47
+ page << %{ notify("#{@asset && @asset.errors.full_messages.to_sentence || t("papermill.not-found", :ressource => params[:id].to_s)}", "warning") }
44
48
  end
45
49
  end
46
50
  end
@@ -65,7 +69,7 @@ class PapermillController < ApplicationController
65
69
  @old_asset.destroy if @old_asset
66
70
  render :partial => "papermill/asset", :object => @asset, :locals => {:gallery => params[:gallery], :thumbnail_style => params[:thumbnail_style]}
67
71
  else
68
- render :text => message, :status => "500"
72
+ render :text => @asset.errors.full_messages.join('<br />'), :status => "500"
69
73
  end
70
74
  end
71
75
 
@@ -1,7 +1,7 @@
1
1
  <%- dom_id = "papermill_asset_#{asset.id}" -%>
2
- <%- delete_link = %{<a onclick="if(confirm('#{escape_javascript I18n.t("delete-confirmation", :scope => :papermill, :resource => asset.name)}')){ $.ajax({async:true, beforeSend:function(request){$('##{dom_id}').hide();}, dataType:'script', error:function(request){$('##{dom_id}').show();}, type:'delete', url:'#{papermill_url(asset)}'})}; return false;" href="#" class="delete"><img title="#{escape_javascript t("delete", :scope => "papermill", :ressource => asset.name)}" src="/papermill/images/delete.png" alt="delete"/></a>} %>
2
+ <%- delete_link = %{<a onclick="if(confirm('#{escape_javascript t("papermill.delete-confirmation", :resource => asset.name)}')){ $.ajax({async:true, beforeSend:function(request){$('##{dom_id}').hide();}, dataType:'script', error:function(request){$('##{dom_id}').show();}, type:'delete', url:'#{papermill_url(asset)}'})}; return false;" href="#" class="delete"><img title="#{escape_javascript t("papermill.delete", :ressource => asset.name)}" src="/papermill/images/delete.png" alt="delete"/></a>} %>
3
3
 
4
- <li id="<%= dom_id %>" title="<%= t("#{thumbnail_style ? "thumbnail-" : ""}edit-title", :scope => "papermill", :ressource => asset.name) %>" onDblClick="popup(jQuery(this).attr('rel')); return false;" rel="<%= edit_papermill_url(asset) %>">
4
+ <li id="<%= dom_id %>" title="<%= t("papermill.#{thumbnail_style ? "thumbnail-" : ""}edit-title", :ressource => asset.name) %>" onDblClick="popup(jQuery(this).attr('rel')); return false;" rel="<%= edit_papermill_url(asset) %>">
5
5
  <%= delete_link %>
6
6
  <%- if thumbnail_style -%>
7
7
  <%= render :partial => "papermill/thumbnail_asset", :object => asset, :locals => {:thumbnail_style => thumbnail_style} %>
@@ -1,13 +1,13 @@
1
1
  <p>
2
- <%= form.label :title, I18n.t("title", :scope => 'papermill') %><br />
2
+ <%= form.label :title, t("papermill.title") %><br />
3
3
  <%= form.text_field :title, :class => "text_field" %>
4
4
  </p>
5
5
  <p>
6
- <%= form.label :copyright, I18n.t("copyright", :scope => 'papermill') %><br />
6
+ <%= form.label :copyright, t("papermill.copyright") %><br />
7
7
  <%= form.text_field :copyright, :class => "text_field" %>
8
8
  </p>
9
9
  <p>
10
- <%= form.label :description, I18n.t("description", :scope => 'papermill') %><br />
10
+ <%= form.label :description, t("papermill.description") %><br />
11
11
  <%= form.text_area :description %>
12
12
  </p>
13
- <%= submit_tag I18n.t('save', :scope => 'papermill') %>
13
+ <%= submit_tag t('papermill.save') %>
@@ -1,23 +1,23 @@
1
1
  <div id="papermill-box">
2
2
  <div id="left">
3
- <%= link_to(@asset.image? ? image_tag(@asset.url("400x#{Papermill::PAPERMILL_DEFAULTS[:max_height]}>")) : I18n.t("file_type", :type => @asset.content_type, :scope => 'papermill'), @asset.url, :popup => true) %>
3
+ <%= link_to(@asset.image? ? image_tag(@asset.url("400x#{Papermill::PAPERMILL_DEFAULTS[:max_height]}>")) : t("file_type", :type => @asset.content_type, :scope => 'papermill'), @asset.url, :popup => true) %>
4
4
  </div>
5
5
  <div id="right">
6
6
  <div id="read-only">
7
7
  <table border="0">
8
- <tr><td class="left-cell"><%= I18n.t("name", :scope => 'papermill') %> </td><td><%= @asset.name %></td></tr>
9
- <tr><td class="left-cell"><%= I18n.t("content_type", :scope => 'papermill') %></td><td><%= @asset.content_type %></td></tr>
10
- <tr><td class="left-cell"><%= I18n.t("size", :scope => 'papermill') %> </td><td><%= number_to_human_size(@asset.size.to_i) %></td></tr>
8
+ <tr><td class="left-cell"><%= t("papermill.name") %> </td><td><%= @asset.name %></td></tr>
9
+ <tr><td class="left-cell"><%= t("papermill.content_type") %></td><td><%= @asset.content_type %></td></tr>
10
+ <tr><td class="left-cell"><%= t("papermill.size") %> </td><td><%= number_to_human_size(@asset.size.to_i) %></td></tr>
11
11
  <% if @asset.image? %>
12
- <tr><td class="left-cell"><%= I18n.t("width", :scope => 'papermill') %> </td><td><%= @asset.width.to_i %>px</td></tr>
13
- <tr><td class="left-cell"><%= I18n.t("height", :scope => 'papermill') %> </td><td><%= @asset.height.to_i %>px</td></tr>
12
+ <tr><td class="left-cell"><%= t("papermill.width") %> </td><td><%= @asset.width.to_i %>px</td></tr>
13
+ <tr><td class="left-cell"><%= t("papermill.height") %> </td><td><%= @asset.height.to_i %>px</td></tr>
14
14
  <% end %>
15
- <tr><td class="left-cell"><%= I18n.t("created_at", :scope => 'papermill') %> </td><td><%= I18n.l(@asset.created_at) %></td></tr>
16
- <tr><td class="left-cell"><%= I18n.t("updated_at", :scope => 'papermill') %> </td><td><%= I18n.l(@asset.updated_at) %></td></tr>
15
+ <tr><td class="left-cell"><%= t("papermill.created_at") %> </td><td><%= I18n.l(@asset.created_at) %></td></tr>
16
+ <tr><td class="left-cell"><%= t("papermill.updated_at") %> </td><td><%= I18n.l(@asset.updated_at) %></td></tr>
17
17
  </table>
18
18
  </div>
19
19
  <div id="read-write">
20
- <form onsubmit="jQuery.ajax({data:jQuery.param(jQuery(this).serializeArray()), dataType:'script', type:'post', url:'/papermill/<%= @asset.id %>'}); return false;" method="post" action="/papermill/76">
20
+ <form onsubmit="jQuery.ajax({data:jQuery.param(jQuery(this).serializeArray()), dataType:'script', type:'post', url:'/papermill/<%= @asset.id %>'}); return false;" method="post" action="/papermill/<%= @asset.id %>">
21
21
  <input type="hidden" value="put" name="_method"/>
22
22
  <% fields_for :papermill_asset, @asset do |form| %>
23
23
  <%= render :partial => 'form', :object => form %>
@@ -27,7 +27,7 @@
27
27
  </div>
28
28
  <div style="clear:both;"></div>
29
29
  <p id="footer">
30
- <%= I18n.t("location", :scope => 'papermill') + @asset.file.path %><br />
31
- <%= I18n.t("url", :scope => 'papermill') + @asset.url %>
30
+ <%= t("papermill.location") + @asset.file.path %><br />
31
+ <%= t("papermill.url") + @asset.url %>
32
32
  </p>
33
33
  </div>
@@ -42,7 +42,7 @@ fr:
42
42
  SWFUPLOAD_LOADING: "Chargement..."
43
43
  SWFUPLOAD_ERROR: "Une erreur est survenue pendant le chargement de"
44
44
  file_type: "Fichier {{type}}"
45
- name: "Nom : "
45
+ name: "Nom"
46
46
  content_type: "Content-type"
47
47
  size: "Taille du fichier"
48
48
  class_name: "Type d'asset"
@@ -91,7 +91,7 @@ module ActionView::Helpers::FormTagHelper
91
91
  collection = asset_class.find(:all, :conditions => conditions, :order => "position")
92
92
 
93
93
  html << %{<div id="#{id}-button-wrapper" class="papermill-button-wrapper" style="height: #{options[:swfupload][:button_height]}px;"><span id="browse_for_#{id}" class="swf_button"></span></div>}
94
- html << @template.content_tag(:ul, :id => id, :class => "papermill #{(options[:thumbnail] ? "papermill-thumb-container" : "papermill-asset-container")} #{(options[:gallery] ? "papermill-multiple-items" : "papermill-unique-item")}") {
94
+ html << @template.content_tag(:ul, :id => id, :class => "#{(options[:thumbnail] ? "papermill-thumb-container" : "papermill-asset-container")} #{(options[:gallery] ? "papermill-multiple-items" : "papermill-unique-item")}") {
95
95
  @template.render :partial => "papermill/asset", :collection => collection, :locals => { :thumbnail_style => (options[:thumbnail] && options[:thumbnail][:style]) }
96
96
  }
97
97
  @template.content_for :papermill_inline_js do
@@ -117,7 +117,7 @@ module ActionView::Helpers::FormTagHelper
117
117
  }
118
118
  end
119
119
  html.reverse! if options[:button_after_container]
120
- html.join("\n")
120
+ %{<div class="papermill">#{html.join("\n")}</div>}
121
121
  end
122
122
  end
123
123
 
@@ -137,4 +137,13 @@ class ActionView::Helpers::FormBuilder
137
137
  def image_upload(key = nil, options = {})
138
138
  papermill_upload_tag key, { :gallery => false }.update(options)
139
139
  end
140
- end
140
+ end
141
+
142
+ class Formtastic::SemanticFormBuilder
143
+ def method_missing(input_type, method, options)
144
+ return super unless input_type.to_s.match("_input")
145
+ input_type = input_type.to_s.split("_input").first
146
+ self.label(method, options_for_label(options)) +
147
+ self.send(input_type, method, options)
148
+ end
149
+ end
@@ -14,7 +14,7 @@ module PapermillHelper
14
14
  end
15
15
  html << %{<script type="text/javascript">}
16
16
  ["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING", "SWFUPLOAD_ERROR"].each do |js_constant|
17
- html << %{var #{js_constant} = "#{I18n.t(js_constant, :scope => "papermill")}";}
17
+ html << %{var #{js_constant} = "#{t("papermill.#{js_constant}")}";}
18
18
  end
19
19
  html << %{</script>}
20
20
  html << javascript_include_tag("/papermill/papermill", "/papermill/swfupload")
@@ -44,7 +44,7 @@ module Papermill
44
44
  :button_width => 61,
45
45
  :button_height => 22,
46
46
  # Wording and CSS processed through an Adobe Flash styler. Result is terrible. Feel free to put a CSS button overlayed directly on the SWF button. See swfupload website.
47
- :button_text => %{<span class="button-text">#{I18n.t("upload-button-wording", :scope => :papermill)}</span>},
47
+ :button_text => %{<span class="button-text">#{I18n.t("papermill.upload-button-wording")}</span>},
48
48
  :button_text_style => %{.button-text { color: red; font-size: 12pt; font-weight: bold; }},
49
49
  :button_disabled => "false",
50
50
  :button_text_top_padding => 4,
@@ -12,37 +12,41 @@
12
12
  #papermill-box .right-cell {}
13
13
  #papermill-box .left-cell {font-weight:bold; padding-right:10px; text-align:right;}
14
14
 
15
+ .papermill { overflow:hidden; }
15
16
  .papermill a:hover { background:none; color:inherit; }
16
17
  .papermill a img { border:0px; }
17
18
  .papermill li:hover { border-color:blue; }
18
- .papermill li a { display:block; }
19
+ .papermill li a { display:block; }
19
20
  .papermill .progress { display:block; border:1px solid #C2E3EF; text-align:left; height:6px; }
20
21
  .papermill .progress span { background:#7BB963; height:6px; width:0; display:block; }
21
22
 
22
- .papermill-thumb-container li { border:0px solid transparent; min-height:25px; min-width:25px; }
23
- .papermill-thumb-container { position:relative; border:5px solid #EEE; padding:4px; overflow-x:hidden; }
24
- .papermill-thumb-container li { display:block; float:left; position:relative; }
25
- .papermill-thumb-container .delete { position:absolute; bottom:5px; right:5px; }
26
- .papermill-thumb-container span { display:block; }
27
- .papermill-thumb-container .name { font-size:10px; overflow:hidden; font-weight:bold; }
28
- .papermill-thumb-container .infos { font-size:8px; overflow:hidden; }
29
- .papermill-thumb-container .status { margin-bottom:10px; }
23
+ .papermill-thumb-container { position:relative; border:5px solid #EEE; padding:4px; overflow:hidden; }
24
+ .papermill-thumb-container li { border:0px solid transparent; min-height:25px; min-width:25px; display:block; float:left; position:relative; }
25
+ .papermill-thumb-container li span { display:block; }
26
+ .papermill-thumb-container li .delete { position:absolute; bottom:5px; right:5px; }
27
+ .papermill-thumb-container li .name { font-size:10px; overflow:hidden; font-weight:bold; }
28
+ .papermill-thumb-container li .infos { font-size:8px; overflow:hidden; }
29
+ .papermill-thumb-container li .status { margin-bottom:10px; }
30
30
 
31
31
  .papermill-asset-container { border:1px solid #EEE; padding:3px; }
32
32
  .papermill-asset-container li { display:block; height:22px; }
33
- .papermill-asset-container .swfupload .name { margin-left:21px; }
34
- .papermill-asset-container .name { float:left; }
35
- .papermill-asset-container .status { margin-left:5px; float:left; }
36
- .papermill-asset-container .progress { float:left; margin-top:6px; margin-left:5px; width:100px; }
37
- .papermill-asset-container .delete { float:left; margin-top:2px; margin-right:5px; }
33
+ .papermill-asset-container li .swfupload .name { margin-left:21px; }
34
+ .papermill-asset-container li .name { float:left; }
35
+ .papermill-asset-container li .status { margin-left:5px; float:left; }
36
+ .papermill-asset-container li .progress { float:left; margin-top:6px; margin-left:5px; width:100px; }
37
+ .papermill-asset-container li .delete { float:left; margin-top:2px; margin-right:5px; }
38
38
 
39
39
  .papermill-asset-container.papermill-multiple-items { padding-left:10px; border-left:5px solid #EEE; min-height:44px; }
40
40
  .papermill-asset-container.papermill-multiple-items li { cursor:row-resize; }
41
41
  .papermill-thumb-container.papermill-multiple-items li { cursor:move; }
42
42
  .papermill-asset-container.papermill-unique-item { padding-left:5px; min-height:22px; }
43
43
 
44
+ /* Using formtastic? Move this to your formtastic_changes.css to make it cleaner : */
45
+ form.formtastic .papermill ul li {
46
+ margin-bottom:0;
47
+ }
48
+
44
49
  /* Need some backgrounds?
45
50
  .papermill li { background:transparent url(images/background.png) repeat top left; }
46
51
  .papermill-thumb-container { background:transparent url(images/container-background.jpg) repeat top left; }
47
52
  */
48
-
@@ -33,7 +33,7 @@ popup = function(url) {
33
33
  */
34
34
 
35
35
  notify = function(message, type) {
36
- alert(type + ": " + message)
36
+ if(type != "notice") { alert(type + ": " + message) }
37
37
  }
38
38
  /*
39
39
  If you have a notification library, override notify
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.13.2
4
+ version: 0.14.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-10-16 00:00:00 +02:00
12
+ date: 2009-10-29 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,8 +71,6 @@ files:
71
71
  - public/papermill/swfupload.swf
72
72
  - rails/init.rb
73
73
  - tasks/papermill_tasks.rake
74
- - test/papermill_test.rb
75
- - test/test_helper.rb
76
74
  - uninstall.rb
77
75
  has_rdoc: true
78
76
  homepage: http://github.com/bbenezech/papermill
@@ -98,10 +96,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
96
  requirements: []
99
97
 
100
98
  rubyforge_project:
101
- rubygems_version: 1.3.4
99
+ rubygems_version: 1.3.5
102
100
  signing_key:
103
101
  specification_version: 3
104
102
  summary: Paperclip Swfupload UploadHelper wrapper
105
- test_files:
106
- - test/papermill_test.rb
107
- - test/test_helper.rb
103
+ test_files: []
104
+
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PapermillTest < ActiveSupport::TestCase
4
- # Replace this with your real tests.
5
-
6
- test "the truth" do
7
- assert true
8
- end
9
- end
data/test/test_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'active_support'
3
- require 'active_support/test_case'