papermill 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/README.rdoc +20 -34
  2. data/VERSION +1 -1
  3. data/app/controllers/papermill_controller.rb +23 -28
  4. data/app/views/papermill/_asset.html.erb +2 -2
  5. data/app/views/papermill/crop.html.erb +34 -0
  6. data/app/views/papermill/edit.html.erb +8 -1
  7. data/config/locales/papermill.yml +15 -15
  8. data/config/routes.rb +1 -1
  9. data/generators/papermill_assets/papermill_assets_generator.rb +1 -2
  10. data/generators/papermill_initializer/papermill_initializer_generator.rb +1 -1
  11. data/lib/papermill.rb +2 -6
  12. data/lib/papermill/form_builder.rb +96 -102
  13. data/lib/papermill/papermill.rb +1 -1
  14. data/lib/papermill/papermill_asset.rb +2 -0
  15. data/lib/papermill/papermill_helper.rb +9 -13
  16. data/lib/papermill/papermill_initializer.rb +132 -0
  17. data/lib/papermill/papermill_options.rb +49 -131
  18. data/lib/papermill/papermill_paperclip_processor.rb +1 -1
  19. data/public/facebox/README.txt +4 -0
  20. data/public/facebox/b.png +0 -0
  21. data/public/facebox/bl.png +0 -0
  22. data/public/facebox/br.png +0 -0
  23. data/public/facebox/closelabel.gif +0 -0
  24. data/public/facebox/facebox.css +95 -0
  25. data/public/facebox/facebox.js +319 -0
  26. data/public/facebox/fbx-border-sprite.png +0 -0
  27. data/public/facebox/loading.gif +0 -0
  28. data/public/facebox/logo.png +0 -0
  29. data/public/facebox/shadow.gif +0 -0
  30. data/public/facebox/tl.png +0 -0
  31. data/public/facebox/tr.png +0 -0
  32. data/public/jgrowl/jquery.jgrowl.css +127 -0
  33. data/public/jgrowl/jquery.jgrowl_minimized.js +4 -0
  34. data/public/papermill/images/mass-delete.png +0 -0
  35. data/public/papermill/jquery-1.3.2.min.js +19 -0
  36. data/public/papermill/jquery-ui-1.7.2.custom.min.js +34 -0
  37. data/public/papermill/jquery.Jcrop.css +35 -0
  38. data/public/papermill/jquery.Jcrop.min.js +163 -0
  39. data/public/papermill/papermill.css +15 -4
  40. data/public/papermill/papermill.js +47 -69
  41. data/test/papermill_test.rb +4 -8
  42. metadata +23 -2
@@ -6,7 +6,7 @@ module Papermill
6
6
  end
7
7
 
8
8
  def self.options
9
- defined?(OPTIONS) ? OPTIONS : {}
9
+ @options ||= BASE_OPTIONS.deep_merge(defined?(OPTIONS) ? OPTIONS : {})
10
10
  end
11
11
 
12
12
 
@@ -17,6 +17,8 @@ class PapermillAsset < ActiveRecord::Base
17
17
 
18
18
  named_scope :key, lambda { |assetable_key| { :conditions => ['assetable_key = ?', assetable_key.to_s] }}
19
19
 
20
+ attr_accessor :crop_h, :crop_w, :crop_x, :crop_y
21
+
20
22
  def Filedata=(data)
21
23
  data.content_type = data.get_content_type # SWFUpload content-type fix
22
24
  self.file = data
@@ -3,23 +3,19 @@
3
3
  module PapermillHelper
4
4
 
5
5
  # Sets all the javascript needed for papermill.
6
- # If you already loaded jQuery and JQueryUI, call papermill_javascript_tag
7
- # If you don't use jQuery or use some other library, call papermill_javascript_tag(:with_jquery => "no_conflict")
8
- # If you want to rely on this helper to load jQuery/jQueryUI and use it, call papermill_javascript_tag(:with_jquery => true)
9
- # If you loaded jQuery and need to load only jQueryUI, call papermill_javascript_tag(:with_jqueryui_only => true)
6
+ # If jQuery and JQueryUI (with Sortable included) are already loaded, call papermill_javascript_tag
7
+ # If you don't use jQuery at all or use some other library, call papermill_javascript_tag(:with_jquery => "no_conflict")
8
+ # If you want to rely on this helper to load jQuery and use it, call papermill_javascript_tag(:with_jquery => true)
9
+ # If jQuery is loaded, load only jQueryUI-Sortable with papermill_javascript_tag(:with_jqueryui_only => true)
10
10
  def papermill_javascript_tag(options = {})
