locomotivecms 3.3.0.rc3 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/app/api/locomotive/api/entities/site_entity.rb +1 -1
- data/app/api/locomotive/api/forms/content_entry_form.rb +12 -3
- data/app/api/locomotive/api/forms/site_form.rb +1 -1
- data/app/api/locomotive/api/helpers/pagination_helper.rb +1 -1
- data/app/api/locomotive/api/resources/current_site_resource.rb +1 -0
- data/app/api/locomotive/api/resources/site_resource.rb +2 -0
- data/app/controllers/locomotive/translations_controller.rb +1 -1
- data/app/models/locomotive/concerns/site/access_points.rb +14 -0
- data/app/models/locomotive/snippet.rb +3 -0
- data/app/policies/locomotive/site_policy.rb +2 -2
- data/app/views/locomotive/current_site/form/_access_points.html.slim +2 -0
- data/config/locales/simple_form.en.yml +1 -0
- data/lib/generators/locomotive/install/install_generator.rb +1 -1
- data/lib/generators/locomotive/install/templates/mongoid.yml +3 -3
- data/lib/locomotive/action_controller/responder.rb +2 -2
- data/lib/locomotive/dependencies.rb +2 -1
- data/lib/locomotive/regexps.rb +3 -0
- data/lib/locomotive/steam/middlewares/wysihtml_css.rb +8 -3
- data/lib/locomotive/version.rb +1 -1
- data/spec/dummy/config/mongoid.yml +2 -2
- data/spec/models/locomotive/concerns/site/access_points_spec.rb +126 -46
- data/spec/models/locomotive/site_spec.rb +36 -0
- data/spec/requests/locomotive/steam/cache_spec.rb +1 -1
- data/spec/requests/locomotive/steam/wysihtml_css_spec.rb +10 -1
- metadata +91 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63ada27d247c263d104f61e50c76975e1c60be31
|
4
|
+
data.tar.gz: 9d63c89ace631caf49bc827b42accc9725835409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4a07cee2278ffe00327ab17fa6f1cdc73fcba68c6883d494e55a1c231b034c0e7119f1052452197611a7b2ba014a3de4f92d33d6675030c75d2b0a492eb3977
|
7
|
+
data.tar.gz: 717311d1ea81fe45d97d991010fd1a2ca126b45ae3ed974e5134c9ffb12d8154e4e72128cb442adeea66f572d370dac6add9968606ae59f489a92c79ed21cbd7
|
data/Gemfile
CHANGED
@@ -18,13 +18,13 @@ end
|
|
18
18
|
|
19
19
|
group :development do
|
20
20
|
# gem 'custom_fields', path: '../gems/custom_fields' # for Developers
|
21
|
-
# gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '
|
21
|
+
# gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '27f1d62'
|
22
22
|
|
23
23
|
# gem 'locomotivecms_common', path: '../gems/common', require: false
|
24
24
|
# gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b', require: false
|
25
25
|
|
26
26
|
# gem 'locomotivecms_steam', path: '../gems/steam', require: false
|
27
|
-
# gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '
|
27
|
+
# gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '0cf606c', require: false
|
28
28
|
|
29
29
|
# gem 'locomotive_liquid', path: '../gems/liquid' # for Developers
|
30
30
|
# gem 'locomotivecms_solid', path: '../gems/solid' # for Developers
|
@@ -7,7 +7,7 @@ module Locomotive
|
|
7
7
|
expose :name, :handle, :seo_title, :meta_keywords, :meta_description,
|
8
8
|
:robots_txt, :cache_enabled, :private_access
|
9
9
|
|
10
|
-
expose :locales, :domains, :url_redirections
|
10
|
+
expose :locales, :domains, :asset_host, :url_redirections
|
11
11
|
|
12
12
|
expose :memberships, using: MembershipEntity
|
13
13
|
|
@@ -4,6 +4,8 @@ module Locomotive
|
|
4
4
|
|
5
5
|
class ContentEntryForm < BaseForm
|
6
6
|
|
7
|
+
NON_CUSTOM_FIELD_ATTRIBUTES = %w{_auth_reset_token _auth_reset_sent_at}
|
8
|
+
|
7
9
|
attr_accessor :content_type, :dynamic_attributes
|
8
10
|
|
9
11
|
attrs :_slug, :_position, :_visible, :seo_title, :meta_keywords, :meta_description
|
@@ -41,8 +43,10 @@ module Locomotive
|
|
41
43
|
if respond_to?(:"set_#{field.type}")
|
42
44
|
public_send(:"set_#{field.type}", field, args.first)
|
43
45
|
else
|
44
|
-
dynamic_attributes[
|
46
|
+
dynamic_attributes[getter_name(name).to_sym] = args.first
|
45
47
|
end
|
48
|
+
elsif NON_CUSTOM_FIELD_ATTRIBUTES.include?(getter_name(name))
|
49
|
+
dynamic_attributes[getter_name(name).to_sym] = args.first
|
46
50
|
else
|
47
51
|
super
|
48
52
|
end
|
@@ -54,14 +58,19 @@ module Locomotive
|
|
54
58
|
|
55
59
|
private
|
56
60
|
|
61
|
+
def getter_name(name)
|
62
|
+
name.to_s.gsub(/=\z/, '')
|
63
|
+
end
|
64
|
+
|
57
65
|
def find_field(name)
|
58
|
-
|
59
|
-
dynamic_setters[_name]
|
66
|
+
dynamic_setters[getter_name(name)]
|
60
67
|
end
|
61
68
|
|
62
69
|
def dynamic_setters
|
63
70
|
@dynamic_setters ||= self.content_type.entries_custom_fields.inject({}) do |hash, field|
|
64
71
|
case field.type.to_sym
|
72
|
+
when :password
|
73
|
+
hash[field.name] = hash["#{field.name}_confirmation"] = field
|
65
74
|
when :file
|
66
75
|
hash[field.name] = hash["remote_#{field.name}_url"] = hash["remove_#{field.name}"] = field
|
67
76
|
when :belongs_to
|
@@ -4,7 +4,7 @@ module Locomotive
|
|
4
4
|
|
5
5
|
class SiteForm < BaseForm
|
6
6
|
|
7
|
-
attrs :name, :handle, :robots_txt, :locales, :domains, :url_redirections, :timezone, :picture, :cache_enabled, :private_access, :password, :metafields_schema, :metafields, :metafields_ui
|
7
|
+
attrs :name, :handle, :robots_txt, :locales, :domains, :url_redirections, :timezone, :picture, :cache_enabled, :private_access, :password, :metafields_schema, :metafields, :metafields_ui, :asset_host
|
8
8
|
attrs :seo_title, :meta_keywords, :meta_description, localized: true
|
9
9
|
|
10
10
|
# Make sure locales and domains are in arrays.
|
@@ -4,7 +4,7 @@ module Locomotive
|
|
4
4
|
module PaginationHelper
|
5
5
|
|
6
6
|
def add_pagination_header(collection)
|
7
|
-
header 'X-Total-Pages', collection.
|
7
|
+
header 'X-Total-Pages', collection.total_pages.to_s
|
8
8
|
header 'X-Per-Page', collection.limit_value.to_s
|
9
9
|
header 'X-Total-Entries', collection.total_count.to_s
|
10
10
|
end
|
@@ -71,6 +71,7 @@ module Locomotive
|
|
71
71
|
optional :metafields_schema
|
72
72
|
optional :metafields
|
73
73
|
optional :metafields_ui
|
74
|
+
optional :asset_host
|
74
75
|
end
|
75
76
|
end
|
76
77
|
post do
|
@@ -101,6 +102,7 @@ module Locomotive
|
|
101
102
|
optional :password
|
102
103
|
optional :metafields_schema
|
103
104
|
optional :metafields
|
105
|
+
optional :asset_host
|
104
106
|
end
|
105
107
|
end
|
106
108
|
put ':id' do
|
@@ -12,6 +12,7 @@ module Locomotive
|
|
12
12
|
field :domains, type: Array, default: []
|
13
13
|
field :redirect_to_first_domain, type: Boolean, default: false
|
14
14
|
field :redirect_to_https, type: Boolean, default: false
|
15
|
+
field :asset_host
|
15
16
|
|
16
17
|
## indexes ##
|
17
18
|
index domains: 1
|
@@ -24,6 +25,7 @@ module Locomotive
|
|
24
25
|
multiline: true
|
25
26
|
validate :domains_must_be_valid_and_unique
|
26
27
|
validate :domains_must_not_be_reserved
|
28
|
+
validate :asset_host_must_be_valid
|
27
29
|
|
28
30
|
## callbacks ##
|
29
31
|
before_validation :prepare_domain_sync
|
@@ -54,6 +56,10 @@ module Locomotive
|
|
54
56
|
array = [] if array.blank?; super(array.map(&:downcase))
|
55
57
|
end
|
56
58
|
|
59
|
+
def asset_host=(asset_host)
|
60
|
+
super(asset_host.try(:downcase))
|
61
|
+
end
|
62
|
+
|
57
63
|
protected
|
58
64
|
|
59
65
|
def prepare_domain_sync
|
@@ -76,6 +82,14 @@ module Locomotive
|
|
76
82
|
end
|
77
83
|
end
|
78
84
|
|
85
|
+
def asset_host_must_be_valid
|
86
|
+
return if self.asset_host.blank?
|
87
|
+
|
88
|
+
if not asset_host =~ Locomotive::Regexps::ASSET_HOST
|
89
|
+
self.errors.add(:asset_host, :invalid_domain, value: asset_host)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
79
93
|
def domains_must_not_be_reserved
|
80
94
|
return if self.domains.empty? || Locomotive.config.reserved_domains.blank?
|
81
95
|
|
@@ -46,11 +46,11 @@ module Locomotive
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def permitted_attributes
|
49
|
-
plain = [:name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :timezone_name, :robots_txt, :cache_enabled, :redirect_to_first_domain, :redirect_to_https, :private_access, :password, :prefix_default_locale]
|
49
|
+
plain = [:name, :handle, :picture, :remove_picture, :seo_title, :meta_keywords, :meta_description, :timezone_name, :robots_txt, :asset_host, :cache_enabled, :redirect_to_first_domain, :redirect_to_https, :private_access, :password, :prefix_default_locale]
|
50
50
|
hash = { domains: [], locales: [], url_redirections: [] }
|
51
51
|
|
52
52
|
unless update_advanced?
|
53
|
-
plain -= [:timezone_name, :robots_txt, :cache_enabled, :prefix_default_locale]
|
53
|
+
plain -= [:timezone_name, :robots_txt, :cache_enabled, :prefix_default_locale, :asset_host]
|
54
54
|
hash.delete(:locales)
|
55
55
|
hash.delete(:url_redirections)
|
56
56
|
end
|
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
= f.input :domains, as: :array, hint: t(:domains, scope: 'simple_form.hints.locomotive.site', domain: Locomotive.config.host || request.host).html_safe, placeholder: true, collection: f.object.domains, template: :domain, template_url: new_domain_current_site_path(current_site)
|
6
6
|
|
7
|
+
= f.input :asset_host, hint: t(:asset_host, scope: 'simple_form.hints.locomotive.site').html_safe
|
8
|
+
|
7
9
|
= f.input :redirect_to_first_domain, as: :toggle
|
8
10
|
= f.input :redirect_to_https, as: :toggle
|
9
11
|
|
@@ -96,6 +96,7 @@ en:
|
|
96
96
|
meta_description: "Meta description used within the head tag of the page. Required for SEO."
|
97
97
|
robots_txt: "Content of the <span class='code'>/robots.txt</span> file. Check the following <a href='http://www.w3.org/TR/html4/appendix/notes.html#h-B.4.1.1'>url</a> for more information."
|
98
98
|
domains: "Add your domains just below. Documentation <a href=\"https://locomotive-v3.readme.io/docs/domains\">here</a> for more information."
|
99
|
+
asset_host: "Site-specific asset host that overrides engine asset host (ex. \"localhost\", \"asset.dev\", \"https://asset-host.com/\")."
|
99
100
|
memberships: "You can invite other accounts to edit/manage the site."
|
100
101
|
cache_enabled: "When enabled, your pages will be cached as long as the content doesn't change. Disabling cache per page is allowed."
|
101
102
|
redirect_to_first_domain: "When enabled, requests made to any domains listed above will be redirected to the first domain."
|
@@ -9,7 +9,7 @@ development:
|
|
9
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
|
+
- 127.0.0.1:27017
|
13
13
|
options:
|
14
14
|
# Change the default write concern. (default = { w: 1 })
|
15
15
|
# write:
|
@@ -129,7 +129,7 @@ test:
|
|
129
129
|
default:
|
130
130
|
database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_test
|
131
131
|
hosts:
|
132
|
-
-
|
132
|
+
- 127.0.0.1:27017
|
133
133
|
options:
|
134
134
|
max_pool_size: 1
|
135
135
|
|
@@ -138,6 +138,6 @@ production:
|
|
138
138
|
default:
|
139
139
|
database: <%= Rails.application.class.parent.to_s.underscore.downcase %>_production
|
140
140
|
hosts:
|
141
|
-
-
|
141
|
+
- 127.0.0.1:27017
|
142
142
|
options:
|
143
143
|
max_pool_size: 1
|
@@ -40,7 +40,7 @@ module Locomotive
|
|
40
40
|
add_authenticated_header
|
41
41
|
|
42
42
|
if get?
|
43
|
-
add_pagination_header if resource.respond_to?(:
|
43
|
+
add_pagination_header if resource.respond_to?(:total_pages)
|
44
44
|
display(resource)
|
45
45
|
elsif has_errors?
|
46
46
|
with_flash_message(:alert) do
|
@@ -100,7 +100,7 @@ module Locomotive
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def add_pagination_header
|
103
|
-
controller.headers['X-Total-Pages'] = resource.
|
103
|
+
controller.headers['X-Total-Pages'] = resource.total_pages.to_s
|
104
104
|
controller.headers['X-Per-Page'] = resource.limit_value.to_s
|
105
105
|
controller.headers['X-Total-Entries'] = resource.total_count.to_s
|
106
106
|
end
|
@@ -8,7 +8,8 @@ require 'devise'
|
|
8
8
|
require 'devise/orm/mongoid'
|
9
9
|
require 'devise-encryptable'
|
10
10
|
require 'simple_token_authentication'
|
11
|
-
require 'kaminari'
|
11
|
+
require 'kaminari/mongoid'
|
12
|
+
require 'kaminari/actionview'
|
12
13
|
require 'bootstrap-kaminari-views'
|
13
14
|
require 'bootstrap-sass'
|
14
15
|
require 'font-awesome-sass'
|
data/lib/locomotive/regexps.rb
CHANGED
@@ -9,5 +9,8 @@ module Locomotive
|
|
9
9
|
|
10
10
|
URL_AND_MAILTO = /\A((https?:\/\/\S+)|(ftp:\/\S+)|(mailto:\S+)|\/\S*)\Z/
|
11
11
|
|
12
|
+
# e.g. hostname, hostname.com, http(s)://hostname, http(s)://hostname.com/
|
13
|
+
ASSET_HOST = /\A((https?:\/\/)?)(([a-z\d])([a-z\d-]){0,61}([a-z\d]))(\.([a-z\d])([a-z\d-]){0,61}([a-z\d]))*\/?$/i
|
14
|
+
|
12
15
|
end
|
13
16
|
end
|
@@ -4,6 +4,8 @@ module Locomotive
|
|
4
4
|
|
5
5
|
class WysihtmlCss
|
6
6
|
|
7
|
+
GOOGLE_AMP_PATH = '_amp'
|
8
|
+
|
7
9
|
def initialize(app, opts = {})
|
8
10
|
@app = app
|
9
11
|
end
|
@@ -11,7 +13,7 @@ module Locomotive
|
|
11
13
|
def call(env)
|
12
14
|
status, headers, response = @app.call(env)
|
13
15
|
|
14
|
-
if content?(env['steam.page'], response)
|
16
|
+
if content?(env['steam.page'], env['steam.path'], response)
|
15
17
|
url = ::ActionController::Base.helpers.stylesheet_path('locomotive/wysihtml5_editor')
|
16
18
|
html = %(<link rel="stylesheet" type="text/css" href="#{url}">)
|
17
19
|
response.first.gsub!('</head>', %(#{html}</head>))
|
@@ -22,8 +24,11 @@ module Locomotive
|
|
22
24
|
|
23
25
|
protected
|
24
26
|
|
25
|
-
def content?(page, response)
|
26
|
-
|
27
|
+
def content?(page, path, response)
|
28
|
+
!path.starts_with?(GOOGLE_AMP_PATH + '/') &&
|
29
|
+
!page.redirect &&
|
30
|
+
page.response_type == 'text/html' &&
|
31
|
+
response.first
|
27
32
|
end
|
28
33
|
|
29
34
|
end
|
data/lib/locomotive/version.rb
CHANGED
@@ -10,7 +10,7 @@ development:
|
|
10
10
|
# Provides the hosts the default client can connect to. Must be an array
|
11
11
|
# of host:port pairs. (required)
|
12
12
|
hosts:
|
13
|
-
-
|
13
|
+
- 127.0.0.1:27017
|
14
14
|
options:
|
15
15
|
# Change the default write concern. (default = { w: 1 })
|
16
16
|
# write:
|
@@ -129,7 +129,7 @@ test:
|
|
129
129
|
default:
|
130
130
|
database: locomotive_engine_test
|
131
131
|
hosts:
|
132
|
-
-
|
132
|
+
- 127.0.0.1:27017
|
133
133
|
options:
|
134
134
|
truncate_logs: false
|
135
135
|
max_pool_size: 1
|
@@ -3,96 +3,176 @@ require 'spec_helper'
|
|
3
3
|
describe Locomotive::Concerns::Site::AccessPoints do
|
4
4
|
|
5
5
|
let(:domains) { [] }
|
6
|
-
let(:
|
6
|
+
let(:asset_host) { nil }
|
7
|
+
let(:site) { build(:site, domains: domains, asset_host: asset_host) }
|
7
8
|
|
8
|
-
describe '
|
9
|
+
describe 'domains' do
|
9
10
|
|
10
|
-
|
11
|
-
site.domains = ['FIRST.com', 'second.com', 'THIRD.com']
|
11
|
+
describe '#domains=' do
|
12
12
|
|
13
|
-
|
13
|
+
it 'downcases the domains' do
|
14
|
+
site.domains = ['FIRST.com', 'second.com', 'THIRD.com']
|
15
|
+
|
16
|
+
expect(site.domains).to eq(['first.com', 'second.com', 'third.com'])
|
17
|
+
end
|
14
18
|
end
|
15
|
-
end
|
16
19
|
|
17
|
-
|
20
|
+
describe '#valid?' do
|
18
21
|
|
19
|
-
|
22
|
+
subject { site.valid? }
|
20
23
|
|
21
|
-
|
24
|
+
it { is_expected.to eq true }
|
22
25
|
|
23
|
-
|
26
|
+
describe 'forbidden domains defined' do
|
24
27
|
|
25
|
-
|
28
|
+
before { allow(Locomotive.config).to receive(:reserved_domains).and_return(['www.locomotiveapp.com', /.+\.acme\.org/]) }
|
26
29
|
|
27
|
-
|
30
|
+
let(:domains) { ['example.fr', 'acme.org'] }
|
28
31
|
|
29
|
-
|
32
|
+
it { is_expected.to eq true }
|
33
|
+
|
34
|
+
context 'setting a forbidden domain name' do
|
30
35
|
|
31
|
-
|
36
|
+
let(:domains) { ['example.fr', 'www.locomotiveapp.com', 'staging.acme.org'] }
|
32
37
|
|
33
|
-
|
38
|
+
it 'adds errors for each invalid domain' do
|
39
|
+
is_expected.to eq false
|
40
|
+
expect(site.errors['domains']).to eq(["www.locomotiveapp.com is already taken", "staging.acme.org is already taken"])
|
41
|
+
end
|
34
42
|
|
35
|
-
it 'adds errors for each invalid domain' do
|
36
|
-
is_expected.to eq false
|
37
|
-
expect(site.errors['domains']).to eq(["www.locomotiveapp.com is already taken", "staging.acme.org is already taken"])
|
38
43
|
end
|
39
44
|
|
40
45
|
end
|
41
46
|
|
42
47
|
end
|
43
48
|
|
44
|
-
|
49
|
+
describe 'domain sync' do
|
45
50
|
|
46
|
-
|
51
|
+
let!(:listener) { DomainEventListener.new }
|
52
|
+
after { listener.shutdown }
|
47
53
|
|
48
|
-
|
49
|
-
after { listener.shutdown }
|
54
|
+
subject { listener }
|
50
55
|
|
51
|
-
|
56
|
+
describe 'on saving' do
|
52
57
|
|
53
|
-
|
58
|
+
before { site.save }
|
54
59
|
|
55
|
-
|
60
|
+
it 'does not emit an event' do
|
61
|
+
expect(subject.size).to eq 0
|
62
|
+
end
|
56
63
|
|
57
|
-
|
58
|
-
expect(subject.size).to eq 0
|
59
|
-
end
|
64
|
+
context 'new site' do
|
60
65
|
|
61
|
-
|
66
|
+
let(:domains) { ['www.example.com', 'example.com'] }
|
62
67
|
|
63
|
-
|
68
|
+
it 'only tracks new domains' do
|
69
|
+
expect(subject.added).to eq(['www.example.com', 'example.com'])
|
70
|
+
expect(subject.removed).to eq([])
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'existing site' do
|
76
|
+
|
77
|
+
let(:domains) { ['www.boring.org', 'www.awesome.io'] }
|
78
|
+
|
79
|
+
before { listener.clear; site.domains = ['www.acme.com', 'www.awesome.io']; site.save; site.reload }
|
80
|
+
|
81
|
+
it 'tracks new domains and removed ones' do
|
82
|
+
expect(subject.added).to eq(['www.acme.com'])
|
83
|
+
expect(subject.removed).to eq(['www.boring.org'])
|
84
|
+
end
|
64
85
|
|
65
|
-
it 'only tracks new domains' do
|
66
|
-
expect(subject.added).to eq(['www.example.com', 'example.com'])
|
67
|
-
expect(subject.removed).to eq([])
|
68
86
|
end
|
69
87
|
|
70
88
|
end
|
71
89
|
|
72
|
-
|
90
|
+
describe 'on destroying' do
|
73
91
|
|
74
|
-
let(:domains) { ['www.
|
92
|
+
let(:domains) { ['www.example.com', 'example.com'] }
|
75
93
|
|
76
|
-
before {
|
94
|
+
before { site.save; listener.clear; site.destroy }
|
77
95
|
|
78
|
-
it 'tracks
|
79
|
-
expect(subject.added).to eq([
|
80
|
-
expect(subject.removed).to eq(['www.
|
96
|
+
it 'tracks removed domains' do
|
97
|
+
expect(subject.added).to eq([])
|
98
|
+
expect(subject.removed).to eq(['www.example.com', 'example.com'])
|
81
99
|
end
|
82
100
|
|
83
101
|
end
|
84
102
|
|
85
103
|
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe 'asset_host' do
|
107
|
+
|
108
|
+
describe '#asset_host=' do
|
109
|
+
it 'downcases the asset host' do
|
110
|
+
site.asset_host = 'ASSET.DEV'
|
111
|
+
|
112
|
+
expect(site.asset_host).to eq('asset.dev')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#valid?' do
|
117
|
+
|
118
|
+
subject { site.valid? }
|
119
|
+
|
120
|
+
it { is_expected.to eq true }
|
86
121
|
|
87
|
-
|
122
|
+
describe 'valid hostname defined' do
|
88
123
|
|
89
|
-
|
124
|
+
let(:asset_host) { 'asset.dev' }
|
90
125
|
|
91
|
-
|
126
|
+
it { is_expected.to eq true }
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe 'valid urls defined' do
|
131
|
+
|
132
|
+
let(:asset_host) { 'https://asset.dev' }
|
133
|
+
|
134
|
+
it { is_expected.to eq true }
|
135
|
+
|
136
|
+
let(:asset_host) { 'https://asset.dev/' }
|
137
|
+
|
138
|
+
it { is_expected.to eq true }
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'invalid hostname or url defined' do
|
143
|
+
|
144
|
+
let(:asset_host) { 'asset.d' }
|
145
|
+
|
146
|
+
it { is_expected.to eq false }
|
147
|
+
|
148
|
+
let(:asset_host) { 'https://asset.d-' }
|
149
|
+
|
150
|
+
it { is_expected.to eq false }
|
151
|
+
|
152
|
+
context 'setting an invalid hostname' do
|
153
|
+
|
154
|
+
let(:asset_host) { 'asset.d' }
|
155
|
+
|
156
|
+
it 'adds error to asset_host field' do
|
157
|
+
is_expected.to eq false
|
158
|
+
|
159
|
+
expect(site.errors['asset_host']).to eq(['asset.d is invalid'])
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'setting an invalid url' do
|
165
|
+
|
166
|
+
let(:asset_host) { 'http://asset.d-' }
|
167
|
+
|
168
|
+
it 'adds error to asset_host field' do
|
169
|
+
is_expected.to eq false
|
170
|
+
|
171
|
+
expect(site.errors['asset_host']).to eq(['http://asset.d- is invalid'])
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
92
175
|
|
93
|
-
it 'tracks removed domains' do
|
94
|
-
expect(subject.added).to eq([])
|
95
|
-
expect(subject.removed).to eq(['www.example.com', 'example.com'])
|
96
176
|
end
|
97
177
|
|
98
178
|
end
|
@@ -126,4 +206,4 @@ describe Locomotive::Concerns::Site::AccessPoints do
|
|
126
206
|
end
|
127
207
|
end
|
128
208
|
|
129
|
-
end
|
209
|
+
end
|
@@ -37,6 +37,42 @@ describe Locomotive::Site do
|
|
37
37
|
|
38
38
|
end
|
39
39
|
|
40
|
+
describe 'asset_host' do
|
41
|
+
|
42
|
+
let(:asset_host) { nil }
|
43
|
+
subject { FactoryGirl.build(:site, asset_host: asset_host) }
|
44
|
+
|
45
|
+
it { is_expected.to be_valid }
|
46
|
+
|
47
|
+
context 'good format without protocol' do
|
48
|
+
|
49
|
+
let(:asset_host) { 'asset.dev' }
|
50
|
+
|
51
|
+
it { is_expected.to be_valid}
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'good format with protocol' do
|
56
|
+
|
57
|
+
let(:asset_host) { 'https://asset.dev' }
|
58
|
+
|
59
|
+
it { is_expected.to be_valid}
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'bad format' do
|
64
|
+
|
65
|
+
let(:asset_host) { 'http://asset.d' }
|
66
|
+
|
67
|
+
it { is_expected.to_not be_valid }
|
68
|
+
|
69
|
+
it 'tells if asset_host is invalid' do
|
70
|
+
subject.valid?
|
71
|
+
expect(subject.errors[:asset_host]).to eq(['http://asset.d is invalid'])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
40
76
|
describe 'handle' do
|
41
77
|
|
42
78
|
it 'validates presence of handle' do
|
@@ -3,10 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe Locomotive::Steam::Middlewares::WysihtmlCss do
|
4
4
|
|
5
5
|
let(:url) { 'http://example.com/' }
|
6
|
+
let(:path) { 'index' }
|
6
7
|
let(:html) { 'Hello world' }
|
7
8
|
let(:page) { nil }
|
8
9
|
let(:app) { ->(env) { [200, env, [html]] } }
|
9
|
-
let(:env) { env_for(url).tap { |e| e['steam.page'] = page } }
|
10
|
+
let(:env) { env_for(url).tap { |e| e['steam.page'] = page; e['steam.path'] = path } }
|
10
11
|
let(:middleware) { described_class.new(app) }
|
11
12
|
|
12
13
|
subject { middleware.call(env).last.first }
|
@@ -35,6 +36,14 @@ describe Locomotive::Steam::Middlewares::WysihtmlCss do
|
|
35
36
|
|
36
37
|
it { is_expected.to match(%r(<html><head><link rel="stylesheet" type="text/css" href="/assets/locomotive/wysihtml5_editor-[^.]+.css"></head><body></body></html>)) }
|
37
38
|
|
39
|
+
context 'Google AMP page' do
|
40
|
+
|
41
|
+
let(:path) { '_amp/simple' }
|
42
|
+
|
43
|
+
it { is_expected.to eq('<html><head></head><body></body></html>') }
|
44
|
+
|
45
|
+
end
|
46
|
+
|
38
47
|
end
|
39
48
|
|
40
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotivecms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.0
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 5.2.
|
103
|
+
version: 5.2.1
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 5.2.
|
110
|
+
version: 5.2.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: mongoid-tree
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1.3.0
|
159
|
+
version: 1.3.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1.3.0
|
166
|
+
version: 1.3.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: slim
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,19 +193,33 @@ dependencies:
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 3.4.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
|
-
name: kaminari
|
196
|
+
name: kaminari-actionview
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
201
|
+
version: 1.1.1
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
208
|
+
version: 1.1.1
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: kaminari-mongoid
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - "~>"
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: 1.0.1
|
216
|
+
type: :runtime
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - "~>"
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: 1.0.1
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: bootstrap-kaminari-views
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1380,9 +1394,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1380
1394
|
version: '0'
|
1381
1395
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1382
1396
|
requirements:
|
1383
|
-
- - "
|
1397
|
+
- - ">="
|
1384
1398
|
- !ruby/object:Gem::Version
|
1385
|
-
version:
|
1399
|
+
version: '0'
|
1386
1400
|
requirements: []
|
1387
1401
|
rubyforge_project:
|
1388
1402
|
rubygems_version: 2.5.2
|
@@ -1390,108 +1404,108 @@ signing_key:
|
|
1390
1404
|
specification_version: 4
|
1391
1405
|
summary: A platform to create, publish and edit sites
|
1392
1406
|
test_files:
|
1393
|
-
- spec/fixtures/
|
1394
|
-
- spec/fixtures/assets/5k@2x.png
|
1395
|
-
- spec/fixtures/assets/5k_2.png
|
1396
|
-
- spec/fixtures/assets/application.js
|
1397
|
-
- spec/fixtures/assets/magic_mime_type.js
|
1398
|
-
- spec/fixtures/assets/main.css
|
1399
|
-
- spec/fixtures/assets/ruby_logo.svg
|
1400
|
-
- spec/fixtures/assets/specs.pdf
|
1401
|
-
- spec/fixtures/assets/wrong.txt
|
1407
|
+
- spec/fixtures/images/rails_2.png
|
1402
1408
|
- spec/fixtures/images/logo1.jpg
|
1403
1409
|
- spec/fixtures/images/logo2.jpg
|
1404
1410
|
- spec/fixtures/images/rails.png
|
1405
|
-
- spec/fixtures/
|
1406
|
-
- spec/
|
1407
|
-
- spec/
|
1408
|
-
- spec/
|
1409
|
-
- spec/
|
1411
|
+
- spec/fixtures/assets/specs.pdf
|
1412
|
+
- spec/fixtures/assets/5k@2x.png
|
1413
|
+
- spec/fixtures/assets/ruby_logo.svg
|
1414
|
+
- spec/fixtures/assets/5k.png
|
1415
|
+
- spec/fixtures/assets/wrong.txt
|
1416
|
+
- spec/fixtures/assets/magic_mime_type.js
|
1417
|
+
- spec/fixtures/assets/5k_2.png
|
1418
|
+
- spec/fixtures/assets/main.css
|
1419
|
+
- spec/fixtures/assets/application.js
|
1410
1420
|
- spec/lib/locomotive/steam/services/api_entry_submission_service_spec.rb
|
1411
1421
|
- spec/lib/locomotive/steam/services/async_email_service_spec.rb
|
1422
|
+
- spec/lib/locomotive/steam/services/api_content_entry_service_spec.rb
|
1412
1423
|
- spec/lib/locomotive/steam/services/liquid_parser_with_cache_service_spec.rb
|
1424
|
+
- spec/lib/locomotive/configuration_spec.rb
|
1425
|
+
- spec/lib/core_ext_spec.rb
|
1426
|
+
- spec/lib/action_view_spec.rb
|
1413
1427
|
- spec/mailers/locomotive/notifications_spec.rb
|
1428
|
+
- spec/models/locomotive/content_type_spec.rb
|
1429
|
+
- spec/models/locomotive/theme_asset_spec.rb
|
1430
|
+
- spec/models/locomotive/membership_spec.rb
|
1414
1431
|
- spec/models/locomotive/account_spec.rb
|
1415
|
-
- spec/models/locomotive/concerns/content_entry/counter_spec.rb
|
1416
|
-
- spec/models/locomotive/concerns/content_entry/csv_spec.rb
|
1417
|
-
- spec/models/locomotive/concerns/content_entry/file_size_spec.rb
|
1418
|
-
- spec/models/locomotive/concerns/content_type/entry_template_spec.rb
|
1419
|
-
- spec/models/locomotive/concerns/page/editable_elements_spec.rb
|
1420
|
-
- spec/models/locomotive/concerns/page/layout_spec.rb
|
1421
|
-
- spec/models/locomotive/concerns/page/redirect_spec.rb
|
1422
|
-
- spec/models/locomotive/concerns/page/render_spec.rb
|
1423
|
-
- spec/models/locomotive/concerns/site/access_points_spec.rb
|
1424
|
-
- spec/models/locomotive/concerns/site/cache_spec.rb
|
1425
|
-
- spec/models/locomotive/concerns/site/locales_spec.rb
|
1426
|
-
- spec/models/locomotive/concerns/site/metafields_spec.rb
|
1427
|
-
- spec/models/locomotive/concerns/site/url_redirections_spec.rb
|
1428
1432
|
- spec/models/locomotive/content_asset_spec.rb
|
1429
|
-
- spec/models/locomotive/content_entry_spec.rb
|
1430
|
-
- spec/models/locomotive/content_type_spec.rb
|
1431
1433
|
- spec/models/locomotive/editable_element_spec.rb
|
1432
|
-
- spec/models/locomotive/
|
1433
|
-
- spec/models/locomotive/page_spec.rb
|
1434
|
+
- spec/models/locomotive/translation_spec.rb
|
1434
1435
|
- spec/models/locomotive/site_spec.rb
|
1436
|
+
- spec/models/locomotive/content_entry_spec.rb
|
1437
|
+
- spec/models/locomotive/page_spec.rb
|
1435
1438
|
- spec/models/locomotive/snippet_spec.rb
|
1436
|
-
- spec/models/locomotive/
|
1437
|
-
- spec/models/locomotive/
|
1438
|
-
- spec/
|
1439
|
-
- spec/
|
1439
|
+
- spec/models/locomotive/concerns/page/render_spec.rb
|
1440
|
+
- spec/models/locomotive/concerns/page/layout_spec.rb
|
1441
|
+
- spec/models/locomotive/concerns/page/redirect_spec.rb
|
1442
|
+
- spec/models/locomotive/concerns/page/editable_elements_spec.rb
|
1443
|
+
- spec/models/locomotive/concerns/content_type/entry_template_spec.rb
|
1444
|
+
- spec/models/locomotive/concerns/site/url_redirections_spec.rb
|
1445
|
+
- spec/models/locomotive/concerns/site/locales_spec.rb
|
1446
|
+
- spec/models/locomotive/concerns/site/metafields_spec.rb
|
1447
|
+
- spec/models/locomotive/concerns/site/access_points_spec.rb
|
1448
|
+
- spec/models/locomotive/concerns/site/cache_spec.rb
|
1449
|
+
- spec/models/locomotive/concerns/content_entry/csv_spec.rb
|
1450
|
+
- spec/models/locomotive/concerns/content_entry/counter_spec.rb
|
1451
|
+
- spec/models/locomotive/concerns/content_entry/file_size_spec.rb
|
1440
1452
|
- spec/requests/locomotive/steam/cache_spec.rb
|
1441
1453
|
- spec/requests/locomotive/steam/wysihtml_css_spec.rb
|
1454
|
+
- spec/requests/locomotive/site_spec.rb
|
1455
|
+
- spec/requests/locomotive/image_thumbnail_spec.rb
|
1442
1456
|
- spec/support/capybara.rb
|
1443
1457
|
- spec/support/carrierwave.rb
|
1444
|
-
- spec/support/
|
1445
|
-
- spec/support/entity.rb
|
1446
|
-
- spec/support/factories.rb
|
1458
|
+
- spec/support/matchers.rb
|
1447
1459
|
- spec/support/features/session_helpers.rb
|
1448
1460
|
- spec/support/features/site_helpers.rb
|
1449
|
-
- spec/support/
|
1450
|
-
- spec/support/matchers.rb
|
1461
|
+
- spec/support/entity.rb
|
1451
1462
|
- spec/support/middlewares.rb
|
1452
|
-
- spec/support/
|
1463
|
+
- spec/support/shared_contexts/api_header_setup.rb
|
1464
|
+
- spec/support/shared_contexts/api_site_setup.rb
|
1453
1465
|
- spec/support/pundit_matcher.rb
|
1454
1466
|
- spec/support/response.rb
|
1467
|
+
- spec/support/mongoid.rb
|
1468
|
+
- spec/support/locomotive.rb
|
1469
|
+
- spec/support/factories.rb
|
1470
|
+
- spec/support/database_cleaner.rb
|
1455
1471
|
- spec/support/sequences.rb
|
1456
|
-
- spec/support/shared_contexts/api_header_setup.rb
|
1457
|
-
- spec/support/shared_contexts/api_site_setup.rb
|
1458
1472
|
- spec/support/shared_examples/site_scope_examples.rb
|
1459
1473
|
- spec/dummy/Rakefile
|
1460
1474
|
- spec/dummy/config.ru
|
1461
|
-
- spec/dummy/app/assets/javascripts/application.js
|
1462
|
-
- spec/dummy/app/assets/javascripts/locomotive_misc.js.coffee
|
1463
|
-
- spec/dummy/app/assets/stylesheets/application.css
|
1464
1475
|
- spec/dummy/app/cells/locomotive/main_menu_cell.rb
|
1476
|
+
- spec/dummy/app/models/foo.rb
|
1465
1477
|
- spec/dummy/app/controllers/application_controller.rb
|
1466
1478
|
- spec/dummy/app/controllers/foo_controller.rb
|
1467
|
-
- spec/dummy/app/helpers/application_helper.rb
|
1468
|
-
- spec/dummy/app/models/foo.rb
|
1469
|
-
- spec/dummy/app/views/foo/index.html.slim
|
1470
|
-
- spec/dummy/app/views/layouts/application.html.erb
|
1471
1479
|
- spec/dummy/app/views/locomotive/shared/_main_app_head.html.slim
|
1472
|
-
- spec/dummy/
|
1473
|
-
- spec/dummy/
|
1474
|
-
- spec/dummy/
|
1475
|
-
- spec/dummy/
|
1480
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
1481
|
+
- spec/dummy/app/views/foo/index.html.slim
|
1482
|
+
- spec/dummy/app/assets/javascripts/application.js
|
1483
|
+
- spec/dummy/app/assets/javascripts/locomotive_misc.js.coffee
|
1484
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
1485
|
+
- spec/dummy/app/helpers/application_helper.rb
|
1486
|
+
- spec/dummy/config/secrets.yml
|
1487
|
+
- spec/dummy/config/routes.rb
|
1488
|
+
- spec/dummy/config/mongoid.yml
|
1489
|
+
- spec/dummy/config/locales/en.yml
|
1490
|
+
- spec/dummy/config/locales/fr.yml
|
1476
1491
|
- spec/dummy/config/environments/production.rb
|
1477
|
-
- spec/dummy/config/environments/
|
1492
|
+
- spec/dummy/config/environments/development.rb
|
1478
1493
|
- spec/dummy/config/environments/test.rb
|
1479
|
-
- spec/dummy/config/
|
1494
|
+
- spec/dummy/config/environments/profile.rb
|
1495
|
+
- spec/dummy/config/environment.rb
|
1496
|
+
- spec/dummy/config/application.rb
|
1497
|
+
- spec/dummy/config/boot.rb
|
1480
1498
|
- spec/dummy/config/initializers/carrierwave.rb
|
1499
|
+
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
1500
|
+
- spec/dummy/config/initializers/session_store.rb
|
1501
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
1502
|
+
- spec/dummy/config/initializers/assets.rb
|
1481
1503
|
- spec/dummy/config/initializers/cookies_serializer.rb
|
1482
1504
|
- spec/dummy/config/initializers/devise.rb
|
1483
|
-
- spec/dummy/config/initializers/dragonfly.rb
|
1484
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
1485
1505
|
- spec/dummy/config/initializers/locomotive.rb
|
1486
1506
|
- spec/dummy/config/initializers/secret_token.rb
|
1487
|
-
- spec/dummy/config/initializers/
|
1488
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
1489
|
-
- spec/dummy/config/locales/en.yml
|
1490
|
-
- spec/dummy/config/locales/fr.yml
|
1491
|
-
- spec/dummy/config/mongoid.yml
|
1492
|
-
- spec/dummy/config/routes.rb
|
1493
|
-
- spec/dummy/config/secrets.yml
|
1507
|
+
- spec/dummy/config/initializers/dragonfly.rb
|
1494
1508
|
- spec/dummy/script/rails
|
1495
|
-
- spec/dummy/public/404.html
|
1496
1509
|
- spec/dummy/public/422.html
|
1497
1510
|
- spec/dummy/public/500.html
|
1511
|
+
- spec/dummy/public/404.html
|