Skip to content

Commit

Permalink
Merge branch 'master' into feature-per-site-asset-host
Browse files Browse the repository at this point in the history
  • Loading branch information
interhive committed Jun 22, 2017
2 parents 176b921 + 3ef3e14 commit 73f7a41
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 75 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -18,13 +18,13 @@ end


group :development do group :development do
# gem 'custom_fields', path: '../gems/custom_fields' # for Developers # gem 'custom_fields', path: '../gems/custom_fields' # for Developers
# gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '4a612e5' gem 'custom_fields', github: 'locomotivecms/custom_fields', ref: '27f1d62'


# gem 'locomotivecms_common', path: '../gems/common', require: false # gem 'locomotivecms_common', path: '../gems/common', require: false
# gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b', require: false # gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b', require: false


# gem 'locomotivecms_steam', path: '../gems/steam', require: false # gem 'locomotivecms_steam', path: '../gems/steam', require: false
# gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'e624ab686', require: false gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: '0cf606c', require: false


# gem 'locomotive_liquid', path: '../gems/liquid' # for Developers # gem 'locomotive_liquid', path: '../gems/liquid' # for Developers
# gem 'locomotivecms_solid', path: '../gems/solid' # for Developers # gem 'locomotivecms_solid', path: '../gems/solid' # for Developers
Expand Down
112 changes: 62 additions & 50 deletions Gemfile.lock
Expand Up @@ -4,10 +4,54 @@ GIT
specs: specs:
database_cleaner (1.5.3) database_cleaner (1.5.3)


GIT
remote: git://github.com/locomotivecms/custom_fields.git
revision: 27f1d621afc894002693de78f0165c0631119194
ref: 27f1d62
specs:
custom_fields (2.8.0)
activesupport (~> 4.2.7)
bcrypt (~> 3.1.11)
carrierwave-mongoid (~> 0.10.0)
monetize (~> 1.6.0)
mongoid (~> 5.2.0)

GIT
remote: git://github.com/locomotivecms/steam.git
revision: 0cf606c56f52dac2587e5890ada904256c6a7c40
ref: 0cf606c
specs:
locomotivecms_steam (1.3.0.rc2)
RedCloth (~> 4.3.2)
autoprefixer-rails (~> 6.7.2)
bcrypt (~> 3.1.11)
chronic (~> 0.10.2)
coffee-script (~> 2.4.1)
compass (~> 1.0.3)
dragonfly (~> 1.1.1)
duktape (~> 1.6.1.0)
httparty (~> 0.14.0)
kramdown (~> 1.13.2)
locomotivecms-solid (~> 4.0.1)
locomotivecms_common (~> 0.2.0)
mime-types (~> 3.1.0)
mimetype-fu (~> 0.1.2)
moneta (~> 1.0.0)
morphine (~> 0.1.1)
nokogiri (~> 1.7.0.1)
pony (~> 1.11)
rack-cache (~> 1.7.0)
rack-rewrite (~> 1.5.1)
rack_csrf (~> 2.6.0)
sanitize (~> 4.4.0)
sass (~> 3.4.23)
sprockets (~> 3.7.1)
uglifier (~> 3.1.6)

PATH PATH
remote: . remote: .
specs: specs:
locomotivecms (3.3.0.rc2) locomotivecms (3.3.0.rc3)
actionmailer-with-request (~> 0.4.0) actionmailer-with-request (~> 0.4.0)
autoprefixer-rails (~> 6.7.2) autoprefixer-rails (~> 6.7.2)
bazaar (~> 0.0.2) bazaar (~> 0.0.2)
Expand All @@ -28,7 +72,7 @@ PATH
jquery-ui-rails (~> 5.0.3) jquery-ui-rails (~> 5.0.3)
json-schema (~> 2.8.0) json-schema (~> 2.8.0)
kaminari (~> 0.17.0) kaminari (~> 0.17.0)
locomotivecms_steam (~> 1.3.0.rc1) locomotivecms_steam (~> 1.3.0.rc2)
mongo_session_store-rails4 (~> 6.0.0) mongo_session_store-rails4 (~> 6.0.0)
mongoid (~> 5.2.0) mongoid (~> 5.2.0)
mongoid-tree (~> 2.1.0) mongoid-tree (~> 2.1.0)
Expand Down Expand Up @@ -88,7 +132,7 @@ GEM
public_suffix (~> 2.0, >= 2.0.2) public_suffix (~> 2.0, >= 2.0.2)
arel (6.0.4) arel (6.0.4)
attr_extras (4.4.0) attr_extras (4.4.0)
autoprefixer-rails (6.7.7.1) autoprefixer-rails (6.7.7.2)
execjs execjs
axiom-types (0.1.1) axiom-types (0.1.1)
descendants_tracker (~> 0.0.4) descendants_tracker (~> 0.0.4)
Expand Down Expand Up @@ -177,12 +221,6 @@ GEM
cucumber-core (1.5.0) cucumber-core (1.5.0)
gherkin (~> 4.0) gherkin (~> 4.0)
cucumber-wire (0.0.1) cucumber-wire (0.0.1)
custom_fields (2.8.0)
activesupport (~> 4.2.7)
bcrypt (~> 3.1.11)
carrierwave-mongoid (~> 0.10.0)
monetize (~> 1.6.0)
mongoid (~> 5.2.0)
debug_inspector (0.0.2) debug_inspector (0.0.2)
descendants_tracker (0.0.4) descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1) thread_safe (~> 0.3, >= 0.3.1)
Expand All @@ -197,7 +235,7 @@ GEM
devise (>= 2.1.0) devise (>= 2.1.0)
diff-lcs (1.3) diff-lcs (1.3)
docile (1.1.5) docile (1.1.5)
dragonfly (1.1.1) dragonfly (1.1.3)
addressable (~> 2.3) addressable (~> 2.3)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (>= 1.3) rack (>= 1.3)
Expand Down Expand Up @@ -228,8 +266,8 @@ GEM
font-awesome-sass (4.7.0) font-awesome-sass (4.7.0)
sass (>= 3.2) sass (>= 3.2)
gherkin (4.0.0) gherkin (4.0.0)
globalid (0.3.7) globalid (0.4.0)
activesupport (>= 4.1.0) activesupport (>= 4.2.0)
grape (0.12.0) grape (0.12.0)
activesupport activesupport
builder builder
Expand Down Expand Up @@ -287,32 +325,6 @@ GEM
attr_extras (~> 4.4.0) attr_extras (~> 4.4.0)
colorize colorize
stringex (~> 2.6.0) stringex (~> 2.6.0)
locomotivecms_steam (1.3.0.rc1)
RedCloth (~> 4.3.2)
autoprefixer-rails (~> 6.7.2)
bcrypt (~> 3.1.11)
chronic (~> 0.10.2)
coffee-script (~> 2.4.1)
compass (~> 1.0.3)
dragonfly (~> 1.1.1)
duktape (~> 1.6.1.0)
httparty (~> 0.14.0)
kramdown (~> 1.13.2)
locomotivecms-solid (~> 4.0.1)
locomotivecms_common (~> 0.2.0)
mime-types (~> 3.1.0)
mimetype-fu (~> 0.1.2)
moneta (~> 1.0.0)
morphine (~> 0.1.1)
nokogiri (~> 1.7.0.1)
pony (~> 1.11)
rack-cache (~> 1.7.0)
rack-rewrite (~> 1.5.1)
rack_csrf (~> 2.6.0)
sanitize (~> 4.4.0)
sass (~> 3.4.23)
sprockets (~> 3.7.1)
uglifier (~> 3.1.6)
loofah (2.0.3) loofah (2.0.3)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
mail (2.6.4) mail (2.6.4)
Expand All @@ -328,14 +340,13 @@ GEM
moneta (1.0.0) moneta (1.0.0)
monetize (1.6.0) monetize (1.6.0)
money (~> 6.8) money (~> 6.8)
money (6.8.2) money (6.9.0)
i18n (>= 0.6.4, < 0.9) i18n (>= 0.6.4, < 0.9)
sixarm_ruby_unaccent (>= 1.1.1, < 2) mongo (2.4.2)
mongo (2.4.1)
bson (>= 4.2.1, < 5.0.0) bson (>= 4.2.1, < 5.0.0)
mongo_session_store-rails4 (6.0.0) mongo_session_store-rails4 (6.0.0)
actionpack (>= 3.1) actionpack (>= 3.1)
mongoid (5.2.0) mongoid (5.2.1)
activemodel (~> 4.0) activemodel (~> 4.0)
mongo (>= 2.4.1, < 3.0.0) mongo (>= 2.4.1, < 3.0.0)
origin (~> 2.3) origin (~> 2.3)
Expand All @@ -351,10 +362,10 @@ GEM
multi_xml (0.6.0) multi_xml (0.6.0)
nokogiri (1.7.0.1) nokogiri (1.7.0.1)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
nokogumbo (1.4.10) nokogumbo (1.4.13)
nokogiri nokogiri
nprogress-rails (0.1.6.8) nprogress-rails (0.1.6.8)
origin (2.3.0) origin (2.3.1)
orm_adapter (0.5.0) orm_adapter (0.5.0)
pickle (0.5.1) pickle (0.5.1)
cucumber (>= 0.8) cucumber (>= 0.8)
Expand Down Expand Up @@ -415,8 +426,8 @@ GEM
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rake (12.0.0) rake (12.0.0)
rb-fsevent (0.9.8) rb-fsevent (0.9.8)
rb-inotify (0.9.8) rb-inotify (0.9.10)
ffi (>= 0.5.0) ffi (>= 0.5.0, < 2)
responders (2.3.0) responders (2.3.0)
railties (>= 4.2.0, < 5.1) railties (>= 4.2.0, < 5.1)
rspec (3.5.0) rspec (3.5.0)
Expand Down Expand Up @@ -466,9 +477,8 @@ GEM
json (>= 1.8, < 3) json (>= 1.8, < 3)
simplecov-html (~> 0.10.0) simplecov-html (~> 0.10.0)
simplecov-html (0.10.0) simplecov-html (0.10.0)
sixarm_ruby_unaccent (1.1.1) slim (3.0.8)
slim (3.0.7) temple (>= 0.7.6, < 0.9)
temple (~> 0.7.6)
tilt (>= 1.3.3, < 2.1) tilt (>= 1.3.3, < 2.1)
slop (3.6.0) slop (3.6.0)
sprockets (3.7.1) sprockets (3.7.1)
Expand All @@ -479,7 +489,7 @@ GEM
activesupport (>= 4.0) activesupport (>= 4.0)
sprockets (>= 3.0.0) sprockets (>= 3.0.0)
stringex (2.6.1) stringex (2.6.1)
temple (0.7.7) temple (0.8.0)
term-ansicolor (1.4.0) term-ansicolor (1.4.0)
tins (~> 1.0) tins (~> 1.0)
terminal-table (1.7.3) terminal-table (1.7.3)
Expand Down Expand Up @@ -517,6 +527,7 @@ DEPENDENCIES
capybara-webkit (~> 1.12.0) capybara-webkit (~> 1.12.0)
coffee-rails (~> 4.1.0) coffee-rails (~> 4.1.0)
coveralls (~> 0.8.19) coveralls (~> 0.8.19)
custom_fields!
database_cleaner! database_cleaner!
email_spec email_spec
factory_girl_rails factory_girl_rails
Expand All @@ -525,6 +536,7 @@ DEPENDENCIES
i18n-tasks (~> 0.8.7) i18n-tasks (~> 0.8.7)
json_spec (~> 1.1.4) json_spec (~> 1.1.4)
locomotivecms! locomotivecms!
locomotivecms_steam!
pickle pickle
pry pry
pry-byebug pry-byebug
Expand Down
2 changes: 1 addition & 1 deletion app/api/locomotive/api/entities/site_entity.rb
Expand Up @@ -7,7 +7,7 @@ class SiteEntity < BaseEntity
expose :name, :handle, :seo_title, :meta_keywords, :meta_description, expose :name, :handle, :seo_title, :meta_keywords, :meta_description,
:robots_txt, :cache_enabled, :private_access :robots_txt, :cache_enabled, :private_access


