Code Monkey home page Code Monkey logo

octoghost's Introduction

octoghost's People

Contributors

evilsocket avatar hothero avatar trumbitta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

octoghost's Issues

KeyError: 'data'

Hi there,

I am just testing out the new 0.5 Ghost and used your script, but I am getting the following error:

$ python octopress2ghost.py octopress_posts ghost_data.json | python -mjson.tool > import-this.json
Traceback (most recent call last):
  File "octopress2ghost.py", line 157, in <module>
    ghost_data['data']['posts'] = posts
KeyError: 'data'
No JSON object could be decoded

The following is Line 154 to Line 159:

ghost_json_file_name = sys.argv[ARG_OUTPUT_JSON]
ghost_data = json.loads(open(ghost_json_file_name).read())

ghost_data['data']['posts'] = posts
ghost_data['data']['tags'] = tags
ghost_data['data']['posts_tags'] = posts_tags

Any ideas?

IndexError

Hi, sorry to nag you with this but I am unsure why I am getting this error when running the command:

[~/Downloads] python ~/.bin/octopress2ghost.py ~/Projects/Personal/blog/source/_posts GhostData.json | python -mjson.tool > import-this.json
Traceback (most recent call last):
  File "/Users/ericb/.bin/octopress2ghost.py", line 114, in <module>
    value = value.split(':')[0] + ":" + value.split(':')[1]
IndexError: list index out of range
No JSON object could be decoded

Any thoughts? Am I doing it correct?

Add support for *.md as well

Almost all my posts were in the .md format instead of .markdown, and that caused problems with the script.

Perhaps could be replaced with simply globbing all files, and leaving it up to the user to ensure only posts are present in the specified folder?

Syntax Error

File "octopress2ghost.py", line 29
SyntaxError: Non-ASCII character '\xc3' in file octopress2ghost.py on line 29, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
No JSON object could be decoded

Wrong categories split

In octropress, categories line can be this:
categories: [Github, git, useful] or sometimes can leave empty categories:.

But script only separate string by blank the_tags = value.split(" "), will cause some error:
Value in [tags.name] cannot be blank. or Duplicate entry found. Multiple values of "xx" found for tags.slug.

I add 3 lines to fix this bug (after line for tag in the_tags:):

tag = tag.strip('[').strip(']').strip(',')
   if tag == "":
       continue

It's not the best solution, but hope help somebody.

Sometimes, other importers don't add dates to converted files. A small fix.

I used WP -> Octopress before, and it didn't import all dates. This led to the JSON having no 'created by' which is required by Ghost to import posts.

I wrote a small fix here:

...
                            post_tag_id = post_tag_id + 1
                    else:
                        pass
            else:
                raise Exception('Unexpected exception!')

// Get times if none found
createdAt = post.get('created_at', int(time.mktime(datetime.datetime.strptime(markdown_file[7:17] + ' 00:00', "%Y-%m-%d %H:%M").timetuple()) * 1e3))

    post["created_at"] = createdAt
    post["updated_at"] = createdAt
    post["published_at"] = createdAt

This works due to the fact that filenames themselves have some part of the date - It parses them and assigns the time at 12 o' clock of that day.

It's an ugly solution since I'm pathetic at python, but should work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.