-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
85 lines (69 loc) · 1.75 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
require 'rubygems'
require 'bundler/setup'
require 'fileutils'
require 'jekyll'
$: << File.dirname( __FILE__)
task :generate_tags do
puts 'Generating tags...'
include Jekyll::Filters
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
html =<<-HTML
---
layout: default
title: Tags
---
<ul class="breadcrumb">
<li class="home"><a href="/">Home</a></li>
<li>Tags</li>
</ul>
<h2>Tags</h2>
HTML
site.categories.sort.each do |category, posts|
html << <<-HTML
<h3 id="#{category}">#{category}</h3>
HTML
html << '<ul class="posts">'
posts.each do |post|
post_data = post.to_liquid
html << <<-HTML
<li>
<div>#{date_to_string post.date}</div>
<a href="#{post.url}">#{post_data['title']}</a>
</li>
HTML
end
html << '</ul>'
end
File.open('tags.html', 'w+') do |file|
file.puts html
end
puts 'Done.'
end
task :tag_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 = ''
max_count = site.categories.map{|t,p| p.count}.max
site.categories.sort.each do |tag, posts|
s = posts.count
font_size = ((20 - 10.0*(max_count-s)/max_count)*2).to_i/2.0
html << "<a href=\"/tags##{tag}\" title=\"Postings tagged #{tag}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\">#{tag}</a> "
end
File.open('_includes/tag_cloud.html', 'w+') do |file|
file.puts html
end
puts 'Done.'
end
task :prepare_release do
puts 'Preparing to release site...'
Rake::Task[:generate_tags].invoke
Rake::Task[:tag_cloud].invoke
end
task :default => :prepare_release