Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added migrator to import entries from Serendipity (S9Y) #399

Closed
wants to merge 3 commits into from

4 participants

@joschi
@joschi

The complete RSS feed of your S9Y installation will contain the full entries of your blog. But you're correct in that the teaser and the extended content of your blog posts will end up together in the markdown files.

Regarding the naming of the markdown files I've updated the pull request to include my changes to that. I somehow forgot about that, sorry.

@teiko

Thanks, I'll try it

@ferochera

I have used it to migrate my previous blog. It is very useful as it saves a lot of work but do not prevent editing work.

Pros:

  • You end with all your posts created and filled with content.

Cons:

  • You have only the intro for every article with "read-more".
  • You lose all comments.

This cons come from the fact that you extract the info from the rss.

Thanks

@teiko

Of course, Yes, your're right

@joschi

@ferochera: You can export a full RSS feed of your blog entries (and not just the abridged version) in the admin backend of your S9Y installation.

@ferochera

Thanks! It's a great work, perhaps I didn't said it loud enough in my previous comment. Sorry for that.

It's been to late for me as I already moved all data. It was a small blog and this gave the opportunity to practise markdown.

But it'll be useful for other s9y migrators ;-)

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

Jekyll PRs #3

@parkr
Owner

Resubmitted via jekyll/jekyll-import#3

@parkr parkr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 11, 2011
  1. @joschi

    Added migrator to import entries from Serendipity (S9Y).

    joschi authored
    * 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")';
  2. @joschi
Commits on Sep 18, 2011
  1. @joschi
This page is out of date. Refresh to see the latest.
Showing with 49 additions and 0 deletions.
  1. +49 −0 lib/jekyll/migrators/s9y_rss.rb
View
49 lib/jekyll/migrators/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
Something went wrong with that request. Please try again.