wp2tumblr 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/bin/wp2tumblr +62 -0
- data/lib/wp2tumblr.rb +8 -0
- data/lib/wp2tumblr/tumblr_client.rb +35 -0
- data/lib/wp2tumblr/version.rb +3 -0
- data/lib/wp2tumblr/wordpress.rb +97 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/wp2tumblr/wordpress_format.xml +157 -0
- data/spec/wp2tumblr_spec.rb +80 -0
- data/wp2tumblr.gemspec +30 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f59412e9fec07818d51b71a5954b774bf9783f7d
|
4
|
+
data.tar.gz: cb0a03a3babfd042d113cac0cd66cbb82dd8157f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3ac975a1b166332f4b622a9bbf8d4639282138501b9e86fe9811bf6a81fe1add62f8b3fd730b7a4fcc359dd19d1a093e31f6abe5b944a67721c35cab72622188
|
7
|
+
data.tar.gz: a4a9bf34d0cf586f8f71442589829b8a413386b2f162d2a7f832edf31ca34d759f08c45a7ce21c4961b8aee8209f23f5555c44820ada8de03d46b2fb9112c1c3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec' do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^wp2tumblr/*.rb$})
|
7
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
8
|
+
watch('spec/spec_helper.rb') { "spec" }
|
9
|
+
end
|
10
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 jonlunsford
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Wp2tumblr
|
2
|
+
|
3
|
+
A CLI tool to import wordpress xml files into Tumblr via the Tumblr api
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install wp2tumblr
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
This gem is dependant on the `~/.tumblr` config file that the [tumblr_client gem]('https://github.com/tumblr/tumblr_client') generates. If you have not previously installed the [tumblr_client gem]('https://github.com/tumblr/tumblr_client') and have run the [irb console setup](https://github.com/tumblr/tumblr_client#the-irb-console) you will be prompted to do so upon first use of this gem.
|
11
|
+
|
12
|
+
### Import
|
13
|
+
Once you have completed the config process simply run the following command:
|
14
|
+
|
15
|
+
$ wp2tumblr text -b myblog.tumblr.com -f ~/path/to/my/wordpress/export/file
|
16
|
+
|
17
|
+
the `text` command tells `wp2tumblr` to import all of the wordpress posts as type "text". Currently "text" is the only option. Since there is no dirrect correlation between wordpress post types and Tumblr post types, text is the default. Future iterations (pull requests are welcome), will allow you to import different Tumblr post types.
|
18
|
+
|
19
|
+
The `-b` option is the Tumblr blogs' name you will be importing to, ex. `myblog.tumblr.com`.
|
20
|
+
|
21
|
+
The `-f` option is the absolute path to your wordpress export file, ex. `~/Downloads/wordpress_export.xml`.
|
22
|
+
|
23
|
+
`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.
|
24
|
+
|
25
|
+
## Configuration Tips
|
26
|
+
|
27
|
+
If you're starting completely from scratch with Tumblr here is a basic outline of the steps to take after you have installed this gem.
|
28
|
+
|
29
|
+
#### Register an Application with Tumblr
|
30
|
+
go to [Tumblr Apps](http://www.tumblr.com/oauth/apps), create your application and take note of your OAuth Consumer Key as well as your Consumer Secret Key. You will need to register a callback url to get your `oauth_verifier` token, I created a [Sinatra](https://github.com/sinatra/sinatra) app for this at `http://localhost:4567/callback`.
|
31
|
+
|
32
|
+
#### Configure the Tumblr Client
|
33
|
+
Once you have your application token's run:
|
34
|
+
|
35
|
+
$ tumblr
|
36
|
+
|
37
|
+
You will be prompted to enter your OAuth Consumer key, then your OAuth Consumer Secret. The [tumblr_client gem]('https://github.com/tumblr/tumblr_client') will then output an authorize url, copy and paste that into your browser and your callback url will receive the `oauth_verifier` post containing the OAuth Verifier token.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/wp2tumblr
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$:.unshift File.join File.dirname(__FILE__), "..", "lib"
|
3
|
+
require "rubygems"
|
4
|
+
require "wp2tumblr"
|
5
|
+
require "yaml"
|
6
|
+
require "optparse"
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
opt_parser = OptionParser.new do |opt|
|
10
|
+
opt.banner = "Usage: wp2tumblr COMMAND [OPTIONS]"
|
11
|
+
opt.separator ""
|
12
|
+
opt.separator "Commands"
|
13
|
+
opt.separator " text: upload posts as type 'text'"
|
14
|
+
opt.separator ""
|
15
|
+
opt.separator "Options"
|
16
|
+
|
17
|
+
opt.on("-b", "--blog_name Blog Name", "The name of the Tumblr blog, ex. 'myblog.tumblr.com'") do |blog_name|
|
18
|
+
options[:blog_name] = blog_name
|
19
|
+
end
|
20
|
+
|
21
|
+
opt.on("-f", "--file XML File", "The absolute path to the wordpress xml export file") do |file|
|
22
|
+
options[:file] = file
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
opt_parser.parse!
|
27
|
+
|
28
|
+
case ARGV[0]
|
29
|
+
when "text"
|
30
|
+
puts "Posting text posts with the options: #{options.inspect}"
|
31
|
+
else
|
32
|
+
puts opt_parser
|
33
|
+
end
|
34
|
+
|
35
|
+
tumblr_config_path = File.join ENV['HOME'], '.tumblr'
|
36
|
+
|
37
|
+
if File.exists?(tumblr_config_path)
|
38
|
+
|
39
|
+
config = YAML.load_file tumblr_config_path
|
40
|
+
client = Wp2tumblr::TumblrClient.new(config["consumer_key"], config["consumer_secret"], config["oauth_token"], config["oauth_token_secret"])
|
41
|
+
file = File.open(options[:file]) if File.exists?(options[:file])
|
42
|
+
|
43
|
+
if client.connect
|
44
|
+
puts "Successfully authenticated with Tumblr!"
|
45
|
+
else
|
46
|
+
puts "There was an error authenticating with Tumblr. Please check #{tumblr_config_path} and make sure your credentials are correct."
|
47
|
+
end
|
48
|
+
|
49
|
+
if ARGV[0] === "text"
|
50
|
+
if file
|
51
|
+
posts = Wp2tumblr::Wordpress.parse_xml(file, :posts)
|
52
|
+
client.text_posts(options[:blog_name], posts)
|
53
|
+
else
|
54
|
+
puts "The path to your XML file is incorrect: #{options[:file]}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
else
|
59
|
+
puts "You need to configure your Tumblr api credentials."
|
60
|
+
puts "For more info see: https://github.com/tumblr/tumblr_client#the-irb-console"
|
61
|
+
puts "run 'tumblr' then try again"
|
62
|
+
end
|
data/lib/wp2tumblr.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require "tumblr_client"
|
2
|
+
require "oauth"
|
3
|
+
|
4
|
+
module Wp2tumblr
|
5
|
+
class TumblrClient
|
6
|
+
attr_accessor :consumer_key, :secret_key, :access_token, :access_token_secret
|
7
|
+
|
8
|
+
def initialize(consumer_key, secret_key, access_token, access_token_secret)
|
9
|
+
@consumer_key = consumer_key
|
10
|
+
@secret_key = secret_key
|
11
|
+
@access_token = access_token
|
12
|
+
@access_token_secret = access_token_secret
|
13
|
+
end
|
14
|
+
|
15
|
+
def connect
|
16
|
+
Tumblr.configure do |config|
|
17
|
+
config.consumer_key = @consumer_key
|
18
|
+
config.consumer_secret = @secret_key
|
19
|
+
config.oauth_token = @access_token
|
20
|
+
config.oauth_token_secret = @access_token_secret
|
21
|
+
end
|
22
|
+
|
23
|
+
@client = Tumblr::Client.new(:client => :httpclient)
|
24
|
+
end
|
25
|
+
|
26
|
+
def text_posts(blog_name, posts)
|
27
|
+
puts "#{posts.count} posts found..."
|
28
|
+
posts.each do |post|
|
29
|
+
puts "Now posting: #{post[:title]}"
|
30
|
+
@client.text(blog_name, {:title => post[:title], :body => post[:content], :date => post[:created_at]})
|
31
|
+
sleep 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Wp2tumblr
|
4
|
+
module Wordpress
|
5
|
+
|
6
|
+
def self.parse_xml(file, type)
|
7
|
+
case type
|
8
|
+
when :posts
|
9
|
+
self.parse_posts(file)
|
10
|
+
when :categories
|
11
|
+
self.parse_categories(file)
|
12
|
+
when :tags
|
13
|
+
self.parse_tags(file)
|
14
|
+
when :all
|
15
|
+
self.parse_all(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse_posts(file)
|
20
|
+
items = get_file_contents(file)
|
21
|
+
@posts = []
|
22
|
+
items.to_enum.with_index(0) do |item, i|
|
23
|
+
@posts[i] = {title: item.at_xpath("title").text, content: item.at_xpath("content:encoded").text, created_at: item.at_xpath("pubDate").text}
|
24
|
+
end
|
25
|
+
@posts
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.parse_categories(file)
|
29
|
+
items = get_file_contents(file)
|
30
|
+
@categories = []
|
31
|
+
items.to_enum.with_index(0) do |item, i|
|
32
|
+
@categories = get_post_meta(item, :category)
|
33
|
+
end
|
34
|
+
@categories
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.parse_tags(file)
|
38
|
+
items = get_file_contents(file)
|
39
|
+
@tags = []
|
40
|
+
items.to_enum.with_index(0) do |item, i|
|
41
|
+
@tags = get_post_meta(item, :tag)
|
42
|
+
end
|
43
|
+
@tags
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.parse_all(file)
|
47
|
+
items = get_file_contents(file)
|
48
|
+
@posts = []
|
49
|
+
items.to_enum.with_index(0) do |item, i|
|
50
|
+
@posts[i] = {
|
51
|
+
title: item.at_xpath("title").text,
|
52
|
+
content: item.at_xpath("content:encoded").text,
|
53
|
+
created_at: item.at_xpath("pubDate").text,
|
54
|
+
categories: get_post_meta(item, :category),
|
55
|
+
tags: get_post_meta(item, :tag),
|
56
|
+
comments: get_post_meta(item, :comment)
|
57
|
+
}
|
58
|
+
end
|
59
|
+
@posts
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get_post_meta(post, type)
|
63
|
+
@meta = []
|
64
|
+
case type
|
65
|
+
when :category
|
66
|
+
post.css("category").each do |item|
|
67
|
+
if item.attr("domain") === "category"
|
68
|
+
@meta.push(item.text) unless @meta.include?(item.text)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
when :tag
|
72
|
+
post.css("category").each do |item|
|
73
|
+
if item.attr("domain") === "post_tag"
|
74
|
+
@meta.push(item.text) unless @meta.include?(item.text)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
when :comment
|
78
|
+
post.xpath("wp:comment").to_enum.with_index(0) do |comment, i|
|
79
|
+
@meta.push({
|
80
|
+
author: comment.at_xpath("wp:comment_author").text,
|
81
|
+
author_email: comment.at_xpath("wp:comment_author_email").text,
|
82
|
+
content: comment.at_xpath("wp:comment_content").text,
|
83
|
+
approved: comment.at_xpath("wp:comment_approved").text === "1" ? true : false
|
84
|
+
})
|
85
|
+
end
|
86
|
+
end
|
87
|
+
@meta
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def self.get_file_contents(file)
|
93
|
+
Nokogiri::XML(file).xpath("//channel//item")
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
|
3
|
+
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
|
4
|
+
<!-- You may use this file to transfer that content from one site to another. -->
|
5
|
+
<!-- This file is not intended to serve as a complete backup of your site. -->
|
6
|
+
|
7
|
+
<!-- To import this information into a WordPress site follow these steps: -->
|
8
|
+
<!-- 1. Log in to that site as an administrator. -->
|
9
|
+
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
|
10
|
+
<!-- 3. Install the "WordPress" importer from the list. -->
|
11
|
+
<!-- 4. Activate & Run Importer. -->
|
12
|
+
<!-- 5. Upload this file using the form provided on that page. -->
|
13
|
+
<!-- 6. You will first be asked to map the authors in this export file to users -->
|
14
|
+
<!-- on the site. For each author, you may choose to map to an -->
|
15
|
+
<!-- existing user on the site or to create a new user. -->
|
16
|
+
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
|
17
|
+
<!-- contained in this file into your site. -->
|
18
|
+
|
19
|
+
<!-- generator="WordPress/3.5.1" created="2013-03-08 20:01" -->
|
20
|
+
<rss version="2.0"
|
21
|
+
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
|
22
|
+
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
23
|
+
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
24
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
25
|
+
xmlns:wp="http://wordpress.org/export/1.2/"
|
26
|
+
>
|
27
|
+
|
28
|
+
<channel>
|
29
|
+
<title>Blog Title</title>
|
30
|
+
<link>http://testblog.com</link>
|
31
|
+
<description>Blog Description</description>
|
32
|
+
<pubDate>Fri, 08 Mar 2013 20:01:27 +0000</pubDate>
|
33
|
+
<language>en-US</language>
|
34
|
+
<wp:wxr_version>1.2</wp:wxr_version>
|
35
|
+
<wp:base_site_url>http://testblog.com</wp:base_site_url>
|
36
|
+
<wp:base_blog_url>http://testblog.com</wp:base_blog_url>
|
37
|
+
|
38
|
+
<wp:author>
|
39
|
+
<wp:author_id>1</wp:author_id><wp:author_login>testuser</wp:author_login>
|
40
|
+
<wp:author_email>testuser@gmail.com</wp:author_email>
|
41
|
+
<wp:author_display_name><![CDATA[Sarah Kathleen]]></wp:author_display_name>
|
42
|
+
<wp:author_first_name><![CDATA[]]></wp:author_first_name>
|
43
|
+
<wp:author_last_name><![CDATA[]]></wp:author_last_name>
|
44
|
+
</wp:author>
|
45
|
+
|
46
|
+
<generator>http://wordpress.org/?v=3.5.1</generator>
|
47
|
+
|
48
|
+
<item>
|
49
|
+
<title>Post Title</title>
|
50
|
+
<link>http://testblog.com/post-title/</link>
|
51
|
+
<pubDate>Fri, 01 Mar 2013 07:59:29 +0000</pubDate>
|
52
|
+
<dc:creator>testuser</dc:creator>
|
53
|
+
<guid isPermaLink="false">http://testblog.com/?p=3199</guid>
|
54
|
+
<description></description>
|
55
|
+
<content:encoded><![CDATA[test content]]></content:encoded>
|
56
|
+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
57
|
+
<wp:post_id>3199</wp:post_id>
|
58
|
+
<wp:post_date>2013-03-01 07:59:29</wp:post_date>
|
59
|
+
<wp:post_date_gmt>2013-03-01 07:59:29</wp:post_date_gmt>
|
60
|
+
<wp:comment_status>open</wp:comment_status>
|
61
|
+
<wp:ping_status>open</wp:ping_status>
|
62
|
+
<wp:post_name>post title</wp:post_name>
|
63
|
+
<wp:status>publish</wp:status>
|
64
|
+
<wp:post_parent>0</wp:post_parent>
|
65
|
+
<wp:menu_order>0</wp:menu_order>
|
66
|
+
<wp:post_type>post</wp:post_type>
|
67
|
+
<wp:post_password></wp:post_password>
|
68
|
+
<wp:is_sticky>0</wp:is_sticky>
|
69
|
+
<category domain="post_tag" nicename="tag-1"><![CDATA[Tag 1]]></category>
|
70
|
+
<category domain="post_tag" nicename="tag-2"><![CDATA[Tag 2]]></category>
|
71
|
+
<category domain="post_tag" nicename="tag-3"><![CDATA[Tag 3]]></category>
|
72
|
+
<category domain="category" nicename="category-1"><![CDATA[Category 1]]></category>
|
73
|
+
<category domain="category" nicename="category-2"><![CDATA[Category 2]]></category>
|
74
|
+
<category domain="category" nicename="category-3"><![CDATA[Category 3]]></category>
|
75
|
+
<wp:postmeta>
|
76
|
+
<wp:meta_key>_edit_last</wp:meta_key>
|
77
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
78
|
+
</wp:postmeta>
|
79
|
+
<wp:comment>
|
80
|
+
<wp:comment_id>1738</wp:comment_id>
|
81
|
+
<wp:comment_author><![CDATA[Test Commenter]]></wp:comment_author>
|
82
|
+
<wp:comment_author_email>testcommenter@gmail.com</wp:comment_author_email>
|
83
|
+
<wp:comment_author_url></wp:comment_author_url>
|
84
|
+
<wp:comment_author_IP>68.1.71.30</wp:comment_author_IP>
|
85
|
+
<wp:comment_date>2013-03-01 16:22:49</wp:comment_date>
|
86
|
+
<wp:comment_date_gmt>2013-03-01 16:22:49</wp:comment_date_gmt>
|
87
|
+
<wp:comment_content><![CDATA[Test Comment]]></wp:comment_content>
|
88
|
+
<wp:comment_approved>1</wp:comment_approved>
|
89
|
+
<wp:comment_type></wp:comment_type>
|
90
|
+
<wp:comment_parent>0</wp:comment_parent>
|
91
|
+
<wp:comment_user_id>0</wp:comment_user_id>
|
92
|
+
</wp:comment>
|
93
|
+
<wp:comment>
|
94
|
+
<wp:comment_id>1738</wp:comment_id>
|
95
|
+
<wp:comment_author><![CDATA[Test Commenter]]></wp:comment_author>
|
96
|
+
<wp:comment_author_email>testcommenter@gmail.com</wp:comment_author_email>
|
97
|
+
<wp:comment_author_url></wp:comment_author_url>
|
98
|
+
<wp:comment_author_IP>68.1.71.30</wp:comment_author_IP>
|
99
|
+
<wp:comment_date>2013-03-01 16:22:49</wp:comment_date>
|
100
|
+
<wp:comment_date_gmt>2013-03-01 16:22:49</wp:comment_date_gmt>
|
101
|
+
<wp:comment_content><![CDATA[Test Comment 2]]></wp:comment_content>
|
102
|
+
<wp:comment_approved>1</wp:comment_approved>
|
103
|
+
<wp:comment_type></wp:comment_type>
|
104
|
+
<wp:comment_parent>0</wp:comment_parent>
|
105
|
+
<wp:comment_user_id>0</wp:comment_user_id>
|
106
|
+
</wp:comment>
|
107
|
+
</item>
|
108
|
+
|
109
|
+
<item>
|
110
|
+
<title>Post Title 2</title>
|
111
|
+
<link>http://testblog.com/post-title/</link>
|
112
|
+
<pubDate>Fri, 01 Mar 2013 07:59:29 +0000</pubDate>
|
113
|
+
<dc:creator>testuser</dc:creator>
|
114
|
+
<guid isPermaLink="false">http://testblog.com/?p=3199</guid>
|
115
|
+
<description></description>
|
116
|
+
<content:encoded><![CDATA[test content]]></content:encoded>
|
117
|
+
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
118
|
+
<wp:post_id>3199</wp:post_id>
|
119
|
+
<wp:post_date>2013-03-01 07:59:29</wp:post_date>
|
120
|
+
<wp:post_date_gmt>2013-03-01 07:59:29</wp:post_date_gmt>
|
121
|
+
<wp:comment_status>open</wp:comment_status>
|
122
|
+
<wp:ping_status>open</wp:ping_status>
|
123
|
+
<wp:post_name>post title</wp:post_name>
|
124
|
+
<wp:status>publish</wp:status>
|
125
|
+
<wp:post_parent>0</wp:post_parent>
|
126
|
+
<wp:menu_order>0</wp:menu_order>
|
127
|
+
<wp:post_type>post</wp:post_type>
|
128
|
+
<wp:post_password></wp:post_password>
|
129
|
+
<wp:is_sticky>0</wp:is_sticky>
|
130
|
+
<category domain="post_tag" nicename="tag-1"><![CDATA[Tag 1]]></category>
|
131
|
+
<category domain="post_tag" nicename="tag-2"><![CDATA[Tag 2]]></category>
|
132
|
+
<category domain="post_tag" nicename="tag-3"><![CDATA[Tag 3]]></category>
|
133
|
+
<category domain="category" nicename="category-1"><![CDATA[Category 1]]></category>
|
134
|
+
<category domain="category" nicename="category-2"><![CDATA[Category 2]]></category>
|
135
|
+
<category domain="category" nicename="category-3"><![CDATA[Category 3]]></category>
|
136
|
+
<wp:postmeta>
|
137
|
+
<wp:meta_key>_edit_last</wp:meta_key>
|
138
|
+
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
139
|
+
</wp:postmeta>
|
140
|
+
<wp:comment>
|
141
|
+
<wp:comment_id>1738</wp:comment_id>
|
142
|
+
<wp:comment_author><![CDATA[Test Commenter]]></wp:comment_author>
|
143
|
+
<wp:comment_author_email>testcommenter@gmail.com</wp:comment_author_email>
|
144
|
+
<wp:comment_author_url></wp:comment_author_url>
|
145
|
+
<wp:comment_author_IP>68.1.71.30</wp:comment_author_IP>
|
146
|
+
<wp:comment_date>2013-03-01 16:22:49</wp:comment_date>
|
147
|
+
<wp:comment_date_gmt>2013-03-01 16:22:49</wp:comment_date_gmt>
|
148
|
+
<wp:comment_content><![CDATA[Test Comment]]></wp:comment_content>
|
149
|
+
<wp:comment_approved>1</wp:comment_approved>
|
150
|
+
<wp:comment_type></wp:comment_type>
|
151
|
+
<wp:comment_parent>0</wp:comment_parent>
|
152
|
+
<wp:comment_user_id>0</wp:comment_user_id>
|
153
|
+
</wp:comment>
|
154
|
+
</item>
|
155
|
+
|
156
|
+
</channel>
|
157
|
+
</rss>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wp2tumblr do
|
4
|
+
context "Dependencies" do
|
5
|
+
it "depends on Nokogiri" do
|
6
|
+
Nokogiri.should_not be_nil
|
7
|
+
end
|
8
|
+
|
9
|
+
it "depends on tumblr_client" do
|
10
|
+
Tumblr.should_not be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "depends on oauth" do
|
14
|
+
OAuth.should_not be_nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe Wp2tumblr::Wordpress do
|
20
|
+
let(:file) { File.open(File.dirname(__FILE__) + "/wp2tumblr/wordpress_format.xml") }
|
21
|
+
|
22
|
+
describe ".parse_xml" do
|
23
|
+
it "delegates parsing of just post content" do
|
24
|
+
parsed_params = Wp2tumblr::Wordpress.parse_xml(file, :posts)
|
25
|
+
parsed_params[0][:title].should eq("Post Title")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".parse_xml" do
|
30
|
+
it "delegates parsing of just post categories" do
|
31
|
+
parsed_params = Wp2tumblr::Wordpress.parse_xml(file, :categories)
|
32
|
+
parsed_params[0].should eq("Category 1")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe ".parse_xml" do
|
37
|
+
it "delegates parsing of just post tags" do
|
38
|
+
parsed_params = Wp2tumblr::Wordpress.parse_xml(file, :tags)
|
39
|
+
parsed_params[0].should eq("Tag 1")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe ".parse_xml" do
|
44
|
+
it "Parses posts, tags, categories, and comments together" do
|
45
|
+
parsed_params = Wp2tumblr::Wordpress.parse_xml(file, :all)
|
46
|
+
parsed_params[0][:title].should eq("Post Title")
|
47
|
+
parsed_params[0][:tags][0].should eq("Tag 1")
|
48
|
+
parsed_params[0][:categories][0].should eq("Category 1")
|
49
|
+
parsed_params[0][:comments][0][:author].should eq("Test Commenter")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe Wp2tumblr::TumblrClient do
|
55
|
+
# config.yml is excluded from this repo, you must provide your own keys for deveopment purposes.
|
56
|
+
let(:config) { YAML.load_file(File.dirname(__FILE__) + "/wp2tumblr/config_spec.yml") }
|
57
|
+
let(:client) { Wp2tumblr::TumblrClient.new(config["tumblr_consumer_key"], config["tumblr_secret_key"], config["oauth_token"], config["oauth_token_secret"]) }
|
58
|
+
let(:file) { File.open(File.dirname(__FILE__) + "/wp2tumblr/wordpress_format.xml") }
|
59
|
+
|
60
|
+
describe "initialize" do
|
61
|
+
it "should return an instance of itself" do
|
62
|
+
client.should_not be_nil
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "authenticate" do
|
67
|
+
it "should complete the oauth protocol with Tumblr" do
|
68
|
+
tumblr_client = client.connect
|
69
|
+
tumblr_client.should_not be_nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "text_posts" do
|
74
|
+
it "should post text posts to the Tumblr api" do
|
75
|
+
posts = Wp2tumblr::Wordpress.parse_xml(file, :posts)
|
76
|
+
client.connect
|
77
|
+
client.text_posts(config["tumblr_blog_name"] ,posts)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/wp2tumblr.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wp2tumblr/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wp2tumblr"
|
8
|
+
spec.version = Wp2tumblr::VERSION
|
9
|
+
spec.authors = ["jonlunsford"]
|
10
|
+
spec.email = ["jon@capturethecastle.net"]
|
11
|
+
spec.description = %q{A CLI tool to import wordpress xml files into Tumblr}
|
12
|
+
spec.summary = %q{This gem utilizes the Tumblr api to create posts from a wordpress post XML export file.}
|
13
|
+
spec.homepage = "https://github.com/jonlunsford/wp2tumblr"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "oauth"
|
22
|
+
spec.add_dependency "tumblr_client"
|
23
|
+
spec.add_dependency "nokogiri"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "guard"
|
29
|
+
spec.add_development_dependency "guard-rspec"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wp2tumblr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jonlunsford
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: oauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tumblr_client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A CLI tool to import wordpress xml files into Tumblr
|
126
|
+
email:
|
127
|
+
- jon@capturethecastle.net
|
128
|
+
executables:
|
129
|
+
- wp2tumblr
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- Gemfile
|
135
|
+
- Guardfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- bin/wp2tumblr
|
140
|
+
- lib/wp2tumblr.rb
|
141
|
+
- lib/wp2tumblr/tumblr_client.rb
|
142
|
+
- lib/wp2tumblr/version.rb
|
143
|
+
- lib/wp2tumblr/wordpress.rb
|
144
|
+
- spec/spec_helper.rb
|
145
|
+
- spec/wp2tumblr/wordpress_format.xml
|
146
|
+
- spec/wp2tumblr_spec.rb
|
147
|
+
- wp2tumblr.gemspec
|
148
|
+
homepage: https://github.com/jonlunsford/wp2tumblr
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.0.5
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: This gem utilizes the Tumblr api to create posts from a wordpress post XML
|
172
|
+
export file.
|
173
|
+
test_files:
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
- spec/wp2tumblr/wordpress_format.xml
|
176
|
+
- spec/wp2tumblr_spec.rb
|