use private before filters, leave sinatra alone. fixes #76
This commit is contained in:
parent
be506c60cc
commit
292ec97bd8
6 changed files with 84 additions and 55 deletions
|
@ -23,25 +23,27 @@ module Middleman::CoreExtensions::FrontMatter
|
|||
::Tilt.prefer(HamlTemplate)
|
||||
|
||||
app.after_feature_init do
|
||||
app.before do
|
||||
app.before_processing do
|
||||
result = resolve_template(request.path_info, :raise_exceptions => false)
|
||||
|
||||
|
||||
if result && Tilt.mappings.has_key?(result[1].to_s)
|
||||
extensionless_path, template_engine = result
|
||||
full_file_path = "#{extensionless_path}.#{template_engine}"
|
||||
system_path = File.join(settings.views, full_file_path)
|
||||
data, content = app.parse_front_matter(File.read(system_path))
|
||||
|
||||
|
||||
request['custom_options'] = {}
|
||||
%w(layout layout_engine).each do |opt|
|
||||
if data.has_key?(opt)
|
||||
request['custom_options'][opt.to_sym] = data.delete(opt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Forward remaining data to helpers
|
||||
app.data_content("page", data)
|
||||
end
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,8 +4,9 @@ module Middleman::CoreExtensions::Routing
|
|||
app.extend ClassMethods
|
||||
|
||||
# Normalize the path and add index if we're looking at a directory
|
||||
app.before do
|
||||
app.before_processing do
|
||||
request.path_info = self.class.path_to_index(request.path)
|
||||
true
|
||||
end
|
||||
end
|
||||
alias :included :registered
|
||||
|
@ -43,7 +44,7 @@ module Middleman::CoreExtensions::Routing
|
|||
|
||||
paths = [url]
|
||||
paths << "#{url}/" if url.length > 1 && url.split("/").last.split('.').length <= 1
|
||||
paths << "#{path_to_index(url)}"
|
||||
paths << "/#{path_to_index(url)}"
|
||||
|
||||
options[:layout] = settings.layout if options[:layout].nil?
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue