bcms_aws_s3-artirix 4.0.0.rc1.art4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +36 -0
  3. data/app/assets/javascripts/bcms_s3/application.js +13 -0
  4. data/app/assets/stylesheets/bcms_s3/application.css +13 -0
  5. data/app/controllers/bcms_s3/application_controller.rb +4 -0
  6. data/app/helpers/bcms_s3/application_helper.rb +4 -0
  7. data/app/views/layouts/bcms_s3/application.html.erb +14 -0
  8. data/config/routes.rb +2 -0
  9. data/lib/bcms_aws_s3-artirix.rb +1 -0
  10. data/lib/bcms_aws_s3.rb +4 -0
  11. data/lib/bcms_s3/engine.rb +31 -0
  12. data/lib/bcms_s3/s3_module.rb +24 -0
  13. data/lib/bcms_s3/version.rb +3 -0
  14. data/lib/cms/attachments/s3_strategy.rb +31 -0
  15. data/lib/generators/bcms_s3/install/USAGE +3 -0
  16. data/lib/generators/bcms_s3/install/install_generator.rb +21 -0
  17. data/lib/tasks/bcms_s3_tasks.rake +4 -0
  18. data/test/bcms_s3_test.rb +7 -0
  19. data/test/dummy/README.rdoc +28 -0
  20. data/test/dummy/Rakefile +6 -0
  21. data/test/dummy/app/assets/javascripts/application.js +13 -0
  22. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  23. data/test/dummy/app/controllers/application_controller.rb +5 -0
  24. data/test/dummy/app/helpers/application_helper.rb +2 -0
  25. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/test/dummy/app/views/layouts/templates/default.html.erb +16 -0
  27. data/test/dummy/bin/bundle +3 -0
  28. data/test/dummy/bin/rails +4 -0
  29. data/test/dummy/bin/rake +4 -0
  30. data/test/dummy/config.ru +4 -0
  31. data/test/dummy/config/application.rb +23 -0
  32. data/test/dummy/config/boot.rb +5 -0
  33. data/test/dummy/config/database.yml +25 -0
  34. data/test/dummy/config/environment.rb +5 -0
  35. data/test/dummy/config/environments/development.rb +29 -0
  36. data/test/dummy/config/environments/production.rb +86 -0
  37. data/test/dummy/config/environments/test.rb +36 -0
  38. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/dummy/config/initializers/browsercms.rb +1 -0
  40. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  41. data/test/dummy/config/initializers/inflections.rb +16 -0
  42. data/test/dummy/config/initializers/mime_types.rb +5 -0
  43. data/test/dummy/config/initializers/secret_token.rb +12 -0
  44. data/test/dummy/config/initializers/session_store.rb +3 -0
  45. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  46. data/test/dummy/config/locales/en.yml +23 -0
  47. data/test/dummy/config/routes.rb +6 -0
  48. data/test/dummy/config/s3.yml +2 -0
  49. data/test/dummy/db/browsercms.seeds.rb +59 -0
  50. data/test/dummy/db/migrate/20140204192558_browsercms300.cms.rb +288 -0
  51. data/test/dummy/db/migrate/20140204192559_browsercms400.cms.rb +91 -0
  52. data/test/dummy/db/migrate/20140204192560_devise_create_users.cms.rb +48 -0
  53. data/test/dummy/db/migrate/20140204192561_kill_reset_password.cms.rb +6 -0
  54. data/test/dummy/db/migrate/20140204192562_create_cms_external_users.cms.rb +11 -0
  55. data/test/dummy/db/schema.rb +558 -0
  56. data/test/dummy/db/seeds.rb +3 -0
  57. data/test/dummy/db/test.sqlite3 +0 -0
  58. data/test/dummy/log/test.log +5 -0
  59. data/test/dummy/public/404.html +58 -0
  60. data/test/dummy/public/422.html +58 -0
  61. data/test/dummy/public/500.html +57 -0
  62. data/test/dummy/public/favicon.ico +0 -0
  63. data/test/integration/navigation_test.rb +10 -0
  64. data/test/test_helper.rb +15 -0
  65. metadata +198 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a69d8fbc87156bec38d698f206daded2257d4708
