Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 139 lines (115 sloc) 2.842 kB
ddf1779 @bogdan Rakefile improved
authored
1 require 'rubygems'
2 require 'jekyll'
3 require "fileutils"
4 require "sass/plugin"
5
dad2272 @bogdan Build 2011-05-20T14:50:11+03:00
authored
6 def f(name)
7 File.dirname(__FILE__) + "/" + name
8 end
9
c703e07 @bogdan Build 2011-05-20T15:59:05+03:00
authored
10 def sass
11 directory = File.dirname(__FILE__) + "/css"
12 Sass::Plugin.options[:template_location] = directory
13 Sass::Plugin.options[:css_location] = directory
14 Sass::Plugin.check_for_updates
15 end
16
7e168ed @bogdan Build 2011-06-06T10:21:24+03:00
authored
17 def build_git(command)
18 puts "git --work-tree=#{f "build"} --git-dir=#{f "build/.git"} #{command}"
19 puts `git --work-tree=#{f "build"} --git-dir=#{f "build/.git"} #{command}`
20 end
21
ea926fc @bogdan Build 2011-05-23T12:13:45+03:00
authored
22 desc "Start development mode"
ddf1779 @bogdan Rakefile improved
authored
23 task :dev => :build do
dd77843 @bogdan Rakefile
authored
24 c = Thread.new do
c703e07 @bogdan Build 2011-05-20T15:59:05+03:00
authored
25 while true do
26 sass
27 sleep(1)
28 end
dd77843 @bogdan Rakefile
authored
29 end
30 j = Thread.new do
0300652 @bogdan posts preview
authored
31 `ejekyll --server --auto`
dd77843 @bogdan Rakefile
authored
32 end
33 sleep(1)
34 c.join
35 j.join
36 end
d2c9840 @bogdan Do
authored
37
ea926fc @bogdan Build 2011-05-23T12:13:45+03:00
authored
38 desc "Build static content"
ddf1779 @bogdan Rakefile improved
authored
39 task :build => [:tags, :cloud, :sass] do
dad2272 @bogdan Build 2011-05-20T14:50:11+03:00
authored
40 unless File.exists? f("build")
41 FileUtils.mkdir_p(f("build"))
42 `git clone gh:bogdan/bogdan.github.com build`
854a320 @bogdan Static content
authored
43 end
44 begin
45 FileUtils.mkdir_p(f("tmp"))
46 FileUtils.mv(f("build/.git"), f("tmp"))
dad2272 @bogdan Build 2011-05-20T14:50:11+03:00
authored
47 puts `ejekyll --no-auto build`
854a320 @bogdan Static content
authored
48 ensure
49 FileUtils.mv(f("tmp/.git"), f("build"))
50 end
ddf1779 @bogdan Rakefile improved
authored
51 end
52
7e168ed @bogdan Build 2011-06-06T10:21:24+03:00
authored
53 namespace :build do
54 desc "Clean build modifications"
55 task :clean do
56 build_git "checkout ."
57 build_git "fetch origin"
58 build_git "merge origin/master"
59 end
60 end
61
ea926fc @bogdan Build 2011-05-23T12:13:45+03:00
authored
62 desc "Upload build to github"
7e168ed @bogdan Build 2011-06-06T10:21:24+03:00
authored
63 task :upload => ["build:clean", :build] do
64 build_git "add ."
65 build_git "commit -m 'Build #{DateTime.now.to_s}'"
66 build_git "push"
dad2272 @bogdan Build 2011-05-20T14:50:11+03:00
authored
67 end
68
d2c9840 @bogdan Do
authored
69 desc 'Generate tags page'
70 task :tags do
71 puts "Generating tags..."
72
73 include Jekyll::Filters
74
75 FileUtils.mkdir_p("tags")
76 options = Jekyll.configuration({})
77 site = Jekyll::Site.new(options)
78 site.read_posts('')
79 site.tags.sort.each do |tag, posts|
80 html = ''
81 html << <<-HTML
82 ---
83 layout: tag
84 title: Posts tagged "#{tag}"
85 ---
86 <h1 id="#{tag}">Posts tagged "#{tag}"</h1>
87 HTML
88
89 html << '<ul class="posts">'
90 posts.each do |post|
91 post_data = post.to_liquid
92 html << <<-HTML
93 <li><a href="#{post.url}">#{post_data['title']}</a></li>
94 HTML
95 end
96 html << '</ul>'
97
98 File.open("tags/#{tag}.html", 'w+') do |file|
99 file.puts html
100 end
101 end
102 puts 'Done.'
103 end
104
105
ea926fc @bogdan Build 2011-05-23T12:13:45+03:00
authored
106 desc "Generate tag cloud"
ddf1779 @bogdan Rakefile improved
authored
107 task :cloud do
d2c9840 @bogdan Do
authored
108 puts 'Generating tag cloud...'
109 include Jekyll::Filters
110
111 options = Jekyll.configuration({})
112 site = Jekyll::Site.new(options)
113 site.read_posts('')
114
115 html = ''
116
117 site.tags.sort.each do |category, posts|
118
119 s = posts.count
120 if s > 1
121 font_size = 14 + (s*1.8);
e5005b6 @bogdan fix tags
authored
122 html << "<a href=\"/tags/#{category}.html\" title=\"Pages tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\" rel=\"tag\">#{category}</a> \n"
d2c9840 @bogdan Do
authored
123 end
124 end
125
ddf1779 @bogdan Rakefile improved
authored
126 File.open('_includes/cloud.html', 'w') do |file|
d2c9840 @bogdan Do
authored
127 file.puts html
128 end
129
130 puts 'Done.'
131 end
132
ea926fc @bogdan Build 2011-05-23T12:13:45+03:00
authored
133 desc "Compile SASS"
ddf1779 @bogdan Rakefile improved
authored
134 task :sass do
c703e07 @bogdan Build 2011-05-20T15:59:05+03:00
authored
135 sass
ddf1779 @bogdan Rakefile improved
authored
136 end
d2c9840 @bogdan Do
authored
137
138
Something went wrong with that request. Please try again.