Last active
December 31, 2015 11:28
-
-
Save robertbrook/7979391 to your computer and use it in GitHub Desktop.
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 'rake/clean' | |
require 'redcarpet' | |
require 'erb' | |
CLEAN.include '*.html' | |
# https://sites.google.com/site/spontaneousderivation/rake-quick-reference#TOC-Defining-Tasks | |
# https://github.com/sivers/sivers.org/blob/master/Rakefile | |
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true) | |
template_string = %q[ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<title><%= @title %></title> | |
<meta content='width=device-width, initial-scale=1.0' name='viewport'> | |
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-8"> | |
<div class="page-header"> | |
<h1><%= @title %> <small>hello world</small></h1> | |
</div> | |
<%= @source %> | |
<hr> | |
</div> | |
</div> | |
<address class="text-muted"> | |
<strong>Robert Brook</strong> LONDON<br> | |
[email protected] | |
</address> | |
</div> | |
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> | |
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> | |
</body> | |
</html> | |
] | |
desc "build" | |
task :build do | |
FileList['*.txt'].each do |file| | |
@source = markdown.render(File.read(file)) | |
@title = file.pathmap('%n') | |
template = ERB.new(template_string) | |
result = template.result | |
File.open(file.ext('html'), 'w') {|html| html.write(result) } | |
# p "Writing #{file.ext('html')}" | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment