locomotivecms 3.0.0.rc3 → 3.0.0.rc4

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.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -3
  3. data/README.md +1 -1
  4. data/app/assets/stylesheets/locomotive/unauthorized/_public.scss +7 -4
  5. data/app/controllers/locomotive/errors_controller.rb +4 -0
  6. data/app/helpers/locomotive/errors_helper.rb +2 -4
  7. data/app/models/locomotive/concerns/content_entry/csv.rb +4 -0
  8. data/app/models/locomotive/concerns/content_entry/slug.rb +0 -2
  9. data/app/models/locomotive/concerns/content_type/sync.rb +2 -2
  10. data/app/models/locomotive/concerns/page/templatized.rb +1 -1
  11. data/app/models/locomotive/concerns/site/access_points.rb +3 -3
  12. data/app/models/locomotive/theme_asset.rb +0 -1
  13. data/app/views/locomotive/developers_documentation/_wagon.html.slim +2 -2
  14. data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -0
  15. data/app/views/locomotive/errors/no_site.json +1 -0
  16. data/app/views/locomotive/shared/_sidebar.html.slim +1 -1
  17. data/app/views/locomotive/shared/_sidebar_without_site.html.slim +1 -1
  18. data/app/views/locomotive/shared/header/_account_menu.html.slim +2 -2
  19. data/config/locales/en.yml +1 -1
  20. data/config/routes.rb +4 -2
  21. data/lib/generators/locomotive/install/install_generator.rb +9 -9
  22. data/lib/generators/locomotive/install/templates/carrierwave.rb +23 -12
  23. data/lib/generators/locomotive/install/templates/carrierwave_aws.rb +36 -0
  24. data/lib/generators/locomotive/install/templates/mongoid.yml +97 -35
  25. data/lib/locomotive/dependencies.rb +1 -1
  26. data/lib/locomotive/middlewares/site.rb +10 -4
  27. data/lib/locomotive/mongoid/patches.rb +1 -1
  28. data/lib/locomotive/steam_adaptor.rb +6 -4
  29. data/lib/locomotive/version.rb +1 -1
  30. data/spec/dummy/config/application.rb +0 -3
  31. data/spec/dummy/config/initializers/devise.rb +128 -58
  32. data/spec/dummy/config/mongoid.yml +95 -78
  33. data/spec/models/locomotive/content_entry_spec.rb +6 -6
  34. data/spec/requests/locomotive/steam/cache_spec.rb +1 -1
  35. data/spec/requests/site_spec.rb +25 -0
  36. data/spec/support/mongoid.rb +2 -0
  37. metadata +16 -189
  38. data/features/api/accounts.feature +0 -43
  39. data/features/api/authentication.feature +0 -41
  40. data/features/api/authorization/accounts.feature +0 -165
  41. data/features/api/authorization/content_assets.feature +0 -147
  42. data/features/api/authorization/content_entries.feature +0 -202
  43. data/features/api/authorization/content_types.feature +0 -237
  44. data/features/api/authorization/current_site.feature +0 -30
  45. data/features/api/authorization/memberships.feature +0 -225
  46. data/features/api/authorization/pages.feature +0 -189
  47. data/features/api/authorization/sites.feature +0 -212
  48. data/features/api/authorization/snippets.feature +0 -179
  49. data/features/api/authorization/theme_assets.feature +0 -185
  50. data/features/api/authorization/translations.feature +0 -253
  51. data/features/api/content_entries.feature +0 -184
  52. data/features/api/content_types.feature +0 -156
  53. data/features/api/editable_elements.feature +0 -190
  54. data/features/api/entries_custom_fields.feature +0 -150
  55. data/features/api/memberships.feature +0 -26
  56. data/features/api/pages.feature +0 -72
  57. data/features/backoffice/authorization/account_settings.feature +0 -28
  58. data/features/backoffice/authorization/content_type.feature +0 -35
  59. data/features/backoffice/authorization/current_site.feature +0 -53
  60. data/features/backoffice/authorization/inline_front_end_editing.feature +0 -46
  61. data/features/backoffice/authorization/pages.feature +0 -95
  62. data/features/backoffice/authorization/theme_assets.feature +0 -50
  63. data/features/backoffice/content_types/edit.feature +0 -20
  64. data/features/backoffice/content_types/email.feature +0 -26
  65. data/features/backoffice/content_types/has_many.feature +0 -80
  66. data/features/backoffice/content_types/integer.feature +0 -26
  67. data/features/backoffice/content_types/localized.feature +0 -63
  68. data/features/backoffice/content_types/many_to_many.feature +0 -70
  69. data/features/backoffice/content_types/tags.feature +0 -22
  70. data/features/backoffice/content_types/uniqueness.feature +0 -29
  71. data/features/backoffice/contents.feature +0 -93
  72. data/features/backoffice/editable_elements.feature +0 -22
  73. data/features/backoffice/installation.feature +0 -33
  74. data/features/backoffice/login.feature +0 -33
  75. data/features/backoffice/mounting.feature +0 -13
  76. data/features/backoffice/my_account.feature +0 -22
  77. data/features/backoffice/pages.feature +0 -73
  78. data/features/backoffice/regressions.feature +0 -19
  79. data/features/backoffice/site.feature +0 -71
  80. data/features/backoffice/snippets.feature +0 -39
  81. data/features/backoffice/theme_assets.feature +0 -72
  82. data/features/backoffice/translations.feature +0 -50
  83. data/features/public/basic.feature +0 -30
  84. data/features/public/contact_form.feature +0 -98
  85. data/features/public/content_entries.feature +0 -69
  86. data/features/public/editable_elements.feature +0 -138
  87. data/features/public/has_many.feature +0 -8
  88. data/features/public/inheritance.feature +0 -157
  89. data/features/public/inline_front_end_editing.feature +0 -26
  90. data/features/public/many_to_many.feature +0 -64
  91. data/features/public/new_contact_form.feature +0 -95
  92. data/features/public/pages.feature +0 -116
  93. data/features/public/pagination.feature +0 -8
  94. data/features/public/robots.feature +0 -22
  95. data/features/public/session.feature +0 -40
  96. data/features/public/sitemap.feature +0 -74
  97. data/features/public/snippets.feature +0 -21
  98. data/features/public/tablerow.feature +0 -42
  99. data/features/public/tags.feature +0 -45
  100. data/features/step_definitions/api_steps.rb +0 -179
  101. data/features/step_definitions/backoffice/mounting_steps.rb +0 -22
  102. data/features/step_definitions/backoffice_steps.rb +0 -47
  103. data/features/step_definitions/content_assets_steps.rb +0 -12
  104. data/features/step_definitions/content_types_steps.rb +0 -135
  105. data/features/step_definitions/current_site_steps.rb +0 -43
  106. data/features/step_definitions/editable_elements_steps.rb +0 -24
  107. data/features/step_definitions/membership_steps.rb +0 -19
  108. data/features/step_definitions/more_web_steps.rb +0 -131
  109. data/features/step_definitions/page_steps.rb +0 -133
  110. data/features/step_definitions/pagination_steps.rb +0 -35
  111. data/features/step_definitions/pickle_steps.rb +0 -100
  112. data/features/step_definitions/relationships_steps.rb +0 -110
  113. data/features/step_definitions/site_steps.rb +0 -111
  114. data/features/step_definitions/snippet_steps.rb +0 -37
  115. data/features/step_definitions/theme_asset_steps.rb +0 -64
  116. data/features/step_definitions/translation_steps.rb +0 -7
  117. data/features/step_definitions/web_steps.rb +0 -225
  118. data/features/step_definitions/within_steps.rb +0 -14
  119. data/features/support/cleaner.rb +0 -4
  120. data/features/support/env.rb +0 -82
  121. data/features/support/factory_girl.rb +0 -2
  122. data/features/support/http.rb +0 -22
  123. data/features/support/locales.rb +0 -5
  124. data/features/support/paths.rb +0 -62
  125. data/features/support/pickle.rb +0 -24
  126. data/features/support/selectors.rb +0 -57
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: adb0a5ebc0f40fc62072340ff10f15d6029d14bb
4
- data.tar.gz: c7d3971de7bd5e22fc8d32b94445e3c6ff96f2cc
3
+ metadata.gz: 2b022aa4b532f3b4ab72f8e7218af9f6eb77f834
4
+ data.tar.gz: 7fa421098346655a1eb58290defc5ffe2d2b1e0f
5
5
  SHA512:
