Skip to content

Instantly share code, notes, and snippets.

@practicingruby
Created August 6, 2008 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save practicingruby/4176 to your computer and use it in GitHub Desktop.
Save practicingruby/4176 to your computer and use it in GitHub Desktop.
def self.generate
entries = Dir["#{Blaag::BASEDIR}/entries/**/*"].
reject { |f| File.directory?(f) }
entries.map! { |e| Entry.load(e) }
@blaag = Blaag.new(entries)
File.open("#{Blaag::BASEDIR}/www/index.html","w") { |f|
f << layout { @blaag.to_html }
}
File.open("#{Blaag::BASEDIR}/www/rss.xml","w") { |f|
f << @blaag.to_rss
}
@blaag.entries.each do |e|
FileUtils.mkdir_p "#{Blaag::BASEDIR}/www/archives/#{e.archive}"
File.open("#{Blaag::BASEDIR}/www/archives/"+
"#{e.archive}/#{e.file}.html","w") { |f|
f << layout { e.to_html }
}
end
build_archive_indices(@blaag.entries)
end
def self.build_archive_indices(entries)
archives = Hash.new { |h,k| h[k] = [] }
entries.each do |e|
archives[e.archive] << e
end
archives.each do |arch, entries|
@top_entries = entries.sort_by { |e| e.published_date }.reverse
File.open("#{Blaag::BASEDIR}/www/archives/"+
"#{arch}/index.html","w") { |f|
f << layout { ProcessTemplate("blog") }
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment