locomotivecms_wagon 2.1.0.rc5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbfa30794e5fef44d286be75267b65d52ed3bcaf
4
- data.tar.gz: 25dd384d0decd405edc613af02956ee6d6065494
3
+ metadata.gz: 39b72c35430dbc4c08cac9452401fd3e366a71c5
4
+ data.tar.gz: f0c9234b8cbb49a67ff9824a5a1a95f0d4f6b365
5
5
  SHA512:
6
- metadata.gz: d4b3d642b06e9b59c7a469baf8d55dc76a2699504975d605425a310b6843a7b9da590518998b93e92136c3efd64e2f75bad42e79f87efe2407f774a133a3f1d3
7
- data.tar.gz: 7e3399257bdf768c364bb85387c65efd92de04d5c8705f11f46a7eb52fa2e2378a099e737d6d53bad1c408472b72de62569f59d030a5d9fa348e0ce45f5b1975
6
+ metadata.gz: 5ae92dd65c7b3e95ca4060358421bd0715621e72a8f5232dfe2711ad1afda2ad2ed0fca2036000c174a401d8afb1a256756e88883559ae94e2a3157079525b42
7
+ data.tar.gz: 2f995dd430b629a66d12657d68debde142a23d9c0e64227bd10cf9c7bd2ae0aa21fee30b9c3fd5a95537b3e842dd7ccb65732bdc8e588ac15e3bbe651397a1f0
data/Gemfile CHANGED
@@ -8,7 +8,7 @@ gem 'rb-fsevent', '~> 0.9.1'
8
8
  # Development
9
9
  # gem 'locomotivecms_common', github: 'locomotivecms/common', ref: '257047b', require: false
10
10
  # gem 'locomotivecms_coal', github: 'locomotivecms/coal', ref: 'f4ff435', require: false
11
- # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'a3054f1', require: false
11
+ # gem 'locomotivecms_steam', github: 'locomotivecms/steam', ref: 'fe7403c', require: false
12
12
 
13
13
  # Local development
14
14
  # gem 'locomotivecms_coal', path: '../gems/coal', require: false
@@ -6,7 +6,7 @@ module Locomotive::Wagon
6
6
 
7
7
  module AssetsConcern
8
8
 
9
- REGEX = /(https?:\/\/\S+)?\/sites\/[0-9a-f]{24}\/(assets|pages|theme|content_entry[0-9a-f]{24})\/(([^;.]+)\/)*([a-zA-Z_\-0-9.]+)\.([A-Za-z]{2,})(\?\w+)?/
9
+ REGEX = /(https?:\/\/\S+)?\/sites\/[0-9a-f]{24}\/(assets|pages|theme|content_entry[0-9a-f]{24})\/(([^;.]+)\/)*([a-zA-Z_\-0-9.%]+)\.([A-Za-z]{2,})(\?\w+)?/
10
10
 
11
11
  # The content assets on the remote engine follows the format: /sites/<id>/assets/<type>/<file>
12
12
  # This method replaces these urls by their local representation. <type>/<file>
@@ -46,6 +46,11 @@ module Locomotive::Wagon
46
46
  ordered_options.each do |option|
47
47
  locales.each { |locale| (_options[locale] ||= []) << option['name'][locale.to_s] }
48
48
  end
49
+
50
+ # if all the values of a locale are nil, then no need to keep that locale
51
+ locales.each do |locale|
52
+ _options.delete(locale) if _options[locale].all? { |v| v.blank? }
53
+ end
49
54
  end
50
55
  else
51
56
  ordered_options.map { |option| option['name'][default_locale] }
@@ -14,6 +14,7 @@ module Locomotive::Wagon
14
14
  end if locales.size > 1
15
15
 
16
16
  decode_metafields(attributes)
17
+ decode_metafields_ui(attributes)
17
18
 
18
19
  write_metafields_schema(attributes.delete('metafields_schema'))
19
20
 
@@ -60,14 +61,13 @@ module Locomotive::Wagon
60
61
  end
61
62
 
62
63
  def decode_metafields(attributes)
63
- metafields = attributes['metafields']
64
-
65
- return if metafields.blank?
66
-
67
- # metafields come under a JSON string format.
68
- metafields = JSON.parse(metafields)
64
+ decode_json_attribute(attributes, 'metafields') do |metafields|
65
+ replace_asset_urls_in_hash(metafields)
66
+ end
67
+ end
69
68
 
70
- attributes['metafields'] = replace_asset_urls_in_hash(metafields)
69
+ def decode_metafields_ui(attributes)
70
+ decode_json_attribute(attributes, 'metafields_ui')
71
71
  end
72
72
 
73
73
  def array_of_hash_to_hash(array, name, &block)
@@ -80,6 +80,17 @@ module Locomotive::Wagon
80
80
  end
81
81
  end
82
82
 
83
+ def decode_json_attribute(attributes, name, &block)
84
+ value = attributes.delete(name)
85
+
86
+ return if value.blank?
87
+
88
+ # JSON string -> Hash
89
+ _value = JSON.parse(value)
90
+
91
+ attributes[name] = block_given? ? yield(_value) : _value
92
+ end
93
+
83
94
  def localized_attributes(&block)
84
95
  %w(seo_title meta_keywords meta_description).each do |name|
85
96
  yield(name)
@@ -7,7 +7,7 @@ module Locomotive::Wagon
7
7
  alias_method :default_push, :_push
8
8
 
9
9
  def _push
10
- (%i(without_relationships only_relationships) + other_locales).each do |step|
10
+ ([:without_relationships] + other_locales + [:only_relationships]).each do |step|
11
11
  @step = step
12
12
  default_push
13
13
  end
@@ -117,7 +117,11 @@ module Locomotive::Wagon
117
117
  def skip?(entity)
118
118
  return false if @only_entities.blank?
119
119
 
120
- _path = entity.template_path[default_locale].gsub('./app/views/pages/', '')
120
+ template_path = entity.template_path[default_locale]
121
+
122
+ return true if template_path == false
123
+
124
+ _path = template_path.gsub('./app/views/pages/', '')
121
125
 
122
126
  !@only_entities.any? { |regexp| regexp.match(_path) }
123
127
  end
@@ -40,7 +40,7 @@ module Locomotive::Wagon
40
40
  return unless entity.stylesheet_or_javascript?
41
41
 
42
42
  Tempfile.new(entity.realname).tap do |file|
43
- content = sprockets_env[entity.short_relative_url].to_s
43
+ content = compress_and_minify(entity)
44
44
 
45
45
  # replace paths to images or fonts by the absolute URL used in the Engine
46
46
  replace_assets!(content)
@@ -85,6 +85,16 @@ module Locomotive::Wagon
85
85
  @remote_urls[resource.local_path] = "#{resource.url}?#{resource.checksum}"
86
86
  end
87
87
 
88
+ def compress_and_minify(entity)
89
+ begin
90
+ sprockets_env[entity.short_relative_url].to_s
91
+ rescue Locomotive::Steam::YUICompressorRuntimeError => e
92
+ instrument :warning, message: "Unable to compress and minify it, number of errors (#{e.errors.size})\n#{e.errors.join("\n")}"
93
+ # use the original file instead
94
+ File.read(File.join(path, entity.source))
95
+ end
96
+ end
97
+
88
98
  def sprockets_env
89
99
  @sprockets_env ||= Locomotive::Steam::SprocketsEnvironment.new(File.join(path, 'public'),
90
100
  minify: ENV['WAGON_NO_MINIFY_ASSETS'].present? ? false : true)
@@ -1,5 +1,7 @@
1
1
  module Locomotive::Wagon
2
2
 
3
+ SiteFinder = Struct.new(:repository, :request) { def find; repository.first; end; }
4
+
3
5
  class ServeCommand < Struct.new(:path, :options, :shell)
4
6
 
5
7
  def initialize(path, options, shell)
@@ -82,6 +84,14 @@ module Locomotive::Wagon
82
84
  end
83
85
 
84
86
  config.middleware.insert_before Rack::Lint, Locomotive::Wagon::Middlewares::ErrorPage
87
+
88
+ config.services_hook = -> (services) {
89
+ if services.request
90
+ services.defer(:site_finder) do
91
+ SiteFinder.new(services.repositories.site, services.request)
92
+ end
93
+ end
94
+ }
85
95
  end
86
96
  end
87
97
 
@@ -1,5 +1,5 @@
1
1
  module Locomotive
2
2
  module Wagon
3
- VERSION = '2.1.0.rc5'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |gem|
28
28
 
29
29
  gem.add_dependency 'locomotivecms_common', '~> 0.1.0'
30
30
  gem.add_dependency 'locomotivecms_coal', '~> 1.1.0'
31
- gem.add_dependency 'locomotivecms_steam', '~> 1.1.0.rc3'
31
+ gem.add_dependency 'locomotivecms_steam', '~> 1.1.0'
32
32
 
33
33
  gem.add_dependency 'listen', '~> 3.0.4'
34
34
  gem.add_dependency 'rack-livereload', '~> 0.3.16'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotivecms_wagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0.rc5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Didier Lafforgue
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-24 00:00:00.000000000 Z
12
+ date: 2016-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -115,14 +115,14 @@ dependencies:
115
115
  requirements:
116
116
  - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 1.1.0.rc3
118
+ version: 1.1.0
119
119
  type: :runtime
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 1.1.0.rc3
125
+ version: 1.1.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: listen
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -653,9 +653,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
653
653
  version: '0'
654
654
  required_rubygems_version: !ruby/object:Gem::Requirement
655
655
  requirements:
656
- - - ">"
656
+ - - ">="
657
657
  - !ruby/object:Gem::Version
658
- version: 1.3.1
658
+ version: '0'
659
659
  requirements: []
660
660
  rubyforge_project:
661
661
  rubygems_version: 2.4.5.1