6
- metadata.gz: 470554e8983fb56b3d2e88bc02dd1276b21baa7153dc9afcd8c98b29e4b4ea9ecb3cbe1eef5bba2df822da81024ac1682ec29eec4c157dd4337709bcf9499ea3
7
- data.tar.gz: e38ef2a4463cd47412a61cc2843242e843db154d8e78f0e58486939535e6318b70453c0763fb5bd6c1eaf0884bca322f65cb35730513fd2180cf4421a732fa27
6
+ metadata.gz: 4dcd634a7df28ca685eb12c1cd2634d259db84a82a77336bd0abcc600d3e91e685129701ff10503367069c36aa3f2e3cb616bfd0b2f9174fcc11ef18ffb17f8d
7
+ data.tar.gz: 514754acae872d4b2ea2c0721990885136f0ba305d4e42b84ad0721ff289d0d4ae9d781b0ddff9053ac97d86553c2d1bcd914b4cebca1f72462e2723bfccf963
data/Gemfile CHANGED
@@ -19,10 +19,10 @@ end
19
19
  group :development do
20
20
  # gem 'custom_fields', path: '../custom_fields'
21
21
  # gem 'custom_fields', path: '../gems/custom_fields' # for Developers
22
- # gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '15cceb66ed'
22
+ # gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '279c6744eb6b7dd'
23
23
 
