Created
March 25, 2011 10:37
-
-
Save robertbrook/886667 to your computer and use it in GitHub Desktop.
siter.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redcloth' | |
require 'erb' | |
task :default => [:test] | |
TEXTFILES = FileList['**/*.txt'] | |
desc "list txt files" | |
task :test do | |
puts TEXTFILES | |
end | |
template = ERB.new %q{<!doctype html> | |
<html> | |
<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> | |
<title>a page</title> | |
<style>body {font-family:"Helvetica Neue",helvetica,sans-serif;width:480px;margin:40px auto;line-height:140%;font-size:1.8em;font-weight:bold;} | |
address {font-style:normal;} | |
h1 {color:crimson;} | |
</style></head> | |
<body><header></header><section><%= clothed %></section><footer><address>[email protected]</address></footer></body> | |
</html>} | |
desc "redclothing" | |
task :red do | |
TEXTFILES.each do |txt_file| | |
clothed = RedCloth.new(IO.read(txt_file)).to_html | |
File.open(txt_file.ext("html"), "w") do |f| | |
f.write template.result(binding) | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment