evilsocket / evilsocket/octoghost

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

Open
#5 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
27
Forks
8
PR merge metrics
No merged PRs in 30d

Description

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:

``` python
...
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.