middleman-more 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,37 @@ Feature: i18n Preview
|
|
18
18
|
Then I should see "Como Esta?"
|
19
19
|
When I go to "/es/hola.html"
|
20
20
|
Then I should see "Hola World"
|
21
|
-
|
21
|
+
|
22
|
+
Scenario: A template changes i18n during preview
|
23
|
+
Given a fixture app "i18n-test-app"
|
24
|
+
And a file named "config.rb" with:
|
25
|
+
"""
|
26
|
+
activate :i18n
|
27
|
+
"""
|
28
|
+
Given the Server is running at "i18n-test-app"
|
29
|
+
And the file "locales/en.yml" has the contents
|
30
|
+
"""
|
31
|
+
---
|
32
|
+
en:
|
33
|
+
greetings: "Howdy"
|
34
|
+
hi: "Hello"
|
35
|
+
"""
|
36
|
+
When I go to "/"
|
37
|
+
Then I should see "Howdy"
|
38
|
+
When I go to "/hello.html"
|
39
|
+
Then I should see "Hello World"
|
40
|
+
When the file "locales/en.yml" has the contents
|
41
|
+
"""
|
42
|
+
---
|
43
|
+
en:
|
44
|
+
greetings: "How You Doin"
|
45
|
+
hi: "Sup"
|
46
|
+
"""
|
47
|
+
When I go to "/"
|
48
|
+
Then I should see "How You Doin"
|
49
|
+
When I go to "/hello.html"
|
50
|
+
Then I should see "Sup World"
|
51
|
+
|
22
52
|
Scenario: Running localize with the alt path config
|
23
53
|
Given a fixture app "i18n-test-app"
|
24
54
|
And a file named "config.rb" with:
|
@@ -13,10 +13,12 @@ module Middleman
|
|
13
13
|
|
14
14
|
# Needed for helpers as well
|
15
15
|
app.after_configuration do
|
16
|
-
|
16
|
+
locales_glob = File.join(locales_dir, "*.yml");
|
17
|
+
|
18
|
+
::I18n.load_path += Dir[File.join(root, locales_glob)]
|
17
19
|
::I18n.reload!
|
18
20
|
|
19
|
-
Localizer.new(self, options)
|
21
|
+
Localizer.new(self, locales_glob, options)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
alias :included :registered
|
@@ -27,8 +29,9 @@ module Middleman
|
|
27
29
|
attr_reader :app
|
28
30
|
delegate :logger, :to => :app
|
29
31
|
|
30
|
-
def initialize(app, options={})
|
32
|
+
def initialize(app, locales_glob, options={})
|
31
33
|
@app = app
|
34
|
+
@locales_glob = locales_glob
|
32
35
|
@maps = {}
|
33
36
|
@options = options
|
34
37
|
|
@@ -62,11 +65,20 @@ module Middleman
|
|
62
65
|
:i18n,
|
63
66
|
self
|
64
67
|
)
|
68
|
+
|
69
|
+
@app.files.changed(&method(:on_file_changed))
|
70
|
+
@app.files.deleted(&method(:on_file_changed))
|
71
|
+
end
|
72
|
+
|
73
|
+
def on_file_changed(file)
|
74
|
+
if File.fnmatch(@locales_glob, file)
|
75
|
+
::I18n.reload!
|
76
|
+
end
|
65
77
|
end
|
66
78
|
|
67
79
|
def langs
|
68
80
|
@options[:langs] || begin
|
69
|
-
Dir[File.join(@app.root, @
|
81
|
+
Dir[File.join(@app.root, @locales_glob)].map { |file|
|
70
82
|
File.basename(file).gsub(".yml", "")
|
71
83
|
}.sort.map(&:to_sym)
|
72
84
|
end
|
@@ -4,6 +4,9 @@ module Middleman
|
|
4
4
|
class << self
|
5
5
|
def registered(app, options={})
|
6
6
|
require 'digest/sha1'
|
7
|
+
require 'rack/test'
|
8
|
+
require 'uri'
|
9
|
+
|
7
10
|
exts = options[:exts] || %w(.jpg .jpeg .png .gif .js .css)
|
8
11
|
|
9
12
|
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
@@ -36,16 +39,12 @@ module Middleman
|
|
36
39
|
next unless @exts.include? resource.ext
|
37
40
|
next if @ignore.any? { |ignore| Middleman::Util.path_match(ignore, resource.destination_path) }
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
|
42
|
+
# Render through the Rack interface so middleware and mounted apps get a shot
|
43
|
+
rack_client = ::Rack::Test::Session.new(@app.class)
|
44
|
+
response = rack_client.get(URI.escape(resource.destination_path), {}, { "bypass_asset_hash" => true })
|
45
|
+
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
|
44
46
|
|
45
|
-
|
46
|
-
else # if it's a static file, just hash it
|
47
|
-
digest = Digest::SHA1.file(resource.source_file).hexdigest[0..7]
|
48
|
-
end
|
47
|
+
digest = Digest::SHA1.hexdigest(response.body)[0..7]
|
49
48
|
|
50
49
|
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
|
51
50
|
end
|
@@ -40,7 +40,7 @@ module Middleman::Extensions
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def self.gzip_file(path)
|
43
|
-
input_file = File.open(path, '
|
43
|
+
input_file = File.open(path, 'rb').read
|
44
44
|
output_filename = path + '.gz'
|
45
45
|
input_file_time = File.mtime(path)
|
46
46
|
|
@@ -49,7 +49,7 @@ module Middleman::Extensions
|
|
49
49
|
return
|
50
50
|
end
|
51
51
|
|
52
|
-
File.open(output_filename, '
|
52
|
+
File.open(output_filename, 'wb') do |f|
|
53
53
|
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
|
54
54
|
gz.mtime = input_file_time.to_i
|
55
55
|
gz.write input_file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman-core
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - '='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.0.
|
22
|
+
version: 3.0.6
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - '='
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version: 3.0.
|
30
|
+
version: 3.0.6
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: uglifier
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
@@ -632,7 +632,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
632
632
|
version: '0'
|
633
633
|
segments:
|
634
634
|
- 0
|
635
|
-
hash:
|
635
|
+
hash: -3726525610890072589
|
636
636
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
637
637
|
none: false
|
638
638
|
requirements:
|
@@ -641,10 +641,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
641
641
|
version: '0'
|
642
642
|
segments:
|
643
643
|
- 0
|
644
|
-
hash:
|
644
|
+
hash: -3726525610890072589
|
645
645
|
requirements: []
|
646
646
|
rubyforge_project:
|
647
|
-
rubygems_version: 1.8.
|
647
|
+
rubygems_version: 1.8.23
|
648
648
|
signing_key:
|
649
649
|
specification_version: 3
|
650
650
|
summary: Hand-crafted frontend development
|