Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: spree/spree
...
head fork: spree/spree
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 26, 2012
@radar radar [api] Prepend app's view path to view path lookups so views can be ov…
…erriden

Fixes #1804
fdc4e88
@radar radar Move S3 handling code into Spree::Core::S3Support
This means that you will only need to modify it in one spot now, rather than in Image and Taxon
f12f84b
View
1  api/lib/spree/api/controller_setup.rb
@@ -16,6 +16,7 @@ def self.included(klass)
include ActionController::MimeResponds
include CanCan::ControllerAdditions
+ prepend_view_path Rails.root + "app/views"
append_view_path File.expand_path("../../../app/views", File.dirname(__FILE__))
respond_to :json
View
11 core/app/models/spree/image.rb
@@ -14,15 +14,8 @@ class Image < Asset
# we need to look at the write-queue for images which have not been saved yet
after_post_process :find_dimensions
- # Load user defined paperclip settings
- if Spree::Config[:use_s3]
- s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
- Spree::Image.attachment_definitions[:attachment][:storage] = :s3
- Spree::Image.attachment_definitions[:attachment][:s3_credentials] = s3_creds
- Spree::Image.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
- Spree::Image.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
- Spree::Image.attachment_definitions[:attachment][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
- end
+ include Spree::Core::S3Support
+ supports_s3 :attachment
Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
Spree::Image.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
View
11 core/app/models/spree/taxon.rb
@@ -18,15 +18,8 @@ class Taxon < ActiveRecord::Base
:path => ':rails_root/public/spree/taxons/:id/:style/:basename.:extension',
:default_url => '/assets/default_taxon.png'
- # Load user defined paperclip settings
- if Spree::Config[:use_s3]
- s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
- Spree::Taxon.attachment_definitions[:icon][:storage] = :s3
- Spree::Taxon.attachment_definitions[:icon][:s3_credentials] = s3_creds
- Spree::Taxon.attachment_definitions[:icon][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
- Spree::Taxon.attachment_definitions[:icon][:bucket] = Spree::Config[:s3_bucket]
- Spree::Taxon.attachment_definitions[:icon][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
- end
+ include Spree::Core::S3Support
+ supports_s3 :icon
include ::Spree::ProductFilters # for detailed defs of filters
View
1  core/lib/spree/core.rb
@@ -86,6 +86,7 @@ def self.config(&block)
require 'spree/core/middleware/seo_assist'
require 'spree/core/permalinks'
require 'spree/core/token_resource'
+require 'spree/core/s3_support'
silence_warnings do
require 'spree/core/authorize_net_cim_hack'
View
24 core/lib/spree/core/s3_support.rb
@@ -0,0 +1,24 @@
+module Spree
+ module Core
+ # This module exists to reduce duplication in S3 settings between
+ # the Image and Taxon models in Spree
+ module S3Support
+ extend ActiveSupport::Concern
+
+ included do
+ def self.supports_s3(field)
+ # Load user defined paperclip settings
+ config = Spree::Config
+ if config[:use_s3]
+ s3_creds = { :access_key_id => config[:s3_access_key], :secret_access_key => config[:s3_secret], :bucket => config[:s3_bucket] }
+ self.attachment_definitions[field][:storage] = :s3
+ self.attachment_definitions[field][:s3_credentials] = s3_creds
+ self.attachment_definitions[field][:s3_headers] = ActiveSupport::JSON.decode(config[:s3_headers])
+ self.attachment_definitions[field][:bucket] = config[:s3_bucket]
+ self.attachment_definitions[field][:s3_protocol] = config[:s3_protocol] unless config[:s3_protocol].blank?
+ end
+ end
+ end
+ end
+ end
+end

No commit comments for this range

Something went wrong with that request. Please try again.