bcms_s3 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  # A [BrowserCMS](http://www.browsercms.org) module to allow storage of images and files on the Amazon S3 storage facility
2
2
  ## Using S3 for file storage
3
- To enable S3 file storage set Cms::S3::Module.enabled in config/initializers/browsercms.rb (create this if it does not exist) to true. Ensure that you as provide a s3.yml file that contains your credentials and bucket.
3
+ To enable S3 file storage set Cms::S3.enabled in config/initializers/browsercms.rb (create this if it does not exist) to true. Ensure that you as provide a s3.yml file that contains your credentials and bucket.
4
4
  This should be in the following format
5
5
 
6
6
  access_key_id: your AWS access key
@@ -8,7 +8,10 @@ This should be in the following format
8
8
  bucket: your unique bucket name
9
9
 
10
10
  ## Using this module with [Heroku](http://heroku.com)
11
- If using this module in conjunction with deployment on heroku you should probably turning heroku caching on by setting Cms::S3::Module.heroku_caching in config/initializers/browsercms.rb to true.
11
+ If using this module in conjunction with deployment on heroku you should probably turning heroku caching on by setting Cms::S3.heroku_caching in config/initializers/browsercms.rb to true.
12
+
13
+ ## www prefix for non cms urls
14
+ If your non cms domain is www.myapp.com rather than app.com this can be enabled by setting Cms::S3.www_domain_prefix in config/initializers/browsercms.rb to true.
12
15
 
13
16
  ## Important things to note
14
17
  1. The s3.yml should be excluded from public repositories (e.g github) since it contains your secret AWS key which should **never** be revealed to the public.
@@ -4,6 +4,7 @@ module Cms
4
4
  class << self
5
5
  attr_accessor :enabled
6
6
  attr_accessor :heroku_caching
7
+ attr_accessor :www_domain_prefix
7
8
  attr_accessor :options
8
9
  end
9
10
  module ContentController
@@ -87,15 +88,31 @@ module Cms
87
88
  end
88
89
  end
89
90
  end
91
+ module ApplicationController
92
+ def self.included(controller_class)
93
+ controller_class.alias_method_chain :url_without_cms_domain_prefix, :www
94
+ end
95
+ def url_without_cms_domain_prefix_with_www
96
+ if Cms::S3.www_domain_prefix
97
+ request.url.sub(/#{cms_domain_prefix}\./,'www.')
98
+ else
99
+ request.url.sub(/#{cms_domain_prefix}\./,'')
100
+ end
101
+ end
102
+ end
90
103
  end
91
104
  end
92
105
 
93
106
  Cms::ContentController.send(:include, Cms::S3::ContentController)
94
107
  Attachment.send(:include, Cms::S3::Attachment)
108
+ Cms::ApplicationController.send(:include, Cms::S3::ApplicationController)
95
109
  # ensure S3 storage disabled by default
96
110
  Cms::S3.enabled = false if Cms::S3.enabled.nil?
97
111
  # ensure heroku caching disabled by default
98
112
  Cms::S3.heroku_caching = false if Cms::S3.heroku_caching.nil?
113
+ # function to set domain prefix without url to 'www' is disabled by default
114
+ Cms::S3.www_domain_prefix = false if Cms::S3.www_domain_prefix.nil?
115
+ # load s3 options if s3.yml exists
99
116
  if File.exists?("#{RAILS_ROOT}/config/s3.yml")
100
117
  Cms::S3.options = YAML.load_file("#{RAILS_ROOT}/config/s3.yml")
101
118
  Cms::S3.options.symbolize_keys!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcms_s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Underwood