Skip to content

Commit

Permalink
Do
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan committed May 18, 2011
1 parent 3a1b92e commit d2c9840
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 17 deletions.
112 changes: 111 additions & 1 deletion Rakefile
Expand Up @@ -3,9 +3,119 @@ task :dev do
`compass watch --sass-dir css --css-dir css`
end
j = Thread.new do
`jekyll --server`
`jekyll --server --auto`
end
sleep(1)
c.join
j.join
end

desc 'Generate tags page'
task :tags do
puts "Generating tags..."
require 'rubygems'
require 'jekyll'
require "fileutils"

include Jekyll::Filters

FileUtils.mkdir_p("tags")
options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')
site.tags.sort.each do |tag, posts|
html = ''
html << <<-HTML
---
layout: tag
title: Posts tagged "#{tag}"
---
<h1 id="#{tag}">Posts tagged "#{tag}"</h1>
HTML

html << '<ul class="posts">'
posts.each do |post|
post_data = post.to_liquid
html << <<-HTML
<li><a href="#{post.url}">#{post_data['title']}</a></li>
HTML
end
html << '</ul>'

File.open("tags/#{tag}.html", 'w+') do |file|
file.puts html
end
end
puts 'Done.'
end


task :cloud_basic do
puts 'Generating tag cloud...'
require 'rubygems'
require 'jekyll'
include Jekyll::Filters

options = Jekyll.configuration({})
site = Jekyll::Site.new(options)
site.read_posts('')

html = ''

site.tags.sort.each do |category, posts|

s = posts.count
if s > 1
font_size = 14 + (s*1.8);
html << "<a href=\"/tag/#{category}/\" title=\"Pages tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\" rel=\"tag\">#{category}</a> \n"
end
end

File.open('_includes/tags.html', 'w+') do |file|
file.puts html
end

puts 'Done.'
end


task :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 =<<-HTML
---
layout: default
title: Tags
type: A tag cloud
---
<h1>Tag cloud for {{site.title}}</h1>
<p>Click on a tag to see the relevant posts.</p>
HTML

site.categories.sort.each do |category, posts|
html << <<-HTML
HTML

s = posts.count
font_size = 12 + (s*1.5);
html << "<a href=\"/tags/#{category}/\" title=\"Entries tagged #{category}\" style=\"font-size: #{font_size}px; line-height:#{font_size}px\">#{category}</a> "
end



File.open('tags/index.html', 'w+') do |file|
file.puts html
end

