diff --git a/.gitignore b/.gitignore index 2e2251a..b740f93 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ assets assets/* public/* +source/blog/tag/* diff --git a/Rakefile b/Rakefile index bdb8534..a462c35 100644 --- a/Rakefile +++ b/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 diff --git a/lib/jekyll/tags/post.rb b/lib/jekyll/tags/post.rb new file mode 100644 index 0000000..759f26f --- /dev/null +++ b/lib/jekyll/tags/post.rb @@ -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) diff --git a/lib/jekyll/tags/related.rb b/lib/jekyll/tags/related.rb new file mode 100644 index 0000000..1832042 --- /dev/null +++ b/lib/jekyll/tags/related.rb @@ -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) diff --git a/source/blog/_config.yml b/source/blog/_config.yml index cc79dd7..e104bf1 100644 --- a/source/blog/_config.yml +++ b/source/blog/_config.yml @@ -1,7 +1,7 @@ auto: false destination: ../../public/blog markdown: rdiscount -permalink: pretty +permalink: /:year/:month/:day/:title paginate: 8 pygments: true lsi: false \ No newline at end of file diff --git a/source/blog/_includes/paginator-empty.html b/source/blog/_includes/paginator-empty.html new file mode 100644 index 0000000..eee6ea4 --- /dev/null +++ b/source/blog/_includes/paginator-empty.html @@ -0,0 +1,4 @@ +
+ archive
+ rss +
\ No newline at end of file diff --git a/source/blog/_includes/paginator.html b/source/blog/_includes/paginator.html new file mode 100644 index 0000000..a95a6eb --- /dev/null +++ b/source/blog/_includes/paginator.html @@ -0,0 +1,14 @@ +
+ {% if paginator.total_pages > paginator.page %} + ← older + {% endif %} + {% if paginator.page > 1 %} + {% if paginator.previous_page == 1 %} + newer → + {% else %} + newer → + {% endif %} + {% endif %} + archive
+ rss +
\ No newline at end of file diff --git a/source/blog/_includes/post-div.html b/source/blog/_includes/post-div.html new file mode 100644 index 0000000..656fff2 --- /dev/null +++ b/source/blog/_includes/post-div.html @@ -0,0 +1,21 @@ +
+
+

{{ page.date | date: "%d%b" }}

+
+ +

+ {{ page.title }} +
+ by Jim Myhrberg – tags: + {% for tag in page.categories %} {% if forloop.last != true %},{% endif %}{% endfor %} +
+

+ +
+ {{ page.content }} +
+ +

+ Comments +

+
\ No newline at end of file diff --git a/source/blog/_includes/sidebar.html b/source/blog/_includes/sidebar.html index 575a209..cb14150 100644 --- a/source/blog/_includes/sidebar.html +++ b/source/blog/_includes/sidebar.html @@ -34,7 +34,7 @@ -
+

Recent Articles

{% for post in site.posts limit:8 %} diff --git a/source/blog/_layouts/post-list.html b/source/blog/_layouts/post-list.html index a321f64..6857ca4 100644 --- a/source/blog/_layouts/post-list.html +++ b/source/blog/_layouts/post-list.html @@ -19,20 +19,7 @@ {% include sidebar.html %} -
- {% if paginator.total_pages > paginator.page %} - ← older - {% endif %} - {% if paginator.page > 1 %} - {% if paginator.previous_page == 1 %} - newer → - {% else %} - newer → - {% endif %} - {% endif %} - archive
- rss -
+ {% include paginator.html %}
diff --git a/source/blog/_layouts/post.html b/source/blog/_layouts/post.html index c614749..1ed506b 100644 --- a/source/blog/_layouts/post.html +++ b/source/blog/_layouts/post.html @@ -21,7 +21,10 @@

{{ page.title }} - by Jim Myhrberg +
+ by Jim Myhrberg – tags: + {% for tag in page.categories %} {% if forloop.last != true %},{% endif %}{% endfor %} +

diff --git a/source/blog/_layouts/tag-page.html b/source/blog/_layouts/tag-page.html new file mode 100644 index 0000000..611f60a --- /dev/null +++ b/source/blog/_layouts/tag-page.html @@ -0,0 +1,26 @@ +{% include _head.html %} + +
+ + + +
+ {{ content }} +
+ + {% include sidebar.html %} + + {% include paginator-empty.html %} + +
+ +{% include _foot.html %} \ No newline at end of file diff --git a/source/blog/_posts/2010-02-03-new-site-and-blog-powered-by-dr-jekyll.md b/source/blog/_posts/2010-02-03-new-site-and-blog-powered-by-dr-jekyll.md index 1eafd08..9170012 100644 --- a/source/blog/_posts/2010-02-03-new-site-and-blog-powered-by-dr-jekyll.md +++ b/source/blog/_posts/2010-02-03-new-site-and-blog-powered-by-dr-jekyll.md @@ -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. diff --git a/source/blog/_posts/2010-02-05-automated-profile-picture-update-server.md b/source/blog/_posts/2010-02-05-automated-profile-picture-update-server.md index dc7d499..c032494 100644 --- a/source/blog/_posts/2010-02-05-automated-profile-picture-update-server.md +++ b/source/blog/_posts/2010-02-05-automated-profile-picture-update-server.md @@ -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: diff --git a/source/blog/_posts/2010-02-05-new-avatar-same-old-fugly-face.md b/source/blog/_posts/2010-02-05-new-avatar-same-old-fugly-face.md index 896cd76..3193c42 100644 --- a/source/blog/_posts/2010-02-05-new-avatar-same-old-fugly-face.md +++ b/source/blog/_posts/2010-02-05-new-avatar-same-old-fugly-face.md @@ -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. diff --git a/source/blog/_posts/2010-02-06-about-that-pad-thing.md b/source/blog/_posts/2010-02-06-about-that-pad-thing.md index a04d94b..5d7d808 100644 --- a/source/blog/_posts/2010-02-06-about-that-pad-thing.md +++ b/source/blog/_posts/2010-02-06-about-that-pad-thing.md @@ -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. diff --git a/source/blog/_posts/2010-02-10-was-i-really-that-social.md b/source/blog/_posts/2010-02-10-was-i-really-that-social.md index 43beed3..67dd86f 100644 --- a/source/blog/_posts/2010-02-10-was-i-really-that-social.md +++ b/source/blog/_posts/2010-02-10-was-i-really-that-social.md @@ -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. diff --git a/source/blog/_posts/2010-02-14-to-caffeinate-or-not-to-caffeinate.md b/source/blog/_posts/2010-02-14-to-caffeinate-or-not-to-caffeinate.md index 7cf70a7..db38f5b 100644 --- a/source/blog/_posts/2010-02-14-to-caffeinate-or-not-to-caffeinate.md +++ b/source/blog/_posts/2010-02-14-to-caffeinate-or-not-to-caffeinate.md @@ -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 legal kind, not the illegal one. diff --git a/source/blog/_posts/2010-02-19-javascript-performance-wars.md b/source/blog/_posts/2010-02-19-javascript-performance-wars.md index 1a8cf09..9825a64 100644 --- a/source/blog/_posts/2010-02-19-javascript-performance-wars.md +++ b/source/blog/_posts/2010-02-19-javascript-performance-wars.md @@ -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? diff --git a/source/blog/_posts/2010-02-22-built-in-sudo-for-ruby-command-line-tools.md b/source/blog/_posts/2010-02-22-built-in-sudo-for-ruby-command-line-tools.md index 7c1bc4d..4d8c02b 100644 --- a/source/blog/_posts/2010-02-22-built-in-sudo-for-ruby-command-line-tools.md +++ b/source/blog/_posts/2010-02-22-built-in-sudo-for-ruby-command-line-tools.md @@ -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. diff --git a/source/blog/index.html b/source/blog/index.html index db58c29..f18ee5c 100644 --- a/source/blog/index.html +++ b/source/blog/index.html @@ -3,23 +3,6 @@ layout: post-list title: jimeh / blog --- -{% for post in paginator.posts %} -
- - -

- {{ post.title }} - by Jim Myhrberg -

- -
- {{ post.content }} -
- -

- Comments -

-
+{% for page in paginator.posts %} + {% include post-div.html %} {% endfor %} \ No newline at end of file diff --git a/source/site/stylesheets/master.css b/source/site/stylesheets/master.css index 4e5d37a..296b47c 100644 --- a/source/site/stylesheets/master.css +++ b/source/site/stylesheets/master.css @@ -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;