From 717a2540e1c6612872d54aef52132c40f41ca3b5 Mon Sep 17 00:00:00 2001 From: lukebayes Date: Thu, 30 Dec 2010 16:41:34 -0800 Subject: [PATCH 01/55] Added support for 'include' configuration parameter. This parameter should work just like 'exclude', except it gives us the ability to enumerate any files that should not be ignored - even if they begin with the dastardly dot or underscore. --- lib/jekyll.rb | 1 + lib/jekyll/site.rb | 5 +++-- test/test_site.rb | 12 ++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 7928850c..7df782cd 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -64,6 +64,7 @@ module Jekyll 'pygments' => false, 'markdown' => 'maruku', 'permalink' => 'date', + 'include' => ['.htaccess'], 'maruku' => { 'use_tex' => false, diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 55b5c9d4..5a2b69d2 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -2,7 +2,7 @@ module Jekyll class Site attr_accessor :config, :layouts, :posts, :pages, :static_files, - :categories, :exclude, :source, :dest, :lsi, :pygments, + :categories, :exclude, :include, :source, :dest, :lsi, :pygments, :permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts attr_accessor :converters, :generators @@ -22,6 +22,7 @@ module Jekyll self.pygments = config['pygments'] self.permalink_style = config['permalink'].to_sym self.exclude = config['exclude'] || [] + self.include = config['include'] || [] self.future = config['future'] self.limit_posts = config['limit_posts'] || nil @@ -263,7 +264,7 @@ module Jekyll # files such as '.htaccess' def filter_entries(entries) entries = entries.reject do |e| - unless ['.htaccess'].include?(e) + unless self.include.include?(e) ['.', '_', '#'].include?(e[0..0]) || e[-1..-1] == '~' || self.exclude.include?(e) end end diff --git a/test/test_site.rb b/test/test_site.rb index d8d1057e..0c63f3ac 100644 --- a/test/test_site.rb +++ b/test/test_site.rb @@ -126,12 +126,20 @@ class TestSite < Test::Unit::TestCase should "filter entries with exclude" do excludes = %w[README TODO] - includes = %w[index.html site.css] + files = %w[index.html site.css .htaccess] @site.exclude = excludes - assert_equal includes, @site.filter_entries(excludes + includes) + assert_equal files, @site.filter_entries(excludes + files) end + should "not filter entries within include" do + includes = %w[_index.html .htaccess] + files = %w[index.html _index.html .htaccess] + + @site.include = includes + assert_equal files, @site.filter_entries(files) + end + context 'with orphaned files in destination' do setup do clear_dest From 2f9d4f5be623f37ca79adf84de83fcc3a1c757d6 Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Sat, 5 Feb 2011 12:25:32 +0000 Subject: [PATCH 02/55] Allow setting default mimetype for --server. Useful if permalinks don't end in .html --- bin/jekyll | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/jekyll b/bin/jekyll index 984aa43b..40437fd5 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -44,6 +44,10 @@ opts = OptionParser.new do |opts| options['baseurl'] = baseurl end + opts.on("--default-mimetype [MT]", "Mimetype to use when no file extension (if --server)") do |mt| + options['default-mimetype'] = mt + end + opts.on("--[no-]lsi", "Use LSI for better related posts") do |lsi| options['lsi'] = lsi end @@ -177,6 +181,9 @@ if options['server'] mime_types = WEBrick::HTTPUtils::DefaultMimeTypes mime_types.store 'js', 'application/javascript' + if options['default-mimetype'] + mime_types.store nil, options['default-mimetype'] + end s = HTTPServer.new( :Port => options['server_port'], From 3468f0a2c3643c0417d52feb895da7ef2d7a47d2 Mon Sep 17 00:00:00 2001 From: laumann Date: Wed, 9 Feb 2011 01:37:30 +0100 Subject: [PATCH 03/55] expanded config yaml to allow setting hard_breaks=false on RedCloth, modified textile converter to take this option into account --- lib/jekyll.rb | 3 +++ lib/jekyll/converters/textile.rb | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 7928850c..59cd1dec 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -90,6 +90,9 @@ module Jekyll 'coderay_bold_every' => 10, 'coderay_css' => 'style' } + }, + 'redcloth' => { + 'hard_breaks' => true } } diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 072e393a..21e1ab49 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -26,7 +26,11 @@ module Jekyll def convert(content) setup - RedCloth.new(content).to_html + r = RedCloth.new(content) + if !@config['redcloth']['hard_breaks'] + r.hard_breaks = false + end + r.to_html end end From 3f889ef077b9157666664205bb484de3efcea4ca Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Wed, 23 Mar 2011 18:17:14 +0100 Subject: [PATCH 04/55] added test case to hard_breaks (disable/enable in _config.yml) --- lib/jekyll/converters/textile.rb | 8 +++++--- test/test_redcloth.rb | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 test/test_redcloth.rb diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 21e1ab49..347ab197 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -27,9 +27,11 @@ module Jekyll def convert(content) setup r = RedCloth.new(content) - if !@config['redcloth']['hard_breaks'] - r.hard_breaks = false - end + r.hard_breaks = @config['redcloth']['hard_breaks'] + # if @config['redcloth']['hard_breaks'] == false + # STDERR.puts 'hards_breaks disabled' + # r.hard_breaks = false + # end r.to_html end end diff --git a/test/test_redcloth.rb b/test/test_redcloth.rb new file mode 100644 index 00000000..9fd32be1 --- /dev/null +++ b/test/test_redcloth.rb @@ -0,0 +1,33 @@ +require File.dirname(__FILE__) + '/helper' + +class TestRedCloth < Test::Unit::TestCase + context "RedCloth with hard_breaks enabled" do + setup do + config = { + 'redcloth' => { + 'hard_breaks' => true # default + } + } + @textile = TextileConverter.new config + end + + should "preserve single line breaks in HTML output" do + assert_equal "

line1
\nline2

", @textile.convert("p. line1\nline2").strip + end + end + + context "RedCloth with hard_breaks disabled" do + setup do + config = { + 'redcloth' => { + 'hard_breaks' => false + } + } + @textile = TextileConverter.new config + end + + should "not generate break tags in HTML output" do + assert_equal "

line1\nline2

", @textile.convert("p. line1\nline2").strip + end + end +end From ef7b4aa57aac400f3a9132ea3b3da7e2b98fec30 Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Wed, 6 Apr 2011 14:18:55 +0200 Subject: [PATCH 05/55] added test_redcloth to gemspec --- jekyll.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/jekyll.gemspec b/jekyll.gemspec index bf9bb663..444605ad 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -133,6 +133,7 @@ Gem::Specification.new do |s| test/test_rdiscount.rb test/test_site.rb test/test_tags.rb + test/test_redcloth.rb ] # = MANIFEST = From ed7f914459bc8710005535214c48803442524794 Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Thu, 7 Jul 2011 11:29:40 +0200 Subject: [PATCH 06/55] removed unused code --- lib/jekyll/converters/textile.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 6433dbb5..4b507996 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -29,10 +29,6 @@ module Jekyll setup r = RedCloth.new(content) r.hard_breaks = @config['redcloth']['hard_breaks'] - # if @config['redcloth']['hard_breaks'] == false - # STDERR.puts 'hards_breaks disabled' - # r.hard_breaks = false - # end r.to_html end end From 1356e75811db42f5aa9596cf73acc8ec38ea1a3c Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Sun, 10 Jul 2011 23:56:51 +0200 Subject: [PATCH 07/55] Generate escaped url for categories with space. Space in URLs should be encoded. Signed-off-by: Laurent Arnoud --- lib/jekyll/post.rb | 2 +- test/test_post.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 5502994c..bafb7257 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -131,7 +131,7 @@ module Jekyll "title" => CGI.escape(slug), "i_day" => date.strftime("%d").to_i.to_s, "i_month" => date.strftime("%m").to_i.to_s, - "categories" => categories.join('/'), + "categories" => categories.map {|c| URI.escape(c) }.join('/'), "output_ext" => self.output_ext }.inject(template) { |result, token| result.gsub(/:#{Regexp.escape token.first}/, token.last) diff --git a/test/test_post.rb b/test/test_post.rb index 1c3ea641..245c30b4 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -141,6 +141,19 @@ class TestPost < Test::Unit::TestCase end end + context "with space (categories)" do + setup do + @post.categories << "French cuisine" + @post.categories << "Belgian beer" + @post.process(@fake_file) + end + + should "process the url correctly" do + assert_equal "/:categories/:year/:month/:day/:title.html", @post.template + assert_equal "/French%20cuisine/Belgian%20beer/2008/09/09/foo-bar.html", @post.url + end + end + context "with none style" do setup do @post.site.permalink_style = :none From 1b2b5ff27831e0f83390027da370fb2e571022ed Mon Sep 17 00:00:00 2001 From: John Croisant Date: Sun, 17 Jul 2011 16:56:01 -0500 Subject: [PATCH 08/55] Greatly improved and extended the wordpress.rb migrator. * It can now export comments, categories, and tags. * It can convert non-ASCII chars into HTML entities. * It can export published, draft, private, and/or revision posts. * It can process "" tags to automatically generate a post excerpt and #anchors. Read the big documentation comment for all the available options. --- lib/jekyll/migrators/wordpress.rb | 308 ++++++++++++++++++++++++++---- 1 file changed, 270 insertions(+), 38 deletions(-) diff --git a/lib/jekyll/migrators/wordpress.rb b/lib/jekyll/migrators/wordpress.rb index 535859c9..d2d19039 100644 --- a/lib/jekyll/migrators/wordpress.rb +++ b/lib/jekyll/migrators/wordpress.rb @@ -11,52 +11,284 @@ require 'yaml' module Jekyll module WordPress - def self.process(dbname, user, pass, host = 'localhost', table_prefix = 'wp_') - db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8') + + # Main migrator function. Call this to perform the migration. + # + # dbname:: The name of the database + # user:: The database user name + # pass:: The database user's password + # host:: The address of the MySQL database host. Default: 'localhost' + # options:: A hash table of configuration options. + # + # Supported options are: + # + # :table_prefix:: Prefix of database tables used by WordPress. + # Default: 'wp_' + # :clean_entities:: If true, convert non-ASCII characters to HTML + # entities in the posts, comments, titles, and + # names. Requires the 'htmlentities' gem to + # work. Default: true. + # :comments:: If true, migrate post comments too. Comments + # are saved in the post's YAML front matter. + # Default: true. + # :categories:: If true, save the post's categories in its + # YAML front matter. + # :tags:: If true, save the post's tags in its + # YAML front matter. + # :more_excerpt:: If true, when a post has no excerpt but + # does have a tag, use the + # preceding post content as the excerpt. + # Default: true. + # :more_anchor:: If true, convert a tag into + # two HTML anchors with ids "more" and + # "more-NNN" (where NNN is the post number). + # Default: true. + # :status:: Array of allowed post statuses. Only + # posts with matching status will be migrated. + # Known statuses are :publish, :draft, :private, + # and :revision. If this is nil or an empty + # array, all posts are migrated regardless of + # status. Default: [:publish]. + # + def self.process(dbname, user, pass, host='localhost', options={}) + options = { + :table_prefix => 'wp_', + :clean_entities => true, + :comments => true, + :categories => true, + :tags => true, + :more_excerpt => true, + :more_anchor => true, + :status => [:publish] # :draft, :private, :revision + }.merge(options) + + if options[:clean_entities] + begin + require 'htmlentities' + rescue LoadError + STDERR.puts "Could not require 'htmlentities', so the " + + ":clean_entities option is now disabled." + options[:clean_entities] = false + end + end FileUtils.mkdir_p("_posts") - # Reads a MySQL database via Sequel and creates a post file for each - # post in wp_posts that has post_status = 'publish'. This restriction is - # made because 'draft' posts are not guaranteed to have valid dates. - query = "SELECT post_title, \ - post_name, \ - post_date, \ - post_content, \ - post_excerpt, \ - ID, \ - guid \ - FROM #{table_prefix}posts \ - WHERE post_status = 'publish' AND \ - post_type = 'post'" + db = Sequel.mysql(dbname, :user => user, :password => pass, + :host => host, :encoding => 'utf8') - db[query].each do |post| - # Get required fields and construct Jekyll compatible name. - title = post[:post_title] - slug = post[:post_name] - date = post[:post_date] - content = post[:post_content] - name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day, - slug] + px = options[:table_prefix] - # Get the relevant fields as a hash, delete empty fields and convert - # to YAML for the header. - data = { - 'layout' => 'post', - 'title' => title.to_s, - 'excerpt' => post[:post_excerpt].to_s, - 'wordpress_id' => post[:ID], - 'wordpress_url' => post[:guid], - 'date' => date - }.delete_if { |k,v| v.nil? || v == '' }.to_yaml + posts_query = " + SELECT + posts.ID AS `id`, + posts.guid AS `guid`, + posts.post_type AS `type`, + posts.post_status AS `status`, + posts.post_title AS `title`, + posts.post_name AS `slug`, + posts.post_date AS `date`, + posts.post_content AS `content`, + posts.post_excerpt AS `excerpt`, + posts.comment_count AS `comment_count`, + users.display_name AS `author`, + users.user_login AS `author_login`, + users.user_email AS `author_email`, + users.user_url AS `author_url` + FROM #{px}posts AS `posts` + LEFT JOIN #{px}users AS `users` + ON posts.post_author = users.ID" - # Write out the data and content to file - File.open("_posts/#{name}", "w") do |f| - f.puts data - f.puts "---" - f.puts content + if options[:status] and not options[:status].empty? + status = options[:status][0] + posts_query << " + WHERE posts.post_status = '#{status.to_s}'" + options[:status][1..-1].each do |status| + posts_query << " OR + posts.post_status = '#{status.to_s}'" end end + + db[posts_query].each do |post| + process_post(post, db, options) + end end + + + def self.process_post(post, db, options) + px = options[:table_prefix] + + title = post[:title] + if options[:clean_entities] + title = clean_entities(title) + end + + slug = post[:slug] + if !slug or slug.empty? + slug = sluggify(title) + end + + date = post[:date] || Time.now + name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, + date.day, slug] + content = post[:content].to_s + if options[:clean_entities] + content = clean_entities(content) + end + + excerpt = post[:excerpt].to_s + + more_index = content.index(//) + more_anchor = nil + if more_index + if options[:more_excerpt] and + (post[:excerpt].nil? or post[:excerpt].empty?) + excerpt = content[0...more_index] + end + if options[:more_anchor] + more_link = "more" + content.sub!(//, + "" + + "") + end + end + + categories = [] + tags = [] + + if options[:categories] or options[:tags] + + cquery = + "SELECT + terms.name AS `name`, + ttax.taxonomy AS `type` + FROM + #{px}terms AS `terms`, + #{px}term_relationships AS `trels`, + #{px}term_taxonomy AS `ttax` + WHERE + trels.object_id = '#{post[:id]}' AND + trels.term_taxonomy_id = ttax.term_taxonomy_id AND + terms.term_id = ttax.term_id" + + db[cquery].each do |term| + if options[:categories] and term[:type] == "category" + if options[:clean_entities] + categories << clean_entities(term[:name]) + else + categories << term[:name] + end + elsif options[:tags] and term[:type] == "post_tag" + if options[:clean_entities] + tags << clean_entities(term[:name]) + else + tags << term[:name] + end + end + end + end + + comments = [] + + if options[:comments] and post[:comment_count].to_i > 0 + cquery = + "SELECT + comment_ID AS `id`, + comment_author AS `author`, + comment_author_email AS `author_email`, + comment_author_url AS `author_url`, + comment_date AS `date`, + comment_date_gmt AS `date_gmt`, + comment_content AS `content` + FROM #{px}comments + WHERE + comment_post_ID = '#{post[:id]}' AND + comment_approved != 'spam'" + + + db[cquery].each do |comment| + + comcontent = comment[:content].to_s + if comcontent.respond_to?(:force_encoding) + comcontent.force_encoding("UTF-8") + end + if options[:clean_entities] + comcontent = clean_entities(comcontent) + end + comauthor = comment[:author].to_s + if options[:clean_entities] + comauthor = clean_entities(comauthor) + end + + comments << { + 'id' => comment[:id].to_i, + 'author' => comauthor, + 'author_email' => comment[:author_email].to_s, + 'author_url' => comment[:author_url].to_s, + 'date' => comment[:date].to_s, + 'date_gmt' => comment[:date_gmt].to_s, + 'content' => comcontent, + } + end + + comments.sort!{ |a,b| a['id'] <=> b['id'] } + end + + # Get the relevant fields as a hash, delete empty fields and + # convert to YAML for the header. + data = { + 'layout' => post[:type].to_s, + 'status' => post[:status].to_s, + 'published' => (post[:status].to_s == "publish"), + 'title' => title.to_s, + 'author' => post[:author].to_s, + 'author_login' => post[:author_login].to_s, + 'author_email' => post[:author_email].to_s, + 'author_url' => post[:author_url].to_s, + 'excerpt' => excerpt, + 'more_anchor' => more_anchor, + 'wordpress_id' => post[:id], + 'wordpress_url' => post[:guid].to_s, + 'date' => date, + 'categories' => options[:categories] ? categories : nil, + 'tags' => options[:tags] ? tags : nil, + 'comments' => options[:comments] ? comments : nil, + }.delete_if { |k,v| v.nil? || v == '' }.to_yaml + + # Write out the data and content to file + File.open("_posts/#{name}", "w") do |f| + f.puts data + f.puts "---" + f.puts content + end + end + + + def self.clean_entities( text ) + if text.respond_to?(:force_encoding) + text.force_encoding("UTF-8") + end + text = HTMLEntities.new.encode(text, :named) + # We don't want to convert these, it would break all + # HTML tags in the post and comments. + text.gsub!("&", "&") + text.gsub!("<", "<") + text.gsub!(">", ">") + text.gsub!(""", '"') + text.gsub!("'", "'") + text + end + + + def self.sluggify( title ) + begin + require 'unidecode' + title = title.to_ascii + rescue LoadError + STDERR.puts "Could not require 'unidecode'. If your post titles have non-ASCII characters, you could get nicer permalinks by installing unidecode." + end + title.downcase.gsub(/[^0-9A-Za-z]+/, " ").strip.gsub(" ", "-") + end + end end From 5cffe5ecb5194ef0e26e66ced1e2ef5285a934e7 Mon Sep 17 00:00:00 2001 From: Andrew Stone Date: Thu, 21 Jul 2011 19:49:09 -0400 Subject: [PATCH 09/55] Adding in the ability to link to posts internally. Syntax: {% post_url 2010-07-21-name-of-post %}; useful for: [Some Link]({% post_url 2010-07-21-name-of-post %}) --- features/create_sites.feature | 12 +++++++++++ lib/jekyll/tags/post_url.rb | 38 +++++++++++++++++++++++++++++++++++ test/test_tags.rb | 26 ++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 lib/jekyll/tags/post_url.rb diff --git a/features/create_sites.feature b/features/create_sites.feature index a7b5d9b1..8496a4e2 100644 --- a/features/create_sites.feature +++ b/features/create_sites.feature @@ -92,3 +92,15 @@ Feature: Create sites When I debug jekyll Then the _site directory should exist And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html" + + Scenario: Basic site with internal post linking + Given I have an "index.html" page that contains "URL: {% post_url 2020-01-31-entry2 %}" + And I have a configuration file with "permalink" set to "pretty" + And I have a _posts directory + And I have the following posts: + | title | date | layout | content | + | entry1 | 12/31/2007 | post | content for entry1. | + | entry2 | 01/31/2020 | post | content for entry2. | + When I run jekyll + Then the _site directory should exist + And I should see "URL: /2020/01/31/entry2/" in "_site/index.html" diff --git a/lib/jekyll/tags/post_url.rb b/lib/jekyll/tags/post_url.rb new file mode 100644 index 00000000..21d3a0b4 --- /dev/null +++ b/lib/jekyll/tags/post_url.rb @@ -0,0 +1,38 @@ +module Jekyll + + class PostComparer + MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/ + + attr_accessor :date, :slug + + def initialize(name) + who, cares, date, slug = *name.match(MATCHER) + @slug = slug + @date = Time.parse(date) + end + end + + class PostUrl < Liquid::Tag + def initialize(tag_name, post, tokens) + super + @orig_post = post.strip + @post = PostComparer.new(@orig_post) + end + + def render(context) + site = context.registers[:site] + + site.posts.each do |p| + if p == @post + return p.url + end + end + + puts "ERROR: post_url: \"#{@orig_post}\" could not be found" + + return "#" + end + end +end + +Liquid::Template.register_tag('post_url', Jekyll::PostUrl) diff --git a/test/test_tags.rb b/test/test_tags.rb index 50750757..cdd395b0 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -9,6 +9,11 @@ class TestTags < Test::Unit::TestCase Jekyll::DEFAULTS.merge({'pygments' => true}).merge(override) end site = Site.new(Jekyll.configuration) + + if override['read_posts'] + site.read_posts('') + end + info = { :filters => [Jekyll::Filters], :registers => { :site => site } } @converter = site.converters.find { |c| c.class == converter_class } payload = { "pygments_prefix" => @converter.pygments_prefix, @@ -137,4 +142,25 @@ CONTENT end end end + + context "simple page with post linking" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "not cause an error" do + assert_no_match /markdown\-html\-error/, @result + end + + should "have the url to the \"complex\" post from 2008-11-21" do + assert_match %r{/2008/11/21/complex/}, @result + end + end end From e8f604b5ae689313de9c9dd08ef89c180935075a Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 8 Aug 2011 15:22:25 +0200 Subject: [PATCH 10/55] Added table prefix option to Drupal migration It's good practice in the Drupal community to always prefix the tables with something so that if you ever need to host two sites in the same database then you will easily know which tables belongs to which site. This commit adds an option to the Drupal migration scripts that makes it possible to add such a prefix to the migration query. --- lib/jekyll/migrators/drupal.rb | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/jekyll/migrators/drupal.rb b/lib/jekyll/migrators/drupal.rb index 32e335cc..2301b0e5 100644 --- a/lib/jekyll/migrators/drupal.rb +++ b/lib/jekyll/migrators/drupal.rb @@ -14,19 +14,24 @@ module Jekyll # Reads a MySQL database via Sequel and creates a post file for each post # in wp_posts that has post_status = 'publish'. This restriction is made # because 'draft' posts are not guaranteed to have valid dates. - QUERY = "SELECT node.nid, \ - node.title, \ - node_revisions.body, \ - node.created, \ - node.status \ - FROM node, \ - node_revisions \ - WHERE (node.type = 'blog' OR node.type = 'story') \ - AND node.vid = node_revisions.vid" + QUERY = "SELECT n.nid, \ + n.title, \ + nr.body, \ + n.created, \ + n.status \ + FROM node AS n, \ + node_revisions AS nr \ + WHERE (n.type = 'blog' OR n.type = 'story') \ + AND n.vid = nr.vid" - def self.process(dbname, user, pass, host = 'localhost') + def self.process(dbname, user, pass, host = 'localhost', prefix = '') db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8') + if prefix != '' + QUERY[" node "] = " " + prefix + "node " + QUERY[" node_revisions "] = " " + prefix + "node_revisions " + end + FileUtils.mkdir_p "_posts" FileUtils.mkdir_p "_drafts" From 2ce0eb00e759126be41d905afe3be0ed624b3338 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 8 Aug 2011 16:19:02 +0200 Subject: [PATCH 11/55] Added redirects for Drupal posts' URL-aliases --- lib/jekyll/migrators/drupal.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/migrators/drupal.rb b/lib/jekyll/migrators/drupal.rb index 2301b0e5..7fd16aef 100644 --- a/lib/jekyll/migrators/drupal.rb +++ b/lib/jekyll/migrators/drupal.rb @@ -78,12 +78,18 @@ EOF # Make a file to redirect from the old Drupal URL if is_published - FileUtils.mkdir_p "node/#{node_id}" - File.open("node/#{node_id}/index.md", "w") do |f| - f.puts "---" - f.puts "layout: refresh" - f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}" - f.puts "---" + aliases = db["SELECT dst FROM #{prefix}url_alias WHERE src = ?", "node/#{node_id}"].all + + aliases.push(:dst => "node/#{node_id}") + + aliases.each do |url_alias| + FileUtils.mkdir_p url_alias[:dst] + File.open("#{url_alias[:dst]}/index.md", "w") do |f| + f.puts "---" + f.puts "layout: refresh" + f.puts "refresh_to_post_id: /#{time.strftime("%Y/%m/%d/") + slug}" + f.puts "---" + end end end end From 4a9094f2d4c47f710af619777e4cb65120004c23 Mon Sep 17 00:00:00 2001 From: Peter Wagenet Date: Mon, 26 Sep 2011 23:47:04 -0700 Subject: [PATCH 12/55] Fix non-pygments code highlighting --- lib/jekyll/tags/highlight.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index aeddfb2d..cdc6d47f 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -53,9 +53,7 @@ module Jekyll #The div is required because RDiscount blows ass <<-HTML
-
-    #{h(code).strip}
-  
+
#{h(code).strip}
HTML end From f0f99eae8a2dc43d4d2bb7f6a020b48f7f654e57 Mon Sep 17 00:00:00 2001 From: Marcello Barnaba Date: Tue, 18 Oct 2011 23:05:39 +0200 Subject: [PATCH 13/55] Fix exception thrown in exception handler at convertible.rb:81 --- lib/jekyll/post.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 5502994c..12ca279d 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -22,6 +22,8 @@ module Jekyll attr_accessor :data, :content, :output, :ext attr_accessor :date, :slug, :published, :tags, :categories + attr_reader :name + # Initialize this Post instance. # +site+ is the Site # +base+ is the String path to the dir containing the post file From bb37858e676e894c8bf6e53f634c63e7da9e184b Mon Sep 17 00:00:00 2001 From: Josh Brown Date: Mon, 24 Oct 2011 14:09:22 -0400 Subject: [PATCH 14/55] Added a sweet Joomla 1.5 migrator --- lib/jekyll/migrators/joomla.rb | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/jekyll/migrators/joomla.rb diff --git a/lib/jekyll/migrators/joomla.rb b/lib/jekyll/migrators/joomla.rb new file mode 100644 index 00000000..87f1e105 --- /dev/null +++ b/lib/jekyll/migrators/joomla.rb @@ -0,0 +1,53 @@ +require 'rubygems' +require 'sequel' +require 'fileutils' +require 'yaml' + +# NOTE: This migrator is made for Joomla 1.5 databases. +# NOTE: This converter requires Sequel and the MySQL gems. +# The MySQL gem can be difficult to install on OS X. Once you have MySQL +# installed, running the following commands should work: +# $ sudo gem install sequel +# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config + +module Jekyll + module Joomla + def self.process(dbname, user, pass, host = 'localhost', table_prefix = 'jos_', section = '1') + db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8') + + FileUtils.mkdir_p("_posts") + + # Reads a MySQL database via Sequel and creates a post file for each + # post in wp_posts that has post_status = 'publish'. This restriction is + # made because 'draft' posts are not guaranteed to have valid dates. + query = "SELECT `title`, `alias`, CONCAT(`introtext`,`fulltext`) as content, `created`, `id` FROM #{table_prefix}content WHERE state = '0' OR state = '1' AND sectionid = '#{section}'" + + db[query].each do |post| + # Get required fields and construct Jekyll compatible name. + title = post[:title] + slug = post[:alias] + date = post[:created] + content = post[:content] + name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day, + slug] + + # Get the relevant fields as a hash, delete empty fields and convert + # to YAML for the header. + data = { + 'layout' => 'post', + 'title' => title.to_s, + 'joomla_id' => post[:id], + 'joomla_url' => post[:alias], + 'date' => date + }.delete_if { |k,v| v.nil? || v == '' }.to_yaml + + # Write out the data and content to file + File.open("_posts/#{name}", "w") do |f| + f.puts data + f.puts "---" + f.puts content + end + end + end + end +end From 69e7f4abef6343538c6e566706bc3be24b7e0983 Mon Sep 17 00:00:00 2001 From: Carl Groner Date: Thu, 3 Nov 2011 11:54:49 -0700 Subject: [PATCH 15/55] Add test cases for default values with no explicit config. for `hard_breaks`. --- lib/jekyll/converters/textile.rb | 6 +++++- test/test_redcloth.rb | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 4b507996..814b2080 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -28,7 +28,11 @@ module Jekyll def convert(content) setup r = RedCloth.new(content) - r.hard_breaks = @config['redcloth']['hard_breaks'] + + if !@config['redcloth'].nil? and !@config['redcloth']['hard_breaks'].nil? + r.hard_breaks = @config['redcloth']['hard_breaks'] + end + r.to_html end end diff --git a/test/test_redcloth.rb b/test/test_redcloth.rb index 9fd32be1..2b43fe24 100644 --- a/test/test_redcloth.rb +++ b/test/test_redcloth.rb @@ -1,6 +1,30 @@ require File.dirname(__FILE__) + '/helper' class TestRedCloth < Test::Unit::TestCase + + context "RedCloth default (no explicit config) hard_breaks enabled" do + setup do + @textile = TextileConverter.new + end + + should "preserve single line breaks in HTML output" do + assert_equal "

line1
\nline2

", @textile.convert("p. line1\nline2").strip + end + end + + context "Default hard_breaks enabled w/ redcloth section, no hard_breaks value" do + setup do + config = { + 'redcloth' => {} + } + @textile = TextileConverter.new config + end + + should "preserve single line breaks in HTML output" do + assert_equal "

line1
\nline2

", @textile.convert("p. line1\nline2").strip + end + end + context "RedCloth with hard_breaks enabled" do setup do config = { From 8c4edb655e44defd2f0c1199440cf4775f0f4277 Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Fri, 4 Nov 2011 17:33:53 +0100 Subject: [PATCH 16/55] Have TextileConverter pass any arguments set to true in config's redcloth section to RedCloth constructor as an array of symbols. This means explicitly setting (for example): redcloth: hard_breaks: false lite_mode: true no_span_caps: true will cause RedCloth to be invoked thusly: RedCloth.new(content, [:lite_mode, :no_span_caps]) (Notice that hard_breaks is ignored.) This means, however, anything set to true in the redcloth section in _config.yml _will_ be passed to RedCloth. Mayhem may ensue. --- lib/jekyll/converters/textile.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 814b2080..838c96a7 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -27,13 +27,18 @@ module Jekyll def convert(content) setup - r = RedCloth.new(content) - if !@config['redcloth'].nil? and !@config['redcloth']['hard_breaks'].nil? - r.hard_breaks = @config['redcloth']['hard_breaks'] + restrictions = Array.new + if !@config['redcloth'].nil? + @config['redcloth'].each do |key, value| + restrictions << key.to_sym if value + end + require 'ap' + ap restrictions end - r.to_html + + RedCloth.new(content, restrictions).to_html end end From ab3927499fc4b96ad3c0540836be4df18c6b3f94 Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Fri, 4 Nov 2011 17:41:47 +0100 Subject: [PATCH 17/55] Forgot to remove debugging code :-/ --- lib/jekyll/converters/textile.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index 838c96a7..aa7201cd 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -33,11 +33,8 @@ module Jekyll @config['redcloth'].each do |key, value| restrictions << key.to_sym if value end - require 'ap' - ap restrictions end - RedCloth.new(content, restrictions).to_html end end From 06f5b7d2e341971f1484af41c0ea64765c7b7669 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 20 Nov 2011 22:07:56 +1100 Subject: [PATCH 18/55] Fixed cgi module name. --- lib/jekyll/migrators/tumblr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index d7cb3969..602f4169 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -2,7 +2,7 @@ require 'rubygems' require 'nokogiri' require 'open-uri' require 'fileutils' -require 'CGI' +require 'cgi' require 'iconv' require 'date' From 6826317e00fac0adbbe80ee341fea3eaaaa3e2e0 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 20 Nov 2011 22:09:43 +1100 Subject: [PATCH 19/55] Use the post's title for the filename rather than its ID, as per Jekyll's naming convention. --- lib/jekyll/migrators/tumblr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 602f4169..97105eb4 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -72,7 +72,7 @@ module Jekyll content << CGI::unescapeHTML(post.at("video-caption").inner_html) unless post.at("video-caption") == nil end # End post types - name = "#{Date.parse(post['date']).to_s}-#{post['id'].downcase.gsub(/[^a-z0-9]/, '-')}.html" + name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" if title != nil || content != nil && name != nil File.open("_posts/tumblr/#{name}", "w") do |f| From 87316894cc6179b36f91cfa97387ea967f793ff2 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 20 Nov 2011 22:13:01 +1100 Subject: [PATCH 20/55] Quote the post's title so reserved yaml chars don't blow up. --- lib/jekyll/migrators/tumblr.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 97105eb4..24f5ffe0 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -80,7 +80,7 @@ module Jekyll f.puts <<-HEADER --- layout: post -title: #{title} +title: "#{title.gsub('"', '\"')}" --- HEADER From b762a1d5c5b10b307df9a7c879f5f1540d21cf96 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 20 Nov 2011 22:15:36 +1100 Subject: [PATCH 21/55] Add a format option for converting posts to markdown via Python's html2text. --- lib/jekyll/migrators/tumblr.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 24f5ffe0..1cbef57f 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -8,7 +8,7 @@ require 'date' module Jekyll module Tumblr - def self.process(url, grab_images = false) + def self.process(url, grab_images = false, format = "html") current_page = 0 while true @@ -75,6 +75,7 @@ module Jekyll name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" if title != nil || content != nil && name != nil + content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" File.open("_posts/tumblr/#{name}", "w") do |f| f.puts <<-HEADER From 1b3abb61d8b7bab0932d0d8cc13a11c69433cebf Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Mon, 21 Nov 2011 05:49:49 +1100 Subject: [PATCH 22/55] Clean up extraneous newlines left by html2text. --- lib/jekyll/migrators/tumblr.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 1cbef57f..332c5fb0 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -75,7 +75,13 @@ module Jekyll name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" if title != nil || content != nil && name != nil - content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" + if format == "md" + content = %x[echo '#{content.gsub("'", "''")}' | html2text] + # html2text leaves extra blank lines in code blocks - clean them up. + begin + content.gsub!("\n \n", "\n") + end until !content.include? "\n \n" + end File.open("_posts/tumblr/#{name}", "w") do |f| f.puts <<-HEADER From ab85c82356ad23d0c9c4b1afc8571ffb4178c40f Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Thu, 24 Nov 2011 06:11:57 +1100 Subject: [PATCH 23/55] Use Tumblr's JSON format instead of XML, to correctly preserve white-space when converting to markdown. --- lib/jekyll/migrators/tumblr.rb | 130 +++++++++++++-------------------- 1 file changed, 49 insertions(+), 81 deletions(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 332c5fb0..3fd15642 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -1,10 +1,8 @@ require 'rubygems' -require 'nokogiri' require 'open-uri' require 'fileutils' -require 'cgi' -require 'iconv' require 'date' +require 'json' module Jekyll module Tumblr @@ -12,97 +10,67 @@ module Jekyll current_page = 0 while true - f = open(url + "/api/read?num=50&start=#{current_page * 50}") - doc = Nokogiri::HTML(Iconv.conv("utf-8", f.charset, f.readlines.join("\n"))) - - puts "Page: #{current_page + 1} - Posts: #{(doc/:tumblr/:posts/:post).size}" + f = open(url + "/api/read/json/?num=50&start=#{current_page * 50}") + # [21...-2] strips Tumblr's Javascript/JSONP start/end chars + json = f.readlines.join("\n")[21...-2] + blog = JSON.parse(json) + puts "Page: #{current_page + 1} - Posts: #{blog["posts"].size}" FileUtils.mkdir_p "_posts/tumblr" - (doc/:tumblr/:posts/:post).each do |post| - title = "" - content = nil - name = nil + blog["posts"].each do |post| - if post['type'] == "regular" - title_element = post.at("regular-title") - title = title_element.inner_text unless title_element == nil - content = CGI::unescapeHTML post.at("regular-body").inner_html unless post.at("regular-body") == nil - elsif post['type'] == "link" - title = post.at("link-text").inner_html unless post.at("link-text") == nil - - if post.at("link-text") != nil - content = "#{post.at("link-text").inner_html}" - else - content = "#{post.at("link-url").inner_html}" - end - - content << "
" + CGI::unescapeHTML(post.at("link-description").inner_html) unless post.at("link-description") == nil - elsif post['type'] == "photo" - content = "" - - if post.at("photo-link-url") != nil - content = "" - else - content = "" - end - - if post.at("photo-caption") != nil - content << "
" unless content == nil - content << CGI::unescapeHTML(post.at("photo-caption").inner_html) - end - elsif post['type'] == "audio" - content = CGI::unescapeHTML(post.at("audio-player").inner_html) - content << CGI::unescapeHTML(post.at("audio-caption").inner_html) unless post.at("audio-caption") == nil - elsif post['type'] == "quote" - content = "
" + CGI::unescapeHTML(post.at("quote-text").inner_html) + "
" - content << "—" + CGI::unescapeHTML(post.at("quote-source").inner_html) unless post.at("quote-source") == nil - elsif post['type'] == "conversation" - title = post.at("conversation-title").inner_html unless post.at("conversation-title") == nil - content = "
" - - (post/:conversation/:line).each do |line| - content << "
" + line['label'] + "
" + line.inner_html + "
" unless line['label'] == nil || line == nil - end - - content << "
" - elsif post['type'] == "video" - title = post.at("video-title").inner_html unless post.at("video-title") == nil - content = CGI::unescapeHTML(post.at("video-player").inner_html) - content << CGI::unescapeHTML(post.at("video-caption").inner_html) unless post.at("video-caption") == nil + case post['type'] + when "regular" + title = post["regular-title"] + content = post["regular-body"] + when "link" + title = post["link-text"] || post["link-url"] + content = "#{title}" + content << "
" + post["link-description"] unless post["link-description"].nil? + when "photo" + title = post["photo-caption"] + content = "" + content = "#{content}" unless post["photo-link-url"].nil? + when "audio" + if !post["id3-title"].nil? + title = post["id3-title"] + content = post.at["audio-player"] + "
" + post["audio-caption"] + else + title = post["audio-caption"] + content = post.at["audio-player"] + end + when "quote" + title = post["quote-text"] + content = "
#{post["quote-text"]}
" + content << "—" + post["quote-source"] unless post["quote-source"].nil? + when "conversation" + title = post["conversation-title"] + content = "
" + post["conversation"]["line"].each do |line| + content << "
#{line['label']}
#{line}
" + end + content << "
" + when "video" + title = post["video-title"] + content = post["video-player"] + content << "
" + post["video-caption"] unless post["video-caption"].nil? end # End post types name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" - if title != nil || content != nil && name != nil - if format == "md" - content = %x[echo '#{content.gsub("'", "''")}' | html2text] - # html2text leaves extra blank lines in code blocks - clean them up. - begin - content.gsub!("\n \n", "\n") - end until !content.include? "\n \n" - end - File.open("_posts/tumblr/#{name}", "w") do |f| - - f.puts <<-HEADER ---- -layout: post -title: "#{title.gsub('"', '\"')}" ---- - -HEADER - - f.puts content - end # End file - end + File.open("_posts/tumblr/#{name}", "w") do |f| + content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" + header = {"layout" => "post", "title" => title, "tags" => post["tags"]} + f.puts header.to_yaml + "---\n" + content + end # End file end # End post XML - if (doc/:tumblr/:posts/:post).size < 50 + if blog["posts"].size < 50 break - else - current_page = current_page + 1 end + current_page += 1 end # End while loop end # End method From bc20ba9be961ece9d5e49283366956d23c71bdd1 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Fri, 25 Nov 2011 06:10:47 +1100 Subject: [PATCH 24/55] Preserve HTML tables as per markdown's support for tables. --- lib/jekyll/migrators/tumblr.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 3fd15642..10f41601 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -60,7 +60,12 @@ module Jekyll name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" File.open("_posts/tumblr/#{name}", "w") do |f| - content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" + if format == "md" + preserve = ["table", "tr", "th", "td"] + preserve.each { |tag| content = content.gsub(/<#{tag}/i, "$$" + tag).gsub(/<\/#{tag}/i, "||" + tag) } + content = %x[echo '#{content.gsub("'", "''")}' | html2text] + preserve.each { |tag| content = content.gsub("$$" + tag, "<" + tag).gsub("||" + tag, " "post", "title" => title, "tags" => post["tags"]} f.puts header.to_yaml + "---\n" + content end # End file From ebc8ab5b531cf0a3545fd55dc2c67b764ff812d4 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 10 Jul 2011 15:18:01 -0700 Subject: [PATCH 25/55] Remove accidentally added doc stuff and change rakefile to prevent this. --- Rakefile | 2 +- doc/output/book.html | 574 ------------------ doc/output/ch00-preface.asc | 41 -- doc/output/ch01-quick-start.asc | 153 ----- doc/output/ch02-directory-layout.asc | 90 --- doc/output/stylesheets/handbookish-quirks.css | 0 doc/output/stylesheets/handbookish.css | 231 ------- doc/output/stylesheets/scribe-quirks.css | 0 doc/output/stylesheets/scribe.css | 177 ------ g.pl | 48 -- output/stylesheets/scribe-quirks.css | 0 output/stylesheets/scribe.css | 177 ------ 12 files changed, 1 insertion(+), 1492 deletions(-) delete mode 100644 doc/output/book.html delete mode 100644 doc/output/ch00-preface.asc delete mode 100644 doc/output/ch01-quick-start.asc delete mode 100644 doc/output/ch02-directory-layout.asc delete mode 100644 doc/output/stylesheets/handbookish-quirks.css delete mode 100644 doc/output/stylesheets/handbookish.css delete mode 100644 doc/output/stylesheets/scribe-quirks.css delete mode 100644 doc/output/stylesheets/scribe.css delete mode 100644 g.pl delete mode 100644 output/stylesheets/scribe-quirks.css delete mode 100644 output/stylesheets/scribe.css diff --git a/Rakefile b/Rakefile index 923816c0..e8f280e7 100644 --- a/Rakefile +++ b/Rakefile @@ -119,7 +119,7 @@ task :release => :build do puts "You must be on the master branch to release!" exit! end - sh "git commit --allow-empty -a -m 'Release #{version}'" + sh "git commit --allow-empty -m 'Release #{version}'" sh "git tag v#{version}" sh "git push origin master" sh "git push origin v#{version}" diff --git a/doc/output/book.html b/doc/output/book.html deleted file mode 100644 index bf20ced7..00000000 --- a/doc/output/book.html +++ /dev/null @@ -1,574 +0,0 @@ - - - - - -Jekyll - - - - - -
-

1. Preface

-
-

Jekyll was born out the desire to create a blog engine that would make it -possible to write posts in my local text editor, version those posts with Git, -and keep up with my desire to tweak the styles and layout of my site.

-

In other words, I wanted something that fit into my existing software -development workflow and toolchain. Jekyll handles not only this case, but a -wide variety of other situations that call for static site generation based on -converted content and layout templates.

-

At its core, Jekyll is a text transformation engine. The concept behind the -system is this: you give it text written in your favorite markup language, be -that Markdown, Textile, or just plain HTML, and it churns that through a -layout or series of layout files. Throughout that process you can tweak how -you want the site URLs to look, what data gets displayed on the layout and -much more.

-

If you’re looking for a simple, yet powerful solution to your blogging or -static site needs, Jekyll may be just what you’ve been looking for.

-

1.1. What this book covers

-

Chapter 1, Quick Start covers installation, introduces the Jekyll command -line interface, and runs through a quick example demonstrating the site -generator, post generator and how to convert your Jekyll site into a static -site.

-

Chapter 2, Directory Layout covers the various files and directories that -comprise a Jekyll site.

-

Chapter 3, Tags and Filters

-

Chapter X, Deploying your Jekyll Site

-

Chapter X, Customizing Jekyll with Plugins

-

Chapter X, Migrating to Jekyll from your Existing Blog

-

Chapter X, Configuration Reference

-
-

2. Chapter 1: Quick Start

-
-

This chapter is designed to get you up and running with Jekyll as quickly as -possible.

-

2.1. Installation

-

The best way to install Jekyll is via RubyGems:

-
-
-
gem install jekyll
-
-

This is all you need in order to get started with a basic Jekyll site. Some -options require additional packages to be installed.

-

If you encounter errors during gem installation, you may need to install the -header files for compiling extension modules for ruby 1.8:

-
-
Debian
-
-
sudo apt-get install ruby1.8-dev
-
-
-
Red Hat / CentOS / Fedora systems
-
-
sudo yum install ruby-devel
-
-
-
NearlyFreeSpeech
-
-
RB_USER_INSTALL=true gem install jekyll
-
-

If you encounter errors like Failed to build gem native extension on Windows -you may need to install RubyInstaller -DevKit.

-

2.1.1. LaTeX to PNG

-

Maruku comes with optional support for LaTeX to PNG rendering via blahtex -(Version 0.6) which must be in your $PATH along with @dvips@.

-

(NOTE: "remi’s fork of Maruku":http://github.com/remi/maruku/tree/master does -not assume a fixed location for @dvips@ if you need that fixed)

-

2.1.2. RDiscount

-

If you prefer to use -RDiscount instead of -Maruku for markdown, just make sure it’s -installed:

-
-
-
sudo gem install rdiscount
-
-

And run Jekyll with the following option:

-
-
-
jekyll --rdiscount
-
-

Or, in your @_config.yml@ file put the following so you don’t have to specify the flag:

-
-
-
markdown: rdiscount
-
-

2.1.3. Pygments

-

If you want syntax highlighting via the @{% highlight %}@ tag in your posts, -you’ll need to install Pygments.

-
-
On OSX with Homebrew
-
-
brew install pip && pip install pygments
-
-
-
On OSX with MacPorts
-
-
sudo port install python25 py25-pygments
-
-
-
Bare OS X Leopard
-
-
sudo easy_install Pygments
-
-
-
Archlinux
-
-
sudo pacman -S python-pygments
-
-
-
Archlinux python2 for Pygments
-
-
$ sudo pacman -S python2-pygments
-
-
- - - -
-
Note
-
python2 pygments version creates a pygmentize2 executable, while -Jekyll tries to find pygmentize. Either create a symlink # ln -s -/usr/bin/pygmentize2 /usr/bin/pygmentize or use the python3 version.
-
-
-
Ubuntu and Debian
-
-
sudo apt-get install python-pygments
-
-
-
Gentoo
-
-
$ sudo emerge -av dev-python/pygments
-
-

2.2. Creating your First Site

-

Jekyll comes with a handy generator that will create a barebones skeleton site -to help you get up and running in no time. Simply create an empty directory to -contain your site, navigate to it, and run the generator command:

-
-
-
$ mkdir mysite
-$ cd mysite
-$ jekyll gen
-
-

Make sure the directory is empty or Jekyll will refuse to run. If everything -was successful, you’ll be left with a complete, valid Jekyll site that’s ready -to be converted into a static site.

-

To perform the conversion, make sure you’re in the root of your Jekyll site -directory and run:

-
-
-
$ jekyll --server
-
-

If all goes well, you should get a few lines with information about config -file detection, source and destination paths, and a success message.

-

The --server command line option fires up a simple web server that will -serve the static site we just generated so that we can easily preview what it -will look like once we deploy it to a production environment.

-

Open up your favorite web browser and navigate to:

-
-
-
http://localhost:4000
-
-

Congratulations! You have now successfully created and converted your first -Jekyll site!

-
-

3. Chapter 2: Directory Layout

-
-

If you followed the Quick Start in the last chapter, you have a Jekyll site on -your local machine. Let’s take a closer look at it and see what makes it tick. -The file layout should look something like this:

-
-
-
.
-|-- _config.yml
-|-- _layouts
-|   |-- default.html
-|   `-- post.html
-|-- _posts
-|   |-- 2007-10-29-why-every-programmer-should-play-nethack.textile
-|   `-- 2009-04-26-barcamp-boston-4-roundup.textile
-|-- _site
-|-- images
-|   `-- logo.png
-`-- index.html
-
-

Notice that some of the files and directories begin with an underscore. These -have special meaning to Jekyll. The underscore ensures that they will not -interfere with the rest of your site’s normal content. It also means that if -any of your normal files start with an underscore, they will cause problems, -so try to avoid this.

-

3.1. _config.yml

-

This file stores configuration data. A majority of these options can be -specified from the command line executable but it’s easier to throw them in -here so you don’t have to type them out every time. Detailed explanations of -configuration directives can be found in Chapter X.

-

3.2. _layouts

-

Files in this directory represent templates that can be used to wrap converted -pages. Layouts are defined on a page-by-page basis in the YAML front matter. -The liquid tag {{ content }} specifies where the content will be placed -during the conversion process.

-

3.3. _posts

-

If you’re using Jekyll as a blog engine, this is where you’ll place your blog -posts. A post’s filename contains several pieces of data, so you must be very -careful about how these files are named. The filename format is: -YEAR-MONTH-DATE-SLUG.MARKUP. The YEAR must be four numbers and the MONTH and -DATE must be two numbers each. The SLUG is what will appear in the URL. The -MARKUP tells Jekyll the format of the post. The date and slug will be used -along with any permalink options you specify (See Chapter X) to construct the -final URL of the post.

-

3.4. _site

-

This is where the generated site will be placed (by default) once Jekyll is -done transforming it. If you’re using version control, you’ll want to add this -directory to the list of files to be ignored.

-

3.5. Normal Files with YAML Front Matter

-

All files outside of the special underscore directories and that do not -themselves begin with an underscore will be scanned by Jekyll and subjected to -conversion if they contain any YAML front matter.

-

3.6. Everything Else

-

Any files and directories that do not fall into one of the above categories -will be copied to the static site as-is without modification. In this example, -images/logo.png will be copied to the same location in the generated site.

-

h2. Running Jekyll

-

Usually this is done through the @jekyll@ executable, which is installed with -the gem. In order to get a server up and running with your Jekyll site, run:

-

@jekyll --server@

-

and then browse to http://0.0.0.0:4000. There’s plenty of available to you as well.

-

On Debian or Ubuntu, you may need to add @/var/lib/gems/1.8/bin/@ to your path.

-

h2. Deployment

-

Since Jekyll simply generates a folder filled with HTML files, it can be -served using practically any available web server out there. Please check the - page for more information regarding specific scenarios.

-
-
-

- - - diff --git a/doc/output/ch00-preface.asc b/doc/output/ch00-preface.asc deleted file mode 100644 index fe3d9908..00000000 --- a/doc/output/ch00-preface.asc +++ /dev/null @@ -1,41 +0,0 @@ -== Preface - -Jekyll was born out the desire to create a blog engine that would make it -possible to write posts in my local text editor, version those posts with Git, -and keep up with my desire to tweak the styles and layout of my site. - -In other words, I wanted something that fit into my existing software -development workflow and toolchain. Jekyll handles not only this case, but a -wide variety of other situations that call for static site generation based on -converted content and layout templates. - -At its core, Jekyll is a text transformation engine. The concept behind the -system is this: you give it text written in your favorite markup language, be -that Markdown, Textile, or just plain HTML, and it churns that through a -layout or series of layout files. Throughout that process you can tweak how -you want the site URLs to look, what data gets displayed on the layout and -much more. - -If you're looking for a simple, yet powerful solution to your blogging or -static site needs, Jekyll may be just what you've been looking for. - - -=== What this book covers - -_Chapter 1, Quick Start_ covers installation, introduces the Jekyll command -line interface, and runs through a quick example demonstrating the site -generator, post generator and how to convert your Jekyll site into a static -site. - -_Chapter 2, Directory Layout_ covers the various files and directories that -comprise a Jekyll site. - -_Chapter 3, Tags and Filters_ - -_Chapter X, Deploying your Jekyll Site_ - -_Chapter X, Customizing Jekyll with Plugins_ - -_Chapter X, Migrating to Jekyll from your Existing Blog_ - -_Chapter X, Configuration Reference_ \ No newline at end of file diff --git a/doc/output/ch01-quick-start.asc b/doc/output/ch01-quick-start.asc deleted file mode 100644 index b287e435..00000000 --- a/doc/output/ch01-quick-start.asc +++ /dev/null @@ -1,153 +0,0 @@ -== Chapter 1: Quick Start - -This chapter is designed to get you up and running with Jekyll as quickly as -possible. - - -=== Installation - -The best way to install Jekyll is via RubyGems: - ----- -gem install jekyll ----- - -This is all you need in order to get started with a basic Jekyll site. Some -options require additional packages to be installed. - -If you encounter errors during gem installation, you may need to install the -header files for compiling extension modules for ruby 1.8: - -.Debian ----- -sudo apt-get install ruby1.8-dev ----- - -.Red Hat / CentOS / Fedora systems ----- -sudo yum install ruby-devel ----- - -.NearlyFreeSpeech ----- -RB_USER_INSTALL=true gem install jekyll ----- - -If you encounter errors like +Failed to build gem native extension+ on Windows -you may need to install http://wiki.github.com/oneclick/rubyinstaller/development-kit[RubyInstaller -DevKit]. - -==== LaTeX to PNG - -Maruku comes with optional support for LaTeX to PNG rendering via blahtex -(Version 0.6) which must be in your $PATH along with @dvips@. - -(NOTE: "remi's fork of Maruku":http://github.com/remi/maruku/tree/master does -not assume a fixed location for @dvips@ if you need that fixed) - -==== RDiscount - -If you prefer to use -http://github.com/rtomayko/rdiscount/tree/master[RDiscount] instead of -http://maruku.rubyforge.org/[Maruku] for markdown, just make sure it's -installed: - ----- -sudo gem install rdiscount ----- - -And run Jekyll with the following option: - ----- -jekyll --rdiscount ----- - -Or, in your @_config.yml@ file put the following so you don't have to specify the flag: - ----- -markdown: rdiscount ----- - -==== Pygments - -If you want syntax highlighting via the @{% highlight %}@ tag in your posts, -you'll need to install http://pygments.org/[Pygments]. - -.On OSX with Homebrew ----- -brew install pip && pip install pygments ----- - -.On OSX with MacPorts ----- -sudo port install python25 py25-pygments ----- - -.Bare OS X Leopard ----- -sudo easy_install Pygments ----- - -.Archlinux ----- -sudo pacman -S python-pygments ----- - -.Archlinux python2 for Pygments ----- -$ sudo pacman -S python2-pygments ----- - -NOTE: python2 pygments version creates a `pygmentize2` executable, while -Jekyll tries to find `pygmentize`. Either create a symlink `# ln -s -/usr/bin/pygmentize2 /usr/bin/pygmentize` or use the python3 version. - -.Ubuntu and Debian ----- -sudo apt-get install python-pygments ----- - -.Gentoo ----- -$ sudo emerge -av dev-python/pygments ----- - - -=== Creating your First Site - -Jekyll comes with a handy generator that will create a barebones skeleton site -to help you get up and running in no time. Simply create an empty directory to -contain your site, navigate to it, and run the generator command: - ----- -$ mkdir mysite -$ cd mysite -$ jekyll gen ----- - -Make sure the directory is empty or Jekyll will refuse to run. If everything -was successful, you'll be left with a complete, valid Jekyll site that's ready -to be converted into a static site. - -To perform the conversion, make sure you're in the root of your Jekyll site -directory and run: - ----- -$ jekyll --server ----- - -If all goes well, you should get a few lines with information about config -file detection, source and destination paths, and a success message. - -The `--server` command line option fires up a simple web server that will -serve the static site we just generated so that we can easily preview what it -will look like once we deploy it to a production environment. - -Open up your favorite web browser and navigate to: - ----- -http://localhost:4000 ----- - -Congratulations! You have now successfully created and converted your first -Jekyll site! \ No newline at end of file diff --git a/doc/output/ch02-directory-layout.asc b/doc/output/ch02-directory-layout.asc deleted file mode 100644 index d9cbcb5b..00000000 --- a/doc/output/ch02-directory-layout.asc +++ /dev/null @@ -1,90 +0,0 @@ -== Chapter 2: Directory Layout - -If you followed the Quick Start in the last chapter, you have a Jekyll site on -your local machine. Let's take a closer look at it and see what makes it tick. -The file layout should look something like this: - ----- -. -|-- _config.yml -|-- _layouts -| |-- default.html -| `-- post.html -|-- _posts -| |-- 2007-10-29-why-every-programmer-should-play-nethack.textile -| `-- 2009-04-26-barcamp-boston-4-roundup.textile -|-- _site -|-- images -| `-- logo.png -`-- index.html ----- - -Notice that some of the files and directories begin with an underscore. These -have special meaning to Jekyll. The underscore ensures that they will not -interfere with the rest of your site's normal content. It also means that if -any of your normal files start with an underscore, they will cause problems, -so try to avoid this. - -=== _config.yml - -This file stores configuration data. A majority of these options can be -specified from the command line executable but it's easier to throw them in -here so you don't have to type them out every time. Detailed explanations of -configuration directives can be found in Chapter X. - -=== _layouts - -Files in this directory represent templates that can be used to wrap converted -pages. Layouts are defined on a page-by-page basis in the YAML front matter. -The liquid tag +{{ content }}+ specifies where the content will be placed -during the conversion process. - -=== _posts - -If you're using Jekyll as a blog engine, this is where you'll place your blog -posts. A post's filename contains several pieces of data, so you must be very -careful about how these files are named. The filename format is: -+YEAR-MONTH-DATE-SLUG.MARKUP+. The YEAR must be four numbers and the MONTH and -DATE must be two numbers each. The SLUG is what will appear in the URL. The -MARKUP tells Jekyll the format of the post. The date and slug will be used -along with any permalink options you specify (See Chapter X) to construct the -final URL of the post. - -=== _site - -This is where the generated site will be placed (by default) once Jekyll is -done transforming it. If you're using version control, you'll want to add this -directory to the list of files to be ignored. - -=== Normal Files with YAML Front Matter - -All files outside of the special underscore directories and that do not -themselves begin with an underscore will be scanned by Jekyll and subjected to -conversion if they contain any YAML front matter. - -=== Everything Else - -Any files and directories that do not fall into one of the above categories -will be copied to the static site as-is without modification. In this example, -+images/logo.png+ will be copied to the same location in the generated site. - - - - -h2. Running Jekyll - -Usually this is done through the @jekyll@ executable, which is installed with -the gem. In order to get a server up and running with your Jekyll site, run: - -@jekyll --server@ - -and then browse to http://0.0.0.0:4000. There's plenty of [[configuration -options|Configuration]] available to you as well. - -On Debian or Ubuntu, you may need to add @/var/lib/gems/1.8/bin/@ to your path. - -h2. Deployment - -Since Jekyll simply generates a folder filled with HTML files, it can be -served using practically any available web server out there. Please check the -[[Deployment]] page for more information regarding specific scenarios. diff --git a/doc/output/stylesheets/handbookish-quirks.css b/doc/output/stylesheets/handbookish-quirks.css deleted file mode 100644 index e69de29b..00000000 diff --git a/doc/output/stylesheets/handbookish.css b/doc/output/stylesheets/handbookish.css deleted file mode 100644 index f07cdf57..00000000 --- a/doc/output/stylesheets/handbookish.css +++ /dev/null @@ -1,231 +0,0 @@ -/* BEG */ -/* --------------------------------------------------------------------------- - Bare AsciiDoc styles - Ryan Tomayko ---------------------------------------------------------------------------- */ - -body { - font-family:verdana,helvetica,arial,sans-serif; - font-size:81.25%; /* 13px */ - line-height:1.538; /* 20px */ - margin:40px 50px; - max-width:53.8461538462em; /* 790px */ - color:#333; -} - -em { - font-style:italic; -} - -strong { - font-weight:bold; - color:#000; -} - -tt { - font-family:consolas, 'lucida console', 'bitstream vera sans mono', - 'courier new', monospace; - color:#000; -} - -p, ul, ol, dl { - margin:10px 0 -} - -dl { } - -dt { - font-weight:normal; - color:#000; -} - -h1, h2, h3, h4, h5 { - font-family:'lucida grande',georgia,verdana,helvetica,arial,sans-serif; - font-weight:normal; - color:#000; -} - -h1 { - font-size:30px; - line-height:1.428; - margin:20px 0; -} - -h2 { - font-size:23px; - line-height:1.36363636; /* repeating, of course */ - margin:20px 0; -} - -h2 + .sectionbody {} - -h3 { - font-size:18px; - line-height:1.1; - margin:30px 0 10px 0; -} - -h4 { - font-size:13px; - font-weight:bold; - line-height:1.538; -} - -h5 { - font-size:13px; - font-style:italic; - line-height:1.538; -} - -pre { - font-size:larger; -} - -#header { - text-align:center; - margin-bottom:30px; -} - -#header h1 { margin-bottom:0 } - - -.title, .sidebar-title { - font-weight:normal; - margin-bottom:0; -} - -.admonitionblock .title { - font-weight:bold; -} - -.admonitionblock { - margin:30px 0px; - color:#555; -} - -.admonitionblock td.icon { - width:30px; - padding-right:20px; - padding-left:20px; - text-transform:uppercase; - font-weight:bold; - color:#888; -} - -.listingblock .content { - border:1px solid silver; - background:#eee; - padding:5px; -} - -.listingblock .content pre { - margin:0; -} - -.literalblock .content { - margin-left:40px; -} - -.verseblock .content { - white-space:pre -} - -.sidebarblock .sidebar-content { - border:1px solid silver; - background:#FFFFEE; - padding:0 10px; - color:#222; - font-size:smaller; - line-height:1.5; -} - -.sidebar-title { - margin:10px 0; - font-weight:bold; - color:#442; -} - -.quoteblock-content { - font-style:italic; - color:#444; - margin-left:40px; -} - -.quoteblock-content .attribution { - font-style:normal; - text-align:right; - color:#000; -} - -.exampleblock-content *:first-child { margin-top:0 } -.exampleblock-content { - border-left:2px solid silver; - padding-left:8px; -} - -#footer { - font-size:11px; - margin-top:40px; - border-top:1px solid silver; - color:#555; -} - -#author { - color:#000; - text-transform:uppercase -} - -/* vim: set ft=css ts=4 sw=4 noexpandtab: */ - -/* END @import url(bare.css); */ - -/* --------------------------------------------------------------------------- - FreeBSD AsciiDoc Theme - Ryan Tomayko - - Based on The FreeBSD Handbook and various other FreeBSD documenration. ---------------------------------------------------------------------------- */ - -body { - font-family:verdana,helvetica,arial,sans-serif; - font-size:100%; - color:#000; -} - -tt { color:#007A00 } -pre tt { color:#000 } - -dt { color:#000 } - -h1, h2, h3, h4, h5 { - font-family:'lucida grande',helvetica,verdana,sans-serif; - color:#900; - font-weight:bold; -} - -#header { - text-align:left; -} -#header h1 { margin-bottom:40px } - -h1 { - font-size:36px; - line-height:1; - margin:40px 0; -} - -h2 { - font-size:28px; - line-height:1; - margin:30px 0 20px 0; -} - -.sectionbody { - margin-left:30px; -} - -pre { - background:#EEE; -} - -/* vim: set ft=css ts=4 sw=4 noexpandtab: */ diff --git a/doc/output/stylesheets/scribe-quirks.css b/doc/output/stylesheets/scribe-quirks.css deleted file mode 100644 index e69de29b..00000000 diff --git a/doc/output/stylesheets/scribe.css b/doc/output/stylesheets/scribe.css deleted file mode 100644 index a1866a77..00000000 --- a/doc/output/stylesheets/scribe.css +++ /dev/null @@ -1,177 +0,0 @@ -/* --------------------------------------------------------------------------- - Bare AsciiDoc styles - Ryan Tomayko ---------------------------------------------------------------------------- */ - -body { - font-family:verdana,helvetica,arial,sans-serif; - font-size:81.25%; /* 13px */ - line-height:1.538; /* 20px */ - margin:40px auto 50px auto; - max-width:53.8461538462em; /* 790px */ - color:#333; -} - -em { - font-style:italic; -} - -strong { - font-weight:bold; - color:#000; -} - -tt { - font-family:consolas, 'lucida console', 'bitstream vera sans mono', - 'courier new', monospace; - color:#000; -} - -p, ul, ol, dl { - margin:10px 0 -} - -dl { - margin-left:40px -} - -dt { - font-weight:normal; - color:#000; -} - -h1, h2, h3, h4, h5 { - font-family:'lucida grande',georgia,verdana,helvetica,arial,sans-serif; - font-weight:normal; - color:#000; -} - -h1 { - font-size:40px; - line-height:1.428; - margin:20px 0; -} - -h2 { - font-size:30px; - line-height:1.36363636; /* repeating, of course */ - margin:60px 0 20px 0; -} - -h2 + .sectionbody {} - -h3 { - font-size:24px; - line-height:1.1; - margin:30px 0 10px 0; -} - -h4 { - font-size:18px; - line-height:1.1; - margin:20px 0 5px 0; -} - -h5 { - font-size:13px; - font-style:italic; - line-height:1.1; -} - -#header { - text-align:center; - margin-bottom:30px; -} - -#header h1 { margin-bottom:0 } - -.title, .sidebar-title { - font-weight:normal; - color:#000; - margin-bottom:0; -} - -.admonitionblock .title { - font-weight:bold; -} - -.admonitionblock { - margin:30px 0px; - color:#555; -} - -.admonitionblock td.icon { - width:30px; - padding-right:20px; - padding-left:20px; - text-transform:uppercase; - font-weight:bold; - color:#888; -} - -.listingblock { - margin: 13px 0; -} - -.listingblock .content { - border:1px solid silver; - background:#eee; - padding:5px; -} - -.listingblock .content pre { - margin:0; -} - -.literalblock .content { - margin-left:40px; -} - -.verseblock .content { - white-space:pre -} - -.sidebarblock .sidebar-content { - border:1px solid silver; - background:#FFFFEE; - padding:0 10px; - color:#222; - font-size:smaller; - line-height:1.5; -} - -.sidebar-title { - margin:10px 0; - font-weight:bold; - color:#442; -} - -.quoteblock-content { - font-style:italic; - color:#444; - margin-left:40px; -} - -.quoteblock-content .attribution { - font-style:normal; - text-align:right; - color:#000; -} - -.exampleblock-content *:first-child { margin-top:0 } -.exampleblock-content { - border-left:2px solid silver; - padding-left:8px; -} - -#footer { - font-size:11px; - margin-top:40px; - border-top:1px solid silver; - color:#555; -} - -#author { - color:#000; - text-transform:uppercase -} \ No newline at end of file diff --git a/g.pl b/g.pl deleted file mode 100644 index 32281c11..00000000 --- a/g.pl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -#fetch Gravatars - -use strict; -use warnings; - -use LWP::Simple; -use Digest::MD5 qw(md5_hex); - -my $size = 90; -my $output_dir = '.git/avatar'; - -die("no .git/ directory found in current path\n") unless -d '.git'; - -mkdir($output_dir) unless -d $output_dir; - -open(GITLOG, q/git log --pretty=format:"%ae|%an" |/) or die("failed to read git-log: $!\n"); - -my %processed_authors; - -while() { - chomp; - my($email, $author) = split(/\|/, $_); - - next if $processed_authors{$author}++; - - my $author_image_file = $output_dir . '/' . $author . '.png'; - - #skip images we have - next if -e $author_image_file; - - #try and fetch image - - my $grav_url = "http://www.gravatar.com/avatar/".md5_hex(lc $email)."?d=404&size=".$size; - - warn "fetching image for '$author' $email ($grav_url)...\n"; - - my $rc = getstore($grav_url, $author_image_file); - - sleep(1); - - if($rc != 200) { - unlink($author_image_file); - next; - } -} - -close GITLOG; diff --git a/output/stylesheets/scribe-quirks.css b/output/stylesheets/scribe-quirks.css deleted file mode 100644 index e69de29b..00000000 diff --git a/output/stylesheets/scribe.css b/output/stylesheets/scribe.css deleted file mode 100644 index a1866a77..00000000 --- a/output/stylesheets/scribe.css +++ /dev/null @@ -1,177 +0,0 @@ -/* --------------------------------------------------------------------------- - Bare AsciiDoc styles - Ryan Tomayko ---------------------------------------------------------------------------- */ - -body { - font-family:verdana,helvetica,arial,sans-serif; - font-size:81.25%; /* 13px */ - line-height:1.538; /* 20px */ - margin:40px auto 50px auto; - max-width:53.8461538462em; /* 790px */ - color:#333; -} - -em { - font-style:italic; -} - -strong { - font-weight:bold; - color:#000; -} - -tt { - font-family:consolas, 'lucida console', 'bitstream vera sans mono', - 'courier new', monospace; - color:#000; -} - -p, ul, ol, dl { - margin:10px 0 -} - -dl { - margin-left:40px -} - -dt { - font-weight:normal; - color:#000; -} - -h1, h2, h3, h4, h5 { - font-family:'lucida grande',georgia,verdana,helvetica,arial,sans-serif; - font-weight:normal; - color:#000; -} - -h1 { - font-size:40px; - line-height:1.428; - margin:20px 0; -} - -h2 { - font-size:30px; - line-height:1.36363636; /* repeating, of course */ - margin:60px 0 20px 0; -} - -h2 + .sectionbody {} - -h3 { - font-size:24px; - line-height:1.1; - margin:30px 0 10px 0; -} - -h4 { - font-size:18px; - line-height:1.1; - margin:20px 0 5px 0; -} - -h5 { - font-size:13px; - font-style:italic; - line-height:1.1; -} - -#header { - text-align:center; - margin-bottom:30px; -} - -#header h1 { margin-bottom:0 } - -.title, .sidebar-title { - font-weight:normal; - color:#000; - margin-bottom:0; -} - -.admonitionblock .title { - font-weight:bold; -} - -.admonitionblock { - margin:30px 0px; - color:#555; -} - -.admonitionblock td.icon { - width:30px; - padding-right:20px; - padding-left:20px; - text-transform:uppercase; - font-weight:bold; - color:#888; -} - -.listingblock { - margin: 13px 0; -} - -.listingblock .content { - border:1px solid silver; - background:#eee; - padding:5px; -} - -.listingblock .content pre { - margin:0; -} - -.literalblock .content { - margin-left:40px; -} - -.verseblock .content { - white-space:pre -} - -.sidebarblock .sidebar-content { - border:1px solid silver; - background:#FFFFEE; - padding:0 10px; - color:#222; - font-size:smaller; - line-height:1.5; -} - -.sidebar-title { - margin:10px 0; - font-weight:bold; - color:#442; -} - -.quoteblock-content { - font-style:italic; - color:#444; - margin-left:40px; -} - -.quoteblock-content .attribution { - font-style:normal; - text-align:right; - color:#000; -} - -.exampleblock-content *:first-child { margin-top:0 } -.exampleblock-content { - border-left:2px solid silver; - padding-left:8px; -} - -#footer { - font-size:11px; - margin-top:40px; - border-top:1px solid silver; - color:#555; -} - -#author { - color:#000; - text-transform:uppercase -} \ No newline at end of file From 3fa51d5da92a4ca48c99cedb1c8d75c1c49b39f1 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 26 Nov 2011 10:05:46 -0800 Subject: [PATCH 26/55] Ignore .DS_Store files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 66fa741f..17ea697f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pkg/ *~ _site/ .bundle/ +.DS_Store From 1da88bb30aa6f20863d75e569e8c4ca085d8a1bc Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 26 Nov 2011 18:48:51 -0800 Subject: [PATCH 27/55] Update and clarify dependencies. --- .gitignore | 1 + Rakefile | 7 +++++- jekyll.gemspec | 41 ++++++++++++++---------------------- lib/jekyll/tags/highlight.rb | 4 ++-- 4 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 17ea697f..ab54fd1b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ pkg/ _site/ .bundle/ .DS_Store +bbin/ diff --git a/Rakefile b/Rakefile index e8f280e7..a1f4b161 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,6 @@ require 'rubygems' require 'rake' +require 'rdoc' require 'date' $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib])) @@ -49,6 +50,10 @@ task :default => [:test, :features] require 'rake/testtask' Rake::TestTask.new(:test) do |test| + if `which pygmentize` == '' + puts "You must have Pygments installed to run the tests." + exit 1 + end test.libs << 'lib' << 'test' test.pattern = 'test/**/test_*.rb' test.verbose = true @@ -62,7 +67,7 @@ task :coverage do sh "open coverage/index.html" end -require 'rake/rdoctask' +require 'rdoc/task' Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = "#{name} #{version}" diff --git a/jekyll.gemspec b/jekyll.gemspec index 9be0c0c1..c0a8884b 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = 'jekyll' s.version = '0.11.0' - s.date = '2011-07-10' + s.date = '2011-11-26' s.rubyforge_project = 'jekyll' s.summary = "A simple, blog aware, static site generator." @@ -22,20 +22,22 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.textile LICENSE] - s.add_runtime_dependency('liquid', ">= 1.9.0") - s.add_runtime_dependency('classifier', ">= 1.3.1") - s.add_runtime_dependency('directory_watcher', ">= 1.1.1") - s.add_runtime_dependency('maruku', ">= 0.5.9") - s.add_runtime_dependency('kramdown', ">= 0.13.2") - s.add_runtime_dependency('albino', ">= 1.3.2") + s.add_runtime_dependency('liquid', "~> 2.3") + s.add_runtime_dependency('classifier', "~> 1.3") + s.add_runtime_dependency('directory_watcher', "~> 1.1") + s.add_runtime_dependency('maruku', "~> 0.5") + s.add_runtime_dependency('kramdown', "~> 0.13") + s.add_runtime_dependency('albino', "~> 1.3") - s.add_development_dependency('redgreen', ">= 1.2.2") - s.add_development_dependency('shoulda', ">= 2.11.3") - s.add_development_dependency('rr', ">= 1.0.2") - s.add_development_dependency('cucumber', ">= 0.10.3") - s.add_development_dependency('RedCloth', ">= 4.2.1") - s.add_development_dependency('rdiscount', ">= 1.6.5") - s.add_development_dependency('redcarpet', ">= 1.9.0") + s.add_development_dependency('rake', "~> 0.9") + s.add_development_dependency('rdoc', "~> 3.11") + s.add_development_dependency('redgreen', "~> 1.2") + s.add_development_dependency('shoulda', "~> 2.11") + s.add_development_dependency('rr', "~> 1.0") + s.add_development_dependency('cucumber', "= 1.1") + s.add_development_dependency('RedCloth', "~> 4.2") + s.add_development_dependency('rdiscount', "~> 1.6") + s.add_development_dependency('redcarpet', "~> 1.9") # = MANIFEST = s.files = %w[ @@ -46,14 +48,6 @@ Gem::Specification.new do |s| Rakefile bin/jekyll cucumber.yml - doc/output/book.html - doc/output/ch00-preface.asc - doc/output/ch01-quick-start.asc - doc/output/ch02-directory-layout.asc - doc/output/stylesheets/handbookish-quirks.css - doc/output/stylesheets/handbookish.css - doc/output/stylesheets/scribe-quirks.css - doc/output/stylesheets/scribe.css features/create_sites.feature features/embed_filters.feature features/markdown.feature @@ -64,7 +58,6 @@ Gem::Specification.new do |s| features/site_data.feature features/step_definitions/jekyll_steps.rb features/support/env.rb - g.pl jekyll.gemspec lib/jekyll.rb lib/jekyll/converter.rb @@ -97,8 +90,6 @@ Gem::Specification.new do |s| lib/jekyll/static_file.rb lib/jekyll/tags/highlight.rb lib/jekyll/tags/include.rb - output/stylesheets/scribe-quirks.css - output/stylesheets/scribe.css test/helper.rb test/source/.htaccess test/source/_includes/sig.markdown diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index cdc6d47f..8642c366 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -36,9 +36,9 @@ module Jekyll def render(context) if context.registers[:site].pygments - render_pygments(context, super.join) + render_pygments(context, super) else - render_codehighlighter(context, super.join) + render_codehighlighter(context, super) end end From 76fa7f016b6f161afb37a47cb34ac0838312767c Mon Sep 17 00:00:00 2001 From: Tomotaka Sakuma Date: Mon, 28 Nov 2011 16:32:20 +0900 Subject: [PATCH 28/55] Fix an issue NoMethodError happens in case number of files under _posts is less than limit_posts. --- lib/jekyll/site.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 9c24f8e4..c7c437d7 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -173,7 +173,10 @@ module Jekyll self.posts.sort! # limit the posts if :limit_posts option is set - self.posts = self.posts[-limit_posts, limit_posts] if limit_posts + if limit_posts + limit = self.posts.length < limit_posts ? self.posts.length : limit_posts + self.posts = self.posts[-limit, limit] + end end # Run each of the Generators. From d80c773b0194dec9400f97c29b48fc8e63a58f3c Mon Sep 17 00:00:00 2001 From: Thomas Laumann Date: Mon, 28 Nov 2011 14:05:34 +0100 Subject: [PATCH 29/55] New solution for passing restrictions to RedCloth - all tests pass with ruby 1.8 (just invoking rake) --- lib/jekyll/converters/textile.rb | 22 +++++++++++++++------- test/test_redcloth.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/lib/jekyll/converters/textile.rb b/lib/jekyll/converters/textile.rb index aa7201cd..6572b518 100644 --- a/lib/jekyll/converters/textile.rb +++ b/lib/jekyll/converters/textile.rb @@ -27,15 +27,23 @@ module Jekyll def convert(content) setup - - restrictions = Array.new - if !@config['redcloth'].nil? - @config['redcloth'].each do |key, value| - restrictions << key.to_sym if value - end + + # Shortcut if config doesn't contain RedCloth section + return RedCloth.new(content).to_html if @config['redcloth'].nil? + + # List of attributes defined on RedCloth + # (from http://redcloth.rubyforge.org/classes/RedCloth/TextileDoc.html) + attrs = ['filter_classes', 'filter_html', 'filter_ids', 'filter_styles', + 'hard_breaks', 'lite_mode', 'no_span_caps', 'sanitize_html'] + + r = RedCloth.new(content) + + # Set attributes in r if they are NOT nil in the config + attrs.each do |attr| + r.instance_variable_set("@#{attr}".to_sym, @config['redcloth'][attr]) unless @config['redcloth'][attr].nil? end - RedCloth.new(content, restrictions).to_html + r.to_html end end diff --git a/test/test_redcloth.rb b/test/test_redcloth.rb index 2b43fe24..55e52cdf 100644 --- a/test/test_redcloth.rb +++ b/test/test_redcloth.rb @@ -54,4 +54,33 @@ class TestRedCloth < Test::Unit::TestCase assert_equal "

line1\nline2

", @textile.convert("p. line1\nline2").strip end end + + context "RedCloth w/no_span_caps set to false" do + setup do + config = { + 'redcloth' => { + 'no_span_caps' => false + } + } + @textile = TextileConverter.new config + end + should "generate span tags around capitalized words" do + assert_equal "

NSC

", @textile.convert("NSC").strip + end + end + + context "RedCloth w/no_span_caps set to true" do + setup do + config = { + 'redcloth' => { + 'no_span_caps' => true + } + } + @textile = TextileConverter.new config + end + + should "not generate span tags around capitalized words" do + assert_equal "

NSC

", @textile.convert("NSC").strip + end + end end From b18bdee6f17f5ccb34eb560c0034eabcb8df9d07 Mon Sep 17 00:00:00 2001 From: OpenSourceXpress Date: Thu, 1 Dec 2011 09:42:12 +0800 Subject: [PATCH 30/55] Invalid migrator for WordPress because of a typo. WordPress importer name should be WordPress not Wordpress. --- bin/jekyll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/jekyll b/bin/jekyll index 2e33f377..9d2e6f91 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -162,7 +162,7 @@ if ARGV.size > 0 migrators = { :posterous => 'Posterous', :wordpressdotcom => 'WordpressDotCom', - :wordpress => 'Wordpress', + :wordpress => 'WordPress', :csv => 'CSV', :drupal => 'Drupal', :enki => 'Enki', From 0f51c81cfab6fcc3fbf6cd2720ad6da216a113d1 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 4 Dec 2011 12:01:37 +1100 Subject: [PATCH 31/55] Added support for rewriting Tumblr URLs to Jekyll URLs in posts, meta redirects for Github pages, and automatic addition of Pygments highlight tags. --- lib/jekyll/migrators/tumblr.rb | 230 ++++++++++++++++++++++----------- 1 file changed, 158 insertions(+), 72 deletions(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 10f41601..0f9c227c 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -3,93 +3,179 @@ require 'open-uri' require 'fileutils' require 'date' require 'json' +require 'uri' +require 'jekyll' module Jekyll module Tumblr - def self.process(url, grab_images = false, format = "html") - current_page = 0 - - while true - - f = open(url + "/api/read/json/?num=50&start=#{current_page * 50}") - # [21...-2] strips Tumblr's Javascript/JSONP start/end chars - json = f.readlines.join("\n")[21...-2] + def self.process(url, format = "html", grab_images = false, + add_highlights = false, rewrite_urls = true) + FileUtils.mkdir_p "_posts/tumblr" + url += "/api/read/json/" + per_page = 50 + posts = [] + # Two passes are required so that we can rewrite URLs. + # First pass builds up an array of each post as a hash. + begin + current_page = (current_page || -1) + 1 + feed = open(url + "?num=#{per_page}&start=#{current_page * per_page}") + json = feed.readlines.join("\n")[21...-2] # Strip Tumblr's JSONP chars. blog = JSON.parse(json) puts "Page: #{current_page + 1} - Posts: #{blog["posts"].size}" - FileUtils.mkdir_p "_posts/tumblr" - - blog["posts"].each do |post| - - case post['type'] - when "regular" - title = post["regular-title"] - content = post["regular-body"] - when "link" - title = post["link-text"] || post["link-url"] - content = "#{title}" - content << "
" + post["link-description"] unless post["link-description"].nil? - when "photo" - title = post["photo-caption"] - content = "" - content = "#{content}" unless post["photo-link-url"].nil? - when "audio" - if !post["id3-title"].nil? - title = post["id3-title"] - content = post.at["audio-player"] + "
" + post["audio-caption"] - else - title = post["audio-caption"] - content = post.at["audio-player"] - end - when "quote" - title = post["quote-text"] - content = "
#{post["quote-text"]}
" - content << "—" + post["quote-source"] unless post["quote-source"].nil? - when "conversation" - title = post["conversation-title"] - content = "
" - post["conversation"]["line"].each do |line| - content << "
#{line['label']}
#{line}
" - end - content << "
" - when "video" - title = post["video-title"] - content = post["video-player"] - content << "
" + post["video-caption"] unless post["video-caption"].nil? - end # End post types - - name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" - - File.open("_posts/tumblr/#{name}", "w") do |f| - if format == "md" - preserve = ["table", "tr", "th", "td"] - preserve.each { |tag| content = content.gsub(/<#{tag}/i, "$$" + tag).gsub(/<\/#{tag}/i, "||" + tag) } - content = %x[echo '#{content.gsub("'", "''")}' | html2text] - preserve.each { |tag| content = content.gsub("$$" + tag, "<" + tag).gsub("||" + tag, " "post", "title" => title, "tags" => post["tags"]} - f.puts header.to_yaml + "---\n" + content - end # End file - - end # End post XML - - if blog["posts"].size < 50 - break + posts += blog["posts"].map { |post| post_to_hash(post, format) } + end until blog["posts"].size < per_page + # Rewrite URLs and create redirects. + posts = rewrite_urls_and_redirects posts if rewrite_urls + # Second pass for writing post files. + posts.each do |post| + if format == "md" + post[:content] = html_to_markdown post[:content] + post[:content] = add_syntax_highlights post[:content] if add_highlights end - current_page += 1 - - end # End while loop - end # End method + File.open("_posts/tumblr/#{post[:name]}", "w") do |f| + f.puts post[:header].to_yaml + "---\n" + post[:content] + end + end + end private + # Converts each type of Tumblr post to a hash with all required + # data for Jekyll. + def self.post_to_hash(post, format) + case post['type'] + when "regular" + title = post["regular-title"] + content = post["regular-body"] + when "link" + title = post["link-text"] || post["link-url"] + content = "#{title}" + unless post["link-description"].nil? + content << "
" + post["link-description"] + end + when "photo" + title = post["photo-caption"] + content = "" + unless post["photo-link-url"].nil? + content = "#{content}" + end + when "audio" + if !post["id3-title"].nil? + title = post["id3-title"] + content = post.at["audio-player"] + "
" + post["audio-caption"] + else + title = post["audio-caption"] + content = post.at["audio-player"] + end + when "quote" + title = post["quote-text"] + content = "
#{post["quote-text"]}
" + unless post["quote-source"].nil? + content << "—" + post["quote-source"] + end + when "conversation" + title = post["conversation-title"] + content = "
" + post["conversation"]["line"].each do |line| + content << "
#{line['label']}
#{line}
" + end + content << "
" + when "video" + title = post["video-title"] + content = post["video-player"] + unless post["video-caption"].nil? + content << "
" + post["video-caption"] + end + end + date = Date.parse(post['date']).to_s + slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') + { + :name => "#{date}-#{slug}.#{format}", + :header => { + "layout" => "post", + "title" => title, + "tags" => post["tags"], + }, + :content => content, + :url => post["url"], + :slug => post["url-with-slug"], + } + end + + # Create a Hash of old urls => new urls, for rewriting and + # redirects, and replace urls in each post. Instantiate Jekyll + # site/posts to get the correct permalink format. + def self.rewrite_urls_and_redirects(posts) + site = Jekyll::Site.new(Jekyll.configuration({})) + dir = File.join(File.dirname(__FILE__), "..") + urls = Hash[posts.map { |post| + tumblr_url = URI.parse(post[:slug]).path + jekyll_url = Jekyll::Post.new(site, dir, "", "tumblr/" + post[:name]).url + redirect_dir = tumblr_url.sub(/\//, "") + "/" + FileUtils.mkdir_p redirect_dir + File.open(redirect_dir + "index.html", "w") do |f| + f.puts "" + end + [tumblr_url, jekyll_url] + }] + posts.map { |post| + urls.each do |tumblr_url, jekyll_url| + post[:content].gsub!(/#{tumblr_url}/i, jekyll_url) + end + post + } + end + + # Uses Python's html2text to convert a post's content to + # markdown. Preserve HTML tables as per the markdown docs. + def self.html_to_markdown(content) + preserve = ["table", "tr", "th", "td"] + preserve.each do |tag| + content.gsub!(/<#{tag}/i, "$$" + tag) + content.gsub!(/<\/#{tag}/i, "||" + tag) + end + content = %x[echo '#{content.gsub("'", "''")}' | html2text] + preserve.each do |tag| + content.gsub!("$$" + tag, "<" + tag) + content.gsub!("||" + tag, " Date: Sat, 3 Dec 2011 22:36:18 -0500 Subject: [PATCH 32/55] Fix typo "destintation" => "destination" --- bin/jekyll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/jekyll b/bin/jekyll index 2e33f377..30b74142 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -191,7 +191,7 @@ end -# Get source and destintation from command line +# Get source and destination from command line case ARGV.size when 0 when 1 From 9a3429dc74bfb5b40801e0f1e6553ca5d69948a0 Mon Sep 17 00:00:00 2001 From: jpravetz Date: Sun, 4 Dec 2011 08:37:42 -0800 Subject: [PATCH 33/55] Update lib/jekyll/convertible.rb --- lib/jekyll/convertible.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index d33abc56..a891e642 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -26,14 +26,13 @@ module Jekyll def read_yaml(base, name) self.content = File.read(File.join(base, name)) - if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m - self.content = $POSTMATCH - - begin + begin + if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m + self.content = $POSTMATCH self.data = YAML.load($1) - rescue => e - puts "YAML Exception reading #{name}: #{e.message}" end + rescue => e + puts "YAML Exception reading #{name}: #{e.message}" end self.data ||= {} From 06d9446ade6db13313780bbf4180965740455d2d Mon Sep 17 00:00:00 2001 From: Simon Griffee Date: Sun, 4 Dec 2011 23:35:36 +0100 Subject: [PATCH 34/55] Added missing require 'yaml', without which the TextPattern migrator script was failing. --- lib/jekyll/migrators/textpattern.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jekyll/migrators/textpattern.rb b/lib/jekyll/migrators/textpattern.rb index 58634c48..3b370ed9 100644 --- a/lib/jekyll/migrators/textpattern.rb +++ b/lib/jekyll/migrators/textpattern.rb @@ -1,6 +1,7 @@ require 'rubygems' require 'sequel' require 'fileutils' +require 'yaml' # NOTE: This converter requires Sequel and the MySQL gems. # The MySQL gem can be difficult to install on OS X. Once you have MySQL From 9523c3990e7a9b142ce56f38ee2ab11d57e5c997 Mon Sep 17 00:00:00 2001 From: Kendall Buchanan Date: Thu, 22 Dec 2011 12:33:15 -0700 Subject: [PATCH 35/55] Adding migrator for RSS feeds. --- lib/jekyll/migrators/rss.rb | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lib/jekyll/migrators/rss.rb diff --git a/lib/jekyll/migrators/rss.rb b/lib/jekyll/migrators/rss.rb new file mode 100644 index 00000000..461abd35 --- /dev/null +++ b/lib/jekyll/migrators/rss.rb @@ -0,0 +1,47 @@ +# Created by Kendall Buchanan (https://github.com/kendagriff) on 2011-12-22. +# Use at your own risk. The end. +# +# Usage: +# (URL) +# ruby -r '_import/rss.rb' -e "Jekyll::MigrateRSS.process('http://yourdomain.com/your-favorite-feed.xml')" +# +# (Local file) +# ruby -r '_import/rss.rb' -e "Jekyll::MigrateRSS.process('./somefile/on/your/computer.xml')" + +require 'rubygems' +require 'rss/1.0' +require 'rss/2.0' +require 'open-uri' +require 'fileutils' +require 'yaml' + +module Jekyll + module MigrateRSS + + # The `source` argument may be a URL or a local file. + def self.process(source) + content = "" + open(source) { |s| content = s.read } + rss = RSS::Parser.parse(content, false) + + raise "There doesn't appear to be any RSS items at the source (#{source}) provided." unless rss + + rss.items.each do |item| + formatted_date = item.date.strftime('%Y-%m-%d') + post_name = item.title.split(%r{ |!|/|:|&|-|$|,}).map { |i| i.downcase if i != '' }.compact.join('-') + name = "#{formatted_date}-#{post_name}" + + header = { + 'layout' => 'post', + 'title' => item.title + } + + File.open("_posts/#{name}.html", "w") do |f| + f.puts header.to_yaml + f.puts "---\n" + f.puts item.description + end + end + end + end +end \ No newline at end of file From 886b9740f2635334d83251875447a6f2bcb7cdce Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Tue, 27 Dec 2011 10:09:59 +1100 Subject: [PATCH 36/55] Fixed grab_images handling. --- lib/jekyll/migrators/tumblr.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 0f9c227c..0c6402ab 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -10,6 +10,7 @@ module Jekyll module Tumblr def self.process(url, format = "html", grab_images = false, add_highlights = false, rewrite_urls = true) + @grab_images = grab_images FileUtils.mkdir_p "_posts/tumblr" url += "/api/read/json/" per_page = 50 @@ -55,7 +56,7 @@ module Jekyll end when "photo" title = post["photo-caption"] - content = "" + content = "" unless post["photo-link-url"].nil? content = "#{content}" end @@ -170,16 +171,15 @@ module Jekyll lines.join("\n") end - def self.save_file(url, grab_image = false) - unless grab_image == false + def self.save_file(url) + if @grab_images FileUtils.mkdir_p "tumblr_files" File.open("tumblr_files/#{url.split('/').last}", "w") do |f| f.write(open(url).read) end - return "/tumblr_files/#{url.split('/').last}" - else - return url + url = "/tumblr_files/#{url.split('/').last}" end + url end end end From 8754a024b520c653e88d137e1dd8fcb464aa29ff Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 27 Dec 2011 10:57:20 -0700 Subject: [PATCH 37/55] Update history. --- History.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/History.txt b/History.txt index 5672af18..bd6a1bbd 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,8 @@ +== HEAD + * Bug Fixes + * Fix extra blank line in highlight blocks (#409) + * Update dependencies + == 0.11.0 / 2011-07-10 * Major Enhancements * Add command line importer functionality (#253) From 3ab7658d1f62b75265d3f3cd03a561c54e1be3ab Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Wed, 28 Dec 2011 08:16:19 +1100 Subject: [PATCH 39/55] Fixed Tumblr URL redirects. --- lib/jekyll/migrators/tumblr.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 0c6402ab..2a2a3034 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -110,6 +110,9 @@ module Jekyll site = Jekyll::Site.new(Jekyll.configuration({})) dir = File.join(File.dirname(__FILE__), "..") urls = Hash[posts.map { |post| + # Create an initial empty file for the post so that + # we can instantiate a post object. + File.open("_posts/tumblr/#{post[:name]}", "w") tumblr_url = URI.parse(post[:slug]).path jekyll_url = Jekyll::Post.new(site, dir, "", "tumblr/" + post[:name]).url redirect_dir = tumblr_url.sub(/\//, "") + "/" From 4ece77300b949a0efbd49f2ab4598095b9aa2a1c Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 27 Dec 2011 17:48:00 -0700 Subject: [PATCH 40/55] Gah, did not commit these for v0.11.1 version release. --- History.txt | 2 +- jekyll.gemspec | 4 ++-- lib/jekyll.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/History.txt b/History.txt index bd6a1bbd..53d11c5c 100644 --- a/History.txt +++ b/History.txt @@ -1,4 +1,4 @@ -== HEAD +== 0.11.1 / 2011-12-27 * Bug Fixes * Fix extra blank line in highlight blocks (#409) * Update dependencies diff --git a/jekyll.gemspec b/jekyll.gemspec index c0a8884b..2e8acf44 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -4,8 +4,8 @@ Gem::Specification.new do |s| s.rubygems_version = '1.3.5' s.name = 'jekyll' - s.version = '0.11.0' - s.date = '2011-11-26' + s.version = '0.11.1' + s.date = '2011-12-27' s.rubyforge_project = 'jekyll' s.summary = "A simple, blog aware, static site generator." diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 9b66199c..612faa9c 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -46,7 +46,7 @@ require_all 'jekyll/generators' require_all 'jekyll/tags' module Jekyll - VERSION = '0.11.0' + VERSION = '0.11.1' # Default options. Overriden by values in _config.yml or command-line opts. # (Strings rather symbols used for compatability with YAML). From b66840ca4686c5a66df68399517c108ff1548365 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Tue, 27 Dec 2011 17:53:50 -0700 Subject: [PATCH 41/55] Release 0.11.2 --- History.txt | 4 ++++ jekyll.gemspec | 4 ++-- lib/jekyll.rb | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/History.txt b/History.txt index 53d11c5c..884b58e9 100644 --- a/History.txt +++ b/History.txt @@ -1,3 +1,7 @@ +== 0.11.2 / 2011-12-27 + * Bug Fixes + * Fix gemspec + == 0.11.1 / 2011-12-27 * Bug Fixes * Fix extra blank line in highlight blocks (#409) diff --git a/jekyll.gemspec b/jekyll.gemspec index 2e8acf44..def6b568 100644 --- a/jekyll.gemspec +++ b/jekyll.gemspec @@ -4,7 +4,7 @@ Gem::Specification.new do |s| s.rubygems_version = '1.3.5' s.name = 'jekyll' - s.version = '0.11.1' + s.version = '0.11.2' s.date = '2011-12-27' s.rubyforge_project = 'jekyll' @@ -34,7 +34,7 @@ Gem::Specification.new do |s| s.add_development_dependency('redgreen', "~> 1.2") s.add_development_dependency('shoulda', "~> 2.11") s.add_development_dependency('rr', "~> 1.0") - s.add_development_dependency('cucumber', "= 1.1") + s.add_development_dependency('cucumber', "1.1") s.add_development_dependency('RedCloth', "~> 4.2") s.add_development_dependency('rdiscount', "~> 1.6") s.add_development_dependency('redcarpet', "~> 1.9") diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 612faa9c..859060c5 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -46,7 +46,7 @@ require_all 'jekyll/generators' require_all 'jekyll/tags' module Jekyll - VERSION = '0.11.1' + VERSION = '0.11.2' # Default options. Overriden by values in _config.yml or command-line opts. # (Strings rather symbols used for compatability with YAML). From 743e01f231649529350edaff6728f1bce87eae27 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Thu, 29 Dec 2011 11:37:06 +1100 Subject: [PATCH 42/55] Fixed a change in Tumblr's API whereby photos no longer have a single URL field. --- lib/jekyll/migrators/tumblr.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 2a2a3034..cc318ca0 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -56,10 +56,10 @@ module Jekyll end when "photo" title = post["photo-caption"] - content = "" - unless post["photo-link-url"].nil? - content = "#{content}" - end + max_size = post.keys.map{ |k| k.gsub("photo-url-", "").to_i }.max + url = post["photo-url"] || post["photo-url-#{max_size}"] + content = "" + content = "#{content}" unless url.nil? when "audio" if !post["id3-title"].nil? title = post["id3-title"] From bab178d9f8502e6941e75dbba1631d26f246fab4 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Thu, 29 Dec 2011 11:37:46 +1100 Subject: [PATCH 43/55] Strip HTML from any caption-based titles. --- lib/jekyll/migrators/tumblr.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index cc318ca0..d1df9678 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -1,6 +1,7 @@ require 'rubygems' require 'open-uri' require 'fileutils' +require 'nokogiri' require 'date' require 'json' require 'uri' @@ -89,6 +90,7 @@ module Jekyll end end date = Date.parse(post['date']).to_s + title = Nokogiri::HTML(title).text slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '') { :name => "#{date}-#{slug}.#{format}", From c26bd30318aae14442fc4f7565d2d6458e10808d Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Thu, 29 Dec 2011 11:58:11 +1100 Subject: [PATCH 44/55] Fix photo link URL. --- lib/jekyll/migrators/tumblr.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index d1df9678..e2758ba8 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -60,7 +60,9 @@ module Jekyll max_size = post.keys.map{ |k| k.gsub("photo-url-", "").to_i }.max url = post["photo-url"] || post["photo-url-#{max_size}"] content = "" - content = "#{content}" unless url.nil? + unless post["photo-link-url"].nil? + content = "#{content}" + end when "audio" if !post["id3-title"].nil? title = post["id3-title"] From f2502dfab2da77f916731edcc4ac22022aeabf4b Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Fri, 30 Dec 2011 23:25:09 +1100 Subject: [PATCH 45/55] Added handling for Tumblr missing image extensions. --- lib/jekyll/migrators/tumblr.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index e2758ba8..367a83c9 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -59,7 +59,10 @@ module Jekyll title = post["photo-caption"] max_size = post.keys.map{ |k| k.gsub("photo-url-", "").to_i }.max url = post["photo-url"] || post["photo-url-#{max_size}"] - content = "" + ext = "." + post[post.keys.select { |k| + k =~ /^photo-url-/ && post[k].split("/").last =~ /\./ + }.first].split(".").last + content = "" unless post["photo-link-url"].nil? content = "#{content}" end @@ -178,13 +181,13 @@ module Jekyll lines.join("\n") end - def self.save_file(url) + def self.save_file(url, ext) if @grab_images + path = "tumblr_files/#{url.split('/').last}" + path += ext unless path =~ /#{ext}$/ FileUtils.mkdir_p "tumblr_files" - File.open("tumblr_files/#{url.split('/').last}", "w") do |f| - f.write(open(url).read) - end - url = "/tumblr_files/#{url.split('/').last}" + File.open(path, "w") { |f| f.write(open(url).read) } + url = "/" + path end url end From 4fe5e6ba99d629dc8f0c030d2ea69de70ed713fe Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 14 Jan 2012 20:17:35 -0800 Subject: [PATCH 46/55] Update history and fix up style. --- History.txt | 1 + bin/jekyll | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 5d6a03cd..ab504a7d 100644 --- a/History.txt +++ b/History.txt @@ -1,6 +1,7 @@ == HEAD * Minor Enhancements * Add ability to explicitly specify included files (#261) + * Add --default-mimetype option (#279) == 0.11.2 / 2011-12-27 * Bug Fixes diff --git a/bin/jekyll b/bin/jekyll index 5e77c156..f639b2ec 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -272,7 +272,7 @@ if options['server'] mime_types = WEBrick::HTTPUtils::DefaultMimeTypes mime_types.store 'js', 'application/javascript' if options['default-mimetype'] - mime_types.store nil, options['default-mimetype'] + mime_types.store(nil, options['default-mimetype']) end s = HTTPServer.new( From c14eb346a376459e358729de64faf3b3cc7e21fa Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 15 Jan 2012 20:35:09 -0800 Subject: [PATCH 47/55] Allow [+.#-] in highlight lang shortnames. Fixes #282. --- History.txt | 2 ++ lib/jekyll/tags/highlight.rb | 15 ++++++++++----- test/test_tags.rb | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/History.txt b/History.txt index ab504a7d..a9cb9661 100644 --- a/History.txt +++ b/History.txt @@ -2,6 +2,8 @@ * Minor Enhancements * Add ability to explicitly specify included files (#261) * Add --default-mimetype option (#279) + * Bug Fixes + * Allow some special characters in highlight names == 0.11.2 / 2011-12-27 * Bug Fixes diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index 8642c366..ed3a0f70 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -3,14 +3,19 @@ module Jekyll class HighlightBlock < Liquid::Block include Liquid::StandardFilters - # We need a language, but the linenos argument is optional. - SYNTAX = /(\w+)\s?([\w\s=]+)*/ + # The regular expression syntax checker. Start with the language specifier. + # Follow that by zero or more space separated options that take one of two + # forms: + # + # 1. name + # 2. name=value + SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=\w+)?)*)$/ def initialize(tag_name, markup, tokens) super - if markup =~ SYNTAX + if markup.strip =~ SYNTAX @lang = $1 - if defined? $2 + if defined?($2) && $2 != '' tmp_options = {} $2.split.each do |opt| key, value = opt.split('=') @@ -23,7 +28,7 @@ module Jekyll end tmp_options[key] = value end - tmp_options = tmp_options.to_a.collect { |opt| opt.join('=') } + tmp_options = tmp_options.to_a.sort.collect { |opt| opt.join('=') } # additional options to pass to Albino @options = { 'O' => tmp_options.join(',') } else diff --git a/test/test_tags.rb b/test/test_tags.rb index 50750757..c1e454ed 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -31,6 +31,41 @@ CONTENT create_post(content, override) end + context "language name" do + should "match only the required set of chars" do + r = Jekyll::HighlightBlock::SYNTAX + assert_match r, "ruby" + assert_match r, "c#" + assert_match r, "xml+cheetah" + assert_match r, "x.y" + assert_match r, "coffee-script" + + assert_no_match r, "blah^" + + assert_match r, "ruby key=val" + assert_match r, "ruby a=b c=d" + end + end + + context "initialized tag" do + should "work" do + tag = Jekyll::HighlightBlock.new('highlight', 'ruby ', ["test", "{% endhighlight %}", "\n"]) + assert_equal({}, tag.instance_variable_get(:@options)) + + tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos ', ["test", "{% endhighlight %}", "\n"]) + assert_equal({'O' => "linenos=inline"}, tag.instance_variable_get(:@options)) + + tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table ', ["test", "{% endhighlight %}", "\n"]) + assert_equal({'O' => "linenos=table"}, tag.instance_variable_get(:@options)) + + tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table nowrap', ["test", "{% endhighlight %}", "\n"]) + assert_equal({'O' => "linenos=table,nowrap=true"}, tag.instance_variable_get(:@options)) + + tag = Jekyll::HighlightBlock.new('highlight', 'ruby linenos=table cssclass=hl', ["test", "{% endhighlight %}", "\n"]) + assert_equal({'O' => "cssclass=hl,linenos=table"}, tag.instance_variable_get(:@options)) + end + end + context "post content has highlight tag" do setup do fill_post("test") From fa6d0137919e089b406a19e9c1a293b712d82ce4 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 15 Jan 2012 21:08:21 -0800 Subject: [PATCH 48/55] Update history. --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index a9cb9661..9e40c72b 100644 --- a/History.txt +++ b/History.txt @@ -2,6 +2,7 @@ * Minor Enhancements * Add ability to explicitly specify included files (#261) * Add --default-mimetype option (#279) + * Allow setting of RedCloth options (#284) * Bug Fixes * Allow some special characters in highlight names From c3b12457a0e6b758af0a3611043f74602f18c2c7 Mon Sep 17 00:00:00 2001 From: Nicholas Firth-McCoy Date: Wed, 18 Jan 2012 10:55:58 +1100 Subject: [PATCH 49/55] Update Posterous migrator to take an api_token instead of email and pass The Posterous API call for retrieving a user's API token (`/api/2/auth/token`) is no longer supported and returns 410 GONE. This patch updates the #process method to accept an API token instead of an email address and password. A user's API token can be retrieved from http://posterous.com/api. --- lib/jekyll/migrators/posterous.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/jekyll/migrators/posterous.rb b/lib/jekyll/migrators/posterous.rb index 6cfc2430..bd753527 100644 --- a/lib/jekyll/migrators/posterous.rb +++ b/lib/jekyll/migrators/posterous.rb @@ -27,12 +27,10 @@ module Jekyll end end - def self.process(email, pass, blog = 'primary') - @email, @pass = email, pass - @api_token = JSON.parse(self.fetch("/api/2/auth/token").body)['api_token'] + def self.process(api_token, blog = 'primary') FileUtils.mkdir_p "_posts" - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}").body) page = 1 while posts.any? @@ -61,7 +59,7 @@ module Jekyll end page += 1 - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}&page=#{page}").body) end end end From 19fc8cb4882e8241025dfd59f75bbcc42643ffa6 Mon Sep 17 00:00:00 2001 From: Nicholas Firth-McCoy Date: Wed, 18 Jan 2012 11:08:02 +1100 Subject: [PATCH 50/55] Oops, still need email and pass. Update usage comment --- lib/jekyll/migrators/posterous.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/jekyll/migrators/posterous.rb b/lib/jekyll/migrators/posterous.rb index bd753527..0a2280f2 100644 --- a/lib/jekyll/migrators/posterous.rb +++ b/lib/jekyll/migrators/posterous.rb @@ -5,7 +5,7 @@ require 'net/http' require 'uri' require "json" -# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, blog)' +# ruby -r './lib/jekyll/migrators/posterous.rb' -e 'Jekyll::Posterous.process(email, pass, api_key, blog)' module Jekyll module Posterous @@ -27,10 +27,11 @@ module Jekyll end end - def self.process(api_token, blog = 'primary') + def self.process(email, pass, api_token, blog = 'primary') + @email, @pass, @api_token = email, pass, api_token FileUtils.mkdir_p "_posts" - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}").body) page = 1 while posts.any? @@ -59,7 +60,7 @@ module Jekyll end page += 1 - posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{api_token}&page=#{page}").body) + posts = JSON.parse(self.fetch("/api/v2/users/me/sites/#{blog}/posts?api_token=#{@api_token}&page=#{page}").body) end end end From 03ad973523b6ac313014dd5f0678a6da05f0183e Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 21 Jan 2012 19:43:03 -0800 Subject: [PATCH 51/55] Update history. --- History.txt | 1 + lib/jekyll/post.rb | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/History.txt b/History.txt index 9e40c72b..0f831c7d 100644 --- a/History.txt +++ b/History.txt @@ -5,6 +5,7 @@ * Allow setting of RedCloth options (#284) * Bug Fixes * Allow some special characters in highlight names + * URL escape category names in URL generation (#360) == 0.11.2 / 2011-12-27 * Bug Fixes diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index bafb7257..a46d0798 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -131,7 +131,7 @@ module Jekyll "title" => CGI.escape(slug), "i_day" => date.strftime("%d").to_i.to_s, "i_month" => date.strftime("%m").to_i.to_s, - "categories" => categories.map {|c| URI.escape(c) }.join('/'), + "categories" => categories.map { |c| URI.escape(c) }.join('/'), "output_ext" => self.output_ext }.inject(template) { |result, token| result.gsub(/:#{Regexp.escape token.first}/, token.last) From 456a9f35747943716f8de6258caa36c47ca82728 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sat, 21 Jan 2012 19:49:41 -0800 Subject: [PATCH 52/55] Update history. --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index 0f831c7d..fefd9baf 100644 --- a/History.txt +++ b/History.txt @@ -6,6 +6,7 @@ * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) + * Fix error with limit_posts (#442) == 0.11.2 / 2011-12-27 * Bug Fixes From c04a9549ea3aa90994612091f92d5481046f4ed2 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 22 Jan 2012 00:27:40 -0800 Subject: [PATCH 53/55] Make note of self.name requirement for Convertible. --- lib/jekyll/convertible.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index a891e642..fe25b30e 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -10,6 +10,7 @@ require 'set' # self.data= # self.ext= # self.output= +# self.name module Jekyll module Convertible # Returns the contents as a String. From 2da64d9c447d460b7153ffabc6c64c03586cfb33 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Sun, 22 Jan 2012 16:25:15 -0800 Subject: [PATCH 54/55] Update history. --- History.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/History.txt b/History.txt index fefd9baf..53bd41c6 100644 --- a/History.txt +++ b/History.txt @@ -3,6 +3,7 @@ * Add ability to explicitly specify included files (#261) * Add --default-mimetype option (#279) * Allow setting of RedCloth options (#284) + * Add post_url Liquid tag for internal post linking (#369) * Bug Fixes * Allow some special characters in highlight names * URL escape category names in URL generation (#360) From 0284b8b22f12081f7e35563592be41ae082c3cfe Mon Sep 17 00:00:00 2001 From: Beau Simensen Date: Sun, 22 Jan 2012 20:58:56 -0800 Subject: [PATCH 55/55] Handle Posterous rate limiting --- lib/jekyll/migrators/posterous.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/jekyll/migrators/posterous.rb b/lib/jekyll/migrators/posterous.rb index deca8689..f1601ba3 100644 --- a/lib/jekyll/migrators/posterous.rb +++ b/lib/jekyll/migrators/posterous.rb @@ -29,6 +29,11 @@ module Jekyll case response when Net::HTTPSuccess then response when Net::HTTPRedirection then fetch(response['location'], limit - 1) + when Net::HTTPForbidden then + retry_after = response.to_hash['retry-after'][0] + puts "We have been told to try again after #{retry_after} seconds" + sleep(retry_after.to_i + 1) + fetch(uri_str, limit - 1) else response.error! end end