Skip to content

Instantly share code, notes, and snippets.

@kez
Created December 23, 2009 13:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kez/262518 to your computer and use it in GitHub Desktop.
Save kez/262518 to your computer and use it in GitHub Desktop.
puts 'Generating tag cloud...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
html =<<-HTML
---
layout: default
title: Tag cloud
---
<h1>Tag cloud</h1>
HTML
site.categories.sort.each do |category, posts|
html << <<-HTML
HTML
s = posts.count
font_size = 12 + (s*1.5);
html << "<a href=\"/tags/#{category}.html\" title=\"Postings tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\">#{category}</a> "
end
File.open('tags.html', 'w+') do |file|
file.puts html
end
puts 'Done.'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment