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 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 * 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 3.0.7

View file

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

View file

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