|
Posted by Vamsi Krishna on March 13th, 2009
We recently migrated from Pebble to Wordpress and we were looking for tools to convert Pebble blogs to Wordpress. Eventually I wrote a simple application based on Ruby and ActiveRecord to do this migration.
Tasks
Using the Application
Now, if you are interested, here is some explanation about the Application. 1. Language - Ruby, ORM framework - ActiveRecord 2. The directory structure is 3. Sample Pebble exported XML Structue:
<?xml version="1.0" encoding="UTF-8"?>
<blogEntry>
<title>Title for the blog</title>
<subtitle/>
<excerpt><![CDATA[Excerpt]]>
</excerpt>
<body><![CDATA[Content for the blog ]]>
</body>
<date>12 Jan 2006 07:33:24:301 +0100</date>
<state>approved</state>
<author>Krishna</author>
<staticName/>
<commentsEnabled>true</commentsEnabled>
<trackBacksEnabled>true</trackBacksEnabled>
<category>/sd</category>
<tags/>
<comment>
<title>Comment1</title>
<body><![CDATA[comment 1
]]>
</body>
<author>anonymous</author>
<email>anonymous@abc.com</email>
<website/>
<ipAddress>127.0.0.1</ipAddress>
<date>23 Jan 2006 16:01:37:839 +0100</date>
<state>approved</state>
</comment>
</blogEntry>
4. Database table structure (wp_comments) This is wp_comments table (wp_posts and wp_comments are linked by comment_post_ID (foreign key), one post can have multiple comments.) Lets see the Application in more detail. 1. main.rb Here is a code snippet of my main.rb file
require 'xml_parsing'
require 'process_data'
# Please give absolute path to your pebble exported xml files.
basedir = "inputXML/"
Dir.chdir(basedir)
files = Dir.glob("*.xml");
files.each { |file|
if File.file?(basedir + file)
begin
parsedPostData = parse_xml(basedir + file)
process_post_data(parsedPostData)
p "Processed postdata for the file: " + file
parsedCommentData = parse_comments_nodelist(basedir + file)
process_comment_data(parsedCommentData)
p "Processed commentdata for the file: " + file
rescue
print "Error: ", $!, "\n"
end
else
p "Error!.. Not a file. Add unit test!.."
end
}
p "Processed " + files.length.to_s + " xml files successfully!"
2. post_data.rb 3. comment_data.rb 4. xml_parsing.rb 5. process_data.rb 6. database.yml This application can be used for parsing pebble xml files and storing that data in to database(any database). You can find the complete source code of the application in Conclusion
If you think of any suggestions/improvements for this application post a comment. Tags: ActiveRecord, Pebble, Ruby, WordpressUnique Views: 57 Total views: 69 Follow responses at RSS 2.0. Leave a response | Trackback. 2 Responses to “Ruby Based Pebble2Wordpress Importer”Leave a Reply |
Thank you, I am hoping to share more information in the near future
[...] importer code, which is written in Ruby. (I first found a reference to this project from The Spritle Blog blog post, which has some more information about how it’s meant to be used.) I selected this [...]