-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
executable file
·55 lines (48 loc) · 1.34 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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|
html = ''
html << <<-CONTENT
---
layout: default
title: Postings tagged "#{category}"
---
<div class="Nav">
<span class='Arrow'>‣</span>
<a href="http://kodfabrik.com">Homepage</a>
<span class='Arrow'>‣</span>
<a href='/'>Blog</a>
<span class='Arrow'>‣</span>
Tags
<span class='Arrow'>‣</span>
#{category}
</div>
{% for page in site.categories.#{category} %}
{% include post.html %}
{% endfor %}
CONTENT
File.open("tags/#{category}.html", 'w+') do |file|
file.puts html
end
end
html = '<div class="TagCloud">'
site.categories.sort.each do |category, posts|
rank = Integer(posts.count*1.5)
size = 14+rank
rgb = [rand(150),rand(150),rand(150)]
rgb[rand(3)] += rank*20
html << "<a href='/tags/#{category}.html' class='Tag' style='font-size:#{size}px; color:rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})'>#{category}</a> "
end
html << '</div>'
File.open("_includes/tagcloud.html",'w+') do |file|
file.puts html
end
puts 'Done.'
end