Created
July 26, 2010 01:21
-
-
Save drio/490066 to your computer and use it in GitHub Desktop.
blosxom jekyll ruby
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
#!/usr/bin/env ruby | |
# | |
require 'find' | |
require 'fileutils' | |
i_dir = ARGV[0] | |
o_dir = "./output" | |
header = <<END | |
--- | |
layout: POST | |
title: XTITLEX | |
-- | |
END | |
FileUtils.mkdir_p o_dir | |
Find.find(i_dir) do |p| | |
if p =~ /txt$/ | |
title = p.split("/")[-1].match(/(.+)\.txt$/)[1] | |
m_time = File::Stat.new(p).mtime.strftime("%Y-%m-%d") | |
content = header + File.open(p).read | |
n_file = "./output/" + m_time + "." + title + ".html" | |
File.open(n_file, "w") {|f| f.puts content.gsub(/XTITLEX/, title)} | |
end | |
end | |
__END__ | |
Comments: | |
From blosxom to jekyll: | |
Pass a dir (output ?) | |
Find all the txt | |
Per each txt (tcpWindowSize.txt) | |
Create output/2007-07-25.title.html | |
--- | |
layout: post | |
title: tz | |
-- | |
>> content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment