dynamic_paperclip 1.0.0a.3 → 1.0.0.alpha.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 520ff66ae208d8c9fd390b036848638a68712442
4
+ data.tar.gz: 361cb3f76ed5bc35d812833a5c312b12c6e7fbce
5
+ SHA512:
6
+ metadata.gz: f49d318831c5c3ad14573450fdcb21ab52efdc0c5cc9ca7c72803d4b4f2c484b607b7a088f0cd148532cf903bfd5393d4c4f7fb7275e20e9d6b78b7330a248e9
7
+ data.tar.gz: 820b5db8650c4e48ed966d1383cdf10ddc217fc48d2d81f50683906c00de269ca538abf9f19f90ba3318024410e00a2e0b294bed0a4ab1c29e52745272471246
data/README.md CHANGED
@@ -135,7 +135,7 @@ Which will return the following url (assuming a JPG avatar and a User ID of 42):
135
135
 
136
136
  When the first request comes in for that URL, Dynamic Paperclip's Rack middleware will intercept the request,
137
137
  validate that "secrethash" to ensure that the dynamic URL was generated by your application and not some third-party,
138
- then simply tell Paperclip to process that style by extracting the definition from the stye name,
138
+ then simply tell Paperclip to process that style by extracting the definition from the style name,
139
139
  and then finally send the processed file back to your visitor's browser.
140
140
 
141
141
  On subsequent requests, the attachment will already exist, and your HTTP server will simply return it without
data/Rakefile CHANGED
@@ -36,5 +36,9 @@ Rake::TestTask.new(:test) do |t|
36
36
  t.verbose = false
37
37
  end
38
38
 
39
-
40
39
  task :default => :test
40
+
41
+ require 'appraisal'
42
+ if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
43
+ task :default => :appraisal
44
+ end
@@ -10,14 +10,18 @@ module DynamicPaperclip
10
10
  # Add existing dynamic styles
11
11
  if instance.persisted?
12
12
  path_with_wildcard = path('dynamic_*')
13
- style_position = path_with_wildcard.index('dynamic_*')
14
13
 
15
- Dir.glob(path_with_wildcard) do |file|
16
- style_name = file[style_position..-1].split('/').first
14
+ # Could be nil if the attachment doesn't exist
15
+ if path_with_wildcard
16
+ style_position = path_with_wildcard.index('dynamic_*')
17
17
 
18
- # In the event that the style name is used as the filename,
19
- # we want to remove the extension for our style name
20
- add_dynamic_style! File.basename(style_name, File.extname(style_name))
18
+ Dir.glob(path_with_wildcard) do |file|
19
+ style_name = file[style_position..-1].split('/').first
20
+
21
+ # In the event that the style name is used as the filename,
22
+ # we want to remove the extension for our style name
23
+ add_dynamic_style! File.basename(style_name, File.extname(style_name))
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -20,7 +20,7 @@ module DynamicPaperclip
20
20
 
21
21
  # The definition will be escaped twice in the URL, so we need to unescape it once.
22
22
  # We should always reference dynamic style names after escaping once - that's how they reside on the FS.
23
- style_name = StyleNaming.dynamic_style_name_from_definition(URI.unescape(match[:definition]), false)
23
+ style_name = StyleNaming.dynamic_style_name_from_definition(CGI.unescape(match[:definition]), false)
24
24
 
25
25
  # Validate URL hash against requested style name
26
26
  if DynamicPaperclip::UrlSecurity.valid_hash?(request.params['s'], style_name)
@@ -4,7 +4,7 @@ module DynamicPaperclip
4
4
  # only supports strings at the moment
5
5
  def self.dynamic_style_name_from_definition(options, uri_escape=true)
6
6
  if options.is_a?(String)
7
- "dynamic_#{uri_escape ? URI.escape(options) : options}".to_sym
7
+ "dynamic_#{uri_escape ? CGI.escape(options) : options}".to_sym
8
8
  else
9
9
  raise 'Only String options are supported with dynamic attachments'
10
10
  end
@@ -13,7 +13,7 @@ module DynamicPaperclip
13
13
  # Reverse of #dynamic_style_name_from_definition,
14
14
  # given a dynamic style name, extracts the definition (style options)
15
15
  def self.style_definition_from_dynamic_style_name(name)
16
- URI.unescape name[8..-1]
16
+ CGI.unescape name[8..-1]
17
17
  end
18
18
  end
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module DynamicPaperclip
2
- VERSION = "1.0.0a.3"
2
+ VERSION = "1.0.0.alpha.4"
3
3
  end
@@ -1,3 +1,7 @@
1
1
  class Photo < ActiveRecord::Base
2
2
  has_dynamic_attached_file :image, styles: { thumb: '100x100#' }
