Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
45 lines (38 sloc) 972 Bytes
require "rdiscount"
require "mustache"
require "active_support/core_ext/string"
require "fileutils"
def generate(page, template = "site/page.ms")
Mustache.render(
File.read(template),
page.merge(:content => RDiscount.new(File.read(page[:src])).to_html)
)
end
task :generate do
pages = Dir["chapters/*.md"].inject([]) do |array, src|
array << ({
:src => src,
:static => File.basename(src, ".md") + ".html",
:name => File.basename(src, ".md").gsub(/\d+_/, "").titleize,
:href => File.basename(src, ".md") + ".html"
})
array
end
pages.each do |page|
File.open(page[:static], "w+") do |f|
f.write generate(page)
end
end
File.open("index.html", "w+") do |f|
f.write(Mustache.render(
File.read("site/index.ms"),
:pages => pages
))
end
File.open("all.html", "w+") do |f|
pages.each do |page|
f.write generate(page)
end
end
end
task :default => :generate