24
24
  # gem 'locomotivecms_steam', path: '../gems/steam', require: false
25
- # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'c9cb7f6', require: false
25
+ # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'b4aa09a', require: false
26
26
 
27
27
  # gem 'locomotive_liquid', path: '../gems/liquid' # for Developers
28
28
  # gem 'locomotivecms_solid', path: '../gems/solid' # for Developers
@@ -64,7 +64,7 @@ group :test do
64
64
  gem 'factory_girl_rails'
65
65
  gem 'pickle'
66
66
  gem 'json_spec', '~> 1.1.4'
67
- gem 'database_cleaner', '~> 1.4.1'
67
+ gem 'database_cleaner', git: 'https://github.com/DatabaseCleaner/database_cleaner.git'
68
68
  gem 'timecop', '~> 0.7.1'
69
69
 
70
70
  gem 'email_spec'
data/README.md CHANGED
@@ -44,7 +44,7 @@ Here is a list of the main gems used to power the Locomotive platform:
44
44
 
45
45
  - Rails 4.2 - *web framework*
46
46
  - Bootstrap - *UI framework*
47
- - Mongoid 4.0 - *Object-Document-Mapper for MongoDB*
47
+ - Mongoid 5 - *Object-Document-Mapper for MongoDB 2/3*
48
48
  - Devise 3.4 - *Authentication*
49
49
  - Carrierwave - *Upload*
50
50
  - Pundit - *Permissions*
@@ -16,24 +16,26 @@
16
16
  }
17
17
 
18
18
  // Centers the content of a public page.
19
+
19
20
  .public-container {
20
- height: 100%;
21
21
  width: 100%;
22
+ height: 100%;
22
23
  text-align: center;
23
24
  animation: fade-down 1s ease-out;
24
25
  &:before {
25
- content: ' ';
26
26
  display: inline-block;
27
- vertical-align: middle;
28
27
  height: 100%;
28
+ vertical-align: middle;
29
+ content: " ";
29
30
  }
30
31
  }
31
32
 
32
33
  // Wraps and centers all content of the public forms.
33
34
 
34
35
  .public-form-wrapper {
35
- width: 480px;
36
36
  display: inline-block;
37
+ width: 480px;
38
+ margin: 25px 0;
37
39
  vertical-align: middle;
38
40
  }
39
41
 
@@ -119,6 +121,7 @@
119
121
  @media (max-width: $screen-xs-min) {
120
122
  .public-form-wrapper {
121
123
  left: 0;
124
+ width: 99%;
122
125
  padding: 20px 10px;
123
126
  margin-left: 0;
124
127
  }
@@ -11,5 +11,9 @@ module Locomotive
11
11
  render '500', status: :internal_server_error
12
12
  end
13
13
 
14
+ def no_site
15
+ render 'no_site', status: :not_found
16
+ end
17
+
14
18
  end
15
19
  end
@@ -8,12 +8,10 @@ module Locomotive
8
8
  def no_site_message_and_link
9
9
  options = Locomotive.config.host ? { host: Locomotive.config.host } : { only_path: true }
10
10
 
11
- if Locomotive::Account.count == 0
12
- [no_site_message(:create_account), sign_up_url(options)]
13
- elsif current_locomotive_account
11
+ if current_locomotive_account
14
12
  [no_site_message(:add_domain), sites_url(options)]
15
13
  else
16
- [no_site_message(:sign_in), new_locomotive_account_session_url(options)]
14
+ [no_site_message(:sign_in), sign_in_url(options)]
17
15
  end
18
16
  end
19
17
 
@@ -56,6 +56,10 @@ module Locomotive
56
56
  # @return [ String ] The well-generated CSV document
57
57
  #
58
58
  def to_csv(options = {})
59
+ # puts "to_csv #{all.count.inspect} / #{all.first.inspect}"
60
+ # puts "#{all.first.content_type_id.inspect}"
61
+ # puts "#{all.first.content_type.inspect}"
62
+ # binding.pry
59
63
  content_type = options.delete(:content_type) || all.first.try(:content_type)
60
64
  csv_options = options.select do |k, v|
61
65
  CSV::DEFAULT_OPTIONS.keys.include?(k.to_sym)
@@ -65,8 +65,6 @@ module Locomotive
65
65
  _last = self.class.where(:_id.ne => self._id, _slug: /^#{slug}-?\d*$/i)
66
66
  .only(:_slug)
67
67
  .order_by(:_id.desc)
68
- .context
69
- .query
70
68
  .first
71
69
 
72
70
  if _last
@@ -60,11 +60,11 @@ module Locomotive
60
60
 
61
61
  operations['$set']['entries_custom_fields_version'] = content_type.entries_custom_fields_version
62
62
 
63
- self.collection.find(_id: content_type._id).update(operations)
63
+ self.collection.find(_id: content_type._id).update_one(operations)
64
64
 
65
65
  collection, selector = content_type.entries.collection, content_type.entries.criteria.selector
66
66
 
67
- collection.find(selector).update({ '$set' => { 'custom_fields_recipe' => content_type.custom_fields_recipe_for(:entries) } }, multi: true)
67
+ collection.find(selector).update_many('$set' => { 'custom_fields_recipe' => content_type.custom_fields_recipe_for(:entries) })
68
68
  end
69
69
 
70
70
  end
@@ -199,7 +199,7 @@ module Locomotive
199
199
  }
200
200
  }
201
201
 
202
- self.collection.find(selector).update(operations, multi: true)
202
+ self.collection.find(selector).update_many(operations)
203
203
  end
204
204
 
205
205
  end
@@ -29,9 +29,9 @@ module Locomotive
29
29
  after_destroy :emit_domain_deletion_event
30
30
 
31
31
  ## named scopes ##
