diff --git a/Rakefile b/Rakefile index bd7ea63..225a2e8 100644 --- a/Rakefile +++ b/Rakefile @@ -3,9 +3,119 @@ task :dev do `compass watch --sass-dir css --css-dir css` end j = Thread.new do - `jekyll --server` + `jekyll --server --auto` end sleep(1) c.join j.join end + +desc 'Generate tags page' +task :tags do + puts "Generating tags..." + require 'rubygems' + require 'jekyll' + require "fileutils" + + include Jekyll::Filters + + FileUtils.mkdir_p("tags") + options = Jekyll.configuration({}) + site = Jekyll::Site.new(options) + site.read_posts('') + site.tags.sort.each do |tag, posts| + html = '' + html << <<-HTML +--- +layout: tag +title: Posts tagged "#{tag}" +--- +

Posts tagged "#{tag}"

+ HTML + + html << '' + + File.open("tags/#{tag}.html", 'w+') do |file| + file.puts html + end + end + puts 'Done.' +end + + +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.tags.sort.each do |category, posts| + + s = posts.count + if s > 1 + font_size = 14 + (s*1.8); + html << "#{category} \n" + end + 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 +--- + +

Tag cloud for {{site.title}}

+ +

Click on a tag to see the relevant posts.

+ HTML + + site.categories.sort.each do |category, posts| + html << <<-HTML + HTML + + s = posts.count + font_size = 12 + (s*1.5); + html << "#{category} " + end + + + + File.open('tags/index.html', 'w+') do |file| + file.puts html + end + + puts 'Done.' +end diff --git a/_includes/tags.html b/_includes/tags.html new file mode 100644 index 0000000..5c04d68 --- /dev/null +++ b/_includes/tags.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/_layouts/default.html b/_layouts/default.html index d5dd5b7..f6a8976 100644 --- a/_layouts/default.html +++ b/_layouts/default.html @@ -60,8 +60,9 @@

Recent Posts

-
+

Browse by tags

+ {% include tags.html %}
diff --git a/_layouts/post.html b/_layouts/post.html index 30c3e8c..85b3875 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -4,11 +4,12 @@

{{ page.title }}

{{ content }} -
- {% for category in page.categories %} +

+ Tags + {% for category in page.tags %} {{ category }} {% endfor %} -

+