papermill 0.14.3 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,125 @@
1
+ # Do not move or rename this file.
2
+ # It MUST stand in your RAILS_ROOT/config/initializer folder
3
+ # It is explicitely early-loaded by Papermill
4
+ # Papermill::OPTIONS constant needs to be set before PapermillAsset is loaded, and PapermillAsset cannot be lazy-loaded
5
+
6
+ module Papermill
7
+
8
+ # All these options will be used as defaults. You can change them :
9
+ #
10
+ # * here
11
+ #
12
+ # * in your association. Ex :
13
+ # class Article < ActiveRecord::Base
14
+ # papermill :diaporama, {
15
+ # :class_name => "MyAssetClass",
16
+ # :inline_css => false,
17
+ # :thumbnail => {:width => 150},
18
+ # ...
19
+ # }
20
+ # end
21
+ #
22
+ # * in your form helper call. Ex :
23
+ # form.image_upload :diaporama, :class_name => "MyAssetClass", :thumbnail => {:width => 150}, :inline_css => false
24
+ #
25
+ #
26
+ # FormHelper options-hash merges with papermill declaration option-hash that merges with this Papermill::OPTIONS hash
27
+ # Merges are recursive (for :gallery, :thumbnail and :swfupload sub-hashs)
28
+
29
+ unless defined?(OPTIONS)
30
+ OPTIONS = {
31
+ # Associated PapermillAsset subclass
32
+ :class_name => "PapermillAsset",
33
+
34
+ # Helper will generates some inline css styling. You can use it to scaffold, then copy the lines you need in your application css and set it to false.
35
+ :inline_css => true,
36
+
37
+ # SwfUpload will only let the user upload images.
38
+ :images_only => false,
39
+
40
+ # Dashboard is only for galleries
41
+ # You can remove/change order of HTML elements.
42
+ # See below for dashboard
43
+ :form_helper_elements => [:upload_button, :container, :dashboard],
44
+
45
+ # Dashboard elements
46
+ # You can remove/change order of HTML elements.
47
+ :dashboard => [:mass_edit, :mass_delete],
48
+
49
+ # Attributes editable at once for all assets in a gallery
50
+ :mass_editable_fields => ["title", "copyright", "description"],
51
+
52
+ # FormHelper gallery options
53
+ # If :inline_css is true, css will be generated automatically and added through @content_for_papermill_inline_css (papermill_stylesheet_tag includes it)
54
+ # Great for quick admin scaffolding.
55
+
56
+ :gallery => {
57
+ # override calculated gallery width. Ex: "auto"
58
+ :width => nil,
59
+ # override calculated gallery height
60
+ :height => nil,
61
+ # Number of columns and lines in a gallery
62
+ :columns => 8,
63
+ :lines => 2,
64
+ # vertical/horizontal padding/margin around each thumbnails
65
+ :vpadding => 0,
66
+ :hpadding => 0,
67
+ :vmargin => 1,
68
+ :hmargin => 1,
69
+ # border around thumbnails
70
+ :border_thickness => 2
71
+ },
72
+
73
+ # FormHelper thumbnail's information.
74
+ # Set :width OR :height to nil to use aspect_ratio value. Remember that 4/3 == 1 => Use : 4.0/3
75
+ # You can override computed ImageMagick transformation strings that defaults to "#{:width}x#{:height}>" by setting a value to :style
76
+ # Needed if you set :aliases_only to true
77
+
78
+ :thumbnail => {
79
+ :width => 100,
80
+ :height => 100,
81
+ :aspect_ratio => nil,
82
+ :style => nil
83
+ },
84
+
85
+ # Options passed on to SWFUpload.
86
+ # To remove an option when overriding, set it to nil.
87
+
88
+ :swfupload => {
89
+ :flash_url => '/papermill/swfupload.swf',
90
+ :button_image_url => '/papermill/images/upload-blank.png',
91
+ :button_width => 61,
92
+ :button_height => 22,
93
+ :button_text => %{<span class="button-text">#{I18n.t("papermill.upload-button-wording")}</span>},
94
+ :button_text_style => %{.button-text { font-size: 12pt; font-weight: bold; }},
95
+ :button_text_top_padding => 4,
96
+ :button_text_left_padding => 4,
97
+ :debug => false,
98
+ :prevent_swf_caching => true,
99
+ :file_size_limit_mb => 10.megabytes
100
+ },
101
+
102
+ # APPLICATION WIDE PARAMETERS
103
+ # Do not change these in your model declaration or form helper call.
104
+
105
+ # Default named_scope name for catch-all :papermill declaration
106
+ :base_association_name => :assets,
107
+
108
+ # Set to true to require aliases in all url/path
109
+ # Don't forget to give an alias value to options[:thumbnail][:style] if true!
110
+ :alias_only => false,
111
+
112
+ # Needed if :alias_only
113
+ :aliases => {
114
+ # 'example' => "100x100#",
115
+ # 'example2' => {:geometry => "100x100#"}
116
+ },
117
+
118
+ # path to the root of your public directory (from NGINX/Apache pov)
119
+ :public_root => ":rails_root/public",
120
+
121
+ # added to :public_root as the root folder for all papermill assets
122
+ :papermill_prefix => "system/papermill"
123
+ }
124
+ end
125
+ end
@@ -0,0 +1,13 @@
1
+ DO NOT !!
2
+
3
+ Modify files in this folder, they are generated by papermill
4
+
5
+
6
+ DO !!
7
+
8
+ Load them before your own and override them in your application.<js|css>
9
+
10
+ And each time you update Papermill's gem :
11
+
12
+ cd my_rails_app
13
+ ./script/generate papermill_assets
Binary file
@@ -13,13 +13,17 @@
13
13
  #papermill-box .left-cell {font-weight:bold; padding-right:10px; text-align:right;}
14
14
 
15
15
  .papermill { overflow:hidden; }
16
- .papermill a:hover { background:none; color:inherit; }
17
16
  .papermill a img { border:0px; }
18
17
  .papermill li:hover { border-color:blue; }
19
18
  .papermill li a { display:block; }
20
19
  .papermill .progress { display:block; border:1px solid #C2E3EF; text-align:left; height:6px; }
21
20
  .papermill .progress span { background:#7BB963; height:6px; width:0; display:block; }
22
21
 
22
+ .papermill .dashboard li { float:left; margin-right:10px; margin-top:3px; }
23
+ .papermill .dashboard li a { float:left; padding-top:3px; padding-right:3px; padding-left:20px; }
24
+ .papermill .dashboard li.mass_edit a { background:transparent url(images/mass-edit.png) no-repeat top left; }
25
+ .papermill .dashboard li.mass_delete a { background:transparent url(images/mass-delete.png) no-repeat top left; }
26
+
23
27
  .papermill-thumb-container { position:relative; border:5px solid #EEE; padding:4px; overflow:hidden; }
24
28
  .papermill-thumb-container li { border:0px solid transparent; min-height:25px; min-width:25px; display:block; float:left; position:relative; }
25
29
  .papermill-thumb-container li span { display:block; }
@@ -36,9 +40,11 @@
36
40
  .papermill-asset-container li .progress { float:left; margin-top:6px; margin-left:5px; width:100px; }
37
41
  .papermill-asset-container li .delete { float:left; margin-top:2px; margin-right:5px; }
38
42
 
43
+ .papermill-thumb-container.papermill-multiple-items li { cursor:move; }
44
+
39
45
  .papermill-asset-container.papermill-multiple-items { padding-left:10px; border-left:5px solid #EEE; min-height:44px; }
40
46
  .papermill-asset-container.papermill-multiple-items li { cursor:row-resize; }
41
- .papermill-thumb-container.papermill-multiple-items li { cursor:move; }
47
+
42
48
  .papermill-asset-container.papermill-unique-item { padding-left:5px; min-height:22px; }
43
49
 
44
50
  /* Using formtastic? Move this to your formtastic_changes.css to make it cleaner : */
@@ -1,10 +1,17 @@
1
- popup = function(title1, title) {
2
- window.open (title1, title, config='height=580, width=870, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
1
+ popup = function(url) {
2
+ window.open (url + "?with_jquery=true", "Papermill", config='height=580, width=870, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
3
+ }
4
+
5
+ close_popup = function(source) {
6
+ source.close();
3
7
  }
4
8
 
5
9
 
6
10
  /*
7
- If you have a popup library, override popup
11
+ If you have a popup library, OVERRIDE popup and close_popup in your application.js
12
+ You'll need jQuery loaded, so specify with_jquery=true if you load edit in an iframe or a true popup.
13
+ You can specify a layout as well, with layout=application in your URL.
14
+
8
15
 
9
16
  * e.g. facebox :
10
17
 
@@ -16,25 +23,32 @@ popup = function(url) {
16
23
  })
17
24
  return false;
18
25
  }
26
+ close_popup = function(source) {
27
+ jQuery(document).trigger('close.facebox');
28
+ }
19
29
 
20
30
  * e.g. Shadowbox :
21
31
 
22
32
  popup = function(url) {
23
- if(url) {
24
- Shadowbox.open({
25
- content: url,
26
- player: "iframe",
27
- width: 870,
28
- height: 580
29
- });
30
- }
33
+ Shadowbox.open({
34
+ content: url + "?with_jquery=true",
35
+ player: "iframe",
36
+ width: 870,
37
+ height: 580
38
+ });
31
39
  return false;
32
40
  }
41
+
42
+ close_popup = function(source) {
43
+ Shadowbox.close();
44
+ }
45
+
33
46
  */
34
47
 
35
48
  notify = function(message, type) {
36
49
  if(type != "notice") { alert(type + ": " + message) }
37
50
  }
51
+
38
52
  /*
39
53
  If you have a notification library, override notify
40
54
 
@@ -120,4 +134,20 @@ var Upload = {
120
134
  file_queue_error: function(file, error_code, message) {
121
135
  upload_error(file, error_code, message)
122
136
  }
123
- }
137
+ }
138
+
139
+ modify_all = function(papermill_id) {
140
+ container = jQuery("#" + papermill_id)[0];
141
+ attribute_name = jQuery("#batch_" + papermill_id)[0].value
142
+ attribute_wording = jQuery("#batch_" + papermill_id + " option:selected").text();
143
+ value = prompt(attribute_wording + ":")
144
+ if(value != null) {
145
+ jQuery.ajax({async:true, data:jQuery(container).sortable('serialize'), dataType:'script', type:'post', url:'/papermill/mass_edit?attribute=' + attribute_name + "&value=" + value})
146
+ }
147
+ }
148
+
149
+ mass_delete = function(papermill_id, wording) {
150
+ if(confirm(wording)){
151
+ jQuery.ajax({async:true, data:jQuery('#' + papermill_id).sortable('serialize'), dataType:'script', type:'post', url:'/papermill/mass_delete'})
152
+ }
153
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ This is not an image.
@@ -0,0 +1,8 @@
1
+ development:
2
+ key: 54321
3
+ production:
4
+ key: 12345
5
+ test:
6
+ bucket: <%= ENV['S3_BUCKET'] %>
7
+ access_key_id: <%= ENV['S3_KEY'] %>
8
+ secret_access_key: <%= ENV['S3_SECRET'] %>
File without changes
Binary file
@@ -4,44 +4,134 @@ require 'rubygems'
4
4
  gem 'rails'
5
5
  require 'active_record'
6
6
  require 'action_view'
7
- require File.join(File.dirname(__FILE__), '../init')
8
-
7
+ require 'active_support'
8
+ ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/info.log")
9
+ RAILS_ROOT = File.join( File.dirname(__FILE__), "../../../.." )
10
+
11
+
12
+ require File.join(File.dirname(__FILE__), '../init.rb')
13
+
14
+ module Papermill
15
+ OPTIONS = OPTIONS.merge(
16
+ :aliases => {
17
+ 'tall' => :"1000x1000",
18
+ :small => "100x100",
19
+ :hashed_style => {:geometry => "100x100"}
20
+ })
21
+ end
22
+
23
+
9
24
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => "test.sqlite3")
10
25
  ActiveRecord::Schema.define(:version => 1) do
11
- create_table :papermill_assets do |t|
26
+ create_table :papermill_assets, :force => true do |t|
12
27
  t.string :title, :file_file_name, :file_content_type, :assetable_type, :assetable_key, :type
13
28
  t.integer :file_file_size, :position, :assetable_id
14
29
  t.timestamps
15
30
  end
16
31
 
17
- create_table :articles do |t|
18
- t.string :title, :type
19
- t.timestamps
32
+ create_table :articles, :force => true do |t|
33
+ t.string :type
20
34
  end
21
35
  end
22
36
 
37
+
38
+
23
39
  class MyAsset < PapermillAsset
24
40
  end
25
41
 
26
- class ArticleGenericAssociation < ActiveRecord::Base
42
+ class Article < ActiveRecord::Base
27
43
  def self.table_name
28
44
  :articles
29
45
  end
30
-
31
- papermill :class_name => MyAsset
46
+ papermill
47
+ papermill :my_assets, :class_name => "MyAsset"
32
48
  end
33
49
 
34
- class ArticleSpecificAssociations < ActiveRecord::Base
35
- def self.table_name
36
- :articles
37
- end
38
-
39
- papermill :my_assets, :class_name => MyAsset
40
- end
41
50
 
42
51
  class PapermillTest < Test::Unit::TestCase
43
-
44
- def test_truth
45
- assert true
52
+ @article = Article.create!
53
+ @decoy_article = Article.create!
54
+ @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
55
+ PapermillAsset.create!(:Filedata => @file, :assetable => @article, :assetable_key => "asset1", :position => 2)
56
+ PapermillAsset.create!(:Filedata => @file, :assetable => @article, :assetable_key => "asset1", :position => 1)
57
+ MyAsset.create!(:Filedata => @file, :assetable => @article, :assetable_key => "my_assets")
58
+ MyAsset.create!(:Filedata => @file, :assetable => @article, :assetable_key => "my_assets")
59
+ MyAsset.create!(:Filedata => @file, :assetable => @decoy_article, :assetable_key => "my_assets")
60
+
61
+ def initialize(*args)
62
+ super
63
+ @file = File.new(File.join(File.dirname(__FILE__), "fixtures", "5k.png"), 'rb')
64
+
65
+ @article = Article.find 1
66
+ @decoy_article = Article.find 2
67
+
68
+ @asset1 = PapermillAsset.find 1
69
+ @asset2 = PapermillAsset.find 2
70
+ @asset3 = PapermillAsset.find 3
71
+ @asset4 = PapermillAsset.find 4
72
+ @asset5 = PapermillAsset.find 5
73
+ end
74
+
75
+ def test_namedscopes_for_specific_associations
76
+ assert_equal @article.my_assets.map(&:id), [3,4]
77
+ assert_equal @article.my_assets(:order => "position DESC").map(&:id), [4,3]
78
+ assert_equal @article.my_assets(:order => "position DESC", :limit => 1).map(&:id), [4]
79
+ end
80
+
81
+ def test_namedscope_for_global_associations_and_default_order
82
+ assert_equal @article.assets(:asset1).map(&:id), [2,1]
83
+ assert_equal @article.assets(:asset1, :order => "position DESC").map(&:id), [1,2]
84
+ assert_equal @article.assets(:asset1, :order => "position DESC", :limit => 1).map(&:id), [1]
85
+ end
86
+
87
+ def test_id_partition
88
+ assert_equal @asset1.id_partition, "000/000/001"
89
+ end
90
+
91
+ def test_name
92
+ assert_equal @asset1.name, "5k.png"
93
+ end
94
+
95
+ def test_width
96
+ assert_equal @asset1.width, 434.0
97
+ end
98
+
99
+ def test_height
100
+ assert_equal @asset1.height, 66.0
101
+ end
102
+
103
+ def test_size
104
+ assert_equal @asset1.size, 4456
105
+ end
106
+
107
+ def test_url
108
+ assert_equal @asset1.url, "/system/papermill/000/000/001/original/5k.png"
109
+ assert_equal @asset1.url("400x300#"), "/system/papermill/000/000/001/400x300%23/5k.png"
110
+ end
111
+
112
+ def test_path
113
+ assert_equal @asset1.path, "./test/../../../../public/system/papermill/000/000/001/original/5k.png"
114
+ assert_equal @asset1.path("400x300#"), "./test/../../../../public/system/papermill/000/000/001/400x300#/5k.png"
115
+ end
116
+
117
+ def test_content_type
118
+ assert_equal @file.get_content_type, "image/png"
119
+ assert_equal @asset1.content_type, "image/png"
120
+ end
121
+
122
+ def test_is_image
123
+ assert @asset1.image?
124
+ end
125
+
126
+ def test_compute_style
127
+ assert_equal PapermillAsset.compute_style(:tall), :geometry => "1000x1000"
128
+ assert_equal PapermillAsset.compute_style("tall"), :geometry => "1000x1000"
129
+ assert_equal PapermillAsset.compute_style(:small), :geometry => "100x100"
130
+ assert_equal PapermillAsset.compute_style("small"), :geometry => "100x100"
131
+ assert_equal PapermillAsset.compute_style("hashed_style"), :geometry => "100x100"
132
+ assert_equal PapermillAsset.compute_style("100x100"), :geometry => "100x100"
133
+ assert_equal PapermillAsset.compute_style(:"100x100"), :geometry => "100x100"
134
+ Papermill::options[:alias_only] = true
135
+ assert_equal PapermillAsset.compute_style("100x100"), false
46
136
  end
47
137
  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: 0.14.3
4
+ version: 0.16.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-11-01 00:00:00 +01:00
12
+ date: 2009-11-13 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -47,22 +47,28 @@ files:
47
47
  - config/routes.rb
48
48
  - generators/papermill_assets/USAGE
49
49
  - generators/papermill_assets/papermill_assets_generator.rb
50
+ - generators/papermill_initializer/USAGE
51
+ - generators/papermill_initializer/papermill_initializer_generator.rb
50
52
  - generators/papermill_table/USAGE
51
53
  - generators/papermill_table/papermill_table_generator.rb
52
54
  - generators/papermill_table/templates/migrate/papermill_migration.rb.erb
53
55
  - init.rb
54
56
  - install.rb
55
57
  - installation-template.txt
56
- - lib/core_extensions.rb
58
+ - lib/extensions.rb
57
59
  - lib/papermill.rb
58
60
  - lib/papermill/form_builder.rb
61
+ - lib/papermill/papermill.rb
59
62
  - lib/papermill/papermill_asset.rb
60
63
  - lib/papermill/papermill_helper.rb
61
- - lib/papermill/papermill_module.rb
64
+ - lib/papermill/papermill_options.rb
62
65
  - public/.DS_Store
66
+ - public/papermill/README
63
67
  - public/papermill/images/background.png
64
68
  - public/papermill/images/container-background.jpg
65
69
  - public/papermill/images/delete.png
70
+ - public/papermill/images/mass-delete.png
71
+ - public/papermill/images/mass-edit.png
66
72
  - public/papermill/images/upload-blank.png
67
73
  - public/papermill/images/upload.png
68
74
  - public/papermill/papermill.css
@@ -71,6 +77,14 @@ files:
71
77
  - public/papermill/swfupload.swf
72
78
  - rails/init.rb
73
79
  - tasks/papermill_tasks.rake
80
+ - test/fixtures/12k.png
81
+ - test/fixtures/50x50.png
82
+ - test/fixtures/5k.png
83
+ - test/fixtures/bad.png
84
+ - test/fixtures/s3.yml
85
+ - test/fixtures/text.txt
86
+ - test/fixtures/twopage.pdf
87
+ - test/papermill_test.rb
74
88
  - uninstall.rb
75
89
  has_rdoc: true
76
90
  homepage: http://github.com/bbenezech/papermill
@@ -96,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
110
  requirements: []
97
111
 
98
112
  rubyforge_project:
99
- rubygems_version: 1.3.4
113
+ rubygems_version: 1.3.5
100
114
  signing_key:
101
115
  specification_version: 3
102
116
  summary: Paperclip Swfupload UploadHelper wrapper