3
+
4
+ if Gem::Version.new(Paperclip::VERSION) >= Gem::Version.new('4')
5
+ do_not_validate_attachment_file_type :image
6
+ end
3
7
  end
@@ -1,8 +1,9 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
1
  require 'rails/all'
4
2
 
3
+ # Require the gems listed in Gemfile, including any gems
4
+ # you've limited to :test, :development, or :production.
5
5
  Bundler.require(*Rails.groups)
6
+
6
7
  require "dynamic_paperclip"
7
8
 
8
9
  module Dummy
@@ -11,16 +12,6 @@ module Dummy
11
12
  # Application configuration should go into files in config/initializers
12
13
  # -- all .rb files in that directory are automatically loaded.
13
14
 
14
- # Custom directories with classes and modules you want to be autoloadable.
15
- # config.autoload_paths += %W(#{config.root}/extras)
16
-
17
- # Only load the plugins named here, in the order given (default is alphabetical).
18
- # :all can be used as a placeholder for all plugins not explicitly named.
19
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
-
21
- # Activate observers that should always be running.
22
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
-
24
15
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
16
  # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
17
  # config.time_zone = 'Central Time (US & Canada)'
@@ -29,31 +20,6 @@ module Dummy
29
20
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
21
  # config.i18n.default_locale = :de
31
22
 
32
- # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
34
-
35
- # Configure sensitive parameters which will be filtered from the log file.
36
- config.filter_parameters += [:password]
37
-
38
- # Enable escaping HTML in JSON.
39
- config.active_support.escape_html_entities_in_json = true
40
-
41
- # Use SQL instead of Active Record's schema dumper when creating the database.
42
- # This is necessary if your schema can't be completely dumped by the schema dumper,
43
- # like if you have constraints or database-specific column types
44
- # config.active_record.schema_format = :sql
45
-
46
- # Enforce whitelist mode for mass assignment.
47
- # This will create an empty whitelist of attributes available for mass-assignment for all models
48
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
49
- # parameters by using an attr_accessible or attr_protected declaration.
50
- config.active_record.whitelist_attributes = true
51
-
52
- # Enable the asset pipeline
53
- config.assets.enabled = true
54
-
55
- # Version of your assets, change this if you want to expire all your assets
56
- config.assets.version = '1.0'
23
+ config.active_record.raise_in_transactional_callbacks = true
57
24
  end
58
25
  end
59
-
@@ -1,5 +1,5 @@
1
- # Load the rails application
1
+ # Load the Rails application.
2
2
  require File.expand_path('../application', __FILE__)
3
3
 
4
- # Initialize the rails application
4
+ # Initialize the Rails application.
5
5
  Dummy::Application.initialize!
@@ -1,5 +1,5 @@
1
1
  Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
@@ -7,31 +7,30 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = false
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
13
14
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = "public, max-age=3600"
16
18
 
17
- # Show full error reports and disable caching
19
+ # Show full error reports and disable caching.
18
20
  config.consider_all_requests_local = true
19
21
  config.action_controller.perform_caching = false
20
22
 
21
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
22
24
  config.action_dispatch.show_exceptions = false
23
25
 
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
26
28
 
27
29
  # Tell Action Mailer not to deliver emails to the real world.
28
30
  # The :test delivery method accumulates sent emails in the
29
31
  # ActionMailer::Base.deliveries array.
30
32
  config.action_mailer.delivery_method = :test
31
33
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
- # Print deprecation notices to the stderr
34
+ # Print deprecation notices to the stderr.
36
35
  config.active_support.deprecation = :stderr
37
36
  end
@@ -1,7 +1,12 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- # Your secret key for verifying the integrity of signed cookies.
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
4
  # If you change this key, all old signed cookies will become invalid!
5
+
5
6
  # Make sure the secret is at least 30 characters and all random,
6
7
  # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = '959ab32349c805bdfd234602c492d9b06bcb9277a650fd6b9fe0670cc1f78ce67a133b90a4ce193401870b30a2194f23652b2a8f41dd50d92cd6a01222325f7a'
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ Dummy::Application.config.secret_key_base = '1308728b934efe940ce301800d4c83287bf7931b6ac3b9bbf68ce053b9faacde9de2052fe243fb5fd6d5e361b53ae353146c4469e59a51c4bdccafdcb068350d'
@@ -1,8 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
3
  Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
@@ -1,14 +1,14 @@
1
1
  # Be sure to restart your server when you modify this file.
2
- #
2
+
3
3
  # This file contains settings for ActionController::ParamsWrapper which
4
4
  # is enabled by default.
5
5
 
6
6
  # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
7
  ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
9
  end
10
10
 
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
Binary file