expose :locales, :domains, :asset_host expose :locales, :domains, :asset_host, :url_redirections


expose :memberships, using: MembershipEntity expose :memberships, using: MembershipEntity


Expand Down
11 changes: 8 additions & 3 deletions app/api/locomotive/api/forms/content_entry_form.rb
Expand Up @@ -41,7 +41,7 @@ def method_missing(name, *args, &block)
if respond_to?(:"set_#{field.type}") if respond_to?(:"set_#{field.type}")
public_send(:"set_#{field.type}", field, args.first) public_send(:"set_#{field.type}", field, args.first)
else else
dynamic_attributes[field.name.to_sym] = args.first dynamic_attributes[getter_name(name).to_sym] = args.first
end end
else else
super super
Expand All @@ -54,14 +54,19 @@ def serializable_hash


private private


def getter_name(name)
name.to_s.gsub(/=\z/, '')
end

def find_field(name) def find_field(name)
_name = name.to_s.gsub(/=$/, '') dynamic_setters[getter_name(name)]
dynamic_setters[_name]
end end


def dynamic_setters def dynamic_setters
@dynamic_setters ||= self.content_type.entries_custom_fields.inject({}) do |hash, field| @dynamic_setters ||= self.content_type.entries_custom_fields.inject({}) do |hash, field|
case field.type.to_sym case field.type.to_sym
when :password
hash[field.name] = hash["#{field.name}_confirmation"] = field
when :file when :file
hash[field.name] = hash["remote_#{field.name}_url"] = hash["remove_#{field.name}"] = field hash[field.name] = hash["remote_#{field.name}_url"] = hash["remove_#{field.name}"] = field
when :belongs_to when :belongs_to
Expand Down
2 changes: 1 addition & 1 deletion app/api/locomotive/api/forms/site_form.rb
Expand Up @@ -4,7 +4,7 @@ module Forms


