commit
c8c6a1938e
9 changed files with 130 additions and 136 deletions
|
@ -99,27 +99,20 @@ module Middleman::Cli
|
|||
# Ignore following method
|
||||
desc "", "", :hide => true
|
||||
|
||||
# Render a template to a file.
|
||||
# Render a page to a file.
|
||||
#
|
||||
# @param [String] source
|
||||
# @param [String] destination
|
||||
# @param [Hash] config
|
||||
# @return [String] the actual destination file path that was created
|
||||
def tilt_template(source, destination, config={})
|
||||
# @param [Middleman::Sitemap::Page] page
|
||||
# @return [void]
|
||||
def tilt_template(page)
|
||||
build_dir = self.class.shared_instance.build_dir
|
||||
request_path = destination.sub(/^#{build_dir}/, "")
|
||||
config[:force] = true
|
||||
output_file = File.join(self.class.shared_instance.build_dir, page.destination_path)
|
||||
|
||||
begin
|
||||
destination, request_path = self.class.shared_instance.reroute_builder(destination, request_path)
|
||||
|
||||
response = self.class.shared_rack.get(request_path.gsub(/\s/, "%20"))
|
||||
|
||||
create_file(destination, response.body, config)
|
||||
|
||||
destination
|
||||
response = self.class.shared_rack.get(page.request_path.gsub(/\s/, "%20"))
|
||||
create_file(output_file, response.body, { :force => true })
|
||||
rescue
|
||||
say_status :error, destination, :red
|
||||
say_status :error, output_file, :red
|
||||
puts $!
|
||||
abort
|
||||
end
|
||||
end
|
||||
|
@ -213,6 +206,8 @@ module Middleman::Cli
|
|||
# Sort paths to be built by the above order. This is primarily so Compass can
|
||||
# find files in the build folder when it needs to generate sprites for the
|
||||
# css files
|
||||
|
||||
# TODO: deal with pages, not paths
|
||||
paths = @app.sitemap.all_paths.sort do |a, b|
|
||||
a_ext = File.extname(a)
|
||||
b_ext = File.extname(b)
|
||||
|
@ -225,21 +220,15 @@ module Middleman::Cli
|
|||
|
||||
# Loop over all the paths and build them.
|
||||
paths.each do |path|
|
||||
file_source = path
|
||||
file_destination = File.join(given_destination, file_source.gsub(source, '.'))
|
||||
file_destination.gsub!('/./', '/')
|
||||
page = @app.sitemap.page(path)
|
||||
|
||||
if @app.sitemap.proxied?(file_source)
|
||||
file_source = @app.sitemap.page(file_source).proxied_to
|
||||
elsif @app.sitemap.page(file_source).ignored?
|
||||
next
|
||||
end
|
||||
|
||||
next if @config[:glob] && !File.fnmatch(@config[:glob], file_source)
|
||||
next if page.ignored?
|
||||
next if @config[:glob] && !File.fnmatch(@config[:glob], path)
|
||||
|
||||
file_destination = base.tilt_template(file_source, file_destination)
|
||||
base.tilt_template(page)
|
||||
|
||||
@cleaning_queue.delete(Pathname.new(file_destination).realpath) if cleaning?
|
||||
output_path = File.join(@destination, page.destination_path)
|
||||
@cleaning_queue.delete(Pathname.new(output_path).realpath) if cleaning?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue