BBenezech-papermill 0.5.0 → 0.5.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/README.rdoc +4 -0
- data/VERSION +1 -1
- data/app/controllers/papermill_controller.rb +12 -20
- data/app/views/papermill/_asset.html.erb +1 -1
- data/config/locales/papermill.yml +0 -2
- data/installation-template.txt +7 -7
- data/lib/papermill/papermill_asset.rb +3 -9
- data/lib/papermill/papermill_module.rb +0 -2
- data/papermill.gemspec +3 -3
- data/public/javascripts/papermill.js +11 -17
- metadata +2 -2
data/README.rdoc
CHANGED
|
@@ -11,6 +11,10 @@ Asset management made easy.
|
|
|
11
11
|
|
|
12
12
|
$ sudo gem install sqlite3-ruby
|
|
13
13
|
$ rails -m http://gist.github.com/177714.txt papermill-example
|
|
14
|
+
$ cd papermill-example
|
|
15
|
+
$ ./script/server
|
|
16
|
+
$ GoTo localhost:3000 and try to create an article with assets but without title
|
|
17
|
+
$ profit
|
|
14
18
|
|
|
15
19
|
== Papermill comes in 2 flavors:
|
|
16
20
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.5.
|
|
1
|
+
0.5.2
|
|
@@ -25,32 +25,25 @@ class PapermillController < ApplicationController
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def destroy
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if @asset.destroy
|
|
32
|
-
page << "jQuery('#papermill_asset_#{params[:id]}').remove()"
|
|
33
|
-
else
|
|
34
|
-
page << "jQuery('#papermill_asset_#{params[:id]}').show()"
|
|
35
|
-
message = t("not-deleted", :ressource => @asset.name, :scope => "papermill")
|
|
36
|
-
page << %{ notify("#{message}", error) }
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
rescue ActiveRecord::RecordNotFound
|
|
40
|
-
render :update do |page|
|
|
28
|
+
@asset = PapermillAsset.find_by_id(params[:id])
|
|
29
|
+
render :update do |page|
|
|
30
|
+
if @asset && @asset.destroy
|
|
41
31
|
page << "jQuery('#papermill_asset_#{params[:id]}').remove()"
|
|
42
|
-
|
|
43
|
-
page <<
|
|
32
|
+
else
|
|
33
|
+
page << "jQuery('#papermill_asset_#{params[:id]}').show()"
|
|
34
|
+
page << %{ notify("#{t((@asset && "not-deleted" || "not-found"), :ressource => @asset.name, :scope => "papermill")}", error) }
|
|
44
35
|
end
|
|
45
36
|
end
|
|
46
37
|
end
|
|
47
38
|
|
|
48
39
|
def update
|
|
49
|
-
@asset = PapermillAsset.
|
|
50
|
-
@asset.update(params)
|
|
40
|
+
@asset = PapermillAsset.find_by_id(params[:id])
|
|
51
41
|
render :update do |page|
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
if @asset && @asset.update(params)
|
|
43
|
+
page << %{ notify("#{t("updated", :ressource => @asset.name, :scope => "papermill")}", "notice") }
|
|
44
|
+
else
|
|
45
|
+
page << %{ notify("#{@asset && @asset.errors.full_messages.to_sentence || t("not-found", :ressource => params[:id].to_s, :scope => "papermill")}", "warning") }
|
|
46
|
+
end
|
|
54
47
|
end
|
|
55
48
|
end
|
|
56
49
|
|
|
@@ -72,7 +65,6 @@ class PapermillController < ApplicationController
|
|
|
72
65
|
@old_asset.destroy if @old_asset
|
|
73
66
|
render :partial => "papermill/asset", :object => @asset, :locals => {:gallery => params[:gallery], :thumbnail_style => params[:thumbnail_style]}
|
|
74
67
|
else
|
|
75
|
-
message = t("not-created", :scope => "papermill")
|
|
76
68
|
render :text => message, :status => "500"
|
|
77
69
|
end
|
|
78
70
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%- dom_id = dom_id(asset) -%>
|
|
2
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="/images/papermill/delete.png" alt="delete"/></a>} %>
|
|
3
3
|
|
|
4
|
-
<li id="<%= dom_id %>" rel="<%= edit_papermill_url(asset) %>" title="<%= t("#{thumbnail_style ? "thumbnail-" : ""}edit-title", :scope => "papermill", :ressource => asset.name) %>">
|
|
4
|
+
<li id="<%= dom_id %>" onDblClick="popup(jQuery(this).attr('rel')); return false;" rel="<%= edit_papermill_url(asset) %>" title="<%= t("#{thumbnail_style ? "thumbnail-" : ""}edit-title", :scope => "papermill", :ressource => asset.name) %>">
|
|
5
5
|
<%= delete_link %>
|
|
6
6
|
<%- if thumbnail_style -%>
|
|
7
7
|
<%= render :partial => "papermill/thumbnail_asset", :object => asset, :locals => {:thumbnail_style => thumbnail_style} %>
|
|
@@ -3,7 +3,6 @@ en:
|
|
|
3
3
|
not-processed: "Error/ressource not processed"
|
|
4
4
|
updated: "{{ressource}} updated"
|
|
5
5
|
not-deleted: "{{ressource}} could not be deleted"
|
|
6
|
-
not-created: "Ressource could not be created"
|
|
7
6
|
not-found: "Asset #{{ressource}} not found"
|
|
8
7
|
edit-title: "" # You can use {{ressource}}
|
|
9
8
|
thumbnail-edit-title: ""
|
|
@@ -18,7 +17,6 @@ fr:
|
|
|
18
17
|
not-processed: "Erreur/ressource non trouvée"
|
|
19
18
|
updated: "{{ressource}} mise à jour"
|
|
20
19
|
not-deleted: "{{ressource}} n'a pas pu être supprimée"
|
|
21
|
-
not-created: "La ressource n'a pas pu être créée"
|
|
22
20
|
not-found: "Asset #{{ressource}} non trouvé"
|
|
23
21
|
edit-title: ""
|
|
24
22
|
thumbnail-edit-title: ""
|
data/installation-template.txt
CHANGED
|
@@ -12,7 +12,7 @@ rake "db:migrate"
|
|
|
12
12
|
file "app/models/article.rb", <<-END
|
|
13
13
|
class Article < ActiveRecord::Base
|
|
14
14
|
validates_presence_of :title
|
|
15
|
-
papermill :thumbnail => {:width =>
|
|
15
|
+
papermill :thumbnail => {:width => 100, :height => 75} # catch-all for non-specified associations
|
|
16
16
|
papermill :image_gallery, :class_name => ImageAsset, :images_only => true, :thumbnail => {:width => 75, :height => 100}
|
|
17
17
|
# image_gallery association (set with define_method)
|
|
18
18
|
end
|
|
@@ -80,24 +80,24 @@ file "app/views/articles/show.html.erb", <<-END
|
|
|
80
80
|
<% end %>
|
|
81
81
|
</p>
|
|
82
82
|
<br /><br />
|
|
83
|
-
<b>@article.papermill_assets(:
|
|
83
|
+
<b>@article.papermill_assets(:my_other_image).first :</b>
|
|
84
84
|
<p>
|
|
85
|
-
<% image = @article.papermill_assets(:
|
|
85
|
+
<% image = @article.papermill_assets(:my_other_image).first %>
|
|
86
86
|
<%= link_to(image_tag(image.url("100x100#")), image.url) if image %>
|
|
87
87
|
</p>
|
|
88
88
|
<br /><br />
|
|
89
|
-
<b>@article.papermill_assets(:
|
|
89
|
+
<b>@article.papermill_assets(:my_assets).each :</b>
|
|
90
90
|
<p>
|
|
91
91
|
<ul>
|
|
92
|
-
<% @article.papermill_assets(:
|
|
92
|
+
<% @article.papermill_assets(:my_assets).each do |asset| %>
|
|
93
93
|
<li><%= link_to asset.name, asset.url %></li>
|
|
94
94
|
<% end %>
|
|
95
95
|
</ul>
|
|
96
96
|
</p>
|
|
97
97
|
<br /><br />
|
|
98
|
-
<b>@article.papermill_assets(:
|
|
98
|
+
<b>@article.papermill_assets(:my_other_asset).first :</b>
|
|
99
99
|
<p>
|
|
100
|
-
<% asset = @article.papermill_assets(:
|
|
100
|
+
<% asset = @article.papermill_assets(:my_other_asset).first %>
|
|
101
101
|
<%= link_to(asset.name, asset.url) if asset %>
|
|
102
102
|
</p>
|
|
103
103
|
|
|
@@ -3,9 +3,7 @@ class PapermillAsset < ActiveRecord::Base
|
|
|
3
3
|
|
|
4
4
|
belongs_to :assetable, :polymorphic => true
|
|
5
5
|
before_destroy :destroy_files
|
|
6
|
-
|
|
7
|
-
named_scope :key, lambda { |key| { :conditions => { :assetable_key => key } } }
|
|
8
|
-
|
|
6
|
+
|
|
9
7
|
Paperclip::Attachment.interpolations[:escaped_basename] = proc do |attachment, style|
|
|
10
8
|
Paperclip::Attachment.interpolations[:basename].call(attachment, style).to_url
|
|
11
9
|
end
|
|
@@ -14,10 +12,7 @@ class PapermillAsset < ActiveRecord::Base
|
|
|
14
12
|
:path => "#{Papermill::PAPERMILL_DEFAULTS[:public_root]}/#{Papermill::PAPERMILL_DEFAULTS[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}",
|
|
15
13
|
:url => "/#{Papermill::PAPERMILL_DEFAULTS[:papermill_prefix]}/#{Papermill::PAPERCLIP_INTERPOLATION_STRING}"
|
|
16
14
|
validates_attachment_presence :file
|
|
17
|
-
|
|
18
|
-
#validates_attachment_content_type :file, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/gif']
|
|
19
|
-
|
|
20
|
-
# Fix the mime types. Make sure to require the mime-types gem
|
|
15
|
+
|
|
21
16
|
def swfupload_file=(data)
|
|
22
17
|
data.content_type = MIME::Types.type_for(data.original_filename).to_s
|
|
23
18
|
self.file = data
|
|
@@ -47,9 +42,8 @@ class PapermillAsset < ActiveRecord::Base
|
|
|
47
42
|
content_type && content_type.first == "image" && content_type[1]
|
|
48
43
|
end
|
|
49
44
|
|
|
50
|
-
# before_filter
|
|
51
45
|
def destroy_files
|
|
52
|
-
system "rm -rf #{Papermill::papermill_interpolated_path({":id_partition" => self.id_partition}, ':id_partition')}/"
|
|
46
|
+
system "rm -rf #{Papermill::papermill_interpolated_path({":id_partition" => self.id_partition}, ':id_partition')}/"
|
|
53
47
|
true
|
|
54
48
|
end
|
|
55
49
|
end
|
|
@@ -70,7 +70,6 @@ module Papermill
|
|
|
70
70
|
:papermill_prefix => "system/papermill"
|
|
71
71
|
}.deep_merge( Papermill.const_defined?("OPTIONS") ? Papermill::OPTIONS : {} )
|
|
72
72
|
|
|
73
|
-
|
|
74
73
|
PAPERCLIP_INTERPOLATION_STRING = ":id_partition/:style/:escaped_basename.:extension"
|
|
75
74
|
|
|
76
75
|
def self.included(base)
|
|
@@ -174,6 +173,5 @@ module Papermill
|
|
|
174
173
|
end
|
|
175
174
|
end
|
|
176
175
|
end
|
|
177
|
-
|
|
178
176
|
end
|
|
179
177
|
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.5.
|
|
8
|
+
s.version = "0.5.2"
|
|
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-
|
|
12
|
+
s.date = %q{2009-09-05}
|
|
13
13
|
s.description = %q{Paperclip Swfupload UploadHelper wrapper}
|
|
14
14
|
s.email = %q{benoit.benezech@gmail.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -60,7 +60,7 @@ Gem::Specification.new do |s|
|
|
|
60
60
|
s.homepage = %q{http://github.com/BBenezech/papermill}
|
|
61
61
|
s.rdoc_options = ["--charset=UTF-8"]
|
|
62
62
|
s.require_paths = ["lib"]
|
|
63
|
-
s.rubygems_version = %q{1.3.
|
|
63
|
+
s.rubygems_version = %q{1.3.5}
|
|
64
64
|
s.summary = %q{Paperclip Swfupload UploadHelper wrapper}
|
|
65
65
|
s.test_files = [
|
|
66
66
|
"test/papermill_test.rb",
|
|
@@ -1,26 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
popup = function(title1, title) {
|
|
2
|
+
window.open (title1, title, config='height=700, width=600, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
|
|
3
|
+
}
|
|
4
|
+
// override at will
|
|
5
5
|
|
|
6
6
|
notify = function(message, type) {
|
|
7
|
-
// wrap with your own javascript alert system (here is the thing for jGrowl)
|
|
8
|
-
//if(type == "notice") { jQuery.noticeAdd({ text: message, stayTime: 4000, stay: false, type: type }) }
|
|
9
|
-
//if(type == "warning") { jQuery.noticeAdd({ text: message, stayTime: 9000, stay: false, type: type }) }
|
|
10
|
-
//if(type == "error") { jQuery.noticeAdd({ text: message, stayTime: 20000, stay: false, type: type }) }
|
|
11
|
-
|
|
12
|
-
// or simply
|
|
13
7
|
alert(type + ": " + message)
|
|
14
8
|
}
|
|
15
|
-
|
|
9
|
+
// You can override notify later, with your own notification system
|
|
16
10
|
|
|
17
11
|
var Upload = {
|
|
18
|
-
// The total number of files queued with SWFUpload
|
|
19
12
|
files_queued: 0,
|
|
20
|
-
|
|
21
|
-
set_recipient_id: function(dom_id) {
|
|
22
|
-
this.recipient_id = dom_id
|
|
23
|
-
},
|
|
24
13
|
file_dialog_complete: function(num_selected, num_queued)
|
|
25
14
|
{
|
|
26
15
|
// SwfUpload doesn't order uploads by name out of the box...
|
|
@@ -74,7 +63,12 @@ var Upload = {
|
|
|
74
63
|
},
|
|
75
64
|
upload_success: function(file, data)
|
|
76
65
|
{
|
|
77
|
-
|
|
66
|
+
if(jQuery(data).length == 0) {
|
|
67
|
+
notify(data, "warning");
|
|
68
|
+
jQuery('#' + file.id).remove();
|
|
69
|
+
} else {
|
|
70
|
+
jQuery('#' + file.id).replaceWith(jQuery(data));
|
|
71
|
+
}
|
|
78
72
|
},
|
|
79
73
|
upload_complete: function(file)
|
|
80
74
|
{
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: BBenezech-papermill
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
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-
|
|
12
|
+
date: 2009-09-05 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|