evilsocket / octoghost Goto Github PK
View Code? Open in Web Editor NEWA python script to process Octopress markdown files and write a JSON file ready to import into Ghost.
License: GNU General Public License v3.0
A python script to process Octopress markdown files and write a JSON file ready to import into Ghost.
License: GNU General Public License v3.0
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?
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?
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?
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
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.