4
+ data.tar.gz: aeeea0c2850569f1c04290c33665cde90b495f5e
5
+ SHA512:
6
+ metadata.gz: 211bca1ebc1bf555c9a7e69f3e7b2423a7eaac3597594b67fbce1637e33bf29be646d3590d770041e7ed62da44619136e2e0492963b50414e4c63d68dbe7d49a
7
+ data.tar.gz: 800b9997a17bb46c394918d6943576fdcbcd61000cc105e5ddf30e3b74e88e2164b24f235ed5747ac1341748ee68a7f0e0d6010072933a5f83182933868f1cb9
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'BcmsS3'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
35
+
36
+ load 'lib/tasks/module_tasks.rake'
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module BcmsS3
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module BcmsS3
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>BcmsS3</title>
5
+ <%= stylesheet_link_tag "bcms_s3/application", media: "all" %>
6
+ <%= javascript_include_tag "bcms_s3/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ BcmsS3::Engine.routes.draw do
2
+ end
@@ -0,0 +1 @@
1
+ require 'bcms_aws_s3'
@@ -0,0 +1,4 @@
1
+ require "bcms_s3/engine"
2
+
3
+ module BcmsS3
4
+ end
@@ -0,0 +1,31 @@
1
+ require 'browsercms'
2
+ require 'bcms_s3/s3_module'
3
+ require 'cms/attachments/s3_strategy'
4
+
5
+ module BcmsS3
6
+ class Engine < ::Rails::Engine
7
+ isolate_namespace BcmsS3
8
+ include Cms::Module
9
+
10
+ config.before_configuration do
11
+ puts '=============================================================='
12
+ puts '=============================================================='
13
+
14
+ config.cms.attachments.s3_credentials = "#{Rails.root}/config/s3.yml"
15
+ config.cms.attachments.storage = :s3
16
+ end
17
+
18
+ config.to_prepare do
19
+ Cms::ApplicationController.send(:include, Cms::S3::ApplicationController)
20
+
21
+ # ensure heroku caching disabled by default
22
+ Cms::S3.heroku_caching = false if Cms::S3.heroku_caching.nil?
23
+
24
+ # function to set domain prefix without url to 'www' is disabled by default
25
+ Cms::S3.www_domain_prefix = false if Cms::S3.www_domain_prefix.nil?
26
+
27
+ end
28
+
29
+
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ module Cms
2
+ module S3
3
+ class << self
4
+ attr_accessor :heroku_caching
5
+ attr_accessor :www_domain_prefix
6
+ attr_accessor :options
7
+ end
8
+
9
+ module ApplicationController
10
+ def self.included(controller_class)
11
+ controller_class.alias_method_chain :url_without_cms_domain_prefix, :www
12
+ end
13
+ def url_without_cms_domain_prefix_with_www
14
+ if Cms::S3.www_domain_prefix
15
+ request.url.sub(/#{cms_domain_prefix}\./,'www.')
16
+ else
17
+ request.url.sub(/#{cms_domain_prefix}\./,'')
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,3 @@
1
+ module BcmsS3
2
+ VERSION = "4.0.0.rc1.art4"
3
+ end
@@ -0,0 +1,31 @@
1
+ module Cms
2
+ module Attachments
3
+
4
+ # Automatically used to serve files when the following configuration is set:
5
+ # config.cms.attachments.storage = :s3
6
+ class S3Strategy
7
+
8
+ # Redirects users to the file on S3.
9
+ # Issues:
10
+ # 1. No security, all files are assumed to be public
11
+ # 2. CNAMEs are not supported.
12
+ def self.send_attachment(attachment, controller)
13
+ controller.redirect_to attachment.url
14
+
15
+ # Possible s3_cname implementation
16
+ # if Cms::S3.options[:s3_cname]
17
+ # redirect_to("http://#{Cms::S3.options[:s3_cname]}/#{@attachment.file_location}")
18
+ # else
19
+ # redirect_to("http://#{Cms::S3.options[:bucket]}.s3.amazonaws.com/#{@attachment.file_location}")
20
+ # end
21
+ end
22
+
23
+ # For S3, this returns the relative path within the bucket.
24
+ # I.e. http://s3.amazonaws.com/:bucket/:attachments_storage_location/:path_to_file
25
+ def self.attachments_storage_location
26
+ "/attachments"
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ Installs bcms_s3 into a project. Typically invoked indirectly via:
2
+
3
+ rails generate cms:install bcms_s3
@@ -0,0 +1,21 @@
1
+ require 'cms/module_installation'
2
+
3
+ class BcmsS3::InstallGenerator < Cms::ModuleInstallation
4
+ add_migrations_directory_to_source_root __FILE__
5
+
6
+
7
+ def copy_migrations
8
+ rake 'bcms_s3:install:migrations'
9
+ end
10
+
11
+ # Uncomment to add module specific seed data to a project.
12
+ #def add_seed_data_to_project
13
+ # copy_file "../bcms_s3.seeds.rb", "db/bcms_s3.seeds.rb"
14
+ # append_to_file "db/seeds.rb", "load File.expand_path('../bcms_s3.seeds.rb', __FILE__)\n"
15
+ #end
16
+
17
+ def add_routes
18
+ mount_engine(BcmsS3)
19
+ end
20
+
21
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :bcms_s3 do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BcmsS3Test < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, BcmsS3
6
+ end
7
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,16 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
5
+ <title><%= page_title %></title>
6
+ <%= yield :html_head %>
7
+ </head>
8
+ <body style="margin: 0; padding: 0; text-align: center;">
9
+ <div id="wrapper" style="width: 700px; margin: 0 auto; text-align: left; padding: 30px">
10
+ Breadcrumbs: <%= render_breadcrumbs %>
11
+ Main Menu: <%= render_menu %>
12
+ <h1><%= page_header %></h1>
13
+ <%= container :main %>
14
+ </div>
15
+ </body>
16
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "bcms_aws_s3"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000