class SiteForm < BaseForm class SiteForm < BaseForm


attrs :name, :handle, :robots_txt, :locales, :domains, :timezone, :picture, :cache_enabled, :private_access, :password, :metafields_schema, :metafields, :metafields_ui, :asset_host attrs :name, :handle, :robots_txt, :locales, :domains, :url_redirections, :timezone, :picture, :cache_enabled, :private_access, :password, :metafields_schema, :metafields, :metafields_ui, :asset_host
attrs :seo_title, :meta_keywords, :meta_description, localized: true attrs :seo_title, :meta_keywords, :meta_description, localized: true


# Make sure locales and domains are in arrays. # Make sure locales and domains are in arrays.
Expand Down
2 changes: 1 addition & 1 deletion app/api/locomotive/api/resources/current_site_resource.rb
Expand Up @@ -27,7 +27,6 @@ def service
present current_site, with: entity_klass present current_site, with: entity_klass
end end



desc 'Update current site' desc 'Update current site'
params do params do
requires :site, type: Hash do requires :site, type: Hash do
Expand All @@ -39,6 +38,7 @@ def service
optional :robots_txt optional :robots_txt
optional :locales, type: Array optional :locales, type: Array
optional :domains, type: Array optional :domains, type: Array
optional :url_redirections, type: Array
optional :timezone optional :timezone
optional :picture optional :picture
optional :metafields_schema optional :metafields_schema
Expand Down
11 changes: 8 additions & 3 deletions lib/locomotive/steam/middlewares/wysihtml_css.rb
Expand Up @@ -4,14 +4,16 @@ module Middlewares


class WysihtmlCss class WysihtmlCss


GOOGLE_AMP_PATH = '_amp'

def initialize(app, opts = {}) def initialize(app, opts = {})
@app = app @app = app
end end


def call(env) def call(env)
status, headers, response = @app.call(env) status, headers, response = @app.call(env)


