wordpress-exporter 0.0.1 → 0.0.2
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/CHANGELOG.md +4 -0
- data/Gemfile.lock +26 -23
- data/README.md +30 -1
- data/lib/version.rb +1 -1
- data/lib/wordpress/post_attachment.rb +2 -6
- data/spec/fixtures/blog/assets/attachment_post/attachment_post_21.json +1 -1
- data/spec/lib/wordpress/post_attachment_spec.rb +50 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72f9768fea76088f936ac4945cf51a3d86c9c4a1
|
|
4
|
+
data.tar.gz: ede9d9bb457e8d6aa2297335e114e653137a2980
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0606e1f5d76fa8636084b4131fa762c29bad11ff0f662f711b771d33100cd6814331ba40d419575dee1e59acb9ff5f22403eb04c3a162e71c7591f349fe36a6c
|
|
7
|
+
data.tar.gz: b3ca0afea007cb2ed8317189890192a988929b1c1564ad2fc30595369c97dedc3f9cf4557b88e3769e2b4737d9c3e806e4a84d7a1cbb2f69dfe24a1550b6eb1d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -13,53 +13,56 @@ PATH
|
|
|
13
13
|
GEM
|
|
14
14
|
remote: https://rubygems.org/
|
|
15
15
|
specs:
|
|
16
|
-
activesupport (4.2.
|
|
16
|
+
activesupport (4.2.1)
|
|
17
17
|
i18n (~> 0.7)
|
|
18
18
|
json (~> 1.7, >= 1.7.7)
|
|
19
19
|
minitest (~> 5.1)
|
|
20
20
|
thread_safe (~> 0.3, >= 0.3.4)
|
|
21
21
|
tzinfo (~> 1.1)
|
|
22
|
+
addressable (2.3.8)
|
|
22
23
|
diff-lcs (1.2.5)
|
|
23
24
|
docile (1.1.5)
|
|
24
25
|
escort (0.4.0)
|
|
25
26
|
nesty
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
form_data (~> 0.1
|
|
27
|
+
http (0.8.4)
|
|
28
|
+
addressable (~> 2.3)
|
|
29
|
+
http-form_data (~> 1.0.1)
|
|
29
30
|
http_parser.rb (~> 0.6.0)
|
|
31
|
+
http-form_data (1.0.1)
|
|
30
32
|
http_parser.rb (0.6.0)
|
|
31
33
|
i18n (0.7.0)
|
|
32
34
|
json (1.8.2)
|
|
33
35
|
mini_portile (0.6.0)
|
|
34
|
-
minitest (5.
|
|
35
|
-
multi_json (1.
|
|
36
|
+
minitest (5.6.1)
|
|
37
|
+
multi_json (1.11.0)
|
|
36
38
|
nesty (1.0.2)
|
|
37
39
|
nokogiri (1.6.3.1)
|
|
38
40
|
mini_portile (= 0.6.0)
|
|
39
41
|
rake (10.4.2)
|
|
40
|
-
reverse_markdown (0.6.
|
|
42
|
+
reverse_markdown (0.6.1)
|
|
41
43
|
nokogiri
|
|
42
|
-
rspec (3.
|
|
43
|
-
rspec-core (~> 3.
|
|
44
|
-
rspec-expectations (~> 3.
|
|
45
|
-
rspec-mocks (~> 3.
|
|
46
|
-
rspec-core (3.
|
|
47
|
-
rspec-support (~> 3.
|
|
48
|
-
rspec-expectations (3.1
|
|
44
|
+
rspec (3.2.0)
|
|
45
|
+
rspec-core (~> 3.2.0)
|
|
46
|
+
rspec-expectations (~> 3.2.0)
|
|
47
|
+
rspec-mocks (~> 3.2.0)
|
|
48
|
+
rspec-core (3.2.3)
|
|
49
|
+
rspec-support (~> 3.2.0)
|
|
50
|
+
rspec-expectations (3.2.1)
|
|
49
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
50
|
-
rspec-support (~> 3.
|
|
52
|
+
rspec-support (~> 3.2.0)
|
|
51
53
|
rspec-its (1.1.0)
|
|
52
54
|
rspec-core (>= 3.0.0)
|
|
53
55
|
rspec-expectations (>= 3.0.0)
|
|
54
|
-
rspec-mocks (3.1
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
rspec-mocks (3.2.1)
|
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
58
|
+
rspec-support (~> 3.2.0)
|
|
59
|
+
rspec-support (3.2.2)
|
|
60
|
+
simplecov (0.10.0)
|
|
58
61
|
docile (~> 1.1.0)
|
|
59
|
-
|
|
60
|
-
simplecov-html (~> 0.
|
|
61
|
-
simplecov-html (0.
|
|
62
|
-
thread_safe (0.3.
|
|
62
|
+
json (~> 1.8)
|
|
63
|
+
simplecov-html (~> 0.10.0)
|
|
64
|
+
simplecov-html (0.10.0)
|
|
65
|
+
thread_safe (0.3.5)
|
|
63
66
|
tzinfo (1.2.2)
|
|
64
67
|
thread_safe (~> 0.1)
|
|
65
68
|
|
data/README.md
CHANGED
|
@@ -46,6 +46,7 @@ Use the [generic-importer](https://github.com/contentful/generic-importer.rb) to
|
|
|
46
46
|
1. [Export](http://en.support.wordpress.com/export/) the content of the blog from WordPress and save it as XML file.
|
|
47
47
|
2. Create YAML file with settings (eg. settings.yml) and fill in the required parameters.
|
|
48
48
|
The generated `content types`, `entries` and `assets` will be saved to the `data_dir`.
|
|
49
|
+
We recommend you to use `wordpress_settings/wordpress_settings.yml` file in this repository
|
|
49
50
|
|
|
50
51
|
3. Extract the content from the XML file and generate the content model and JSON files for the import:
|
|
51
52
|
|
|
@@ -68,4 +69,32 @@ Use the [generic-importer](https://github.com/contentful/generic-importer.rb) to
|
|
|
68
69
|
```
|
|
69
70
|
This will only touch the content body of a blog post, other attributes will not be changed.
|
|
70
71
|
|
|
71
|
-
5.
|
|
72
|
+
5. Create your content model from JSON:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
wordpress-exporter --config-file settings.yml --create-contentful-model-from-json
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
6. Use the [contentful-importer](https://github.com/contentful/generic-importer.rb) to import the content to [contentful.com](https://www.contentful.com)
|
|
80
|
+
|
|
81
|
+
7. Add you organization id and the access token to your `settings.yml`
|
|
82
|
+
|
|
83
|
+
8. Next we import the content model (the collection of content types), make sure you add the new created space id to your `settings.yml` file.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
contentful-importer --config-file settings.yml --import-content-types --space_name my-blog
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
9. We use the following command to import our entries and assets:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
contentful-importer --config-file settings.yml --import
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
10. And finally publish the entries and assets:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
contentful-importer --config-file settings.yml --publish-entries
|
|
99
|
+
contentful-importer --config-file settings.yml --publish-assets
|
|
100
|
+
```
|
data/lib/version.rb
CHANGED
|
@@ -31,12 +31,8 @@ module Contentful
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def attachment_description
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
meta_arr.each do |meta|
|
|
37
|
-
return meta.at_xpath('wp:meta_value').text if meta.at_xpath('wp:meta_key').text == '_wp_attachment_image_alt'
|
|
38
|
-
end
|
|
39
|
-
end
|
|
34
|
+
alt = post.xpath('.//wp:meta_key[contains(text(), "_wp_attachment_image_alt")]').first
|
|
35
|
+
alt ? alt.parent.at_xpath('wp:meta_value').text : ''
|
|
40
36
|
end
|
|
41
37
|
end
|
|
42
38
|
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require './lib/wordpress/post'
|
|
3
|
+
require './lib/wordpress/blog'
|
|
4
|
+
require './lib/wordpress/post_attachment'
|
|
5
|
+
|
|
6
|
+
module Contentful
|
|
7
|
+
module Exporter
|
|
8
|
+
module Wordpress
|
|
9
|
+
describe PostAttachment do
|
|
10
|
+
before do
|
|
11
|
+
xml_doc = Nokogiri::XML(File.open('spec/fixtures/wordpress.xml'))
|
|
12
|
+
@items = xml_doc.search('item')
|
|
13
|
+
@post = PostAttachment.new(@items[-2], @settings)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'can extract the url of an attachment' do
|
|
17
|
+
url = @post.send(:attachment_url)
|
|
18
|
+
|
|
19
|
+
expect(url).to eq 'https://szpryc.files.wordpress.com/2014/11/screen-shot-2014-11-27-at-12-34-47-pm.png'
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'can extract the id of an attachment' do
|
|
23
|
+
id = @post.send(:attachment_id)
|
|
24
|
+
|
|
25
|
+
expect(id).to eq 'attachment_post_15'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'can extract the description of an attachment' do
|
|
29
|
+
description = @post.send(:attachment_description)
|
|
30
|
+
|
|
31
|
+
expect(description).to eq 'MOJ_DESC'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'is resilient against missing wp:meta_keys' do
|
|
35
|
+
@post = PostAttachment.new(@items.last, @settings)
|
|
36
|
+
description = @post.send(:attachment_description)
|
|
37
|
+
|
|
38
|
+
expect(description).to eq ''
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'is resilient against missing _wp_attachment_image_alt' do
|
|
42
|
+
@post = PostAttachment.new(@items[2], @settings)
|
|
43
|
+
description = @post.send(:attachment_description)
|
|
44
|
+
|
|
45
|
+
expect(description).to eq ''
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wordpress-exporter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Contentful GmbH (Andreas Tiefenthaler)
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-05-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: http
|
|
@@ -219,6 +219,7 @@ files:
|
|
|
219
219
|
- spec/lib/wordpress/blog_spec.rb
|
|
220
220
|
- spec/lib/wordpress/category_spec.rb
|
|
221
221
|
- spec/lib/wordpress/export_spec.rb
|
|
222
|
+
- spec/lib/wordpress/post_attachment_spec.rb
|
|
222
223
|
- spec/lib/wordpress/post_category_domain_spec.rb
|
|
223
224
|
- spec/lib/wordpress/post_spec.rb
|
|
224
225
|
- spec/lib/wordpress/tag_spec.rb
|
|
@@ -280,9 +281,11 @@ test_files:
|
|
|
280
281
|
- spec/lib/wordpress/blog_spec.rb
|
|
281
282
|
- spec/lib/wordpress/category_spec.rb
|
|
282
283
|
- spec/lib/wordpress/export_spec.rb
|
|
284
|
+
- spec/lib/wordpress/post_attachment_spec.rb
|
|
283
285
|
- spec/lib/wordpress/post_category_domain_spec.rb
|
|
284
286
|
- spec/lib/wordpress/post_spec.rb
|
|
285
287
|
- spec/lib/wordpress/tag_spec.rb
|
|
286
288
|
- spec/spec_helper.rb
|
|
287
289
|
- spec/support/db_rows_json.rb
|
|
288
290
|
- spec/support/shared_configuration.rb
|
|
291
|
+
has_rdoc:
|