wp2tumblr 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/wp2tumblr/tumblr_client.rb +2 -2
- data/lib/wp2tumblr/version.rb +1 -1
- data/lib/wp2tumblr/wordpress.rb +14 -4
- data/spec/wp2tumblr_spec.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cb55d6555d982077812f3d6c37175d6051450b2
|
4
|
+
data.tar.gz: 68aa2d831556792ce17188038a7e5c08d9bb2aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e783ef13375c6001ff63d513b3ec9a12d45d34217540e8c6f965d2c8dd71856f3b8f7eb6d4b7a0f764ae7fa5c2619b28ab065a392056e7a49701dcf954a3974
|
7
|
+
data.tar.gz: 5d5ab611b62924adb1b5afd1a0c0eba9202dee3fc92078bbf9a8ee7648ddeeb1814de79fd0a756afd3de2388440a001dc252902ccb304d3dc9d99b1e176f2d45
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# Wp2tumblr
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/wp2tumblr.png)](http://badge.fury.io/rb/wp2tumblr)
|
2
3
|
|
3
4
|
A CLI tool to import wordpress xml files into Tumblr via the Tumblr api
|
4
5
|
|
@@ -16,11 +17,11 @@ Before you will be able to import your posts into Tumblr you will need to config
|
|
16
17
|
You will be asked to register your application, provide your application's secret and public keys, and obtain an oauth_verifier token.
|
17
18
|
|
18
19
|
### Server
|
19
|
-
`wp2tumblr` includes a small Sinatra server to aid in collecting your oauth_verifier token. When you
|
20
|
+
`wp2tumblr` includes a small Sinatra server to aid in collecting your oauth_verifier token. When you register your application just give it the callback url `http://localhost:9292/callback`, open up a seprate terminal window or session and run:
|
20
21
|
|
21
22
|
$ wp2tumblr server
|
22
23
|
|
23
|
-
Now when you visit the redirect url
|
24
|
+
Now when you visit the redirect url you're given from `wp2tumblr config` you will see the oauth_verifier in your console.
|
24
25
|
|
25
26
|
### Import
|
26
27
|
Once you have completed the config process simply run the following command:
|
@@ -36,10 +37,16 @@ The `-f` option is the absolute path to your wordpress export file, ex. `~/Downl
|
|
36
37
|
`wp2tumblr` will sleep one second between each post to not overload the Tumblr api. You will also see feedback stating how many posts were parsed from the wordpress export file as well as the title of each post that is currently being submitted to the Tumblr api.
|
37
38
|
|
38
39
|
## Changelog
|
40
|
+
|
41
|
+
- **Version 0.1.3:** Entire post object is now sent to tumblr, title, body, date, tags, slug and state.
|
42
|
+
- **Version 0.1.2:** Minor Feature, added server to help capture the oauth_verifier token
|
39
43
|
- **Version 0.1.1:** Refactored config process
|
40
44
|
- **Version 0.1.0:** Minor Feature, added Base64 encoding of images
|
41
45
|
- **Version 0.0.1:** Initial Release
|
42
46
|
|
47
|
+
## Contributers
|
48
|
+
- [@apeckham](https://github.com/apeckham)
|
49
|
+
|
43
50
|
## Contributing
|
44
51
|
|
45
52
|
1. Fork it
|
@@ -27,10 +27,10 @@ module Wp2tumblr
|
|
27
27
|
puts "#{posts.count} posts found..."
|
28
28
|
posts.each do |post|
|
29
29
|
puts "Now posting: #{post[:title]}"
|
30
|
-
@client.text(blog_name,
|
30
|
+
@client.text(blog_name, post)
|
31
31
|
sleep 1
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
data/lib/wp2tumblr/version.rb
CHANGED
data/lib/wp2tumblr/wordpress.rb
CHANGED
@@ -20,7 +20,14 @@ module Wp2tumblr
|
|
20
20
|
items = get_file_contents(file)
|
21
21
|
@posts = []
|
22
22
|
items.to_enum.with_index(0) do |item, i|
|
23
|
-
@posts[i] = {
|
23
|
+
@posts[i] = {
|
24
|
+
title: item.at_xpath("title").text,
|
25
|
+
body: parse_images(item.at_xpath("content:encoded")),
|
26
|
+
date: item.at_xpath("pubDate").text,
|
27
|
+
tags: get_post_meta(item, :tag).join(','),
|
28
|
+
slug: item.at_xpath('wp:post_name').content,
|
29
|
+
state: item.at_xpath('wp:status').content == 'publish' ? 'published' : 'draft'
|
30
|
+
}
|
24
31
|
end
|
25
32
|
@posts
|
26
33
|
end
|
@@ -88,7 +95,10 @@ module Wp2tumblr
|
|
88
95
|
end
|
89
96
|
|
90
97
|
def self.parse_images(post_content)
|
91
|
-
|
98
|
+
#data uris have a maximum size; this strategy might only work for small files
|
99
|
+
#http://stackoverflow.com/questions/695151/data-protocol-url-size-limitations
|
100
|
+
|
101
|
+
html = Nokogiri::HTML::fragment(post_content.content)
|
92
102
|
html.css("img").each do |image|
|
93
103
|
begin
|
94
104
|
encoded_image = Base64.encode64(open(image['src']) {|io| io.read})
|
@@ -99,7 +109,7 @@ module Wp2tumblr
|
|
99
109
|
file_extension = image['src'][/\.[^.]*$/].split('.')[1]
|
100
110
|
image['src'] = "data:image/#{file_extension};base64,#{encoded_image}" if encoded_image
|
101
111
|
end
|
102
|
-
html
|
112
|
+
html.to_s
|
103
113
|
end
|
104
114
|
|
105
115
|
private
|
@@ -109,4 +119,4 @@ module Wp2tumblr
|
|
109
119
|
end
|
110
120
|
|
111
121
|
end
|
112
|
-
end
|
122
|
+
end
|
data/spec/wp2tumblr_spec.rb
CHANGED
@@ -53,8 +53,7 @@ describe Wp2tumblr::Wordpress do
|
|
53
53
|
describe ".parse_images" do
|
54
54
|
it "Encodes images as base64" do
|
55
55
|
posts = Wp2tumblr::Wordpress.parse_xml(file, :posts)
|
56
|
-
|
57
|
-
Wp2tumblr::Wordpress.parse_images(post).to_s.should include('base64')
|
56
|
+
posts[0][:body].should include('base64')
|
58
57
|
end
|
59
58
|
end
|
60
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wp2tumblr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jonlunsford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oauth
|