papermill 1.0.3 → 1.0.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/README.rdoc +1 -6
- data/TODO.txt +1 -0
- data/VERSION +1 -1
- data/app/controllers/papermill_controller.rb +6 -15
- data/config/locales/papermill.yml +1 -3
- data/installation-template.txt +13 -25
- data/lib/papermill/form_builder.rb +5 -4
- data/lib/papermill/papermill.rb +4 -7
- data/lib/papermill/papermill_helper.rb +3 -1
- data/lib/papermill/papermill_options.rb +1 -1
- data/public/papermill/papermill.js +37 -8
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
Asset management made easy.
|
4
4
|
|
5
|
-
== News..
|
6
|
-
|
7
|
-
I can't make it work with IE6, there seems to be a jQuery problem. SWFUpload and jQuery should both work fine with it, but anyway, it dies with strange errors that I don't understand. Any help appreciated...
|
8
|
-
|
9
5
|
== Install the gems
|
10
6
|
|
11
7
|
$ gem source -a http://gemcutter.org
|
@@ -115,8 +111,7 @@ FormTagHelpers
|
|
115
111
|
With generic papermill association, Papermill generates an #assets(:key, *args) named_scope
|
116
112
|
@article.assets(:illustrations)
|
117
113
|
@article.assets(:illustrations, :order => "created_at DESC")
|
118
|
-
@article.illustrations.red.first
|
119
|
-
@article.assets(:illustrations, :order => "created_at DESC").red.first
|
114
|
+
@article.assets(:illustrations).red.first
|
120
115
|
# etc.
|
121
116
|
|
122
117
|
With declarative papermill associations, Papermill generates an #<association_key>(*args) named_scope
|
data/TODO.txt
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
@@ -27,11 +27,8 @@ class PapermillController < ApplicationController
|
|
27
27
|
|
28
28
|
def update
|
29
29
|
render :update do |page|
|
30
|
-
|
31
|
-
|
32
|
-
else
|
33
|
-
page << %{ notify("#{ escape_javascript @asset.errors.full_messages.to_sentence }", "warning") }
|
34
|
-
end
|
30
|
+
@asset.update_attributes(params[:papermill_asset])
|
31
|
+
page << %{ notify("#{ escape_javascript t("papermill.updated", :ressource => @asset.name)}", "notice") }
|
35
32
|
end
|
36
33
|
end
|
37
34
|
|
@@ -41,11 +38,8 @@ class PapermillController < ApplicationController
|
|
41
38
|
|
42
39
|
def create
|
43
40
|
@asset = params[:asset_class].constantize.new(params.reject{|k, v| !(PapermillAsset.columns.map(&:name)+["Filedata", "Filename"]).include?(k)})
|
44
|
-
|
45
|
-
|
46
|
-
else
|
47
|
-
render :text => @asset.errors.full_messages.join('<br />'), :status => 500
|
48
|
-
end
|
41
|
+
@asset.save(:unique => !params[:gallery])
|
42
|
+
render :partial => "papermill/asset", :object => @asset, :locals => {:gallery => params[:gallery], :thumbnail_style => params[:thumbnail_style]}
|
49
43
|
end
|
50
44
|
|
51
45
|
def sort
|
@@ -58,11 +52,8 @@ class PapermillController < ApplicationController
|
|
58
52
|
def mass_delete
|
59
53
|
render :update do |page|
|
60
54
|
@assets.each do |asset|
|
61
|
-
|
62
|
-
|
63
|
-
else
|
64
|
-
page << %{ notify('#{ escape_javascript t("papermill.not-deleted", :ressource => asset.name)}', 'error') }
|
65
|
-
end
|
55
|
+
asset.destroy
|
56
|
+
page << "jQuery('#papermill_asset_#{asset.id}').remove()"
|
66
57
|
end
|
67
58
|
end
|
68
59
|
end
|
@@ -11,8 +11,7 @@ en:
|
|
11
11
|
delete-confirmation: "Delete '{{resource}}'?"
|
12
12
|
SWFUPLOAD_PENDING: "Pending..."
|
13
13
|
SWFUPLOAD_LOADING: "Loading..."
|
14
|
-
|
15
|
-
file_type: "{{type.capitalize}} file"
|
14
|
+
file_type: "{{type}} file"
|
16
15
|
name: "Name"
|
17
16
|
content_type: "Content-type"
|
18
17
|
size: "File size"
|
@@ -44,7 +43,6 @@ fr:
|
|
44
43
|
delete-confirmation: "Êtes-vous sûr de vouloir supprimer '{{resource}}' ?"
|
45
44
|
SWFUPLOAD_PENDING: "En attente..."
|
46
45
|
SWFUPLOAD_LOADING: "Chargement..."
|
47
|
-
SWFUPLOAD_ERROR: "Fichier trop gros, type de fichier non autorisé ou erreur serveur."
|
48
46
|
file_type: "Fichier {{type}}"
|
49
47
|
name: "Nom"
|
50
48
|
content_type: "Content-type"
|
data/installation-template.txt
CHANGED
@@ -36,30 +36,18 @@ END
|
|
36
36
|
|
37
37
|
file "app/views/articles/_form.html.erb", <<-END
|
38
38
|
<% form_for(@article) do |f| %>
|
39
|
-
<%= f.error_messages
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
</p>
|
52
|
-
<p>
|
53
|
-
<%= f.label :my_assets %><br />
|
54
|
-
<%= f.assets_upload(:my_assets) %>
|
55
|
-
</p>
|
56
|
-
<p>
|
57
|
-
<%= f.label :my_other_asset %><br />
|
58
|
-
<%= f.asset_upload(:my_other_asset) %>
|
59
|
-
</p>
|
60
|
-
<p>
|
61
|
-
<%= f.submit 'Send' %>
|
62
|
-
</p>
|
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' %>
|
63
51
|
<% end %>
|
64
52
|
END
|
65
53
|
|
@@ -115,8 +103,8 @@ file "app/views/layouts/application.html.erb", <<-END
|
|
115
103
|
</head>
|
116
104
|
<body>
|
117
105
|
<%= yield %>
|
118
|
-
</body>
|
119
106
|
<%= papermill_javascript_tag :with_jquery => true %>
|
107
|
+
</body>
|
120
108
|
</html>
|
121
109
|
END
|
122
110
|
|
@@ -42,8 +42,8 @@ module ActionView::Helpers::FormTagHelper
|
|
42
42
|
|
43
43
|
assetable = options[:assetable] || @template.instance_variable_get("@#{@object_name}")
|
44
44
|
options = (
|
45
|
-
if assetable && (association = (assetable.class.papermill_associations[key] || assetable.class.papermill_associations[Papermill::options[:base_association_name]]))
|
46
|
-
association
|
45
|
+
if assetable && (association = (assetable.class.papermill_associations[key.to_sym] || assetable.class.papermill_associations[Papermill::options[:base_association_name]]))
|
46
|
+
association.deep_merge(options)
|
47
47
|
elsif assetable.nil?
|
48
48
|
Papermill::options.deep_merge(options)
|
49
49
|
else
|
@@ -83,12 +83,12 @@ module ActionView::Helpers::FormTagHelper
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
url_options = {
|
88
88
|
:escape => false,
|
89
89
|
:controller => "/papermill",
|
90
90
|
:action => "create",
|
91
|
-
:asset_class => (options[:class_name]
|
91
|
+
:asset_class => (options[:class_name] || PapermillAsset).to_s,
|
92
92
|
:gallery => !!options[:gallery],
|
93
93
|
:thumbnail_style => options[:thumbnail] && options[:thumbnail][:style]
|
94
94
|
}
|
@@ -152,6 +152,7 @@ module ActionView::Helpers::FormTagHelper
|
|
152
152
|
file_dialog_complete_handler: Upload.file_dialog_complete,
|
153
153
|
upload_start_handler: Upload.upload_start,
|
154
154
|
upload_progress_handler: Upload.upload_progress,
|
155
|
+
file_queue_error_handler: Upload.file_queue_error,
|
155
156
|
upload_error_handler: Upload.upload_error,
|
156
157
|
upload_success_handler: Upload.upload_success,
|
157
158
|
upload_complete_handler: Upload.upload_complete,
|
data/lib/papermill/papermill.rb
CHANGED
@@ -14,13 +14,10 @@ module Papermill
|
|
14
14
|
attr_reader :papermill_associations
|
15
15
|
|
16
16
|
def papermill(*args)
|
17
|
-
assoc_name = (!args.first.is_a?(Hash) && args.shift
|
18
|
-
|
19
|
-
|
20
|
-
(@papermill_associations ||= {}).merge!(
|
21
|
-
:class => (class_name = options.delete(:class_name)) && class_name.to_s.constantize || PapermillAsset,
|
22
|
-
:options => Papermill::options.deep_merge(options)
|
23
|
-
}})
|
17
|
+
assoc_name = (!args.first.is_a?(Hash) && args.shift || Papermill::options[:base_association_name]).to_sym
|
18
|
+
local_options = args.first || {}
|
19
|
+
|
20
|
+
(@papermill_associations ||= {}).merge!( assoc_name => Papermill::options.deep_merge(local_options) )
|
24
21
|
|
25
22
|
include Papermill::InstanceMethods
|
26
23
|
before_destroy :destroy_assets
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module PapermillHelper
|
2
4
|
|
3
5
|
# Sets all the javascript needed for papermill.
|
@@ -13,7 +15,7 @@ module PapermillHelper
|
|
13
15
|
html << %{<script type="text/javascript">jQuery.noConflict();</script>} if options[:with_jquery] == "no_conflict"
|
14
16
|
end
|
15
17
|
html << %{<script type="text/javascript">}
|
16
|
-
["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING"
|
18
|
+
["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING"].each do |js_constant|
|
17
19
|
html << %{var #{js_constant} = "#{t("papermill.#{js_constant}")}";}
|
18
20
|
end
|
19
21
|
html << %{</script>}
|
@@ -79,7 +79,7 @@ var Upload = {
|
|
79
79
|
global_index++;
|
80
80
|
} while (file != null);
|
81
81
|
this.sorted_queue = file_queue.sort(function(a,b){
|
82
|
-
if(b.name < a.name){return (1)}
|
82
|
+
if(b.name < a.name){ return (1) } else { return (-1) }
|
83
83
|
})
|
84
84
|
var self = this;
|
85
85
|
jQuery(this.sorted_queue).each( function(index, file) {
|
@@ -107,11 +107,20 @@ var Upload = {
|
|
107
107
|
percent = Math.ceil((bytes / total) * 100);
|
108
108
|
jQuery('#' + file.id + ' .progress span').width(percent + '%');
|
109
109
|
},
|
110
|
-
upload_error: function(file,
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
110
|
+
upload_error: function(file, errorCode, message) {
|
111
|
+
try {
|
112
|
+
switch (errorCode) {
|
113
|
+
case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:
|
114
|
+
notify("Too many files selected", "error");
|
115
|
+
return;
|
116
|
+
default:
|
117
|
+
notify("An error occurred while sending the file" + errorCode, "error");
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
} catch (ex) {
|
121
|
+
}
|
122
|
+
},
|
123
|
+
|
115
124
|
upload_success: function(file, data)
|
116
125
|
{
|
117
126
|
if(jQuery(data).length == 0) {
|
@@ -128,8 +137,28 @@ var Upload = {
|
|
128
137
|
this.startUpload(this.sorted_queue[this.index++].id)
|
129
138
|
}
|
130
139
|
},
|
131
|
-
|
132
|
-
|
140
|
+
|
141
|
+
file_queue_error: function(file, errorCode, message) {
|
142
|
+
try {
|
143
|
+
switch (errorCode) {
|
144
|
+
case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
|
145
|
+
notify("Too many files selected", "error");
|
146
|
+
return;
|
147
|
+
case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
|
148
|
+
notify("File is too big", "error");
|
149
|
+
return;
|
150
|
+
case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
|
151
|
+
notify("File is empty. Please select another file", "error");
|
152
|
+
return;
|
153
|
+
case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
|
154
|
+
notify("File is not an allowed file type", "error");
|
155
|
+
return;
|
156
|
+
default:
|
157
|
+
notify("An error occurred while sending the file" + errorCode, "error");
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
} catch (e) {
|
161
|
+
}
|
133
162
|
}
|
134
163
|
}
|
135
164
|
|
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.
|
4
|
+
version: 1.0.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: 2009-11-
|
12
|
+
date: 2009-11-18 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|