Wordpress xml file (export) to Refinerycms-blog (3.0.x)

30 views
Skip to first unread message

Yanik Crépeau

unread,
Mar 7, 2017, 3:36:18 PM3/7/17
to Refinery CMS
I am building a new site for a client using Refinerycms (3.0.x).

Currently, the client uses a Wordpress site with about 10K messages and about 15K pictures. 

I am looking for a solution to import these posts/pictures in the new site. 

I have seen a couple interesting gems in Github BUT they are old (2010-2012) and don't work with current version of Refinerycms (3.0.x).

Has someone any suggestion for me?

---
YC

Ruby: 2.3.1
Rails: 4.2.6
Refinery: 3.0.5
Refinery-blog: ??
Wordpress export file: xml 1.0/rss 2.0

Anita Graham

unread,
Mar 11, 2017, 8:08:05 AM3/11/17
to Refinery CMS
I worked on one of those old gems.

The main changes would be due to changes in Rails from 3 to 4.

Refinery has at least one document about the upgrade from Refinery 2 to 3, which covers the Rails 3-4 issues.

The main one I can think of is the change from attr_accessible to strong_parameters.

Not sure how that will interact with the blog importer, which, iirc was a rake task that did lots of XML conversions.

What tools have you tried?  What specific problems do you have?

Anita

Yanik Crépeau

unread,
Mar 13, 2017, 2:25:37 PM3/13/17
to Refinery CMS
The obstacle is more pragmatic: the gem/bundler check for installed version of refinerycms and refuses to install.

I don't want to install version 2 of refinery, import the Worldpress blog and then upgrade to version 3. I have too much work already done with version 3.

I have moved to my own solution, writing a rake task and use Nogogiri. At this time is is fine for the text content but I have a lot to work to images as well. I don't want to import the same image more than once, so I will have to create two (2) tables:

import_image_table
  import_image_id
  old_url
  new_url

import_image_use
  import_image_id
  post_id

So:

1- For each post (old site), import text (html content) (aka 10K entries)
  1.1 Create a new post
  1.2 Copy html from old to post to the new one
2- Scan html content for images
3- For each image found in the post
  3.1 Find or create entry in import_image_table with old_url
  3.2 Add the current post_id/import_image_id to import_image_use

4-For each entry in import_image_table (aka 15K entries)
  4.1 Import the image, 
  4.2 set new_url

5- For each entry in import_image_use
  5.1 get the post
  5.2 find the <img> tag in the post
  5.3 Replace the source with the new url

6. Clean up (drop the two tables).

Anita Graham

unread,
Mar 25, 2017, 8:59:39 AM3/25/17
to Refinery CMS
Yanik,

I didn't spot your response immediately, so apologies if you are long past this. However,

I have upgraded refinerycms-wordpress-import gem so that it is compatible with Refinery 3.0 versions. The gem is at https://github.com/anitagraham/refinerycms-wordpress-import,

The tests run without errors. I used Refinery 3-0-stable.

Anita Graham

Anita Graham

unread,
Mar 25, 2017, 9:01:09 AM3/25/17
to Refinery CMS
I should add that I haven't accounted for any new wordpress features or syntax.  If you come across something that needs work we need to add it to the tests.

Reply all
Reply to author
Forward
0 new messages