11
11
  html = []
12
- if options[:with_jquery] || options[:with_jqueryui_only]
13
- html << %{<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>} if options[:with_jquery]
14
- html << %{<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>} if options[:with_jquery] || options[:with_jqueryui_only]
15
- html << %{<script type="text/javascript">jQuery.noConflict();</script>} if options[:with_jquery].to_s == "no_conflict"
16
- end
17
12
  html << %{<script type="text/javascript">}
18
- ["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING"].each do |js_constant|
19
- html << %{var #{js_constant} = "#{t("papermill.#{js_constant}")}";}
13
+ ["SWFUPLOAD_PENDING", "SWFUPLOAD_LOADING"].each do |js_constant|
14
+ html << %{var #{escape_javascript js_constant} = "#{t("papermill.#{escape_javascript js_constant}")}";}
20
15
  end
21
16
  html << %{</script>}
22
- html << javascript_include_tag("/papermill/papermill", "/papermill/swfupload")
17
+ html << javascript_include_tag([options[:with_jquery] && "/papermill/jquery-1.3.2.min.js", (options[:with_jquery] || options[:with_jqueryui_only]) && "/papermill/jquery-ui-1.7.2.custom.min.js", "/facebox/facebox.js", "/jgrowl/jquery.jgrowl_minimized.js", "/papermill/jquery.Jcrop.min.js", "/papermill/swfupload.js", "/papermill/papermill.js"].compact, :cache => "papermill")
18
+ html << %{<script type="text/javascript">jQuery.noConflict();</script>} if options[:with_jquery].to_s == "no_conflict"
23
19
  unless @content_for_papermill_inline_js.blank?
24
20
  html << '<script type="text/javascript">'
25
21
  html << '//<![CDATA['
@@ -35,7 +31,7 @@ module PapermillHelper
35
31
  # Sets the css tags needed for papermill.
36
32
  def papermill_stylesheet_tag(options = {})
37
33
  html = []
38
- html << stylesheet_link_tag("/papermill/papermill")
34
+ html << stylesheet_link_tag("/facebox/facebox.css", "/jgrowl/jquery.jgrowl.css", "/papermill/jquery.Jcrop.css", "/papermill/papermill.css", :cache => "papermill")
39
35
  unless @content_for_papermill_inline_css.blank?
40
36
  html << %{<style type="text/css">}
41
37
  html << @content_for_papermill_inline_css
@@ -0,0 +1,132 @@
1
+ # DO NOT MOVE OR RENAME THIS FILE.
2
+ # It must stand in your RAILS_ROOT/config/initializer folder and be named papermill.rb, because it is explicitely early-loaded by Papermill.
3
+ module Papermill
4
+
5
+ # All the options here already are papermill defaults. You can set them :
6
+ #
7
+ # * here
8
+ #
9
+ # * in your association. Ex :
10
+ # class Article < ActiveRecord::Base
11
+ # papermill :diaporama, {
12
+ # :class_name => "MyAssetClass",
13
+ # :inline_css => false,
14
+ # :thumbnail => {:width => 150},
15
+ # ...
16
+ # }
17
+ # end
18
+ #
19
+ # * in your form helper call. Ex :
20
+ # form.image_upload :diaporama, :class_name => "MyAssetClass", :thumbnail => {:width => 150}, :inline_css => false
21
+ #
22
+ #
23
+ # FormHelper options-hash merges with model papermill declaration option-hash, that merges with this Papermill::OPTIONS, that merge with Papermill::DEFAULT_OPTIONS hash.
24
+ # Don't freak-out, there's a 99% chance that it is exactly what you expect it to do.
25
+ # Merges are recursive (for :gallery, :thumbnail and :swfupload sub-hashs)
26
+
27
+ unless defined?(OPTIONS)
28
+
29
+ OPTIONS = {
30
+ # Associated PapermillAsset subclass
31
+ # :class_name => "PapermillAsset",
32
+
33
+ # 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.
34
+ # :inline_css => true,
35
+
36
+ # SwfUpload will only let the user upload images.
37
+ # :images_only => false,
38
+
39
+ # Dashboard is only for galleries
40
+ # You can remove/change order of HTML elements.
41
+ # See below for dashboard
42
+ # :form_helper_elements => [:upload_button, :container, :dashboard],
43
+
44
+ # Dashboard elements
45
+ # You can remove/change order of HTML elements.
46
+ # :dashboard => [:mass_edit, :mass_delete],
47
+
48
+ # Attributes editable at once for all assets in a gallery
49
+ # :mass_editable_fields => ["title", "copyright", "description"],
50
+
51
+ # Attributes you can edit in the form. You can use :type and :label
52
+ # :editable_fields => [
53
+ # {:title => {:type => "string"}},
54
+ # {:alt => {:type => "string"}},
55
+ # {:copyright => {:type => "string"}},
56
+ # {:description => {:type => "text" }},
57
+ # ],
58
+
59
+ # FormHelper gallery options
60
+ # If :inline_css is true, css will be generated automatically and added through @content_for_papermill_inline_css (papermill_stylesheet_tag includes it)
61
+ # Great for quick admin scaffolding.
62
+
63
+ :gallery => {
64
+ # override calculated gallery width. Ex: "auto"
65
+ # :width => nil,
66
+ # override calculated gallery height
67
+ # :height => nil,
68
+ # Number of columns and lines in a gallery
69
+ # :columns => 8,
70
+ # :lines => 2,
71
+ # vertical/horizontal padding/margin around each thumbnails
72
+ # :vpadding => 0,
73
+ # :hpadding => 0,
74
+ # :vmargin => 1,
75
+ # :hmargin => 1,
76
+ # border around thumbnails
77
+ # :border_thickness => 2
78
+ },
79
+
80
+ # FormHelper thumbnail's information.
81
+ # Set :width OR :height to nil to use aspect_ratio value. Remember that 4/3 == 1 => Use : 4.0/3
82
+ # You can override computed ImageMagick transformation strings that defaults to "#{:width}x#{:height}>" by setting a value to :style
83
+ # Needed if you set :aliases_only to true
84
+
85
+ :thumbnail => {
86
+ # :width => 100,
87
+ # :height => 100,
88
+ # :aspect_ratio => nil,
89
+ # :style => nil
90
+ },
91
+
92
+ # Options passed on to SWFUpload.
93
+ # To remove an option when overriding, set it to nil.
94
+
95
+ :swfupload => {
96
+ # :flash_url => '/papermill/swfupload.swf',
97
+ # :button_image_url => '/papermill/images/upload-blank.png',
98
+ # :button_width => 61,
99
+ # :button_height => 22,
100
+ # :button_text => %{<span class="button-text">#{I18n.t("papermill.upload-button-wording")}</span>},
101
+ # :button_text_style => %{.button-text { font-size: 12pt; font-weight: bold; }},
102
+ # :button_text_top_padding => 4,
103
+ # :button_text_left_padding => 4,
104
+ # :debug => false,
105
+ # :prevent_swf_caching => true,
106
+ # :file_size_limit => "10 MB"
107
+ },
108
+
109
+ # APPLICATION WIDE PARAMETERS
110
+ # Do not change these in your model declaration or form helper call.
111
+
112
+ # Default named_scope name for catch-all :papermill declaration
113
+ # :base_association_name => :assets,
114
+
115
+ # Set to true to require aliases in all url/path
116
+ # Don't forget to give an alias value to options[:thumbnail][:style] if true!
117
+ # :alias_only => false,
118
+
119
+ # Needed if :alias_only
120
+ :aliases => {
121
+ # 'example' => "100x100#",
122
+ # 'example2' => {:geometry => "100x100#"}
123
+ },
124
+
125
+ # path to the root of your public directory (from NGINX/Apache pov)
126
+ # :public_root => ":rails_root/public",
127
+
128
+ # added to :public_root as the root folder for all papermill assets
129
+ # :papermill_prefix => "system/papermill"
130
+ }
131
+ end
132
+ end
@@ -1,133 +1,51 @@
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
1
  module Papermill
6
-
7
- # All the options setted here will be used as defaults. You can set them :
8
- #
9
- # * here
10
- #
11
- # * in your association. Ex :
12
- # class Article < ActiveRecord::Base
13
- # papermill :diaporama, {
14
- # :class_name => "MyAssetClass",
15
- # :inline_css => false,
16
- # :thumbnail => {:width => 150},
17
- # ...
18
- # }
19
- # end
20
- #
21
- # * in your form helper call. Ex :
22
- # form.image_upload :diaporama, :class_name => "MyAssetClass", :thumbnail => {:width => 150}, :inline_css => false
23
- #
24
- #
25
- # FormHelper options-hash merges with papermill declaration option-hash that merges with this Papermill::OPTIONS hash
26
- # Merges are recursive (for :gallery, :thumbnail and :swfupload sub-hashs)
27
-
28
- unless defined?(OPTIONS)
29
-
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
- # Attributes you can edit in the form. You can use :type and :label
53
- :editable_fields => [
54
- {:title => {:type => "string"}},
55
- {:alt => {:type => "string"}},
56
- {:copyright => {:type => "string"}},
57
- {:description => {:type => "text" }},
58
- ],
59
-
60
- # FormHelper gallery options
61
- # If :inline_css is true, css will be generated automatically and added through @content_for_papermill_inline_css (papermill_stylesheet_tag includes it)
62
- # Great for quick admin scaffolding.
63
-
64
- :gallery => {
65
- # override calculated gallery width. Ex: "auto"
66
- :width => nil,
67
- # override calculated gallery height
68
- :height => nil,
69
- # Number of columns and lines in a gallery
70
- :columns => 8,
71
- :lines => 2,
72
- # vertical/horizontal padding/margin around each thumbnails
73
- :vpadding => 0,
74
- :hpadding => 0,
75
- :vmargin => 1,
76
- :hmargin => 1,
77
- # border around thumbnails
78
- :border_thickness => 2
79
- },
80
-
81
- # FormHelper thumbnail's information.
82
- # Set :width OR :height to nil to use aspect_ratio value. Remember that 4/3 == 1 => Use : 4.0/3
83
- # You can override computed ImageMagick transformation strings that defaults to "#{:width}x#{:height}>" by setting a value to :style
84
- # Needed if you set :aliases_only to true
85
-
86
- :thumbnail => {
87
- :width => 100,
88
- :height => 100,
89
- :aspect_ratio => nil,
90
- :style => nil
91
- },
92
-
93
- # Options passed on to SWFUpload.
94
- # To remove an option when overriding, set it to nil.
95
-
96
- :swfupload => {
97
- :flash_url => '/papermill/swfupload.swf',
98
- :button_image_url => '/papermill/images/upload-blank.png',
99
- :button_width => 61,
100
- :button_height => 22,
101
- :button_text => %{<span class="button-text">#{I18n.t("papermill.upload-button-wording")}</span>},
102
- :button_text_style => %{.button-text { font-size: 12pt; font-weight: bold; }},
103
- :button_text_top_padding => 4,
104
- :button_text_left_padding => 4,
105
- :debug => false,
106
- :prevent_swf_caching => true,
107
- :file_size_limit => "10 MB"
108
- },
109
-
110
- # APPLICATION WIDE PARAMETERS
111
- # Do not change these in your model declaration or form helper call.
112
-
113
- # Default named_scope name for catch-all :papermill declaration
114
- :base_association_name => :assets,
115
-
116
- # Set to true to require aliases in all url/path
117
- # Don't forget to give an alias value to options[:thumbnail][:style] if true!
118
- :alias_only => false,
119
-
120
- # Needed if :alias_only
121
- :aliases => {
122
- # 'example' => "100x100#",
123
- # 'example2' => {:geometry => "100x100#"}
124
- },
125
-
126
- # path to the root of your public directory (from NGINX/Apache pov)
127
- :public_root => ":rails_root/public",
128
-
129
- # added to :public_root as the root folder for all papermill assets
130
- :papermill_prefix => "system/papermill"
131
- }
132
- end
2
+ BASE_OPTIONS = {
3
+ :class_name => "PapermillAsset",
4
+ :inline_css => true,
5
+ :form_helper_elements => [:upload_button, :container, :dashboard],
6
+ :dashboard => [:mass_edit, :mass_delete],
7
+ :mass_editable_fields => ["title", "copyright", "description"],
8
+ :editable_fields => [
9
+ {:title => {:type => "string"}},
10
+ {:alt => {:type => "string"}},
11
+ {:copyright => {:type => "string"}},
12
+ {:description => {:type => "text" }}
13
+ ],
14
+ :gallery => {
15
+ :width => nil,
16
+ :height => nil,
17
+ :columns => 8,
18
+ :lines => 2,
19
+ :vpadding => 0,
20
+ :hpadding => 0,
21
+ :vmargin => 1,
22
+ :hmargin => 1,
23
+ :border_thickness => 2
24
+ },
25
+ :thumbnail => {
26
+ :width => 100,
27
+ :height => 100,
28
+ :aspect_ratio => nil,
29
+ :style => nil
30
+ },
31
+ :swfupload => {
32
+ :flash_url => '/papermill/swfupload.swf',
33
+ :button_image_url => '/papermill/images/upload-blank.png',
34
+ :button_width => 61,
35
+ :button_height => 22,
36
+ :button_text => %{<span class="button-text">#{I18n.t("papermill.upload-button-wording")}</span>},
37
+ :button_text_style => %{.button-text { font-size: 12pt; font-weight: bold; }},
38
+ :button_text_top_padding => 4,
39
+ :button_text_left_padding => 4,
40
+ :debug => false,
41
+ :prevent_swf_caching => true,
42
+ :file_size_limit => "10 MB"
43
+ },
44
+ :images_only => false,
45
+ :base_association_name => :assets,
46
+ :alias_only => false,
47
+ :aliases => {},
48
+ :public_root => ":rails_root/public",
49
+ :papermill_prefix => "system/papermill"
50
+ }
133
51
  end
@@ -3,7 +3,7 @@ module Paperclip
3
3
  # Handles thumbnailing images that are uploaded.
4
4
  class PapermillPaperclipProcessor < Thumbnail
5
5
 
6
- attr_reader :crop_h, :crop_w, :crop_x, :crop_y, :copyright
6
+ attr_accessor :crop_h, :crop_w, :crop_x, :crop_y, :copyright
7
7
 
8
8
  def initialize(file, options = {}, attachment = nil)
9
9
  @crop_h, @crop_w, @crop_x, @crop_y = options[:crop_h], options[:crop_w], options[:crop_x], options[:crop_y]
@@ -0,0 +1,4 @@
1
+ Please visit http://famspam.com/facebox/ or open index.html in your favorite browser.
2
+
3
+ Need help? Join our Google Groups mailing list:
4
+ http://groups.google.com/group/facebox/
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,95 @@
1
+ #facebox .b {
2
+ background:url(/facebox/b.png);
3
+ }
4
+
5
+ #facebox .tl {
6
+ background:url(/facebox/tl.png);
7
+ }
8
+
9
+ #facebox .tr {
10
+ background:url(/facebox/tr.png);
11
+ }
12
+
13
+ #facebox .bl {
14
+ background:url(/facebox/bl.png);
15
+ }
16
+
17
+ #facebox .br {
18
+ background:url(/facebox/br.png);
19
+ }
20
+
21
+ #facebox {
22
+ position: absolute;
23
+ top: 0;
24
+ left: 0;
25
+ z-index: 100;
26
+ text-align: left;
27
+ }
28
+
29
+ #facebox .popup {
30
+ position: relative;
31
+ }
32
+
33
+ #facebox table {
34
+ border-collapse: collapse;
35
+ }
36
+
37
+ #facebox td {
38
+ border-bottom: 0;
39
+ padding: 0;
40
+ }
41
+
42
+ #facebox .body {
43
+ padding: 10px;
44
+ background: #fff;
45
+ width: 370px;
46
+ }
47
+
48
+ #facebox .loading {
49
+ text-align: center;
50
+ }
51
+
52
+ #facebox .image {
53
+ text-align: center;
54
+ }
55
+
56
+ #facebox img {
57
+ border: 0;
58
+ margin: 0;
59
+ }
60
+
61
+ #facebox .footer {
62
+ border-top: 1px solid #DDDDDD;
63
+ padding-top: 5px;
64
+ margin-top: 10px;
65
+ text-align: right;
66
+ }
67
+
68
+ #facebox .tl, #facebox .tr, #facebox .bl, #facebox .br {
69
+ height: 10px;
70
+ width: 10px;
71
+ overflow: hidden;
72
+ padding: 0;
73
+ }
74
+
75
+ #facebox_overlay {
76
+ position: fixed;
77
+ top: 0px;
78
+ left: 0px;
79
+ height:100%;
80
+ width:100%;
81
+ }
82
+
83
+ .facebox_hide {
84
+ z-index:-100;
85
+ }
86
+
87
+ .facebox_overlayBG {
88
+ background-color: #000;
89
+ z-index: 99;
90
+ }
91
+
92
+ * html #facebox_overlay { /* ie6 hack */
93
+ position: absolute;
94
+ height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px');
95
+ }