Commit 09766fbe1a27cb31f04f3a50098a4bbc5ecf0127
Exists in
master
and in
29 other branches
Merge branch 'merge-requests/63'
Showing
12 changed files
with
131 additions
and
131 deletions
Show diff stats
vendor/plugins/active_record_validations_delete/init.rb
@@ -1,9 +0,0 @@ | @@ -1,9 +0,0 @@ | ||
1 | -# monkey patch to remove a single error from the errors collection | ||
2 | -# http://dev.rubyonrails.org/ticket/8137 | ||
3 | - | ||
4 | -ActiveRecord::Errors.module_eval do | ||
5 | - # remove a single error from the errors collection by key | ||
6 | - def delete(key) | ||
7 | - @errors.delete(key.to_s) | ||
8 | - end | ||
9 | -end |
vendor/plugins/attachment_fu_validates_attachment/init.rb
@@ -1,34 +0,0 @@ | @@ -1,34 +0,0 @@ | ||
1 | -# friendlier attachment validations by Tim Lucas | ||
2 | -# ref.: http://toolmantim.com/article/2007/12/3/rollin_your_own_attachment_fu_messages_evil_twin_stylee | ||
3 | - | ||
4 | -Technoweenie::AttachmentFu::InstanceMethods.module_eval do | ||
5 | - protected | ||
6 | - def attachment_valid? | ||
7 | - if self.filename.nil? | ||
8 | - errors.add :empty, attachment_validation_options[:empty] | ||
9 | - return | ||
10 | - end | ||
11 | - [:content_type, :size].each do |option| | ||
12 | - if attachment_validation_options[option] && attachment_options[option] && !attachment_options[option].include?(self.send(option)) | ||
13 | - errors.add option, attachment_validation_options[option] | ||
14 | - end | ||
15 | - end | ||
16 | - end | ||
17 | -end | ||
18 | - | ||
19 | -Technoweenie::AttachmentFu::ClassMethods.module_eval do | ||
20 | - # Options: | ||
21 | - # * <tt>:empty</tt> - Base error message when no file is uploaded. Default is "No file uploaded" | ||
22 | - # * <tt>:content_type</tt> - Base error message when the uploaded file is not a valid content type. | ||
23 | - # * <tt>:size</tt> - Base error message when the uploaded file is not a valid size. | ||
24 | - # | ||
25 | - # Example: | ||
26 | - # validates_attachment :content_type => "The file you uploaded was not a JPEG, PNG or GIF", | ||
27 | - # :size => "The image you uploaded was larger than the maximum size of 10MB" | ||
28 | - def validates_attachment(options={}) | ||
29 | - options[:empty] ||= "No file uploaded" | ||
30 | - class_inheritable_accessor :attachment_validation_options | ||
31 | - self.attachment_validation_options = options | ||
32 | - validate :attachment_valid? | ||
33 | - end | ||
34 | -end |
vendor/plugins/monkey_patches/active_record_validations_delete/init.rb
0 → 100644
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +# monkey patch to remove a single error from the errors collection | ||
2 | +# http://dev.rubyonrails.org/ticket/8137 | ||
3 | + | ||
4 | +ActiveRecord::Errors.module_eval do | ||
5 | + # remove a single error from the errors collection by key | ||
6 | + def delete(key) | ||
7 | + @errors.delete(key.to_s) | ||
8 | + end | ||
9 | +end |
vendor/plugins/monkey_patches/attachment_fu_validates_attachment/init.rb
0 → 100644
@@ -0,0 +1,34 @@ | @@ -0,0 +1,34 @@ | ||
1 | +# friendlier attachment validations by Tim Lucas | ||
2 | +# ref.: http://toolmantim.com/article/2007/12/3/rollin_your_own_attachment_fu_messages_evil_twin_stylee | ||
3 | + | ||
4 | +Technoweenie::AttachmentFu::InstanceMethods.module_eval do | ||
5 | + protected | ||
6 | + def attachment_valid? | ||
7 | + if self.filename.nil? | ||
8 | + errors.add :empty, attachment_validation_options[:empty] | ||
9 | + return | ||
10 | + end | ||
11 | + [:content_type, :size].each do |option| | ||
12 | + if attachment_validation_options[option] && attachment_options[option] && !attachment_options[option].include?(self.send(option)) | ||
13 | + errors.add option, attachment_validation_options[option] | ||
14 | + end | ||
15 | + end | ||
16 | + end | ||
17 | +end | ||
18 | + | ||
19 | +Technoweenie::AttachmentFu::ClassMethods.module_eval do | ||
20 | + # Options: | ||
21 | + # * <tt>:empty</tt> - Base error message when no file is uploaded. Default is "No file uploaded" | ||
22 | + # * <tt>:content_type</tt> - Base error message when the uploaded file is not a valid content type. | ||
23 | + # * <tt>:size</tt> - Base error message when the uploaded file is not a valid size. | ||
24 | + # | ||
25 | + # Example: | ||
26 | + # validates_attachment :content_type => "The file you uploaded was not a JPEG, PNG or GIF", | ||
27 | + # :size => "The image you uploaded was larger than the maximum size of 10MB" | ||
28 | + def validates_attachment(options={}) | ||
29 | + options[:empty] ||= "No file uploaded" | ||
30 | + class_inheritable_accessor :attachment_validation_options | ||
31 | + self.attachment_validation_options = options | ||
32 | + validate :attachment_valid? | ||
33 | + end | ||
34 | +end |
vendor/plugins/monkey_patches/schema_dumper_sort_indexes/init.rb
0 → 100644
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +# based on https://rails.lighthouseapp.com/projects/8994/tickets/1266-order-add_index-statements-in-schemarb | ||
2 | +# only needed for rails < 2.2 | ||
3 | +if Rails::VERSION::STRING < "2.2.0" | ||
4 | + class ActiveRecord::SchemaDumper | ||
5 | + def indexes(table, stream) | ||
6 | + if (indexes = @connection.indexes(table)).any? | ||
7 | + | ||
8 | + add_index_statements = indexes.map do |index| | ||
9 | + statment_parts = [ ('add_index ' + index.table.inspect) ] | ||
10 | + statment_parts << index.columns.inspect | ||
11 | + statment_parts << (':name => ' + index.name.inspect) | ||
12 | + statment_parts << ':unique => true' if index.unique | ||
13 | + | ||
14 | + ' ' + statment_parts.join(', ') | ||
15 | + end | ||
16 | + | ||
17 | + stream.puts add_index_statements.sort.join("\n") | ||
18 | + stream.puts | ||
19 | + end | ||
20 | + end | ||
21 | + end | ||
22 | +end |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +if ActiveRecord::Base.instance_methods.include?("touch") && Class.const_defined?('TOUCH_LOADED') | ||
2 | + puts "W: ActiveRecord already provides a touch method, which means you must be using rails 2.3.3 or later." | ||
3 | + puts "W: In this case the touch plugin could probably be removed" | ||
4 | +end | ||
5 | +TOUCH_LOADED = true | ||
6 | + | ||
7 | +module Touch | ||
8 | + def touch | ||
9 | + update_attribute(:updated_at, Time.now) | ||
10 | + end | ||
11 | +end | ||
12 | + | ||
13 | +ActiveRecord::Base.send(:include, Touch) |
vendor/plugins/monkey_patches/white_list_sanitizer_unescape_before_reescape/init.rb
0 → 100644
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +# monkey patch to fix WhiteListSanitizer bug | ||
2 | +# http://apidock.com/rails/HTML/WhiteListSanitizer/process_attributes_for | ||
3 | +# | ||
4 | +# this was solved in rails 2.2.1, then remove this patch when upgrade to it | ||
5 | + | ||
6 | +HTML::WhiteListSanitizer.module_eval do | ||
7 | + | ||
8 | + def sanitize_with_filter_fixes(*args, &block) | ||
9 | + text = sanitize_without_filter_fixes(*args, &block) | ||
10 | + if text | ||
11 | + final_text = text.gsub(/<!/, '<!') | ||
12 | + final_text = final_text.gsub(/<!--.*\[if IE\]-->(.*)<!--\[endif\]-->/, '<!–-[if IE]>\1<![endif]-–>') #FIX for itheora comments | ||
13 | + | ||
14 | + final_text = final_text.gsub(/&quot;/, '"') #FIX problems with archive.org | ||
15 | + final_text | ||
16 | + end | ||
17 | + end | ||
18 | + alias_method_chain :sanitize, :filter_fixes | ||
19 | + | ||
20 | + # unescape before reescape to avoid: | ||
21 | + # & -> & -> &amp; -> &amp;amp; -> &amp;amp;amp; -> etc | ||
22 | + protected | ||
23 | + def process_attributes_for(node, options) | ||
24 | + return unless node.attributes | ||
25 | + node.attributes.keys.each do |attr_name| | ||
26 | + value = node.attributes[attr_name].to_s | ||
27 | + | ||
28 | + if !options[:attributes].include?(attr_name) || contains_bad_protocols?(attr_name, value) | ||
29 | + node.attributes.delete(attr_name) | ||
30 | + else | ||
31 | + node.attributes[attr_name] = attr_name == 'style' ? sanitize_css(value) : CGI::escapeHTML(value.gsub('&', '&')) | ||
32 | + end | ||
33 | + end | ||
34 | + end | ||
35 | +end |
vendor/plugins/monkey_patches/will_paginate_check_finder_sql/init.rb
0 → 100644
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +# monkey patch to fix WillPaginate bug | ||
2 | +# this was solved in will_paginate 3.x.pre, then remove this patch when upgrade to it | ||
3 | +# | ||
4 | +# http://sod.lighthouseapp.com/projects/17958/tickets/120-paginate-association-with-finder_sql-raises-typeerror | ||
5 | +require 'will_paginate' | ||
6 | + | ||
7 | +WillPaginate::Finder::ClassMethods.module_eval do | ||
8 | + def paginate_with_finder_sql(*args) | ||
9 | + if respond_to?(:proxy_reflection) && !proxy_reflection.options[:finder_sql].nil? | ||
10 | + # note: paginate_by_sql ignores the blocks. So don't pass the block | ||
11 | + paginate_by_sql(@finder_sql, args.extract_options!) | ||
12 | + else | ||
13 | + paginate_without_finder_sql(*args) | ||
14 | + end | ||
15 | + end | ||
16 | + # patch to deal with the custom_sql scenario | ||
17 | + alias_method_chain :paginate, :finder_sql | ||
18 | +end |
vendor/plugins/schema_dumper_sort_indexes/init.rb
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -# based on https://rails.lighthouseapp.com/projects/8994/tickets/1266-order-add_index-statements-in-schemarb | ||
2 | -# only needed for rails < 2.2 | ||
3 | -if Rails::VERSION::STRING < "2.2.0" | ||
4 | - class ActiveRecord::SchemaDumper | ||
5 | - def indexes(table, stream) | ||
6 | - if (indexes = @connection.indexes(table)).any? | ||
7 | - | ||
8 | - add_index_statements = indexes.map do |index| | ||
9 | - statment_parts = [ ('add_index ' + index.table.inspect) ] | ||
10 | - statment_parts << index.columns.inspect | ||
11 | - statment_parts << (':name => ' + index.name.inspect) | ||
12 | - statment_parts << ':unique => true' if index.unique | ||
13 | - | ||
14 | - ' ' + statment_parts.join(', ') | ||
15 | - end | ||
16 | - | ||
17 | - stream.puts add_index_statements.sort.join("\n") | ||
18 | - stream.puts | ||
19 | - end | ||
20 | - end | ||
21 | - end | ||
22 | -end |
vendor/plugins/touch/init.rb
@@ -1,13 +0,0 @@ | @@ -1,13 +0,0 @@ | ||
1 | -if ActiveRecord::Base.instance_methods.include?("touch") && Class.const_defined?('TOUCH_LOADED') | ||
2 | - puts "W: ActiveRecord already provides a touch method, which means you must be using rails 2.3.3 or later." | ||
3 | - puts "W: In this case the touch plugin could probably be removed" | ||
4 | -end | ||
5 | -TOUCH_LOADED = true | ||
6 | - | ||
7 | -module Touch | ||
8 | - def touch | ||
9 | - update_attribute(:updated_at, Time.now) | ||
10 | - end | ||
11 | -end | ||
12 | - | ||
13 | -ActiveRecord::Base.send(:include, Touch) |
vendor/plugins/white_list_sanitizer_unescape_before_reescape/init.rb
@@ -1,35 +0,0 @@ | @@ -1,35 +0,0 @@ | ||
1 | -# monkey patch to fix WhiteListSanitizer bug | ||
2 | -# http://apidock.com/rails/HTML/WhiteListSanitizer/process_attributes_for | ||
3 | -# | ||
4 | -# this was solved in rails 2.2.1, then remove this patch when upgrade to it | ||
5 | - | ||
6 | -HTML::WhiteListSanitizer.module_eval do | ||
7 | - | ||
8 | - def sanitize_with_filter_fixes(*args, &block) | ||
9 | - text = sanitize_without_filter_fixes(*args, &block) | ||
10 | - if text | ||
11 | - final_text = text.gsub(/<!/, '<!') | ||
12 | - final_text = final_text.gsub(/<!--.*\[if IE\]-->(.*)<!--\[endif\]-->/, '<!–-[if IE]>\1<![endif]-–>') #FIX for itheora comments | ||
13 | - | ||
14 | - final_text = final_text.gsub(/&quot;/, '"') #FIX problems with archive.org | ||
15 | - final_text | ||
16 | - end | ||
17 | - end | ||
18 | - alias_method_chain :sanitize, :filter_fixes | ||
19 | - | ||
20 | - # unescape before reescape to avoid: | ||
21 | - # & -> & -> &amp; -> &amp;amp; -> &amp;amp;amp; -> etc | ||
22 | - protected | ||
23 | - def process_attributes_for(node, options) | ||
24 | - return unless node.attributes | ||
25 | - node.attributes.keys.each do |attr_name| | ||
26 | - value = node.attributes[attr_name].to_s | ||
27 | - | ||
28 | - if !options[:attributes].include?(attr_name) || contains_bad_protocols?(attr_name, value) | ||
29 | - node.attributes.delete(attr_name) | ||
30 | - else | ||
31 | - node.attributes[attr_name] = attr_name == 'style' ? sanitize_css(value) : CGI::escapeHTML(value.gsub('&', '&')) | ||
32 | - end | ||
33 | - end | ||
34 | - end | ||
35 | -end |
vendor/plugins/will_paginate_check_finder_sql/init.rb
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -# monkey patch to fix WillPaginate bug | ||
2 | -# this was solved in will_paginate 3.x.pre, then remove this patch when upgrade to it | ||
3 | -# | ||
4 | -# http://sod.lighthouseapp.com/projects/17958/tickets/120-paginate-association-with-finder_sql-raises-typeerror | ||
5 | -require 'will_paginate' | ||
6 | - | ||
7 | -WillPaginate::Finder::ClassMethods.module_eval do | ||
8 | - def paginate_with_finder_sql(*args) | ||
9 | - if respond_to?(:proxy_reflection) && !proxy_reflection.options[:finder_sql].nil? | ||
10 | - # note: paginate_by_sql ignores the blocks. So don't pass the block | ||
11 | - paginate_by_sql(@finder_sql, args.extract_options!) | ||
12 | - else | ||
13 | - paginate_without_finder_sql(*args) | ||
14 | - end | ||
15 | - end | ||
16 | - # patch to deal with the custom_sql scenario | ||
17 | - alias_method_chain :paginate, :finder_sql | ||
18 | -end |