Created
April 13, 2010 08:14
-
-
Save kez/364416 to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ @@site_url = 'http://www.mysite.com' task :cloud_basic do puts 'Generating tag cloud...' -
There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,112 @@ task :cloud_basic do puts 'Generating tag cloud...' require 'rubygems' require 'jekyll' include Jekyll::Filters options = Jekyll.configuration({}) site = Jekyll::Site.new(options) site.read_posts('') html = '' site.categories.sort.each do |category, posts| s = posts.count font_size = 12 + (s*1.2); html << "<a href=\"#{@@site_url}/tag/#{category}/\" title=\"Pages tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\" rel=\"tag\">#{category}</a> " end File.open('_includes/tags.html', 'w+') do |file| file.puts html end puts 'Done.' end task :cloud do 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: Tags type: A tag cloud --- <h1>Tag cloud for {{site.title}}</h1> <p>Click on a tag to see the relevant posts.</p> HTML site.categories.sort.each do |category, posts| next if category == ".net" html << <<-HTML HTML s = posts.count font_size = 12 + (s*1.5); html << "<a href=\"#{@@site_url}/tag/#{category}/\" title=\"Entries tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\">#{category}</a> " end html << "<p>You may also wish to browse the <a href=\"#{@@site_url}/archives/\" title=\"Archives for {{site.title}}\">archives</a>." File.open('tags/index.html', 'w+') do |file| file.puts html end puts 'Done.' end desc 'Generate tags page' task :tags do puts "Generating tags..." require 'rubygems' require 'jekyll' include Jekyll::Filters options = Jekyll.configuration({}) site = Jekyll::Site.new(options) site.read_posts('') site.categories.sort.each do |category, posts| next if category == ".net" html = '' html << <<-HTML --- layout: default title: Entries tagged "#{category}" type: "#{category.gsub(/\b\w/){$&.upcase}}" --- <h1 id="#{category}">Entries tagged "#{category}"</h1> <a href="#{@@site_url}/tags/" title="Tag cloud for {{site.title}}">« Show all tags...</a> HTML html << '<ul class="posting_list">' posts.each do |post| post_data = post.to_liquid html << <<-HTML <li><a href="#{@@site_url}/#{post.url}" rel="tag" title="Entries tagged #{post_data['title']}">#{post_data['title']}</a></li> HTML end html << '</ul>' html << '<p>You may also be interested in browsing the <a href="#'+@@site_url+'/archives/" title="Archives for {{site.title}}">archives</a> or seeing <a href="'+@@site_url+'/tags/" title="Tag cloud for {{site.title}}">the tag cloud for {{site.title}}</a>.' FileUtils.mkdir_p "tag/#{category}" File.open("tag/#{category}/index.html", 'w+') do |file| file.puts html end end puts 'Done.' end