forked from weusethat/we-use-that
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrakefile.rb
106 lines (103 loc) · 2.09 KB
/
rakefile.rb
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
desc 'Generate tags page'
task :tags do
puts "Generating tag pages..."
require 'rubygems'
require 'jekyll'
require 'fileutils'
include Jekyll::Filters
FileUtils.rm_rf("tags/.", secure: true)
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
interview_content = <<-HTML
---
layout: default
title: Interviews
---
<div class="interviews">
<div class="interview-index">
<h2>All interviews:</h2>
<ol>
HTML
site.posts.sort.reverse.each do |post|
post_data = post.to_liquid
interview_content << <<-HTML
<li>
<a href="#{ post.url }">
#{ post_data['title'] }
</a>
</li>
HTML
end
interview_content << <<-HTML
</ol>
</div>
<div class="tags">
<h2>All tags:</h2>
HTML
site.tags.sort.each do |tag, posts|
interview_content << <<-HTML
<a href="/tags/#{ tag }">
<div class="tag">
#{ tag }
</div>
</a>
HTML
html = ''
html = <<-HTML
---
layout: default
title: "#{tag.capitalize}"
---
<div class="featured-interviews">
HTML
posts.reverse.each do |post|
post_data = post.to_liquid
html << <<-HTML
<div class="featured-interview">
<a href="#{post.url}">
<img src="/images/featured#{ post.url }.png">
</a>
<a href="#{ post.url }">
<div class="title">
#{post_data['title']}
</div>
</a>
<div class="subtitle">
#{post_data['subtitle']}
</div>
<div class="posted-date">
Posted on #{ post.date.strftime("%Y-%m-%d") } in
</div>
<div class="tags">
HTML
post.tags.each do |tag|
html << <<-HTML
<a href="/tags/#{ tag }">
<div class="tag">
#{ tag }
</div>
</a>
HTML
end
html << <<-HTML
</div>
</div>
HTML
end
html << <<-HTML
</div>
HTML
File.open("tags/#{tag}.html", 'w+') do |file|
file.puts html
end
end
interview_content << <<-HTML
</div>
</div>
HTML
File.open("interviews.html", 'w') do |file|
file.puts interview_content
end
puts 'Done.'
end