if content?(env['steam.page'], response) if content?(env['steam.page'], env['steam.path'], response)
url = ::ActionController::Base.helpers.stylesheet_path('locomotive/wysihtml5_editor') url = ::ActionController::Base.helpers.stylesheet_path('locomotive/wysihtml5_editor')
html = %(<link rel="stylesheet" type="text/css" href="#{url}">) html = %(<link rel="stylesheet" type="text/css" href="#{url}">)
response.first.gsub!('</head>', %(#{html}</head>)) response.first.gsub!('</head>', %(#{html}</head>))
Expand All @@ -22,8 +24,11 @@ def call(env)


protected protected


def content?(page, response) def content?(page, path, response)
page && !page.redirect && page.response_type == 'text/html' && response.first !path.starts_with?(GOOGLE_AMP_PATH + '/') &&
!page.redirect &&
page.response_type == 'text/html' &&
response.first
end end


end end
Expand Down
2 changes: 1 addition & 1 deletion lib/locomotive/version.rb
Expand Up @@ -2,5 +2,5 @@
# MAJOR.MINOR.PATCH format. # MAJOR.MINOR.PATCH format.
# 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 # 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
module Locomotive #:nodoc module Locomotive #:nodoc
VERSION = '3.3.0.rc2' VERSION = '3.3.0.rc3'
end end
2 changes: 1 addition & 1 deletion locomotive_cms.gemspec
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |s|
s.add_dependency 'mongo_session_store-rails4', '~> 6.0.0' s.add_dependency 'mongo_session_store-rails4', '~> 6.0.0'


s.add_dependency 'custom_fields', '~> 2.8.0' s.add_dependency 'custom_fields', '~> 2.8.0'
s.add_dependency 'locomotivecms_steam', '~> 1.3.0.rc1' s.add_dependency 'locomotivecms_steam', '~> 1.3.0.rc2'


s.add_dependency 'slim', '~> 3.0.7' s.add_dependency 'slim', '~> 3.0.7'
s.add_dependency 'simple_form', '~> 3.4.0' s.add_dependency 'simple_form', '~> 3.4.0'
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/locomotive/steam/cache_spec.rb
Expand Up @@ -40,7 +40,7 @@


subject { middleware.send(:cache_key, steam_env) } subject { middleware.send(:cache_key, steam_env) }


it { expect(subject).to eq '6f10bd02e43a99e1bef1223da0e266ec' } it { expect(subject).to eq 'e86d1e803b59f9eeeca84cce457808e3' }


end end


Expand Down
11 changes: 10 additions & 1 deletion spec/requests/locomotive/steam/wysihtml_css_spec.rb
Expand Up @@ -3,10 +3,11 @@
describe Locomotive::Steam::Middlewares::WysihtmlCss do describe Locomotive::Steam::Middlewares::WysihtmlCss do


let(:url) { 'http://example.com/' } let(:url) { 'http://example.com/' }
let(:path) { 'index' }
let(:html) { 'Hello world' } let(:html) { 'Hello world' }
let(:page) { nil } let(:page) { nil }
let(:app) { ->(env) { [200, env, [html]] } } let(:app) { ->(env) { [200, env, [html]] } }
let(:env) { env_for(url).tap { |e| e['steam.page'] = page } } let(:env) { env_for(url).tap { |e| e['steam.page'] = page; e['steam.path'] = path } }
let(:middleware) { described_class.new(app) } let(:middleware) { described_class.new(app) }


subject { middleware.call(env).last.first } subject { middleware.call(env).last.first }
Expand Down Expand Up @@ -35,6 +36,14 @@


it { is_expected.to match(%r(<html><head><link rel="stylesheet" type="text/css" href="/assets/locomotive/wysihtml5_editor-[^.]+.css"></head><body></body></html>)) } it { is_expected.to match(%r(<html><head><link rel="stylesheet" type="text/css" href="/assets/locomotive/wysihtml5_editor-[^.]+.css"></head><body></body></html>)) }


context 'Google AMP page' do

let(:path) { '_amp/simple' }

it { is_expected.to eq('<html><head></head><body></body></html>') }

end

end end


end end
Expand Down

0 comments on commit 73f7a41

Please sign in to comment.