Skip to content

Instantly share code, notes, and snippets.

@kyungw00k
Created July 24, 2013 09:37
Show Gist options
  • Save kyungw00k/6069236 to your computer and use it in GitHub Desktop.
Save kyungw00k/6069236 to your computer and use it in GitHub Desktop.
Migrate Wordpress to Haroopress using XML-RPC in NodeJS
var conf = require('./config.js')
, wp = require('wordpress')
;
// TODO Account Validation
// TODO Make Output Directories
//
// Client Instance
//
var blog = wp.createClient(conf.account);
//
// Process Data
//
blog.getPosts(conf.filter, null, function(error, posts){
if ( error ) {
throw new Error(error);
}
if ( !posts ) {
throw new Error("No Articles");
}
posts.forEach(function(post, idx){
// TODO mapping wp post to haroopress post
if ( post.post_type == 'post' ) {
// POST
}
if ( post.post_type == 'page' ) {
// PAGE
}
});
});
var config = module.exports = {};
//
// Account Information
//
config.account = {
"username" : "[USERNAME]"
, "password" : "[PASSWORD]"
, "url" : "http://[YOUR-WORDPRESS-URL]"
};
//
// Filter for post and page
//
config.filter = {
"offset" : "0"
, "number" : "4294967295" // MAX DATA SET
};
{
"name": "haroopress-wp-importer",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node app"
},
"dependencies": {
"wordpress": "*",
"markx": "~0.2.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment