mirror of
https://github.com/jimeh/jimeh.me-v3.0.git
synced 2026-02-19 05:46:40 +00:00
post tags, and tag pages
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
||||
assets
|
||||
assets/*
|
||||
public/*
|
||||
source/blog/tag/*
|
||||
|
||||
74
Rakefile
74
Rakefile
@@ -1,12 +1,40 @@
|
||||
$: << File.expand_path(File.join(File.dirname(__FILE__), "lib"))
|
||||
|
||||
require 'fileutils'
|
||||
|
||||
#
|
||||
# Config
|
||||
#
|
||||
|
||||
$server = "jimeh.me"
|
||||
$user = "jimeh"
|
||||
$path = "jimeh.me/www"
|
||||
SERVER = "jimeh.me"
|
||||
USER = "jimeh"
|
||||
|
||||
REMOTE_PATH = "jimeh.me/www"
|
||||
RSYNC_TARGET = "#{USER}@#{SERVER}:#{REMOTE_PATH}"
|
||||
|
||||
TAGS_DIR = "source/blog/tag"
|
||||
|
||||
SITE_SRC = "source/site"
|
||||
SITE_DEST = "public"
|
||||
|
||||
BLOG_SRC = "source/blog"
|
||||
BLOG_DEST = "public/blog"
|
||||
|
||||
#
|
||||
# Jekyll init
|
||||
#
|
||||
|
||||
namespace :jekyll do
|
||||
task :initialize do
|
||||
gem "jekyll"
|
||||
require "jekyll"
|
||||
require "jekyll/tags/post"
|
||||
require "jekyll/tags/related"
|
||||
@options = Jekyll.configuration("auto" => false, "source" => BLOG_SRC, "destination" => BLOG_DEST)
|
||||
@blog = Jekyll::Site.new(@options)
|
||||
@blog.read_posts("")
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Build tasks
|
||||
@@ -24,16 +52,31 @@ desc "Build site, excluding JavaScript libs."
|
||||
task :build => "build:default"
|
||||
|
||||
namespace :build do
|
||||
task :default do
|
||||
task :default => ["jekyll:initialize", "build:tags"] do
|
||||
system "jekyll ./source/site ./public"
|
||||
system "jekyll ./source/blog ./public/blog"
|
||||
@blog.process
|
||||
end
|
||||
|
||||
desc "Build tags"
|
||||
task :tags => "jekyll:initialize" do
|
||||
FileUtils.rm_rf(TAGS_DIR)
|
||||
FileUtils.mkdir_p(TAGS_DIR)
|
||||
tags = @blog.categories
|
||||
tags.each do |tag, posts|
|
||||
File.open(File.join(TAGS_DIR, tag + ".html"), "w") do |file|
|
||||
generate_index posts, file, "title" => "#{tag}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
desc "Compress JavaScript libs specified in the Jimfile."
|
||||
task :js do
|
||||
system "jim compress"
|
||||
end
|
||||
|
||||
desc "Build site and compress JavaScript libs"
|
||||
task :all => ["build", "build:js"]
|
||||
|
||||
end
|
||||
|
||||
desc "Sync assets into public folder for local testing."
|
||||
@@ -78,24 +121,24 @@ task :deploy => "deploy:default"
|
||||
|
||||
namespace :deploy do
|
||||
task :default do
|
||||
rsync "public/", "#{$user}@#{$server}:#{$path}"
|
||||
rsync "public/", RSYNC_TARGET
|
||||
end
|
||||
desc "Deploy assets folder to remote server."
|
||||
task :assets do
|
||||
rsync "assets/", "#{$user}@#{$server}:#{$path}"
|
||||
rsync "assets/", RSYNC_TARGET
|
||||
end
|
||||
desc "Deploy both public and assets folders to remote server."
|
||||
task :all => "build:all" do
|
||||
rsync ["public/", "assets/"], "#{$user}@#{$server}:#{$path}"
|
||||
rsync ["public/", "assets/"], RSYNC_TARGET
|
||||
end
|
||||
desc "Deploy all via rsync removing remote files that don't exist locally."
|
||||
task :clean => "build:all" do
|
||||
rsync ["public/", "assets/"], "#{$user}@#{$server}:#{$path}", ["--delete"]
|
||||
rsync ["public/", "assets/"], RSYNC_TARGET, ["--delete"]
|
||||
end
|
||||
desc "Reset remote files completely via 'rm -rf' and redeploy everything via rsync."
|
||||
task :reset => "build:all" do
|
||||
system "ssh #{$user}@#{$server} 'cd \"#{$path}\" && rm -rf ./* && rm -rf ./.*'"
|
||||
rsync ["public/", "assets/"], "#{$user}@#{$server}:#{$path}"
|
||||
system "ssh #{USER}@#{SERVER} 'cd \"#{REMOTE_PATH}\" && rm -rf ./* && rm -rf ./.*'"
|
||||
rsync ["public/", "assets/"], RSYNC_TARGET
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,3 +157,12 @@ def rsync(source, dest, options = [])
|
||||
system "rsync -vr #{options.join(" ")} #{source} #{dest}"
|
||||
end
|
||||
|
||||
def generate_index(posts, file, options = {})
|
||||
file.puts YAML.dump(options.merge({"layout" => "tag-page", "robots" => "noindex"}))
|
||||
file.puts "---"
|
||||
posts = posts.sort{|x, y| x.date <=> y.date }.reverse!
|
||||
output = posts.collect do |post|
|
||||
%{{% post #{post.url} %}}
|
||||
end.join("\n")
|
||||
file.puts(output)
|
||||
end
|
||||
|
||||
37
lib/jekyll/tags/post.rb
Normal file
37
lib/jekyll/tags/post.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
module Tomafro
|
||||
module Jekyll
|
||||
module Tags
|
||||
# {% post "2009/08/this-is-the-url" %}
|
||||
|
||||
class PostTag < Liquid::Tag
|
||||
def initialize(tag_name, url, tokens)
|
||||
super
|
||||
@url = url.strip
|
||||
@file = 'post-div.html'
|
||||
end
|
||||
|
||||
def render(context)
|
||||
context.stack do
|
||||
post = context.registers[:site].posts.detect {|x| x.url == @url }
|
||||
context.scopes.last['page'] = post
|
||||
context.scopes.last['body'] = post.content
|
||||
Dir.chdir(File.join(context.registers[:site].source, '_includes')) do
|
||||
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
||||
if choices.include?(@file)
|
||||
source = File.read(@file)
|
||||
partial = Liquid::Template.parse(source)
|
||||
context.stack do
|
||||
partial.render(context)
|
||||
end
|
||||
else
|
||||
"Included file '#{@file}' not found in _includes directory"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('post', Tomafro::Jekyll::Tags::PostTag)
|
||||
51
lib/jekyll/tags/related.rb
Normal file
51
lib/jekyll/tags/related.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
module Tomafro
|
||||
module Jekyll
|
||||
module Tags
|
||||
# {% post "2009/08/this-is-the-url" %}
|
||||
|
||||
class RelatedTag < Liquid::Tag
|
||||
def initialize(tag_name, url, tokens)
|
||||
super
|
||||
@url = url.strip
|
||||
@file = 'related-posts.markdown'
|
||||
end
|
||||
|
||||
def render(context)
|
||||
context.stack do
|
||||
site = context.registers[:site]
|
||||
post = site.posts.detect {|x| x.url == context['page']['url'] }
|
||||
related = post.categories.inject([]) do |memo, tag|
|
||||
memo << site.posts.select {|p| p.categories.include?(tag) }
|
||||
end
|
||||
related = (related.flatten.uniq - [post])
|
||||
|
||||
# top up related if less than 5 entries
|
||||
|
||||
if related.size < 7
|
||||
missing = 7 - related.size
|
||||
candidates = (site.posts - related - [post])
|
||||
related = related + candidates[0..missing]
|
||||
end
|
||||
|
||||
context.scopes.last['related'] = related
|
||||
|
||||
Dir.chdir(File.join(context.registers[:site].source, '_includes')) do
|
||||
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
||||
if choices.include?(@file)
|
||||
source = File.read(@file)
|
||||
partial = Liquid::Template.parse(source)
|
||||
context.stack do
|
||||
partial.render(context)
|
||||
end
|
||||
else
|
||||
"Included file '#{@file}' not found in _includes directory"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Liquid::Template.register_tag('related', Tomafro::Jekyll::Tags::RelatedTag)
|
||||
@@ -1,7 +1,7 @@
|
||||
auto: false
|
||||
destination: ../../public/blog
|
||||
markdown: rdiscount
|
||||
permalink: pretty
|
||||
permalink: /:year/:month/:day/:title
|
||||
paginate: 8
|
||||
pygments: true
|
||||
lsi: false
|
||||
4
source/blog/_includes/paginator-empty.html
Normal file
4
source/blog/_includes/paginator-empty.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<div class="post-paginator">
|
||||
<a href="/blog/archive/">archive</a><br />
|
||||
<a href="http://feeds.feedburner.com/jimeh">rss</a>
|
||||
</div>
|
||||
14
source/blog/_includes/paginator.html
Normal file
14
source/blog/_includes/paginator.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<div class="post-paginator">
|
||||
{% if paginator.total_pages > paginator.page %}
|
||||
<a href="/blog/page{{ paginator.next_page }}/" class="older">← older</a>
|
||||
{% endif %}
|
||||
{% if paginator.page > 1 %}
|
||||
{% if paginator.previous_page == 1 %}
|
||||
<a href="/blog/" class="newer">newer →</a>
|
||||
{% else %}
|
||||
<a href="/blog/page{{ paginator.previous_page }}" class="newer">newer →</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="/blog/archive/">archive</a><br />
|
||||
<a href="http://feeds.feedburner.com/jimeh">rss</a>
|
||||
</div>
|
||||
21
source/blog/_includes/post-div.html
Normal file
21
source/blog/_includes/post-div.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="post-item">
|
||||
<div class="post-meta">
|
||||
<p class="date">{{ page.date | date: "<i>%d</i><b>%b</b>" }}</p>
|
||||
</div>
|
||||
|
||||
<h1 class="post-title">
|
||||
<a href="/blog{{ page.url }}">{{ page.title }}</a>
|
||||
<div class="post-title-sub">
|
||||
by Jim Myhrberg – tags:
|
||||
{% for tag in page.categories %} <a href="/blog/tag/{{tag}}" rel="tag"><i class="hash">#</i>{{tag}}</a>{% if forloop.last != true %},{% endif %}{% endfor %}
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
<div class="post-content">
|
||||
{{ page.content }}
|
||||
</div>
|
||||
|
||||
<p class="post-comment-link">
|
||||
<a href="/blog{{ page.url }}#disqus_thread">Comments</a>
|
||||
</p>
|
||||
</div>
|
||||
@@ -34,7 +34,7 @@
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="recent-articles">
|
||||
<div class="section recent-articles">
|
||||
<h2>Recent Articles</h2>
|
||||
<dl class="labels">
|
||||
{% for post in site.posts limit:8 %}
|
||||
|
||||
@@ -19,20 +19,7 @@
|
||||
|
||||
{% include sidebar.html %}
|
||||
|
||||
<div class="post-paginator">
|
||||
{% if paginator.total_pages > paginator.page %}
|
||||
<a href="/blog/page{{ paginator.next_page }}/" class="older">← older</a>
|
||||
{% endif %}
|
||||
{% if paginator.page > 1 %}
|
||||
{% if paginator.previous_page == 1 %}
|
||||
<a href="/blog/" class="newer">newer →</a>
|
||||
{% else %}
|
||||
<a href="/blog/page{{ paginator.previous_page }}" class="newer">newer →</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a href="/blog/archive/">archive</a><br />
|
||||
<a href="http://feeds.feedburner.com/jimeh">rss</a>
|
||||
</div>
|
||||
{% include paginator.html %}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
|
||||
<h1 class="post-title">
|
||||
{{ page.title }}
|
||||
<span class="author">by Jim Myhrberg</span>
|
||||
<div class="post-title-sub">
|
||||
by Jim Myhrberg – tags:
|
||||
{% for tag in page.categories %} <a href="/blog/tag/{{tag}}" rel="tag"><i class="hash">#</i>{{tag}}</a>{% if forloop.last != true %},{% endif %}{% endfor %}
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
<div class="post-content">
|
||||
|
||||
26
source/blog/_layouts/tag-page.html
Normal file
26
source/blog/_layouts/tag-page.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% include _head.html %}
|
||||
|
||||
<div id="universe">
|
||||
|
||||
<div id="header">
|
||||
<div id="title">
|
||||
<a href="/blog/">blog</a> / {{ page.title }}
|
||||
</div>
|
||||
<div id="navigation">
|
||||
<a href="/">about</a>
|
||||
<a href="/blog/" class="selected">blog</a>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<div class="post-world">
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
{% include sidebar.html %}
|
||||
|
||||
{% include paginator-empty.html %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include _foot.html %}
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: New Site and Blog Powered by Dr. Jekyll
|
||||
categories: [technology, ruby, jekyll, git, rsync, disqus, font, design]
|
||||
---
|
||||
|
||||
I finally found some time to rebuild my site, and add a blog. I'm also working on a portfolio, which I will probably be putting up on [heartb.it][]. I haven't really decided how I'm gonna make the split between my personal site and work portfolio yet though.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: Automated Profile Picture Update Service?
|
||||
categories: [technology, web-service, idea]
|
||||
---
|
||||
|
||||
After I updated my [profile picture][avatar] today, a friend of mine [responded][tweet] with:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: New Avatar, Same Old Fugly Face
|
||||
categories: [personal]
|
||||
---
|
||||
|
||||
Today marks the day I update my online avatar/profile picture. I've had the same sepia colored half-face avatar for 4 or 5 years now. So it was about time for a change. However, the biggest reason I changed it, was cause I cut my hair short in November, after having long hair for about 10 years.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: About That “Pad” Thing
|
||||
categories: [technology, apple, ipad]
|
||||
---
|
||||
|
||||
So I was gonna write a post with my opinions about the iPad, but a cup of tea and staring at wall of wet paint is almost more tempting. If you don't get why the iPad is important, and why it will succeed, I'm not even gonna try convincing you otherwise, time will just prove you wrong and make you feel stupid.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: Was I Really “That” Social?
|
||||
categories: [personal, technology, social]
|
||||
---
|
||||
|
||||
As some of you might have noticed the last couple of days, I haven't been online much on IM networks. I'm not sure what originally kept me from launching Adium the other day, but along the way I've come to a realization.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: To Caffeinate, Or Not To Caffeinate?
|
||||
categories: [personal, productivity]
|
||||
---
|
||||
|
||||
I used to be a caffeine junkie. My caffeinated poison of choice was Coke, the <a href="http://files.jimeh.me/.blog/legal-coke-20100213-224302.png" class="fancybox" title="I look more like the ad...or, uhmm, used to.....">legal</a> kind, not the <a href="http://files.jimeh.me/.blog/illegal-coke-20100213-224557.png" class="fancybox">illegal</a> one.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: JavaScript Performance Wars
|
||||
categories: [technology, javascript, performance, web-browser]
|
||||
---
|
||||
|
||||
Is the difference between [Chrome][]'s [V8][] engine, and [WebKit][]'s [SquirrelFish Extreme][sfx] (SFX for short) significant enough that we need to care if we use Chrome or Safari/WebKit?
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
layout: post
|
||||
title: Built-in Sudo for Ruby Command-Line Tools
|
||||
categories: [technology, ruby, git, gist]
|
||||
---
|
||||
|
||||
I was looking through [my gists][gists] today on GitHub, and decided I'd do a couple of posts on some of the pieces of code I've put up there. The first of which is the `sudome` Ruby method.
|
||||
|
||||
@@ -3,23 +3,6 @@ layout: post-list
|
||||
title: jimeh / blog
|
||||
---
|
||||
|
||||
{% for post in paginator.posts %}
|
||||
<div class="post-item">
|
||||
<div class="post-meta">
|
||||
<p class="date">{{ post.date | date: "<i>%d</i><b>%b</b>" }}</p>
|
||||
</div>
|
||||
|
||||
<h1 class="post-title">
|
||||
<a href="/blog{{ post.url }}">{{ post.title }}</a>
|
||||
<span class="author">by Jim Myhrberg</span>
|
||||
</h1>
|
||||
|
||||
<div class="post-content">
|
||||
{{ post.content }}
|
||||
</div>
|
||||
|
||||
<p class="post-comment-link">
|
||||
<a href="/blog{{ post.url }}#disqus_thread">Comments</a>
|
||||
</p>
|
||||
</div>
|
||||
{% for page in paginator.posts %}
|
||||
{% include post-div.html %}
|
||||
{% endfor %}
|
||||
@@ -458,6 +458,8 @@ blockquote {
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group .sidebar */
|
||||
|
||||
.sidebar {
|
||||
float: right;
|
||||
width: 270px;
|
||||
@@ -466,6 +468,23 @@ blockquote {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* @group .section */
|
||||
|
||||
.sidebar .section {
|
||||
|
||||
}
|
||||
.sidebar .section h2 {
|
||||
font-size: 17px;
|
||||
margin-bottom: 3px;
|
||||
margin-left: 25px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
|
||||
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group .post-* */
|
||||
|
||||
.post-world {
|
||||
@@ -489,12 +508,27 @@ blockquote {
|
||||
.post-title a:hover {
|
||||
border-bottom: 1px dotted #ccc !important;
|
||||
}
|
||||
.post-title .author {
|
||||
|
||||
/* @end */
|
||||
|
||||
/* @group .post-title-sub */
|
||||
|
||||
.post-title-sub {
|
||||
color: #bbb;
|
||||
font-size: 13px;
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
left: 0px;
|
||||
}
|
||||
.post-title-sub a {
|
||||
color: #bbb;
|
||||
font-size: 13px;
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
left: 0px;
|
||||
}
|
||||
.post-title-sub a:hover {
|
||||
border-color: #bbb !important;
|
||||
}
|
||||
.post-title-sub .hash {
|
||||
color: #eee;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
@@ -690,11 +724,6 @@ blockquote {
|
||||
.recent-articles {
|
||||
font-size: 13px;
|
||||
}
|
||||
.recent-articles h2 {
|
||||
font-size: 17px;
|
||||
margin-bottom: 3px;
|
||||
margin-left: 25px;
|
||||
}
|
||||
.recent-articles ul {
|
||||
color: #ddd;
|
||||
list-style: none;
|
||||
|
||||
Reference in New Issue
Block a user