puts 'Done.'
end
21 changes: 21 additions & 0 deletions _includes/tags.html
@@ -0,0 +1,21 @@
<a href="/tag/activerecord/" title="Pages tagged activerecord" style="font-size: 19.4px; line-height:19.4px" rel="tag">activerecord</a>
<a href="/tag/application/" title="Pages tagged application" style="font-size: 17.6px; line-height:17.6px" rel="tag">application</a>
<a href="/tag/bdd/" title="Pages tagged bdd" style="font-size: 17.6px; line-height:17.6px" rel="tag">bdd</a>
<a href="/tag/behavior/" title="Pages tagged behavior" style="font-size: 17.6px; line-height:17.6px" rel="tag">behavior</a>
<a href="/tag/criticism/" title="Pages tagged criticism" style="font-size: 23.0px; line-height:23.0px" rel="tag">criticism</a>
<a href="/tag/database/" title="Pages tagged database" style="font-size: 19.4px; line-height:19.4px" rel="tag">database</a>
<a href="/tag/howto/" title="Pages tagged howto" style="font-size: 21.2px; line-height:21.2px" rel="tag">howto</a>
<a href="/tag/html/" title="Pages tagged html" style="font-size: 19.4px; line-height:19.4px" rel="tag">html</a>
<a href="/tag/idea/" title="Pages tagged idea" style="font-size: 17.6px; line-height:17.6px" rel="tag">idea</a>
<a href="/tag/java/" title="Pages tagged java" style="font-size: 19.4px; line-height:19.4px" rel="tag">java</a>
<a href="/tag/javascript/" title="Pages tagged javascript" style="font-size: 21.2px; line-height:21.2px" rel="tag">javascript</a>
<a href="/tag/named_scope/" title="Pages tagged named_scope" style="font-size: 17.6px; line-height:17.6px" rel="tag">named_scope</a>
<a href="/tag/pattern/" title="Pages tagged pattern" style="font-size: 17.6px; line-height:17.6px" rel="tag">pattern</a>
<a href="/tag/programming/" title="Pages tagged programming" style="font-size: 21.2px; line-height:21.2px" rel="tag">programming</a>
<a href="/tag/query/" title="Pages tagged query" style="font-size: 17.6px; line-height:17.6px" rel="tag">query</a>
<a href="/tag/rails/" title="Pages tagged rails" style="font-size: 19.4px; line-height:19.4px" rel="tag">rails</a>
<a href="/tag/rspec/" title="Pages tagged rspec" style="font-size: 21.2px; line-height:21.2px" rel="tag">rspec</a>
<a href="/tag/ruby/" title="Pages tagged ruby" style="font-size: 24.8px; line-height:24.8px" rel="tag">ruby</a>
<a href="/tag/sql/" title="Pages tagged sql" style="font-size: 17.6px; line-height:17.6px" rel="tag">sql</a>
<a href="/tag/test/" title="Pages tagged test" style="font-size: 17.6px; line-height:17.6px" rel="tag">test</a>
<a href="/tag/usability/" title="Pages tagged usability" style="font-size: 17.6px; line-height:17.6px" rel="tag">usability</a>
3 changes: 2 additions & 1 deletion _layouts/default.html
Expand Up @@ -60,8 +60,9 @@ <h2>Recent Posts</h2>
<!--<input type="submit" class="submitbutton" value="Find it" />-->
<!--</form> -->
<!--</div>-->
<div class="sidebarbox">
<div class="sidebarbox tag-cloud">
<h2>Browse by tags</h2>
{% include tags.html %}
</div>
</div><!-- Closes Sidebar_full -->
<div class="clear"></div>
Expand Down
7 changes: 4 additions & 3 deletions _layouts/post.html
Expand Up @@ -4,11 +4,12 @@
<div id="post">
<h2>{{ page.title }}</h2>
{{ content }}
<div class="tags">
{% for category in page.categories %}
<h4 class="tags">
<strong>Tags</strong>
{% for category in page.tags %}
<a href="/tags/{{ category }}.html">{{ category }}</a>
{% endfor %}
</div>
</h4>

<div id="related">
<h3>Related Posts</h3>
Expand Down
16 changes: 11 additions & 5 deletions css/default.css
Expand Up @@ -78,30 +78,36 @@ ul li ul li {
}
/* line 54, css/default.sass */
.recent-posts .rss {
margin-top: 10px;
display: inline-block;
float: right;
}

/* line 59, css/default.sass */
/* line 60, css/default.sass */
.pages {
margin: 35px 60px;
float: left;
}
/* line 62, css/default.sass */
/* line 63, css/default.sass */
.pages a {
padding: 0 20px;
}

/* line 66, css/default.sass */
/* line 67, css/default.sass */
.tags {
margin: 10px 0;
}
/* line 68, css/default.sass */
/* line 69, css/default.sass */
.tags a {
margin: 0 10px;
}

/* line 71, css/default.sass */
/* line 72, css/default.sass */
.header {
float: left;
}

/* line 76, css/default.sass */
.tag-cloud a {
margin: 0 2px;
}
4 changes: 4 additions & 0 deletions css/default.sass
Expand Up @@ -72,3 +72,7 @@ ul
.header
float: left

.tag-cloud
a
margin: 0 2px

37 changes: 30 additions & 7 deletions index.html
Expand Up @@ -2,12 +2,35 @@
layout: default
title: Move along, nothing to see here
---
{% for post in site.posts %}
<div class="post">
<h2>
<a href='{{ post.url }}'>{{ post.title }}</a>
</h2>
{{ post.content }}
</div>
{% for post in paginator.posts %}
<div class="post">
<h2>
<a href='{{ post.url }}'>{{ post.title }}</a>
</h2>
{{ post.content }}
</div>
{% endfor %}

<div class='paginator'>
{% if paginator.next_page %}
<div class='paginator-next'>
<a href='/?page={{paginator.next_page}}'>
Earlier posts &rarr;
</a>
</div>
{% endif %}
{% if paginator.previous_page %}
<div class='paginator-prev'>
{% if paginator.previous_page==1 %}
<a href='/page{{paginator.previous_page}}'>
&larr; Later posts
</a>
{% else %}
<a href='/'>
&larr; Later posts
</a>
{% endif %}
</div>
{% endif %}
<div class='clear'></div>
</div>

0 comments on commit d2c9840

Please sign in to comment.