Skip to content

Loading…

Jekyll PRs #3

Closed
wants to merge 9 commits into from

5 participants

@parkr
Jekyll member

ACHTUNG!! This is merging into initial-migrator-import. Ensure you merge that branch into master once you accept the former.

Accepting the good import PRs on mojombo/jekyll.

joschi added some commits
@joschi joschi Added migrator to import entries from Serendipity (S9Y).
* Only uses classes from Ruby's standard library, no database required
* Entries can be exported from http://blog.example.com/rss.php?version=2.0&all=1
* Usage: ruby -r './s9y_rss.rb' -e 'Jekyll::S9Y.process("http://blog.example.com/rss.php?version=2.0&all=1")';

Signed-off-by: Parker Moore <parkrmoore@gmail.com>
71bca9b
@joschi joschi Changed generated file name for articles to correct format
Signed-off-by: Parker Moore <parkrmoore@gmail.com>
0d677b6
@joschi joschi Changed generated posts to use 'permalink' attribute to retain old links
Signed-off-by: Parker Moore <parkrmoore@gmail.com>
bbd0741
@parkr
Jekyll member

above is from jekyll/jekyll#399 by @joschi.

@parkr
Jekyll member

Above is from jekyll/jekyll#483 by @mattrose. 1 of 3 accepted.

@parkr parkr referenced this pull request in jekyll/jekyll
Closed

first pass at cleaning up the tumblr migrator #483

docunext making mt.rb migrator more flexible
Signed-off-by: Parker Moore <parkrmoore@gmail.com>
8160eb5
@parkr parkr referenced this pull request in jekyll/jekyll
Closed

Extra options to make mt.rb migrator more flexible #408

@parkr
Jekyll member

Above is from jekyll/jekyll#408 by @docunext.

@parkr parkr referenced this pull request in jekyll/jekyll
Closed

tumblr.rb: warning and error with ruby 1.9.3-p194 #595

@parkr
Jekyll member

Above fixes jekyll/jekyll#523

@parkr
Jekyll member

Above integrates jekyll/jekyll#526

@mojombo

Merged.

@mojombo mojombo closed this
@parkr parkr referenced this pull request in jekyll/jekyll
Closed

"conversation" import on tumblr doesn't work #480

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 30, 2013
  1. @joschi @parkr

    Added migrator to import entries from Serendipity (S9Y).

    joschi committed with parkr
    * Only uses classes from Ruby's standard library, no database required
    * Entries can be exported from http://blog.example.com/rss.php?version=2.0&all=1
    * Usage: ruby -r './s9y_rss.rb' -e 'Jekyll::S9Y.process("http://blog.example.com/rss.php?version=2.0&all=1")';
    
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
  2. @joschi @parkr

    Changed generated file name for articles to correct format

    joschi committed with parkr
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
  3. @joschi @parkr

    Changed generated posts to use 'permalink' attribute to retain old links

    joschi committed with parkr
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
  4. @mattrose @parkr
  5. @parkr

    Tumblr's conversation line hash contains keys: 'name', 'label', and '…

    parkr committed
    …phrase'. Getting phrase correctly.
  6. @parkr

    making mt.rb migrator more flexible

    docunext committed with parkr
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
Commits on Jan 31, 2013
  1. @parkr
  2. @mbainter @parkr

    Added support for handling extended posts

    mbainter committed with parkr
    Signed-off-by: Parker Moore <parkrmoore@gmail.com>
  3. @parkr
View
5 lib/jekyll/importers/mt.rb
@@ -27,12 +27,13 @@ module MT
entry_convert_breaks \
FROM mt_entry"
- def self.process(dbname, user, pass, host = 'localhost')
+ def self.process(dbname, user, pass, host = 'localhost', blog_id = nil)
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
FileUtils.mkdir_p "_posts"
- db[QUERY].each do |post|
+ q = blog_id.nil? ? QUERY : "#{QUERY} WHERE entry_blog_id = #{blog_id}"
+ db[q].each do |post|
title = post[:entry_title]
slug = post[:entry_basename].gsub(/_/, '-')
date = post[:entry_authored_on]
View
49 lib/jekyll/importers/s9y_rss.rb
@@ -0,0 +1,49 @@
+# Migrator to import entries from an Serendipity (S9Y) blog
+#
+# Entries can be exported from http://blog.example.com/rss.php?version=2.0&all=1
+#
+# Usage:
+# ruby -r './s9y_rss.rb' -e 'Jekyll::S9Y.process("http://blog.example.com/rss.php?version=2.0&all=1")'
+
+require 'open-uri'
+require 'rss'
+require 'fileutils'
+require 'yaml'
+
+module Jekyll
+ module S9Y
+ def self.process(file_name)
+ FileUtils.mkdir_p("_posts")
+
+ text = ''
+ open(file_name, 'r') { |line| text = line.read }
+ rss = RSS::Parser.parse(text)
+
+ rss.items.each do |item|
+ post_url = item.link.match('.*(/archives/.*)')[1]
+ categories = item.categories.collect { |c| c.content }
+ content = item.content_encoded.strip
+ date = item.date
+ slug = item.link.match('.*/archives/[0-9]+-(.*)\.html')[1]
+ name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
+ slug]
+
+ data = {
+ 'layout' => 'post',
+ 'title' => item.title,
+ 'categories' => categories,
+ 'permalink' => post_url,
+ 's9y_link' => item.link,
+ 'date' => item.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
View
4 lib/jekyll/importers/tumblr.rb
@@ -83,8 +83,8 @@ def self.post_to_hash(post, format)
when "conversation"
title = post["conversation-title"]
content = "<section><dialog>"
- post["conversation"]["line"].each do |line|
- content << "<dt>#{line['label']}</dt><dd>#{line}</dd>"
+ post["conversation"].each do |line|
+ content << "<dt>#{line['label']}</dt><dd>#{line['phrase']}</dd>"
end
content << "</section></dialog>"
when "video"
View
10 lib/jekyll/importers/typo.rb
@@ -13,6 +13,7 @@ module Typo
c.title title,
c.permalink slug,
c.body body,
+ c.extended extended,
c.published_at date,
c.state state,
COALESCE(tf.name, 'html') filter
@@ -27,6 +28,15 @@ def self.process dbname, user, pass, host='localhost'
db[SQL].each do |post|
next unless post[:state] =~ /published/
+ if post[:slug] == nil
+ post[:slug] = "no slug"
+ end
+
+ if post[:extended]
+ post[:body] << "\n<!-- more -->\n"
+ post[:body] << post[:extended]
+ end
+
name = [ sprintf("%.04d", post[:date].year),
sprintf("%.02d", post[:date].month),
sprintf("%.02d", post[:date].day),
View
2 lib/jekyll/importers/wordpressdotcom.rb
@@ -76,7 +76,7 @@ def self.process(filename = "wordpress.xml")
end
def self.sluggify(title)
- title.downcase.split.join('-').gsub('/','-')
+ title.gsub(/[^[:alnum:]]+/, '-').downcase
end
end
end
Something went wrong with that request. Please try again.