Really fixing extensionless file support
Pieced together a fix using Regex and `File.extname` from http://github.com/vast/rocco Closes GH-24.
This commit is contained in:
parent
515966dcc9
commit
ba93d23634
@ -90,7 +90,7 @@ end
|
|||||||
# Run each file through Rocco and write output.
|
# Run each file through Rocco and write output.
|
||||||
sources.each do |filename|
|
sources.each do |filename|
|
||||||
rocco = Rocco.new(filename, sources, options)
|
rocco = Rocco.new(filename, sources, options)
|
||||||
dest = File.join(output_dir, (filename.split('.')[0..-2].empty? ? filename : filename.split('.')[0..-2].join('.')) + '.html')
|
dest = File.join(output_dir, filename.sub(Regexp.new("#{File.extname(filename)}$"),".html"))
|
||||||
puts "rocco: #{filename} -> #{dest}"
|
puts "rocco: #{filename} -> #{dest}"
|
||||||
FileUtils.mkdir_p File.dirname(dest)
|
FileUtils.mkdir_p File.dirname(dest)
|
||||||
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
File.open(dest, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||||
|
@ -38,9 +38,9 @@ class Rocco::Layout < Mustache
|
|||||||
def sources
|
def sources
|
||||||
@doc.sources.sort.map do |source|
|
@doc.sources.sort.map do |source|
|
||||||
{
|
{
|
||||||
:path => source,
|
:path => source,
|
||||||
:basename => File.basename(source),
|
:basename => File.basename(source),
|
||||||
:url => File.basename(source).split('.')[0..-2].join('.') + '.html'
|
:url => source.sub( Regexp.new( "#{File.extname(source)}$"), ".html" )
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -70,7 +70,7 @@ class Rocco
|
|||||||
# Run over the source file list, constructing destination filenames
|
# Run over the source file list, constructing destination filenames
|
||||||
# and defining file tasks.
|
# and defining file tasks.
|
||||||
@sources.each do |source_file|
|
@sources.each do |source_file|
|
||||||
dest_file = File.basename(source_file).split('.')[0..-2].join('.') + '.html'
|
dest_file = source_file.sub(Regexp.new("#{File.extname(source_file)}$"), ".html")
|
||||||
define_file_task source_file, "#{@dest}#{dest_file}"
|
define_file_task source_file, "#{@dest}#{dest_file}"
|
||||||
|
|
||||||
# If `rake/clean` was required, add the generated files to the list.
|
# If `rake/clean` was required, add the generated files to the list.
|
||||||
@ -103,6 +103,7 @@ class Rocco
|
|||||||
file dest_file => prerequisites do |f|
|
file dest_file => prerequisites do |f|
|
||||||
verbose { puts "rocco: #{source_file} -> #{dest_file}" }
|
verbose { puts "rocco: #{source_file} -> #{dest_file}" }
|
||||||
rocco = Rocco.new(source_file, @sources.to_a, @options)
|
rocco = Rocco.new(source_file, @sources.to_a, @options)
|
||||||
|
FileUtils.mkdir_p(File.dirname(dest_file))
|
||||||
File.open(dest_file, 'wb') { |fd| fd.write(rocco.to_html) }
|
File.open(dest_file, 'wb') { |fd| fd.write(rocco.to_html) }
|
||||||
end
|
end
|
||||||
task @name => dest_file
|
task @name => dest_file
|
||||||
|
Loading…
Reference in New Issue
Block a user