jekyll_ghost_importer 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Guardfile +4 -4
- data/bin/jekyll_ghost_importer +11 -4
- data/features/import_posts.feature +9 -0
- data/lib/jekyll_ghost_importer.rb +1 -2
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f4e1614379288009878b6b78cc1c2ff88ad2e58
|
4
|
+
data.tar.gz: b853b18df8322d55a5e8a883bab607d55f6f5d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e734942234ef4b488c73a4c95b6f2dc32f8133141cfeaab15fab6e0b5e4352c9cd5dc881540129edd7e56977a553a2786a23f7798937776facc7330838bc684
|
7
|
+
data.tar.gz: 6c241ec90f74a420f37a9a14795d3f0661016b1a9ac54a11a02e9dde309ffa5371ad715357c6a55e91569241b96fcef402950ed95ddec304b2d523fd6b16b7f6
|
data/Guardfile
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard 'cucumber' do
|
4
|
+
guard 'cucumber', bundler: false do
|
5
5
|
watch(%r{^features/.+\.feature$})
|
6
|
-
watch(%r{^features/support/.+$})
|
7
|
-
watch(%r{^bin/.+$})
|
8
|
-
watch(%r{^features/step_definitions
|
6
|
+
watch(%r{^features/support/.+$}) { 'features' }
|
7
|
+
watch(%r{^bin/.+$}) { 'features' }
|
8
|
+
watch(%r{^features/step_definitions/.+\.rb$}) { 'features' }
|
9
9
|
end
|
data/bin/jekyll_ghost_importer
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'json'
|
5
5
|
require 'date'
|
6
|
+
require 'yaml'
|
6
7
|
|
7
8
|
FileUtils.mkdir_p("_posts")
|
8
9
|
FileUtils.mkdir_p("_drafts")
|
@@ -12,17 +13,23 @@ json = JSON.parse File.read(ARGV.pop), symbolize_names: true
|
|
12
13
|
posts = json[:data][:posts]
|
13
14
|
|
14
15
|
posts.each do |post|
|
15
|
-
date =
|
16
|
+
date = DateTime.parse(post[:published_at]) if post[:published_at]
|
16
17
|
slug = post[:slug]
|
17
|
-
|
18
|
+
front_matter_hash = {
|
19
|
+
'layout' => "post",
|
20
|
+
'title' => post[:title]
|
21
|
+
}
|
22
|
+
front_matter_hash['date'] = date.strftime('%Y-%m-%d %H:%M:%S') if date
|
23
|
+
|
24
|
+
body = front_matter_hash.to_yaml + "---\n\n" + post[:markdown]
|
18
25
|
draft = post[:status] == 'draft'
|
19
26
|
basename = if draft
|
20
27
|
"#{ slug }.markdown"
|
21
28
|
else
|
22
|
-
"#{ date }-#{ slug }.markdown"
|
29
|
+
"#{ date.strftime('%Y-%m-%d') }-#{ slug }.markdown"
|
23
30
|
end
|
24
31
|
folder = draft ? '_drafts' : '_posts'
|
25
32
|
filename = File.join folder, basename
|
26
|
-
puts filename
|
33
|
+
puts "Importing filename..."
|
27
34
|
File.write filename, body
|
28
35
|
end
|
@@ -10,8 +10,11 @@ Feature: Import posts
|
|
10
10
|
"data": {
|
11
11
|
"posts": [
|
12
12
|
{
|
13
|
+
"title": "Welcome to Ghost",
|
13
14
|
"slug": "welcome-to-ghost",
|
14
15
|
"markdown": "You're live!",
|
16
|
+
"featured": 0,
|
17
|
+
"status": "published",
|
15
18
|
"published_at": "2014-02-21T01:14:57.000Z"
|
16
19
|
}
|
17
20
|
]
|
@@ -22,6 +25,12 @@ Feature: Import posts
|
|
22
25
|
Then a directory named "_posts" should exist
|
23
26
|
Then the file "_posts/2014-02-21-welcome-to-ghost.markdown" should contain:
|
24
27
|
"""
|
28
|
+
---
|
29
|
+
layout: post
|
30
|
+
title: Welcome to Ghost
|
31
|
+
date: '2014-02-21 01:14:57'
|
32
|
+
---
|
33
|
+
|
25
34
|
You're live!
|
26
35
|
"""
|
27
36
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_ghost_importer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eloy Espinaco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -141,4 +141,3 @@ summary: Import your posts from a ghost backup file.
|
|
141
141
|
test_files:
|
142
142
|
- features/import_posts.feature
|
143
143
|
- features/support/requires.rb
|
144
|
-
has_rdoc:
|