32
- scope :match_domain, lambda { |domain| { any_in: { domains: [*domain] } } }
33
- scope :match_domain_with_exclusion_of, lambda { |domain, site|
34
- { any_in: { domains: [*domain] }, where: { :_id.ne => site.id } }
32
+ scope :match_domain, ->(domain) { any_in(domains: [*domain]) }
33
+ scope :match_domain_with_exclusion_of, ->(domain, site) {
34
+ any_in(domains: [*domain]).where(:_id.ne => site.id)
35
35
  }
36
36
  end
37
37
 
@@ -46,7 +46,6 @@ module Locomotive
46
46
 
47
47
  def local_path(short = false)
48
48
  if short && self.read_attribute(:local_path)
49
- # self.read_attribute(:local_path).gsub(/^#{self.content_type.to_s.pluralize}\//, '')
50
49
  self.read_attribute(:local_path).split('/')[1..-1].join('/')
51
50
  else
52
51
  self.read_attribute(:local_path)
@@ -31,7 +31,7 @@ h3 Run your site locally
31
31
 
32
32
  pre
33
33
  code.bash
34
- | cd #{current_site_name_with_underscores}</br>wagon serve
34
+ | cd #{current_site_name_with_underscores}</br>bundle exec wagon serve
35
35
 
36
36
  p Now, update any files of your site and see the results locally.
37
37
 
@@ -39,4 +39,4 @@ h3 Deploy your modifications
39
39
 
40
40
  pre
41
41
  code.bash
42
- | wagon push production
42
+ | bundle exec wagon push production
@@ -10,3 +10,4 @@ p
10
10
  == t('.wrong_request_instruction')
11
11
  p
12
12
  == t('.unchange_password_message')
13
+
@@ -0,0 +1 @@
1
+ {"error":"no site found"}
@@ -22,5 +22,5 @@
22
22
 
23
23
  = render 'locomotive/shared/sidebar/link', icon: 'fa-suitcase', label: t(:sites, scope: 'locomotive.shared.header'), url: sites_path, section_class: 'visible-xs-block'
24
24
 
25
- = render 'locomotive/shared/sidebar/link', icon: 'fa-sign-out', label: t(:logout, scope: 'locomotive.shared.header'), url: destroy_locomotive_account_session_path, data: { confirm: t('locomotive.messages.confirm') }, section_class: 'visible-xs-block'
25
+ = render 'locomotive/shared/sidebar/link', icon: 'fa-sign-out', label: t(:logout, scope: 'locomotive.shared.header'), url: sign_out_path, data: { method: 'delete' }, section_class: 'visible-xs-block'
26
26
 
@@ -2,4 +2,4 @@
2
2
 
3
3
  = render 'locomotive/shared/sidebar/link', icon: 'fa-suitcase', label: t(:sites, scope: 'locomotive.shared.header'), url: sites_path
4
4
 
5
- = render 'locomotive/shared/sidebar/link', icon: 'fa-sign-out', label: t(:logout, scope: 'locomotive.shared.header'), url: destroy_locomotive_account_session_path, data: { confirm: t('locomotive.messages.confirm') }
5
+ = render 'locomotive/shared/sidebar/link', icon: 'fa-sign-out', label: t(:logout, scope: 'locomotive.shared.header'), url: sign_out_path, data: { method: 'delete' }
@@ -1,5 +1,5 @@
1
1
  li= link_to t(:sites, scope: 'locomotive.shared.header'), sites_path
2
2
  li= link_to t(:account, scope: 'locomotive.shared.header'), edit_my_account_path(_location: request.fullpath)
3
- li= link_to t(:help, scope: 'locomotive.shared.header'), 'http://doc.locomotivecms.com'
3
+ li= link_to t(:help, scope: 'locomotive.shared.header'), 'http://locomotive-v3.readme.io'
4
4
  li class="divider"
5
- li= link_to t(:logout, scope: 'locomotive.shared.header'), destroy_locomotive_account_session_path, data: { confirm: t('locomotive.messages.confirm') }
5
+ li= link_to t(:logout, scope: 'locomotive.shared.header'), sign_out_path, data: { method: 'delete' }
@@ -21,7 +21,7 @@ en:
21
21
  sr: Serbian
22
22
 
23
23
  messages:
24
- confirm: Are you sure ?
24
+ confirm: Are you sure?
25
25
 
26
26
  shared:
27
27
  header:
data/config/routes.rb CHANGED
@@ -10,8 +10,10 @@ Locomotive::Engine.routes.draw do
10
10
  failure_app: 'Locomotive::Devise::FailureApp'
11
11
 
12
12
  devise_scope :locomotive_account do
13
- get 'sign_up' => 'registrations#new', as: :sign_up
14
- post 'sign_up' => 'registrations#create'
13
+ get 'sign_up' => 'registrations#new', as: :sign_up
14
+ post 'sign_up' => 'registrations#create'
15
+ get 'sign_in' => 'sessions#new', as: :sign_in
16
+ delete 'sign_out' => 'sessions#destroy', as: :sign_out
15
17
  end
16
18
 
17
19
  root to: 'sites#index'
@@ -12,8 +12,6 @@ module Locomotive
12
12
 
13
13
  template 'locomotive.rb', 'config/initializers/locomotive.rb'
14
14
 
15
- template 'carrierwave.rb', 'config/initializers/carrierwave.rb'
16
-
17
15
  template 'devise.rb', 'config/initializers/devise.rb'
18
16
 
19
17
  template 'dragonfly.rb', 'config/initializers/dragonfly.rb'
@@ -21,6 +19,15 @@ module Locomotive
21
19
  template 'mongoid.yml', 'config/mongoid.yml'
22
20
  end
23
21
 
22
+ def install_aws
23
+ if options.heroku? || yes?('Do you want to store your assets on Amazon S3?')
24
+ template 'carrierwave_aws.rb', 'config/initializers/carrierwave.rb'
25
+ gem 'carrierwave-aws'
26
+ else
27
+ template 'carrierwave.rb', 'config/initializers/carrierwave.rb'
28
+ end
29
+ end
30
+
24
31
  def insert_engine_routes
25
32
  route %(
26
33
  # Locomotive Back-office
@@ -60,13 +67,6 @@ end
60
67
  RUBY
61
68
  end
62
69
 
63
- inject_into_file 'config/initializers/carrierwave.rb', after: " config.fog_directory = ENV['S3_BUCKET']\n" do <<-'RUBY'
64
-
65
- # Put your CDN host below instead
66
- config.asset_host = ENV['S3_BUCKET_REGION'].present? ? "s3-#{ENV['S3_BUCKET_REGION']}.amazonaws.com" : 's3.amazonaws.com'
67
- RUBY
68
- end
69
-
70
70
  gem 'platform-api', '~> 0.3.0'
71
71
  end
72
72
  end
@@ -9,20 +9,31 @@ CarrierWave.configure do |config|
9
9
  config.root = File.join(Rails.root, 'public')
10
10
 
11
11
  when :production
12
- # the following configuration works for Amazon S3
12
+ config.storage = :file
13
+ config.root = File.join(Rails.root, 'public')
14
+
15
+ # # put your CDN host below instead
16
+ # # config.asset_host = 'http://cdn.example.com'
17
+
18
+ # # You can also use Amazon S3 instead. The following configuration works for AWS
19
+ # #
20
+ # # WARNING: add the "carrierwave-aws" gem in your Rails app Gemfile.
21
+ # # More information here: https://github.com/sorentwo/carrierwave-aws
22
+ #
23
+ # config.storage = :aws
24
+ # config.aws_bucket = ENV['S3_BUCKET']
25
+ # config.aws_acl = 'public-read'
13
26
  #
14
- # WARNING: add the "carrierwave-aws" gem in your Rails app Gemfile.
15
- # More information here: https://github.com/sorentwo/carrierwave-aws
27
+ # config.aws_credentials = {
28
+ # access_key_id: ENV['S3_KEY_ID'],
29
+ # secret_access_key: ENV['S3_SECRET_KEY'],
30
+ # region: ENV['S3_BUCKET_REGION']
31
+ # }
16
32
  #
17
- config.storage = :aws
18
- config.aws_bucket = ENV['S3_BUCKET']
19
- config.aws_acl = 'public-read'
20
-
21
- config.aws_credentials = {
22
- access_key_id: ENV['S3_KEY_ID'],
23
- secret_access_key: ENV['S3_SECRET_KEY'],
24
- region: ENV['S3_BUCKET_REGION']
25
- }
33
+ # # Put your CDN host below instead
34
+ # if ENV['S3_ASSET_HOST_URL'].present?
35
+ # config.asset_host = ENV['S3_ASSET_HOST_URL']
36
+ # end
26
37
 
27
38
  else
28
39
  # settings for the local filesystem
@@ -0,0 +1,36 @@
1
+ CarrierWave.configure do |config|
2
+
3
+ config.cache_dir = File.join(Rails.root, 'tmp', 'uploads')
4
+
5
+ case Rails.env.to_sym
6
+
7
+ when :development
8
+ config.storage = :file
9
+ config.root = File.join(Rails.root, 'public')
10
+
11
+ when :production
12
+ # WARNING: add the "carrierwave-aws" gem in your Rails app Gemfile.
13
+ # More information here: https://github.com/sorentwo/carrierwave-aws
14
+
15
+ config.storage = :aws
16
+ config.aws_bucket = ENV['S3_BUCKET']
17
+ config.aws_acl = 'public-read'
18
+
19
+ config.aws_credentials = {
20
+ access_key_id: ENV['S3_KEY_ID'],
21
+ secret_access_key: ENV['S3_SECRET_KEY'],
22
+ region: ENV['S3_BUCKET_REGION']
23
+ }
24
+
25
+ # Put your CDN host below instead
26
+ if ENV['S3_ASSET_HOST_URL'].present?
27
+ config.asset_host = ENV['S3_ASSET_HOST_URL']
28
+ end
29
+
30
+ else
31
+ # settings for the local filesystem
32
+ config.storage = :file
33
+ config.root = File.join(Rails.root, 'public')
34
+ end
35
+
36
+ end
@@ -1,46 +1,115 @@
1
1
  development:
2
- # Configure available database sessions. (required)
3
- sessions:
4
- # Defines the default session. (required)
2
+ # Configure available database clients. (required)
3
+ clients:
4
+ # Defines the default client. (required)
5
5
  default:
6
6
  # Defines the name of the default database that Mongoid can connect to.
7
7
  # (required).
8
8
  database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_dev
9
- # Provides the hosts the default session can connect to. Must be an array
9
+ # Provides the hosts the default client can connect to. Must be an array
10
10
  # of host:port pairs. (required)
11
11
  hosts:
12
12
  - localhost:27017
13
13
  options:
14
- # Change whether the session persists in safe mode by default.
15
- # (default: false)
16
- # safe: false
17
-
18
- # Change the default consistency model to :eventual or :strong.
19
- # :eventual will send reads to secondaries, :strong sends everything
20
- # to master. (default: :eventual)
21
- # consistency: :strong
22
- # Configure Mongoid specific options. (optional)
23
- options:
24
- # Configuration for whether or not to allow access to fields that do
25
- # not have a field definition on the model. (default: true)
26
- # allow_dynamic_fields: true
14
+ # Change the default write concern. (default = { w: 1 })
15
+ # write:
16
+ # w: 1
17
+
18
+ # Change the default read preference. Valid options for mode are: :secondary,
19
+ # :secondary_preferred, :primary, :primary_preferred, :nearest
20
+ # (default: primary)
21
+ # read:
22
+ # mode: :secondary_preferred
23
+
24
+ # The name of the user for authentication.
25
+ # user: 'user'
26
+
27
+ # The password of the user for authentication.
28
+ # password: 'password'
29
+
30
+ # The user's database roles.
31
+ # roles:
32
+ # - 'dbOwner'
33
+
34
+ # Change the default authentication mechanism. Valid options are: :scram,
35
+ # :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default
36
+ # on 2.4 and 2.6 is :plain)
37
+ # auth_mech: :scram
38
+
39
+ # The database or source to authenticate the user against. (default: admin)
40
+ # auth_source: admin
41
+
42
+ # Force a the driver cluster to behave in a certain manner instead of auto-
43
+ # discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
44
+ # when connecting to hidden members of a replica set.
45
+ # connect: :direct
46
+
47
+ # Changes the default time in seconds the server monitors refresh their status
48
+ # via ismaster commands. (default: 10)
49
+ # heartbeat_frequency: 10
50
+
51
+ # The time in seconds for selecting servers for a near read preference. (default: 5)
52
+ # local_threshold: 5
53
+
54
+ # The timeout in seconds for selecting a server for an operation. (default: 30)
55
+ # server_selection_timeout: 30
56
+
57
+ # The maximum number of connections in the connection pool. (default: 5)
58
+ # max_pool_size: 5
59
+
60
+ # The minimum number of connections in the connection pool. (default: 1)
61
+ # min_pool_size: 1
27
62
 
28
- # Enable the identity map, needed for eager loading. (default: false)
29
- # identity_map_enabled: true
63
+ # The time to wait, in seconds, in the connection pool for a connection
64
+ # to be checked in before timing out. (default: 5)
65
+ # wait_queue_timeout: 5
30
66
 
67
+ # The time to wait to establish a connection before timing out, in seconds.
68
+ # (default: 5)
69
+ # connect_timeout: 5
70
+
71
+ # The timeout to wait to execute operations on a socket before raising an error.
72
+ # (default: 5)
73
+ # socket_timeout: 5
74
+
75
+ # The name of the replica set to connect to. Servers provided as seeds that do
76
+ # not belong to this replica set will be ignored.
77
+ # replica_set: name
78
+
79
+ # Whether to connect to the servers via ssl. (default: false)
80
+ # ssl: true
81
+
82
+ # The certificate file used to identify the connection against MongoDB.
83
+ # ssl_cert: /path/to/my.cert
84
+
85
+ # The private keyfile used to identify the connection against MongoDB.
86
+ # Note that even if the key is stored in the same file as the certificate,
87
+ # both need to be explicitly specified.
88
+ # ssl_key: /path/to/my.key
89
+
90
+ # A passphrase for the private key.
91
+ # ssl_key_pass_phrase: password
92
+
93
+ # Whether or not to do peer certification validation. (default: false)
94
+ # ssl_verify: true
95
+
96
+ # The file containing a set of concatenated certification authority certifications
97
+ # used to validate certs passed from the other end of the connection.
98
+ # ssl_ca_cert: /path/to/ca.cert
99
+
100
+
101
+ # Configure Mongoid specific options. (optional)
102
+ options:
31
103
  # Includes the root model name in json serialization. (default: false)
32
104
  # include_root_in_json: false
33
105
 
34
- # Include the _type field in serializaion. (default: false)
106
+ # Include the _type field in serialization. (default: false)
35
107
  # include_type_for_serialization: false
36
108
 
37
109
  # Preload all models in development, needed when models use
38
110
  # inheritance. (default: false)
39
111
  # preload_models: false
40
112
 
41
- # Protect id and type from mass assignment. (default: true)
42
- # protect_sensitive_fields: true
43
-
44
113
  # Raise an error when performing a #find and the document is not found.
45
114
  # (default: true)
46
115
  # raise_not_found_error: true
@@ -49,33 +118,26 @@ development:
49
118
  # existing method. (default: false)
50
119
  # scope_overwrite_exception: false
51
120
 
52
- # Skip the database version check, used when connecting to a db without
53
- # admin access. (default: false)
54
- # skip_version_check: false
55
-
56
- # User Active Support's time zone in conversions. (default: true)
121
+ # Use Active Support's time zone in conversions. (default: true)
57
122
  # use_activesupport_time_zone: true
58
123
 
59
124
  # Ensure all times are UTC in the app side. (default: false)
60
125
  # use_utc: false
61
126
 
62
127
  test:
63
- sessions:
128
+ clients:
64
129
  default:
65
130
  database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_test
66
131
  hosts:
67
132
  - localhost:27017
68
133
  options:
69
- # consistency: :strong
70
- # identity_map_enabled: true
134
+ max_pool_size: 1
71
135
 
72
136
  production:
73
- sessions:
137
+ clients:
74
138
  default:
75
139
  database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_production
76
140
  hosts:
77
141
  - localhost:27017
78
142
  options:
79
- # consistency: :strong
80
- # identity_map_enabled: true
81
- # uri: <%%= ENV['MONGOLAB_URI'] || ENV['MONGOHQ_URL'] %>
143
+ max_pool_size: 1
@@ -1,5 +1,5 @@
1
1
  require 'bson'
2
- require 'moped'
2
+ require 'mongo'
3
3
  require 'mongoid'
4
4
  require 'mongoid/railtie'
5
5
  require 'mongoid/tree'
@@ -25,7 +25,7 @@ module Locomotive
25
25
  begin
26
26
  @app.call(env)
27
27
  rescue ::Locomotive::Steam::NoSiteException => exception
28
- handle_no_account_or_site(env)
28
+ handle_no_account_or_site(env, request)
29
29
  end
30
30
  end
31
31
  end
@@ -50,10 +50,12 @@ module Locomotive
50
50
 
51
51
  # if no account in the database, must be a fresh install,
52
52
  # then ask the user to create the first account.
53
- # if accounts but not no site, render a specific error page.
54
- def handle_no_account_or_site(env)
53
+ # if accounts but no site, redirect to the sign in page
54
+ def handle_no_account_or_site(env, request)
55
55
  if Locomotive::Account.count == 0
56
- [301, { 'Location' => sign_up_path, 'Content-Type' => 'text/html' }, []]
56
+ redirect_to(sign_up_path)
57
+ elsif default_host?(request)
58
+ redirect_to(sign_in_path)
57
59
  else
58
60
  Locomotive::ErrorsController.action(:no_site).call(env)
59
61
  end
@@ -93,6 +95,10 @@ module Locomotive
93
95
  nil
94
96
  end
95
97
 
98
+ def redirect_to(destination)
99
+ [301, { 'Location' => destination, 'Content-Type' => 'text/html' }, []]
100
+ end
101
+
96
102
  def site_handle_regexp
97
103
  @regexp ||= /#{Locomotive.mounted_on}\/([^\/]+)/o
98
104
  end
@@ -127,7 +127,7 @@ module Mongoid #:nodoc:
127
127
  fields = _criteria.options[:fields]
128
128
  sort = _criteria.options[:sort]
129
129
 
130
- document = collection.find(selector).select(fields).sort(sort).limit(1).first
130
+ document = collection.find(selector).projection(fields).sort(sort).limit(1).first
131
131
  document ? document[field.to_s].to_i : nil
132
132
  end
133
133
 
@@ -9,14 +9,16 @@ Locomotive::Steam.configure do |config|
9
9
  # Dragonfly instance embedded in Steam needs a secret key
10
10
  config.image_resizer_secret = Locomotive.config.steam_image_resizer_secret
11
11
 
12
- if asset_host = CarrierWave::Uploader::Base.asset_host
12
+ if asset_host = CarrierWave::Uploader::Base.asset_host # CDN?
13
13
  config.asset_host = asset_host
14
- else
15
- config.asset_host = CarrierWave.base_host
14
+ elsif asset_host = CarrierWave.base_host # Example: AWS storage
15
+ config.asset_host = asset_host
16
+ else # Example: File storage
17
+ config.asset_path = Rails.root.join('public').to_s
16
18
  end
17
19
 
18
20
  # rely on Mongoid for the connection information
19
- if mongoid = Mongoid.configure.sessions[:default]
21
+ if mongoid = Mongoid.configure.clients[:default]
20
22
  options = mongoid[:uri] ? mongoid.slice(:uri) : mongoid.slice(:database, :hosts, :username, :password)
21
23
  config.adapter = { name: :'mongoDB' }.merge(options.symbolize_keys)
22
24
  end
@@ -2,5 +2,5 @@
2
2
  # MAJOR.MINOR.PATCH format.
3
3
  # 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 < 1.0.0-rc.1 < 1.0.0
4
4
  module Locomotive #:nodoc
5
- VERSION = '3.0.0.rc3'
5
+ VERSION = '3.0.0.rc4'
6
6
  end
@@ -10,9 +10,6 @@ require "sprockets/railtie"
10
10
 
11
11
  Bundler.require(*Rails.groups)
12
12
 
13
- # require 'bson'
14
- # require 'moped'
15
-
16
13
  require 'locomotive/engine'
17
14
 
18
15
  module Dummy