I just spent an hour trying to install ghost 1.0

#1

hosted install, I have a Wordpress XML file I am trying to convert. After an hour of fiddling with Node versions, can someone please help? This is not working. I just want a JSON file to upload. I’m hoping someone has a running pipeline for converting import XML files. Thanks!

#2

It’s ok, I’ll just write something in Ruby to to cycle through and hit the API. No worries.

#3

Hi @kaxel! Which process of migrating from WordPress did you follow? Are you using Ghost WordPress plugin or wp2ghost CLI tool?

#4

I was using the CLI tool, but it looks like I am going to have to build my own parsing script.

#5

So, I’m thinking of just writing my own Ghost-compliant JSON, using this model:

"data": {
    "posts": [
      {
        "id": 1,
        "title": "my blog post title",
        "slug": "my-blog-post-title",
        //Optional,
        willbegeneratedbyGhostifmissing//mobiledocisusedtorepresentyourcontent"mobiledoc": "{\"version\":\"0.3.1\",\"atoms\":[],\"cards\":[],\"markups\":[],\"sections\":[[1,\"p\",[[0,[],0,\"You're live, nice!\"]]]]}",
        "feature_image": null,
        "featured": 0,
        //booleanindicatingfeaturedstatus"page": 0,
        //booleanindicatingifthisisapageorpost"status": "published",
        //ordraft"published_at": 1283780649000,
        //epochtimeinmilliseconds"published_by": 1,
        //thefirstusercreatedhasanidof1"meta_title": null,
        "meta_description": null,
        "author_id": 1,
        //thefirstusercreatedhasanidof1"created_at": 1283780649000,
        //epochtimeinmilliseconds"created_by": 1,
        //thefirstusercreatedhasanidof1"updated_at": 1286958624000,
        //epochtimeinmilliseconds"updated_by": 1//thefirstusercreatedhasanidof1
      }
    ],

My question is how to insert the mobiledoc json.

#6

I can use this to create the mobiledoc snippet, but not exactly sure where to insert in the above block.

mobiledoc = JSON.stringify({
    version: '0.3.1',
    markups: [],
    atoms: [],
    cards: [['html', {cardName: 'html', html: '<p>HTML goes here</p>'}]],
    sections: [[10, 0]]
});
#7

If I shove my posts into an html card, and stringify that into a mobiledoc variable, how does that get inserted here:

willbegeneratedbyGhostifmissing//mobiledocisusedtorepresentyourcontent"mobiledoc": "{\"version\":\"0.3.1\",\"atoms\":[],\"cards\":[],\"markups\":[],\"sections\":[[1,\"p\",[[0,[],0,\"You're live, nice!\"]]]]}",

And what would that make the ‘sections’ snippet look like?

That’s my question. :slight_smile:

#8

Hey @kaxel, sorry for the late reply :sweat_smile: Think if you are after converting HTML into mobiledoc you might use want to take a look at html-to-mobiledoc converter that Ghost also uses internally here. There might be some sanitization you would need to do though as not all html is directly compatible with mobiledoc format (but should work fine if there’s nothing extra ordinary going on in your markup). Let me know if that helpst :slight_smile:

What was the issue with CLI tool though? Why didn’t it work for you?

#9

I could never get Ghost 1.0 installed correctly - it was an issue with Node versioning. I am trying to build my own direct XML -> JSON -> Ghost Format pipeline because I have about 700+ records that need to come over and I was going to need to test it out anyway. My html is pretty standard so I’m thinking that might work. I’ll know by this weekend. I’m building a Ruby script to build the ingest file from the Squarespace XML export that I converted to JSON.

#10

so I’m assuming this line simply becomes:

"mobiledoc": mobiledoc,

where mobiledoc is the var where I put either the stringify result, or the converter.toMobiledoc method call, whichever seems to work better.

#11

I suspect in your situation it would be a stringified JSON that comes out from toMobiledoc method call, similarly how it’s done here. Would love to see what kind of tool you come up with in the end, is it open source and available somewhere to track?

#12

No, it’s a private repo right now, but once I get it going maybe I’ll turn it into a gem or something. :slight_smile: - I am not having any luck with mobiledoc, but I’m going to ignore that for now, the json formats seems fine and my proof of concept seems to be working. I am having an issue with paths, so I am wondering if you can help because I really don’t want to break all of my existing links. So far, I can bring the content over, I can update all the image links, but the only problem left is the old path structure.

all of the old posts live inside a blog/year/month/day/ file structure, which is not possible with Ghost routes. Is there a way to set up a dynamic route that maps /blog/%/%/%/slug to /slug? I know how to do that with a Rails config, or Apache, but outside of that I have no idea. Fingers crossed you can point me in the right direction.

#13

hmm, just reading about redirects, so that could work. Sounds like I’m covered!

#14

The fact that this one line of code will make me not have to write 700+ custom redirects is basically everything.

[{"from":"/blog/\\d{4}/\\d{1,2}/\\d{1,2}/(\\S{1,999})/","to":"/$1","permanent":true}]

1 Like
#15

Awesome, good to see you making progress and redirects worked just as they are supposed to :slight_smile:

1 Like
closed #16

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.