merge frontmatter fix

This commit is contained in:
Thomas Reynolds 2013-01-11 17:00:41 -08:00
parent a76b02a55b
commit 277f1b5bb4
3 changed files with 31 additions and 10 deletions

View file

@ -1,6 +1,22 @@
Master
===
3.0.10
====
* Avoid looking in binary files for frontmatter. #728
* Allow nested i18n files. #725
* Better adapt to Rack interface. #709
3.0.9
====
* Lock Rack to 1.4.1 until BodyProxy bug is resolved. #709
* Safely de-register Tilt extensions which are missing gems. #713
3.0.8
====
* Directly send binary files in preview and copy them in build, avoiding reading large binary files into memory for rendering. #643 #699
3.0.7

View file

@ -19,6 +19,9 @@ group :test do
gem "liquid", "~> 2.2"
# gem "cane"
gem "pry"
gem "pry-debugger"
platforms :ruby do
gem "therubyracer", "0.10.2"

View file

@ -13,12 +13,7 @@ module Middleman
# Needed for helpers as well
app.after_configuration do
locales_glob = File.join(config[:locales_dir], "*.yml");
::I18n.load_path += Dir[File.join(root, locales_glob)]
::I18n.reload!
Localizer.new(self, locales_glob, options)
Localizer.new(self, options)
end
end
alias :included :registered
@ -29,12 +24,19 @@ module Middleman
attr_reader :app
delegate :logger, :to => :app
def initialize(app, locales_glob, options={})
def initialize(app, options={})
@app = app
@locales_glob = locales_glob
@locales_glob = File.join(app.locales_dir, "**", "*.{rb,yml}")
regex = @locales_glob.sub(/\./, '\.').sub(File.join("**", "*"), ".*").sub(/\//, '\/').sub("{rb,yml}", "rb|yml")
@locales_regex = %r{^#{regex}}
@maps = {}
@options = options
::I18n.load_path += Dir[File.join(app.root, @locales_glob)]
::I18n.reload!
@lang_map = @options[:lang_map] || {}
@path = @options[:path] || "/:locale/"
@templates_dir = @options[:templates_dir] || "localizable"
@ -71,7 +73,7 @@ module Middleman
end
def on_file_changed(file)
if File.fnmatch(@locales_glob, file)
if @locales_regex.match(file)
::I18n.reload!
end
end
@ -79,7 +81,7 @@ module Middleman
def langs
@options[:langs] || begin
Dir[File.join(@app.root, @locales_glob)].map { |file|
File.basename(file).gsub(".yml", "")
File.basename(file).sub(/\.yml$/, "").sub(/\.rb$/, "")
}.sort.map(&:to_sym)
end
end