Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed critical bug, added a few minor features #1

Merged
merged 1 commit into from

2 participants

@simensen

This was not working because the filename (and only the filename) was being added to the YAML front matter. I think this was probably a typo and is an easy fix.

While I was at it I added the ability to save tag information as well. I have it set to use the categories key by default for tags, but some people may want to actually import the information as tags instead. In that case, they can specify a specific key.

You did a great job with this and I'd very much like to see #402 accepted. This patch will fix a bug and add a tiny bit of functionality. If you accept and merge this it should automatically be included in #402.

@simensen simensen YAML front matter fix, cleaned up slug generation, added tags and sto…
…re some posterous information from the original post.
840b0c1
@alagu alagu merged commit 20385b5 into alagu:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 26, 2011
  1. @simensen

    YAML front matter fix, cleaned up slug generation, added tags and sto…

    simensen authored
    …re some posterous information from the original post.
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/jekyll/migrators/posterous.rb
View
18 lib/jekyll/migrators/posterous.rb
@@ -6,7 +6,7 @@
require 'uri'
require "json"
-# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_token, blog)'
+# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_token, blog, tags_key)'
# You can find your api token in posterous api page - http://posterous.com/api . Click on any of the 'view token' links to see your token.
# blog is optional, by default it is the primary one
@@ -33,7 +33,7 @@ def self.fetch(uri_str, limit = 10)
end
end
- def self.process(email, pass, api_token, blog = 'primary')
+ def self.process(email, pass, api_token, blog = 'primary', tags_key = 'categories')
@email, @pass , @api_token = email, pass, api_token
FileUtils.mkdir_p "_posts"
@@ -43,24 +43,32 @@ def self.process(email, pass, api_token, blog = 'primary')
while posts.any?
posts.each do |post|
title = post["title"]
- slug = title.gsub(/[^[:alnum:]]+/, '-').downcase
+ slug = title.gsub(/[^[:alnum:]]+/, '-').gsub(/^-+|-+$/, '').downcase
+ posterous_slug = post["slug"]
date = Date.parse(post["display_date"])
content = post["body_html"]
published = !post["is_private"]
name = "%02d-%02d-%02d-%s.html" % [date.year, date.month, date.day, slug]
+ tags = []
+ post["tags"].each do |tag|
+ tags.push(tag["name"])
+ end
# Get the relevant fields as a hash, delete empty fields and convert
# to YAML for the header
data = {
'layout' => 'post',
'title' => title.to_s,
- 'published' => published
+ 'published' => published,
+ tags_key => tags,
+ 'posterous_url' => post["full_url"],
+ 'posterous_slug' => posterous_slug
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
# Write out the data and content to file
File.open("_posts/#{name}", "w") do |f|
puts name
- f.puts name
+ f.puts data
f.puts "---"
f.puts content
end
Something went wrong with that request. Please try again.