-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathRakefile
76 lines (65 loc) · 1.83 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
task :default => "site:generate"
task :server => "site:jekyll:server"
task :clean => "site:clean"
namespace :site do
task :jekyll => :pre do
sh "PATH=$PATH:~/.gem/ruby/1.8/bin jekyll --bluecloth --permalink shortdate"
end
task :pre do
require 'jekyll'
require 'bluecloth'
Jekyll.markdown_proc = Proc.new { |x| BlueCloth.new(x).to_html }
site = Jekyll::Site.new('.', File.join('.', '_site'))
site.read_posts('.')
topics = site.posts.collect do |post|
post.topics
end.flatten.uniq!
FileUtils.mkdir_p("tags")
topics.each do |topic|
tag_template =<<-END
---
layout: default
title: "Tag archive: #{topic}"
---
{% for post in site.topics.#{topic} %}
<div class="item">
<div class="item_details">
<h3><a href="{{ post.url }}">{{ post.title }}</h3>
<h4>Posted on <a href="{{ post.url }}" title="Permalink for this post">{{ post.date | date_to_string }}</a></h4>
</div>
<div class="item_content">
{{ post.content }}
</div>
<div class="item_meta">
<span class="item_tags">
Tags:
{% for topic in post.topics %}
<a href="http://www.paperplanes.de/tags/{{ topic }}.html" title="View posts tagged with "{{ topic }}"">{{ topic }}</a>{% if forloop.last != true %}, {% endif %}
{% endfor %}
</span>
</div>
</div>
{% endfor %}
</ul>
END
File.open("tags/#{topic}.html", "w") do |f|
f.write(tag_template)
end
end
end
namespace :jekyll do
task :server do
sh "jekyll --bluecloth --permalink shortdate --server --auto"
end
end
task :purge do
sh "rm _site/Capfile _site/README.markdown _site/Rakefile"
end
task :generate => ["jekyll", "purge"]
task :clean do
sh "rm -rf _site"
end
end
task :publish do
sh "git push origin master && cap deploy "
end