Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
05bf79536d | |||
249de047b2 | |||
9aa403612e | |||
201233f89f | |||
ede3baae64 | |||
6382ceb7dc | |||
10df4f5494 | |||
3807af7ff3 | |||
84ba9eac1c | |||
0031b7046f | |||
5d96f3a336 | |||
39914c83c9 | |||
5f564bdbff | |||
ce3e947b83 | |||
c06bc8142d | |||
4b36eaeccf | |||
d4b2457787 | |||
bd4cccd91a | |||
60ce62ad1b | |||
![]() |
1e1f3574eb | ||
![]() |
0beaa90a3d | ||
![]() |
6188f58706 | ||
![]() |
b2700960d8 | ||
![]() |
d3352df3a5 | ||
![]() |
e02aeefeb5 | ||
![]() |
cdbb1d001a | ||
![]() |
054e7f3b91 | ||
![]() |
ec1162fc4b | ||
![]() |
368561cfc7 | ||
![]() |
32bb8a528a | ||
![]() |
309ec660b9 | ||
![]() |
90665484c7 | ||
![]() |
a24ea686fa | ||
![]() |
7265d31f62 | ||
![]() |
2581895c7c | ||
![]() |
7550dfa164 | ||
![]() |
9a2b5acef6 | ||
![]() |
772cfdc25b |
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,3 +4,6 @@ pkg/
|
|||||||
spec/dummy/db/*.sqlite3
|
spec/dummy/db/*.sqlite3
|
||||||
spec/dummy/log/*.log
|
spec/dummy/log/*.log
|
||||||
spec/dummy/tmp/
|
spec/dummy/tmp/
|
||||||
|
*.un~
|
||||||
|
refinerycms-wordpress-import-*.gem
|
||||||
|
*.swp
|
||||||
|
4
.travis.yml
Normal file
4
.travis.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
rvm:
|
||||||
|
- 1.9.2
|
||||||
|
- 1.8.7
|
||||||
|
- ruby-head
|
18
Gemfile
18
Gemfile
@ -1,16 +1,26 @@
|
|||||||
source "http://rubygems.org"
|
source "http://rubygems.org"
|
||||||
|
|
||||||
gem "rails", "3.0.7"
|
ruby '2.0.0'
|
||||||
|
|
||||||
|
gem "rails", "4.0.0"
|
||||||
#gem "capybara", ">= 1.0.0.beta1"
|
#gem "capybara", ">= 1.0.0.beta1"
|
||||||
gem "sqlite3"
|
gem "sqlite3"
|
||||||
|
gem "rmagick"
|
||||||
|
gem 'shortcode', "0.1.2"
|
||||||
|
|
||||||
|
group :development, :test do
|
||||||
|
gem 'byebug'
|
||||||
gem "rspec-rails", ">= 2.6.0"
|
gem "rspec-rails", ">= 2.6.0"
|
||||||
gem "database_cleaner"
|
gem "database_cleaner"
|
||||||
|
gem 'guard-rspec'
|
||||||
|
gem 'ffi'
|
||||||
|
gem 'guard-bundler'
|
||||||
|
gem 'libnotify' if RUBY_PLATFORM =~ /linux/i
|
||||||
|
gem 'fakeweb'
|
||||||
|
end
|
||||||
|
|
||||||
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
|
||||||
# gem 'ruby-debug'
|
# gem 'ruby-debug'
|
||||||
# gem 'ruby-debug19'
|
# gem 'ruby-debug19'
|
||||||
|
|
||||||
gem 'refinerycms'
|
gem 'wordpress-import', :path => './'
|
||||||
gem 'refinerycms-blog'
|
|
||||||
gem 'refinerycms-wordpress-import', :path => './'
|
|
||||||
|
314
Gemfile.lock
314
Gemfile.lock
@ -1,180 +1,176 @@
|
|||||||
PATH
|
PATH
|
||||||
remote: ./
|
remote: ./
|
||||||
specs:
|
specs:
|
||||||
refinerycms-wordpress-import (0.1.0)
|
wordpress-import (0.4.4)
|
||||||
bundler (~> 1.0)
|
bundler (~> 1.0)
|
||||||
nokogiri (~> 1.4.4)
|
nokogiri (~> 1.6.0)
|
||||||
refinerycms (~> 1.0.0)
|
shortcode (~> 0.1.1)
|
||||||
refinerycms-blog (~> 1.5.2)
|
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
abstract (1.0.0)
|
actionmailer (4.0.0)
|
||||||
actionmailer (3.0.7)
|
actionpack (= 4.0.0)
|
||||||
actionpack (= 3.0.7)
|
mail (~> 2.5.3)
|
||||||
mail (~> 2.2.15)
|
actionpack (4.0.0)
|
||||||
actionpack (3.0.7)
|
activesupport (= 4.0.0)
|
||||||
activemodel (= 3.0.7)
|
builder (~> 3.1.0)
|
||||||
activesupport (= 3.0.7)
|
erubis (~> 2.7.0)
|
||||||
builder (~> 2.1.2)
|
rack (~> 1.5.2)
|
||||||
erubis (~> 2.6.6)
|
rack-test (~> 0.6.2)
|
||||||
i18n (~> 0.5.0)
|
activemodel (4.0.0)
|
||||||
rack (~> 1.2.1)
|
activesupport (= 4.0.0)
|
||||||
rack-mount (~> 0.6.14)
|
builder (~> 3.1.0)
|
||||||
rack-test (~> 0.5.7)
|
activerecord (4.0.0)
|
||||||
tzinfo (~> 0.3.23)
|
activemodel (= 4.0.0)
|
||||||
activemodel (3.0.7)
|
activerecord-deprecated_finders (~> 1.0.2)
|
||||||
activesupport (= 3.0.7)
|
activesupport (= 4.0.0)
|
||||||
builder (~> 2.1.2)
|
arel (~> 4.0.0)
|
||||||
i18n (~> 0.5.0)
|
activerecord-deprecated_finders (1.0.3)
|
||||||
activerecord (3.0.7)
|
activesupport (4.0.0)
|
||||||
activemodel (= 3.0.7)
|
i18n (~> 0.6, >= 0.6.4)
|
||||||
activesupport (= 3.0.7)
|
minitest (~> 4.2)
|
||||||
arel (~> 2.0.2)
|
multi_json (~> 1.3)
|
||||||
tzinfo (~> 0.3.23)
|
thread_safe (~> 0.1)
|
||||||
activeresource (3.0.7)
|
tzinfo (~> 0.3.37)
|
||||||
activemodel (= 3.0.7)
|
arel (4.0.2)
|
||||||
activesupport (= 3.0.7)
|
atomic (1.1.15)
|
||||||
activesupport (3.0.7)
|
blankslate (2.1.2.4)
|
||||||
acts-as-taggable-on (2.0.6)
|
builder (3.1.4)
|
||||||
acts_as_indexed (0.7.2)
|
byebug (2.7.0)
|
||||||
arel (2.0.10)
|
columnize (~> 0.3)
|
||||||
awesome_nested_set (2.0.0)
|
debugger-linecache (~> 1.2)
|
||||||
activerecord (>= 3.0.0)
|
celluloid (0.15.2)
|
||||||
babosa (0.3.4)
|
timers (~> 1.1.0)
|
||||||
bcrypt-ruby (2.1.4)
|
celluloid-io (0.15.0)
|
||||||
builder (2.1.2)
|
celluloid (>= 0.15.0)
|
||||||
database_cleaner (0.6.7)
|
nio4r (>= 0.5.0)
|
||||||
devise (1.3.4)
|
coderay (1.1.0)
|
||||||
bcrypt-ruby (~> 2.1.2)
|
columnize (0.3.6)
|
||||||
orm_adapter (~> 0.0.3)
|
database_cleaner (1.2.0)
|
||||||
warden (~> 1.0.3)
|
debugger-linecache (1.2.0)
|
||||||
diff-lcs (1.1.2)
|
diff-lcs (1.2.5)
|
||||||
dragonfly (0.9.3)
|
erubis (2.7.0)
|
||||||
rack
|
fakeweb (1.3.0)
|
||||||
erubis (2.6.6)
|
ffi (1.9.3)
|
||||||
abstract (>= 1.0.0)
|
formatador (0.2.4)
|
||||||
filters_spam (0.3)
|
guard (2.5.1)
|
||||||
friendly_id_globalize3 (3.2.1.3)
|
formatador (>= 0.2.4)
|
||||||
babosa (~> 0.3.0)
|
listen (~> 2.6)
|
||||||
globalize3 (0.1.0)
|
lumberjack (~> 1.0)
|
||||||
activemodel (>= 3.0.0)
|
pry (>= 0.9.12)
|
||||||
activerecord (>= 3.0.0)
|
thor (>= 0.18.1)
|
||||||
i18n (0.5.0)
|
guard-bundler (2.0.0)
|
||||||
mail (2.2.19)
|
bundler (~> 1.0)
|
||||||
activesupport (>= 2.3.6)
|
guard (~> 2.2)
|
||||||
i18n (>= 0.4.0)
|
guard-rspec (4.2.8)
|
||||||
|
guard (~> 2.1)
|
||||||
|
rspec (>= 2.14, < 4.0)
|
||||||
|
haml (4.0.5)
|
||||||
|
tilt
|
||||||
|
hike (1.2.3)
|
||||||
|
i18n (0.6.9)
|
||||||
|
libnotify (0.8.2)
|
||||||
|
ffi (>= 1.0.11)
|
||||||
|
listen (2.7.0)
|
||||||
|
celluloid (>= 0.15.2)
|
||||||
|
celluloid-io (>= 0.15.0)
|
||||||
|
rb-fsevent (>= 0.9.3)
|
||||||
|
rb-inotify (>= 0.9)
|
||||||
|
lumberjack (1.0.4)
|
||||||
|
mail (2.5.4)
|
||||||
mime-types (~> 1.16)
|
mime-types (~> 1.16)
|
||||||
treetop (~> 1.4.8)
|
treetop (~> 1.4.8)
|
||||||
mime-types (1.16)
|
method_source (0.8.2)
|
||||||
nokogiri (1.4.4)
|
mime-types (1.25.1)
|
||||||
orm_adapter (0.0.5)
|
mini_portile (0.5.2)
|
||||||
polyglot (0.3.1)
|
minitest (4.7.5)
|
||||||
rack (1.2.3)
|
multi_json (1.9.0)
|
||||||
rack-cache (1.0.2)
|
nio4r (1.0.0)
|
||||||
rack (>= 0.4)
|
nokogiri (1.6.1)
|
||||||
rack-mount (0.6.14)
|
mini_portile (~> 0.5.0)
|
||||||
rack (>= 1.0.0)
|
parslet (1.5.0)
|
||||||
rack-test (0.5.7)
|
blankslate (~> 2.0)
|
||||||
|
polyglot (0.3.4)
|
||||||
|
pry (0.9.12.6)
|
||||||
|
coderay (~> 1.0)
|
||||||
|
method_source (~> 0.8)
|
||||||
|
slop (~> 3.4)
|
||||||
|
rack (1.5.2)
|
||||||
|
rack-test (0.6.2)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (3.0.7)
|
rails (4.0.0)
|
||||||
actionmailer (= 3.0.7)
|
actionmailer (= 4.0.0)
|
||||||
actionpack (= 3.0.7)
|
actionpack (= 4.0.0)
|
||||||
activerecord (= 3.0.7)
|
activerecord (= 4.0.0)
|
||||||
activeresource (= 3.0.7)
|
activesupport (= 4.0.0)
|
||||||
activesupport (= 3.0.7)
|
bundler (>= 1.3.0, < 2.0)
|
||||||
bundler (~> 1.0)
|
railties (= 4.0.0)
|
||||||
railties (= 3.0.7)
|
sprockets-rails (~> 2.0.0)
|
||||||
railties (3.0.7)
|
railties (4.0.0)
|
||||||
actionpack (= 3.0.7)
|
actionpack (= 4.0.0)
|
||||||
activesupport (= 3.0.7)
|
activesupport (= 4.0.0)
|
||||||
rake (>= 0.8.7)
|
rake (>= 0.8.7)
|
||||||
thor (~> 0.14.4)
|
thor (>= 0.18.1, < 2.0)
|
||||||
rake (0.9.1)
|
rake (10.1.1)
|
||||||
refinerycms (1.0.0)
|
rb-fsevent (0.9.4)
|
||||||
bundler (~> 1.0)
|
rb-inotify (0.9.3)
|
||||||
refinerycms-authentication (= 1.0.0)
|
ffi (>= 0.5.0)
|
||||||
refinerycms-base (= 1.0.0)
|
rmagick (2.13.2)
|
||||||
refinerycms-core (= 1.0.0)
|
rspec (2.14.1)
|
||||||
refinerycms-dashboard (= 1.0.0)
|
rspec-core (~> 2.14.0)
|
||||||
refinerycms-images (= 1.0.0)
|
rspec-expectations (~> 2.14.0)
|
||||||
refinerycms-pages (= 1.0.0)
|
rspec-mocks (~> 2.14.0)
|
||||||
refinerycms-resources (= 1.0.0)
|
rspec-core (2.14.8)
|
||||||
refinerycms-settings (= 1.0.0)
|
rspec-expectations (2.14.5)
|
||||||
refinerycms-authentication (1.0.0)
|
diff-lcs (>= 1.1.3, < 2.0)
|
||||||
devise (~> 1.3.0)
|
rspec-mocks (2.14.6)
|
||||||
friendly_id_globalize3 (~> 3.2.1)
|
rspec-rails (2.14.1)
|
||||||
refinerycms-core (= 1.0.0)
|
actionpack (>= 3.0)
|
||||||
refinerycms-base (1.0.0)
|
activemodel (>= 3.0)
|
||||||
refinerycms-blog (1.5.2)
|
activesupport (>= 3.0)
|
||||||
acts-as-taggable-on
|
railties (>= 3.0)
|
||||||
filters_spam (~> 0.2)
|
rspec-core (~> 2.14.0)
|
||||||
refinerycms-core (~> 1.0.0)
|
rspec-expectations (~> 2.14.0)
|
||||||
seo_meta (~> 1.1.0)
|
rspec-mocks (~> 2.14.0)
|
||||||
refinerycms-core (1.0.0)
|
shortcode (0.1.2)
|
||||||
acts_as_indexed (~> 0.7)
|
haml (~> 4.0)
|
||||||
awesome_nested_set (~> 2.0)
|
parslet (= 1.5.0)
|
||||||
friendly_id_globalize3 (~> 3.2.1)
|
slop (3.5.0)
|
||||||
globalize3 (~> 0.1)
|
sprockets (2.12.0)
|
||||||
rails (~> 3.0.7)
|
hike (~> 1.2)
|
||||||
refinerycms-base (= 1.0.0)
|
multi_json (~> 1.0)
|
||||||
refinerycms-generators (~> 1.0)
|
rack (~> 1.0)
|
||||||
refinerycms-settings (= 1.0.0)
|
tilt (~> 1.1, != 1.3.0)
|
||||||
truncate_html (~> 0.5)
|
sprockets-rails (2.0.1)
|
||||||
will_paginate (~> 3.0.pre)
|
actionpack (>= 3.0)
|
||||||
refinerycms-dashboard (1.0.0)
|
activesupport (>= 3.0)
|
||||||
refinerycms-core (= 1.0.0)
|
sprockets (~> 2.8)
|
||||||
refinerycms-generators (1.0.2)
|
sqlite3 (1.3.9)
|
||||||
refinerycms-images (1.0.0)
|
thor (0.18.1)
|
||||||
dragonfly (~> 0.9.0)
|
thread_safe (0.2.0)
|
||||||
rack-cache (>= 0.5.3)
|
atomic (>= 1.1.7, < 2)
|
||||||
refinerycms-core (= 1.0.0)
|
tilt (1.4.1)
|
||||||
refinerycms-pages (1.0.0)
|
timers (1.1.0)
|
||||||
awesome_nested_set (~> 2.0)
|
treetop (1.4.15)
|
||||||
friendly_id_globalize3 (~> 3.2.1)
|
polyglot
|
||||||
globalize3 (~> 0.1)
|
|
||||||
refinerycms-core (= 1.0.0)
|
|
||||||
seo_meta (~> 1.1)
|
|
||||||
refinerycms-resources (1.0.0)
|
|
||||||
dragonfly (~> 0.9.0)
|
|
||||||
rack-cache (>= 0.5.3)
|
|
||||||
refinerycms-core (= 1.0.0)
|
|
||||||
refinerycms-settings (1.0.0)
|
|
||||||
refinerycms-base (= 1.0.0)
|
|
||||||
rspec (2.6.0)
|
|
||||||
rspec-core (~> 2.6.0)
|
|
||||||
rspec-expectations (~> 2.6.0)
|
|
||||||
rspec-mocks (~> 2.6.0)
|
|
||||||
rspec-core (2.6.3)
|
|
||||||
rspec-expectations (2.6.0)
|
|
||||||
diff-lcs (~> 1.1.2)
|
|
||||||
rspec-mocks (2.6.0)
|
|
||||||
rspec-rails (2.6.1)
|
|
||||||
actionpack (~> 3.0)
|
|
||||||
activesupport (~> 3.0)
|
|
||||||
railties (~> 3.0)
|
|
||||||
rspec (~> 2.6.0)
|
|
||||||
seo_meta (1.1.1)
|
|
||||||
refinerycms-generators (~> 1.0.1)
|
|
||||||
sqlite3 (1.3.3)
|
|
||||||
thor (0.14.6)
|
|
||||||
treetop (1.4.9)
|
|
||||||
polyglot (>= 0.3.1)
|
polyglot (>= 0.3.1)
|
||||||
truncate_html (0.5.1)
|
tzinfo (0.3.39)
|
||||||
tzinfo (0.3.27)
|
|
||||||
warden (1.0.4)
|
|
||||||
rack (>= 1.0)
|
|
||||||
will_paginate (3.0.pre2)
|
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
byebug
|
||||||
database_cleaner
|
database_cleaner
|
||||||
rails (= 3.0.7)
|
fakeweb
|
||||||
refinerycms
|
ffi
|
||||||
refinerycms-blog
|
guard-bundler
|
||||||
refinerycms-wordpress-import!
|
guard-rspec
|
||||||
|
libnotify
|
||||||
|
rails (= 4.0.0)
|
||||||
|
rmagick
|
||||||
rspec-rails (>= 2.6.0)
|
rspec-rails (>= 2.6.0)
|
||||||
|
shortcode (= 0.1.2)
|
||||||
sqlite3
|
sqlite3
|
||||||
|
wordpress-import!
|
||||||
|
21
Guardfile
Normal file
21
Guardfile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# A sample Guardfile
|
||||||
|
# More info at https://github.com/guard/guard#readme
|
||||||
|
|
||||||
|
guard 'bundler' do
|
||||||
|
watch('Gemfile')
|
||||||
|
# Uncomment next line if Gemfile contain `gemspec' command
|
||||||
|
watch(/^.+\.gemspec/)
|
||||||
|
end
|
||||||
|
|
||||||
|
guard 'rspec', :version => 2 do
|
||||||
|
watch(%r{^spec/.+_spec\.rb$})
|
||||||
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||||
|
watch('spec/spec_helper.rb') { "spec" }
|
||||||
|
|
||||||
|
# Rails example
|
||||||
|
watch(%r{^spec/.+_spec\.rb$})
|
||||||
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
||||||
|
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
||||||
|
watch('spec/spec_helper.rb') { "spec" }
|
||||||
|
end
|
||||||
|
|
@ -1,4 +1,5 @@
|
|||||||
Copyright 2011 YOURNAME
|
Copyright 2014 Will Bradley
|
||||||
|
portions Copyright 2011 Marc Remolt
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
55
README.rdoc
55
README.rdoc
@ -1,34 +1,32 @@
|
|||||||
= Refinerycms-wordpress-import
|
= Wordpress-import
|
||||||
|
|
||||||
This litte project is an importer for WordPress XML dumps into refinerycms(-blog).
|
This little project is an importer for WordPress XML dumps into Rails.
|
||||||
|
|
||||||
You can find the source code on github: https://github.com/mremolt/refinerycms-wordpress-import
|
It's been somewhat customized for one particular project; you probably want to fork this and modify it to fit your app's schema.
|
||||||
|
|
||||||
Keep in mind, this gem imports blog posts and pages, NOT the media files, as they are not
|
It's a fork of Marc Remolt's Refinerycms-wordpress-import ( https://github.com/mremolt/refinerycms-wordpress-import )
|
||||||
part of the XML dump! You have to manually readd them to Refinery.
|
|
||||||
|
|
||||||
The same goes for links to other pages on your site. WordPress exports them just as <a>-Tags.
|
You can find the source code on github: https://github.com/zyphlar/wordpress-import
|
||||||
|
|
||||||
|
Keep in mind that links to other pages of your blog are just copied, as WordPress exports them as <a>-Tags.
|
||||||
If your site (blog) structure uses new urls, the links WILL break! For example, if you used
|
If your site (blog) structure uses new urls, the links WILL break! For example, if you used
|
||||||
the popular WP blog url structure "YYYY-MM/slug", be warned that Refinery just uses "blog/slug".
|
the popular WP blog url structure "YYYY-MM/slug", be warned that Refinery just uses "blog/slug".
|
||||||
So your inner site links will point to the old WP url.
|
So your inner site links will point to the old WP url.
|
||||||
|
|
||||||
|
|
||||||
== Prerequisites
|
== Prerequisites
|
||||||
|
|
||||||
As refinerycms-wordpress-import is an addon for RefineryCMS, is shares the prerequisites with it.
|
TODO
|
||||||
So you'll first need a running installation of refinerycms and refinerycms-blog. Make sure
|
|
||||||
the site is running, all migrations are run and you created the first refinery user.
|
|
||||||
|
|
||||||
|
|
||||||
== Installation
|
== Installation
|
||||||
|
|
||||||
Just add the gem to your projects Gemfile:
|
Just add the gem to your projects Gemfile:
|
||||||
|
|
||||||
gem 'refinerycms-wordpress-import'
|
gem 'wordpress-import'
|
||||||
|
|
||||||
Or if you want to stay on the bleeding edge:
|
Or if you want to stay on the bleeding edge:
|
||||||
|
|
||||||
gem 'refinerycms-wordpress-import', :git => 'git://github.com/mremolt/refinerycms-wordpress-import.git'
|
gem 'wordpress-import', :git => 'git://github.com/zyphlar/wordpress-import.git'
|
||||||
|
|
||||||
and run
|
and run
|
||||||
|
|
||||||
@ -84,6 +82,39 @@ If you want to clean the tables and import in one task:
|
|||||||
|
|
||||||
rake wordpress:reset_and_import_pages[file_name]
|
rake wordpress:reset_and_import_pages[file_name]
|
||||||
|
|
||||||
|
Finally, if you want to reset and import all data including media (see below):
|
||||||
|
|
||||||
|
rake wordpress:full_import[file_name]
|
||||||
|
|
||||||
|
|
||||||
|
== Importing media files
|
||||||
|
|
||||||
|
The WP XML dump contains absolute links to media files linked inside posts, like:
|
||||||
|
|
||||||
|
www.mysite.com/wordpress/wp-content/uploads/2011/05/cv.txt
|
||||||
|
|
||||||
|
The dump does NOT contain the files itself! To get them imported, this gem downloads the files
|
||||||
|
from the given URL and imports them to refinery. So for a working media import the old site with
|
||||||
|
the media URLs must still be online.
|
||||||
|
|
||||||
|
After importing the files, this gem replaces the old links in pages and blog posts with the
|
||||||
|
new generated ones. It parses all existing records searching for the right pattern. That
|
||||||
|
means, you have to import pages and posts FIRST to get the URLs replaced.
|
||||||
|
|
||||||
|
Now to the rake tasks for media import:
|
||||||
|
|
||||||
|
rake wordpress:reset_media
|
||||||
|
|
||||||
|
This task deletes all data from the media tables (images and resources), ensuring a clean import.
|
||||||
|
|
||||||
|
rake wordpress:import_and_replace_media[file_name]
|
||||||
|
|
||||||
|
This task imports all the WordPress media into Refinery. After the import it parses all
|
||||||
|
pages and blog posts, replacing the legacy links with the current refinery ones.
|
||||||
|
|
||||||
|
If you want to clean the tables and import in one task:
|
||||||
|
|
||||||
|
rake wordpress:reset_import_and_replace_media[file_name]
|
||||||
|
|
||||||
== Usage on ZSH
|
== Usage on ZSH
|
||||||
|
|
||||||
|
16
Rakefile
16
Rakefile
@ -7,7 +7,7 @@ rescue LoadError
|
|||||||
end
|
end
|
||||||
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'rdoc/task'
|
#require 'rdoc/task'
|
||||||
|
|
||||||
require 'rspec/core'
|
require 'rspec/core'
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
@ -16,10 +16,10 @@ RSpec::Core::RakeTask.new(:spec)
|
|||||||
|
|
||||||
task :default => :spec
|
task :default => :spec
|
||||||
|
|
||||||
Rake::RDocTask.new(:rdoc) do |rdoc|
|
#RDoc::Task.new(:rdoc) do |rdoc|
|
||||||
rdoc.rdoc_dir = 'rdoc'
|
#rdoc.rdoc_dir = 'rdoc'
|
||||||
rdoc.title = 'Refinerycms-wordpress-import'
|
#rdoc.title = 'Refinerycms-wordpress-import'
|
||||||
rdoc.options << '--line-numbers' << '--inline-source'
|
#rdoc.options << '--line-numbers' << '--inline-source'
|
||||||
rdoc.rdoc_files.include('README.rdoc')
|
#rdoc.rdoc_files.include('README.rdoc')
|
||||||
rdoc.rdoc_files.include('lib/**/*.rb')
|
#rdoc.rdoc_files.include('lib/**/*.rb')
|
||||||
end
|
#end
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
module Refinery
|
|
||||||
module WordPress
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'wordpress'
|
|
@ -5,77 +5,183 @@ namespace :wordpress do
|
|||||||
task :reset_blog do
|
task :reset_blog do
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
|
|
||||||
%w(taggings tags blog_comments blog_categories blog_categories_blog_posts
|
%w(posts post_translations taggings tags).each do |table_name|
|
||||||
blog_posts).each do |table_name|
|
|
||||||
p "Truncating #{table_name} ..."
|
p "Truncating #{table_name} ..."
|
||||||
ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
|
ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "import blog data from a Refinery::WordPress XML dump"
|
desc "import blog data from a WordPressImport XML dump"
|
||||||
task :import_blog, :file_name do |task, params|
|
task :import_blog, :file_name, :blog_slug do |task, params|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
dump = Refinery::WordPress::Dump.new(params[:file_name])
|
p "Loading XML from #{params[:file_name]} (using blog #{params[:blog_slug]}) ..."
|
||||||
|
dump = WordPressImport::Dump.new(params[:file_name])
|
||||||
|
|
||||||
dump.authors.each(&:to_refinery)
|
p "Importing #{dump.authors.count} authors ..."
|
||||||
|
dump.authors.each(&:to_rails)
|
||||||
|
|
||||||
|
# by default, import all; unless $ONLY_PUBLISHED = "true"
|
||||||
only_published = ENV['ONLY_PUBLISHED'] == 'true' ? true : false
|
only_published = ENV['ONLY_PUBLISHED'] == 'true' ? true : false
|
||||||
dump.posts(only_published).each(&:to_refinery)
|
p "Importing #{dump.posts(only_published).count} posts ..."
|
||||||
|
|
||||||
Refinery::WordPress::Post.create_blog_page_if_necessary
|
if only_published
|
||||||
|
p "(only published posts)"
|
||||||
ENV["MODEL"] = 'BlogPost'
|
else
|
||||||
Rake::Task["friendly_id:redo_slugs"].invoke
|
p "(export ONLY_PUBLISHED=true to import only published posts)"
|
||||||
ENV.delete("MODEL")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "reset blog tables and then import blog data from a Refinery::WordPress XML dump"
|
dump.posts(only_published).each{|p| p.to_rails(params[:blog_slug]) }
|
||||||
task :reset_and_import_blog, :file_name do |task, params|
|
end
|
||||||
|
|
||||||
|
desc "reset blog tables and then import blog data from a WordPressImport XML dump"
|
||||||
|
task :reset_and_import_blog, :file_name, :blog_slug do |task, params|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
Rake::Task["wordpress:reset_blog"].invoke
|
Rake::Task["wordpress:reset_blog"].invoke
|
||||||
Rake::Task["wordpress:import_blog"].invoke(params[:file_name])
|
Rake::Task["wordpress:import_blog"].invoke(params[:file_name], params[:blog_slug])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
desc "Reset the cms relevant tables for a clean import"
|
desc "download images in posts to public folder"
|
||||||
task :reset_pages do
|
task :download_post_images, :host_match do |task, params|
|
||||||
|
raise "Error: you must specify a host to match for this download (i.e. rake wordpress:download_post_images['mywebsite']" if params[:host_match].blank?
|
||||||
|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
|
|
||||||
%w(page_part_translations page_translations page_parts pages).each do |table_name|
|
# scrape images
|
||||||
|
@posts = ::Post.all
|
||||||
|
@posts.each do |post|
|
||||||
|
doc = Nokogiri::HTML(post.body)
|
||||||
|
doc.css("img").each do |img|
|
||||||
|
# find remote file path
|
||||||
|
remote_file = img.attributes["src"].text
|
||||||
|
# load uri
|
||||||
|
begin
|
||||||
|
remote_uri = URI(remote_file)
|
||||||
|
rescue => error
|
||||||
|
puts "Error parsing URL #{remote_file}: #{error.message}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# only download if the image is a LFA-hosted image
|
||||||
|
if remote_uri && remote_uri.host.match(params[:host_match]) != nil
|
||||||
|
# find a local path for it
|
||||||
|
local_file = File.expand_path(File.join(Rails.public_path,remote_uri.path))
|
||||||
|
# only download if not already there or if it's zero bytes
|
||||||
|
unless File.size?(local_file)
|
||||||
|
# create local folders if necessary
|
||||||
|
dirname = File.dirname(local_file)
|
||||||
|
unless File.directory?(dirname)
|
||||||
|
FileUtils.mkdir_p(dirname)
|
||||||
|
end
|
||||||
|
# save remote file to local
|
||||||
|
begin
|
||||||
|
remote_file_io = open(remote_file)
|
||||||
|
File.open(local_file,'wb'){ |f| f.write(remote_file_io.read) }
|
||||||
|
puts "Saved file: #{local_file}"
|
||||||
|
rescue OpenURI::HTTPError => error
|
||||||
|
puts "Error saving file #{remote_file}: #{error.message}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
puts "Finished downloding images from #{@posts.count} posts"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
# desc "Reset the cms relevant tables for a clean import"
|
||||||
|
# task :reset_pages do
|
||||||
|
# Rake::Task["environment"].invoke
|
||||||
|
|
||||||
|
# %w(page_part_translations page_translations page_parts pages).each do |table_name|
|
||||||
|
# p "Truncating #{table_name} ..."
|
||||||
|
# ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
# desc "import cms data from a WordPress XML dump"
|
||||||
|
# task :import_pages, :file_name do |task, params|
|
||||||
|
# Rake::Task["environment"].invoke
|
||||||
|
# dump = WordPressImport::Dump.new(params[:file_name])
|
||||||
|
|
||||||
|
# only_published = ENV['ONLY_PUBLISHED'] == 'true' ? true : false
|
||||||
|
# dump.pages(only_published).each(&:to_rails)
|
||||||
|
|
||||||
|
# # After all pages are persisted we can now create the parent - child
|
||||||
|
# # relationships. This is necessary, as WordPress doesn't dump the pages in
|
||||||
|
# # a correct order.
|
||||||
|
# dump.pages(only_published).each do |dump_page|
|
||||||
|
# page = ::Page.find(dump_page.post_id)
|
||||||
|
# page.parent_id = dump_page.parent_id
|
||||||
|
# page.save!
|
||||||
|
# end
|
||||||
|
|
||||||
|
# WordPressImport::Post.create_blog_page_if_necessary
|
||||||
|
|
||||||
|
# ENV["MODEL"] = 'Page'
|
||||||
|
# Rake::Task["friendly_id:redo_slugs"].invoke
|
||||||
|
# ENV.delete("MODEL")
|
||||||
|
# end
|
||||||
|
|
||||||
|
# desc "reset cms tables and then import cms data from a WordPress XML dump"
|
||||||
|
# task :reset_and_import_pages, :file_name do |task, params|
|
||||||
|
# Rake::Task["environment"].invoke
|
||||||
|
# Rake::Task["wordpress:reset_pages"].invoke
|
||||||
|
# Rake::Task["wordpress:import_pages"].invoke(params[:file_name])
|
||||||
|
# end
|
||||||
|
|
||||||
|
|
||||||
|
desc "Reset the media relevant tables for a clean import"
|
||||||
|
task :reset_media do
|
||||||
|
Rake::Task["environment"].invoke
|
||||||
|
|
||||||
|
%w(rich_rich_files).each do |table_name|
|
||||||
p "Truncating #{table_name} ..."
|
p "Truncating #{table_name} ..."
|
||||||
ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
|
ActiveRecord::Base.connection.execute "DELETE FROM #{table_name}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "import cms data from a Refinery::WordPress XML dump"
|
desc "import media data (images and files) from a WordPress XML dump and replace target URLs in pages and posts"
|
||||||
task :import_pages, :file_name do |task, params|
|
task :import_and_replace_media, :file_name do |task, params|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
dump = Refinery::WordPress::Dump.new(params[:file_name])
|
dump = WordPressImport::Dump.new(params[:file_name])
|
||||||
|
|
||||||
only_published = ENV['ONLY_PUBLISHED'] == 'true' ? true : false
|
p "Importing #{dump.attachments.each_slice(200).first.count} attachments ..."
|
||||||
dump.pages(only_published).each(&:to_refinery)
|
attachments = dump.attachments.each_slice(200).first.each(&:to_rails)
|
||||||
|
unless $ATTACHMENT_EXCEPTIONS.blank?
|
||||||
# After all pages are persisted we can now create the parent - child
|
p "----------------------------------------------------------"
|
||||||
# relationships. This is necessary, as WordPress doesn't dump the pages in
|
p "ERRORS WERE ENCOUNTERED IMPORTING ATTACHMENTS:"
|
||||||
# a correct order.
|
$ATTACHMENT_EXCEPTIONS.each{|exception| puts exception}
|
||||||
dump.pages(only_published).each do |dump_page|
|
p "----------------------------------------------------------"
|
||||||
page = ::Page.find(dump_page.post_id)
|
|
||||||
page.parent_id = dump_page.parent_id
|
|
||||||
page.save!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Refinery::WordPress::Post.create_blog_page_if_necessary
|
# parse all created Post and Page bodys and replace the old wordpress media urls
|
||||||
|
# with the newly created ones
|
||||||
|
p "Replacing attachment URLs found in posts/pages ..."
|
||||||
|
attachments.each(&:replace_url)
|
||||||
|
|
||||||
ENV["MODEL"] = 'Page'
|
unless $REPLACEMENT_EXCEPTIONS.blank?
|
||||||
Rake::Task["friendly_id:redo_slugs"].invoke
|
p "----------------------------------------------------------"
|
||||||
ENV.delete("MODEL")
|
p "ERRORS WERE ENCOUNTERED REPLACING ATTACHMENTS:"
|
||||||
|
$REPLACEMENT_EXCEPTIONS.each{|exception| puts exception}
|
||||||
|
p "----------------------------------------------------------"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "reset cms tables and then import cms data from a Refinery::WordPress XML dump"
|
desc "reset media tables and then import media data from a WordPress XML dump"
|
||||||
task :reset_and_import_pages, :file_name do |task, params|
|
task :reset_import_and_replace_media, :file_name do |task, params|
|
||||||
Rake::Task["environment"].invoke
|
Rake::Task["environment"].invoke
|
||||||
Rake::Task["wordpress:reset_pages"].invoke
|
Rake::Task["wordpress:reset_media"].invoke
|
||||||
Rake::Task["wordpress:import_pages"].invoke(params[:file_name])
|
Rake::Task["wordpress:import_and_replace_media"].invoke(params[:file_name])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "reset and import all data (see the other tasks)"
|
||||||
|
task :full_import, :file_name, :blog_slug do |task, params|
|
||||||
|
Rake::Task["environment"].invoke
|
||||||
|
Rake::Task["wordpress:reset_and_import_blog"].invoke(params[:file_name],params[:blog_slug])
|
||||||
|
#Rake::Task["wordpress:reset_and_import_pages"].invoke(params[:file_name])
|
||||||
|
#Rake::Task["wordpress:reset_import_and_replace_media"].invoke(params[:file_name])
|
||||||
|
Rake::Task["wordpress:import_and_replace_media"].invoke(params[:file_name])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
5
lib/wordpress-import.rb
Normal file
5
lib/wordpress-import.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module WordPressImport
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'wordpress'
|
@ -1,15 +1,15 @@
|
|||||||
module Refinery
|
|
||||||
module WordPress
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
require 'wordpress/author'
|
|
||||||
require 'wordpress/tag'
|
|
||||||
require 'wordpress/category'
|
|
||||||
require 'wordpress/page'
|
|
||||||
require 'wordpress/post'
|
|
||||||
require 'wordpress/comment'
|
|
||||||
require 'wordpress/dump'
|
|
||||||
|
|
||||||
require "wordpress/railtie"
|
require "wordpress/railtie"
|
||||||
|
require 'shortcode'
|
||||||
|
|
||||||
|
module WordPressImport
|
||||||
|
autoload :Author, 'wordpress/author'
|
||||||
|
autoload :Tag, 'wordpress/tag'
|
||||||
|
autoload :Category, 'wordpress/category'
|
||||||
|
autoload :Page, 'wordpress/page'
|
||||||
|
autoload :Post, 'wordpress/post'
|
||||||
|
autoload :Comment, 'wordpress/comment'
|
||||||
|
autoload :Dump, 'wordpress/dump'
|
||||||
|
autoload :Attachment, 'wordpress/attachment'
|
||||||
|
end
|
||||||
|
|
||||||
|
179
lib/wordpress/attachment.rb
Normal file
179
lib/wordpress/attachment.rb
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
module WordPressImport
|
||||||
|
class Attachment
|
||||||
|
attr_reader :node
|
||||||
|
attr_reader :paperclip_image
|
||||||
|
attr_reader :paperclip_file
|
||||||
|
|
||||||
|
def initialize(node)
|
||||||
|
@node = node
|
||||||
|
end
|
||||||
|
|
||||||
|
def title
|
||||||
|
node.xpath("title").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def description
|
||||||
|
node.xpath("description").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_name
|
||||||
|
url.split('/').last
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_date
|
||||||
|
DateTime.parse node.xpath("wp:post_date").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def url
|
||||||
|
node.xpath("wp:attachment_url").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def url_pattern
|
||||||
|
url_parts = url.split('.')
|
||||||
|
extension = url_parts.pop
|
||||||
|
url_without_extension = url_parts.join('.')
|
||||||
|
|
||||||
|
/#{url_without_extension}(-\d+x\d+)?\.#{extension}/
|
||||||
|
end
|
||||||
|
|
||||||
|
def image?
|
||||||
|
url.match /\.(png|jpg|jpeg|gif)$/
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_rails
|
||||||
|
begin
|
||||||
|
if image?
|
||||||
|
to_image
|
||||||
|
else
|
||||||
|
to_file
|
||||||
|
end
|
||||||
|
rescue StandardError => ex
|
||||||
|
message = "ERROR saving attachment #{url} -- #{ex.message}"
|
||||||
|
p message
|
||||||
|
$ATTACHMENT_EXCEPTIONS = [] if $ATTACHMENT_EXCEPTIONS.blank?
|
||||||
|
$ATTACHMENT_EXCEPTIONS << message
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_url
|
||||||
|
begin
|
||||||
|
@occurrance_count = 0
|
||||||
|
if image?
|
||||||
|
replace_image_url
|
||||||
|
else
|
||||||
|
replace_resource_url
|
||||||
|
end
|
||||||
|
p "Replaced #{@occurrance_count} occurrances of #{url}"
|
||||||
|
rescue StandardError => ex
|
||||||
|
message = "ERROR replacing URL #{url} -- #{ex.message}"
|
||||||
|
p message
|
||||||
|
$REPLACEMENT_EXCEPTIONS = [] if $REPLACEMENT_EXCEPTIONS.blank?
|
||||||
|
$REPLACEMENT_EXCEPTIONS << message
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def rich_file_clean_file_name(full_file_name)
|
||||||
|
extension = File.extname(full_file_name).gsub(/^\.+/, '')
|
||||||
|
filename = full_file_name.gsub(/\.#{extension}$/, '')
|
||||||
|
|
||||||
|
filename = CGI::unescape(filename)
|
||||||
|
filename = CGI::unescape(filename)
|
||||||
|
|
||||||
|
extension = extension.downcase
|
||||||
|
filename = filename.downcase.gsub(/[^a-z0-9]+/i, '-')
|
||||||
|
|
||||||
|
"#{filename}.#{extension}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_image
|
||||||
|
# avoid duplicates; use our storage system's filename cleaner for lookup
|
||||||
|
image = ::Rich::RichFile.find_or_initialize_by(rich_file_file_name: rich_file_clean_file_name(file_name))
|
||||||
|
|
||||||
|
if image.rich_file.instance.id.blank?
|
||||||
|
p "Importing image #{file_name}"
|
||||||
|
image.simplified_type = "image"
|
||||||
|
image.created_at = post_date
|
||||||
|
image.rich_file = URI.parse(url)
|
||||||
|
image.save!
|
||||||
|
else
|
||||||
|
p "image #{file_name} already exists..."
|
||||||
|
end
|
||||||
|
|
||||||
|
@paperclip_image = image
|
||||||
|
image
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_file
|
||||||
|
# avoid duplicates; use our storage system's filename cleaner for lookup
|
||||||
|
file = ::Rich::RichFile.find_or_initialize_by(rich_file_file_name: rich_file_clean_file_name(file_name))
|
||||||
|
|
||||||
|
if file.rich_file.instance.id.blank?
|
||||||
|
p "Importing file #{file_name}"
|
||||||
|
file.created_at = post_date
|
||||||
|
file.rich_file = URI.parse(url) if file.rich_file.blank?
|
||||||
|
file.save!
|
||||||
|
else
|
||||||
|
p "file #{file_name} already exists..."
|
||||||
|
end
|
||||||
|
|
||||||
|
@paperclip_file = file
|
||||||
|
file
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def replace_image_url
|
||||||
|
replace_image_url_in_blog_posts
|
||||||
|
replace_image_url_in_pages
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_resource_url
|
||||||
|
replace_resource_url_in_blog_posts
|
||||||
|
replace_resource_url_in_pages
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_image_url_in_blog_posts
|
||||||
|
replace_url_in_blog_posts(paperclip_image.rich_file.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_image_url_in_pages
|
||||||
|
replace_url_in_pages(paperclip_image.rich_file.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_resource_url_in_blog_posts
|
||||||
|
replace_url_in_blog_posts(paperclip_file.rich_file.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_resource_url_in_pages
|
||||||
|
replace_url_in_pages(paperclip_file.rich_file.url)
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_url_in_blog_posts(new_url)
|
||||||
|
::Post.all.each do |post|
|
||||||
|
if (! post.body.empty?) && post.body.include?(url)
|
||||||
|
@occurrance_count += 1
|
||||||
|
post.body = post.body.gsub(url_pattern, new_url)
|
||||||
|
post.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def replace_url_in_pages(new_url)
|
||||||
|
::Page.all.each do |page|
|
||||||
|
page.translations.each do |translation|
|
||||||
|
translation.parts.each do |part|
|
||||||
|
if (! part.content.to_s.blank?) && part.content.include?(url)
|
||||||
|
@occurrance_count += 1
|
||||||
|
part.content = part.content.gsub(url_pattern, new_url)
|
||||||
|
part.save!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Author
|
class Author
|
||||||
attr_reader :author_node
|
attr_reader :author_node
|
||||||
|
|
||||||
@ -7,6 +6,12 @@ module Refinery
|
|||||||
@author_node = author_node
|
@author_node = author_node
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name
|
||||||
|
name = author_node.xpath("wp:author_display_name").text
|
||||||
|
name = author_node.xpath("wp:author_first_name").text + " " + author_node.xpath("wp:author_first_name").text if name.blank?
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
def login
|
def login
|
||||||
author_node.xpath("wp:author_login").text
|
author_node.xpath("wp:author_login").text
|
||||||
end
|
end
|
||||||
@ -23,15 +28,20 @@ module Refinery
|
|||||||
"WordPress::Author: #{login} <#{email}>"
|
"WordPress::Author: #{login} <#{email}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_refinery
|
def to_rails
|
||||||
user = User.find_or_initialize_by_username_and_email(login, email)
|
user = ::User.find_or_initialize_by_email(email)
|
||||||
|
user.wp_username = login
|
||||||
|
|
||||||
unless user.persisted?
|
unless user.persisted?
|
||||||
|
user.name = name
|
||||||
user.password = 'password'
|
user.password = 'password'
|
||||||
user.password_confirmation = 'password'
|
user.password_confirmation = 'password'
|
||||||
user.save
|
|
||||||
end
|
end
|
||||||
|
user.save
|
||||||
|
|
||||||
|
puts "User #{login} imported."
|
||||||
|
|
||||||
user
|
user
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Category
|
class Category
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
@ -11,9 +10,8 @@ module Refinery
|
|||||||
name == other.name
|
name == other.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_refinery
|
def to_rails
|
||||||
BlogCategory.find_or_create_by_title(name)
|
Tag.find_or_create_by_title(name)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Comment
|
class Comment
|
||||||
attr_reader :node
|
attr_reader :node
|
||||||
|
|
||||||
@ -45,4 +44,3 @@ module Refinery
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Dump
|
class Dump
|
||||||
attr_reader :doc
|
attr_reader :doc
|
||||||
|
|
||||||
def initialize(file_name)
|
def initialize(file_name)
|
||||||
file_name = File.absolute_path(file_name)
|
begin
|
||||||
|
file_name = File.expand_path(file_name)
|
||||||
raise "Given file '#{file_name}' no file or not readable." \
|
raise "error" unless File.file?(file_name) && File.readable?(file_name)
|
||||||
unless File.file?(file_name) && File.readable?(file_name)
|
rescue
|
||||||
|
raise "Given file '#{file_name}' is not a file or not readable. Rake tasks take filename arguments like this: rake wordpress:full_import['/path/to/my_file']"
|
||||||
|
end
|
||||||
|
|
||||||
file = File.open(file_name)
|
file = File.open(file_name)
|
||||||
@doc = Nokogiri::XML(file)
|
|
||||||
|
if file.size >= 10485760 # 10MB
|
||||||
|
puts "WARNING: LibXML by default supports 10MB max file size. On some systems your file will be silently truncated; on others, an error will be raised. Consider splitting your file into smaller chunks and running rake tasks individually (authors, then blog/pages, then media), and double-check the import results."
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc = Nokogiri::XML(file.read().gsub("\u0004", "")) # get rid of all EOT characters
|
||||||
end
|
end
|
||||||
|
|
||||||
def authors
|
def authors
|
||||||
@ -47,6 +53,11 @@ module Refinery
|
|||||||
Category.new(category.text)
|
Category.new(category.text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def attachments
|
||||||
|
doc.xpath("//item[wp:post_type = 'attachment']").collect do |attachment|
|
||||||
|
Attachment.new(attachment)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Page
|
class Page
|
||||||
include ::ActionView::Helpers::TagHelper
|
include ::ActionView::Helpers::TagHelper
|
||||||
include ::ActionView::Helpers::TextHelper
|
include ::ActionView::Helpers::TextHelper
|
||||||
@ -14,6 +13,10 @@ module Refinery
|
|||||||
"WordPress::Page(#{post_id}): #{title}"
|
"WordPress::Page(#{post_id}): #{title}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def link
|
||||||
|
node.xpath("link").text
|
||||||
|
end
|
||||||
|
|
||||||
def title
|
def title
|
||||||
node.xpath("title").text
|
node.xpath("title").text
|
||||||
end
|
end
|
||||||
@ -23,7 +26,7 @@ module Refinery
|
|||||||
end
|
end
|
||||||
|
|
||||||
def content_formatted
|
def content_formatted
|
||||||
formatted = format_syntax_highlighter(format_paragraphs(content))
|
formatted = format_shortcodes(format_syntax_highlighter(format_paragraphs(content)))
|
||||||
|
|
||||||
# remove all tags inside <pre> that simple_format created
|
# remove all tags inside <pre> that simple_format created
|
||||||
# TODO: replace format_paragraphs with a method, that ignores pre-tags
|
# TODO: replace format_paragraphs with a method, that ignores pre-tags
|
||||||
@ -39,7 +42,15 @@ module Refinery
|
|||||||
end
|
end
|
||||||
|
|
||||||
def post_date
|
def post_date
|
||||||
DateTime.parse node.xpath("wp:post_date").text
|
Time.parse node.xpath("wp:post_date").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def publish_date
|
||||||
|
Time.parse node.xpath("pubDate").text
|
||||||
|
end
|
||||||
|
|
||||||
|
def post_name
|
||||||
|
node.xpath("wp:post_name").text
|
||||||
end
|
end
|
||||||
|
|
||||||
def post_id
|
def post_id
|
||||||
@ -67,12 +78,20 @@ module Refinery
|
|||||||
post_id == other.post_id
|
post_id == other.post_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_refinery
|
#NEED:
|
||||||
page = ::Page.create!(:id => post_id, :title => title,
|
# creator -> "user_id"
|
||||||
:created_at => post_date, :draft => draft?)
|
# wp:post_name -> "slug"
|
||||||
|
# pubDate -> "published_at"
|
||||||
|
#OK:
|
||||||
|
# title -> "title"
|
||||||
|
# content:encoded -> "body"
|
||||||
|
# wp:post_date_gmt -> "created_at"
|
||||||
|
|
||||||
page.parts.create(:title => 'Body', :body => content_formatted)
|
def to_rails
|
||||||
page
|
# :user_id => creator
|
||||||
|
page = ::Page.create!(:id => post_id, :title => title,
|
||||||
|
:created_at => post_date, :slug => post_name,
|
||||||
|
:published_at => publish_date, :body => content_formatted)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -84,8 +103,8 @@ module Refinery
|
|||||||
text = ''.html_safe if text.nil?
|
text = ''.html_safe if text.nil?
|
||||||
start_tag = tag('p', html_options, true)
|
start_tag = tag('p', html_options, true)
|
||||||
|
|
||||||
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
|
text.gsub!(/\n\n+/, "</p>#{start_tag}") # 2+ newline -> paragraph
|
||||||
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
|
text.gsub!(/\r?\n/, "<br/>\n") # \r\n and \n -> line break (must be after the paragraph detection to avoid <br/><br/>)
|
||||||
text.insert 0, start_tag
|
text.insert 0, start_tag
|
||||||
|
|
||||||
text.html_safe.safe_concat("</p>")
|
text.html_safe.safe_concat("</p>")
|
||||||
@ -102,6 +121,24 @@ module Refinery
|
|||||||
# -> <pre class="brush: ruby">p "Hello world"</pre>
|
# -> <pre class="brush: ruby">p "Hello world"</pre>
|
||||||
text.gsub(/\[(\w+)\](.+?)\[\/\1\]/m, '<pre class="brush: \1">\2</pre>')
|
text.gsub(/\[(\w+)\](.+?)\[\/\1\]/m, '<pre class="brush: \1">\2</pre>')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Replace Wordpress shortcodes with formatted HTML (see shortcode gem and support/templates folder)
|
||||||
|
def format_shortcodes(text)
|
||||||
|
Shortcode.setup do |config|
|
||||||
|
# the template parser to use
|
||||||
|
config.template_parser = :haml # :erb or :haml supported, :haml is default
|
||||||
|
|
||||||
|
# location of the template files
|
||||||
|
config.template_path = ::File.join(::File.dirname(__FILE__), "..", "..","support/templates/haml")
|
||||||
|
|
||||||
|
# a list of block tags to support e.g. [quote]Hello World[/quote]
|
||||||
|
config.block_tags = [:caption, :column]
|
||||||
|
|
||||||
|
# a list of self closing tags to support e.g. [youtube id="12345"]
|
||||||
|
config.self_closing_tags = [:end_columns, "google-map-v3"]
|
||||||
|
end
|
||||||
|
|
||||||
|
Shortcode.process(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Post < Page
|
class Post < Page
|
||||||
def tags
|
def tags
|
||||||
# xml dump has "post_tag" for wordpress 3.1 and "tag" for 3.0
|
# xml dump has "post_tag" for wordpress 3.1 and "tag" for 3.0
|
||||||
@ -30,56 +29,39 @@ module Refinery
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_refinery
|
# blog_slug is used to identify which blog this import is from
|
||||||
user = ::User.find_by_username(creator) || ::User.first
|
def to_rails(blog_slug)
|
||||||
raise "Referenced User doesn't exist! Make sure the authors are imported first." \
|
|
||||||
unless user
|
|
||||||
|
|
||||||
begin
|
user = ::User.find_by_wp_username(creator)
|
||||||
post = ::BlogPost.new :title => title, :body => content_formatted,
|
|
||||||
:draft => draft?, :published_at => post_date, :created_at => post_date,
|
|
||||||
:author => user, :tag_list => tag_list
|
|
||||||
post.save!
|
|
||||||
|
|
||||||
::BlogPost.transaction do
|
if user.nil?
|
||||||
categories.each do |category|
|
raise "User with wp_username #{creator} not found"
|
||||||
post.categories << category.to_refinery
|
|
||||||
end
|
end
|
||||||
|
|
||||||
comments.each do |comment|
|
post = ::Post.create({
|
||||||
comment = comment.to_refinery
|
:wp_post_id => post_id, :slug => post_name,
|
||||||
comment.post = post
|
:user_id => user.id, :title => title,
|
||||||
comment.save
|
:created_at => post_date,
|
||||||
end
|
:published_at => publish_date,
|
||||||
end
|
:wp_link => link,
|
||||||
rescue ActiveRecord::RecordInvalid
|
:wp_blog => blog_slug,
|
||||||
# if the title has already been taken (WP allows duplicates here,
|
:translations_attributes => { "0" => {
|
||||||
# refinery doesn't) append the post_id to it, making it unique
|
:locale => "en",
|
||||||
post.title = "#{title}-#{post_id}"
|
:title => title,
|
||||||
post.save
|
:body => content_formatted,
|
||||||
end
|
# merge the translation's category list with the wordpress post's
|
||||||
|
:category_list => categories.collect(&:name) | tags.collect(&:name)
|
||||||
|
}}
|
||||||
|
})
|
||||||
|
|
||||||
post
|
if post.errors.blank?
|
||||||
end
|
puts "Post #{post_name} imported."
|
||||||
|
return post.reload
|
||||||
def self.create_blog_page_if_necessary
|
else
|
||||||
# refinerycms wants a page at /blog, so let's make sure there is one
|
puts post.inspect
|
||||||
# taken from the original db seeds from refinery-blog
|
raise post.errors.full_messages.to_s
|
||||||
unless ::Page.where("link_url = ?", '/blog').exists?
|
|
||||||
page = ::Page.create(
|
|
||||||
:title => "Blog",
|
|
||||||
:link_url => "/blog",
|
|
||||||
:deletable => false,
|
|
||||||
:position => ((::Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
|
|
||||||
:menu_match => "^/blogs?(\/|\/.+?|)$"
|
|
||||||
)
|
|
||||||
|
|
||||||
::Page.default_parts.each do |default_page_part|
|
|
||||||
page.parts.create(:title => default_page_part, :body => nil)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Railtie < Rails::Railtie
|
class Railtie < Rails::Railtie
|
||||||
rake_tasks do
|
rake_tasks do
|
||||||
load "tasks/wordpress.rake"
|
load "tasks/wordpress.rake"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
module Refinery
|
module WordPressImport
|
||||||
module WordPress
|
|
||||||
class Tag
|
class Tag
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
|
|
||||||
@ -17,4 +16,3 @@ module Refinery
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
# Provide a simple gemspec so you can easily use your enginex
|
|
||||||
# project in your rails apps through git.
|
|
||||||
Gem::Specification.new do |s|
|
|
||||||
s.name = "refinerycms-wordpress-import"
|
|
||||||
s.summary = "Import WordPress XML dumps into refinerycms(-blog)."
|
|
||||||
s.description = "This gem imports a WordPress XML dump into refinerycms (Page, User) and refinerycms-blog (BlogPost, BlogCategory, Tag, BlogComment)"
|
|
||||||
s.version = "0.2.0"
|
|
||||||
s.date = "2011-06-05"
|
|
||||||
|
|
||||||
s.authors = ['Marc Remolt']
|
|
||||||
s.email = 'marc.remolt@googlemail.com'
|
|
||||||
s.homepage = 'https://github.com/mremolt/refinerycms-wordpress-import'
|
|
||||||
|
|
||||||
s.add_dependency 'bundler', '~> 1.0'
|
|
||||||
s.add_dependency 'refinerycms', '~> 1.0.0'
|
|
||||||
s.add_dependency 'refinerycms-blog', '~> 1.5.2'
|
|
||||||
s.add_dependency 'nokogiri', '~> 1.4.4'
|
|
||||||
|
|
||||||
s.add_development_dependency 'rspec-rails'
|
|
||||||
s.add_development_dependency 'database_cleaner'
|
|
||||||
|
|
||||||
s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
|
||||||
end
|
|
@ -1,6 +1,3 @@
|
|||||||
require 'yaml'
|
|
||||||
YAML::ENGINE.yamler= 'syck'
|
|
||||||
|
|
||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
||||||
|
|
||||||
|
@ -24,4 +24,6 @@ Dummy::Application.configure do
|
|||||||
config.action_dispatch.best_standards_support = :builtin
|
config.action_dispatch.best_standards_support = :builtin
|
||||||
end
|
end
|
||||||
|
|
||||||
Refinery.rescue_not_found = false
|
Refinery.rescue_not_found = false# When true will use Amazon's Simple Storage Service on your production machine
|
||||||
|
# instead of the default file system for resources and images
|
||||||
|
Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?)
|
||||||
|
@ -47,4 +47,6 @@ Dummy::Application.configure do
|
|||||||
# Send deprecation notices to registered listeners
|
# Send deprecation notices to registered listeners
|
||||||
config.active_support.deprecation = :notify
|
config.active_support.deprecation = :notify
|
||||||
end
|
end
|
||||||
Refinery.rescue_not_found = true
|
Refinery.rescue_not_found = true# When true will use Amazon's Simple Storage Service on your production machine
|
||||||
|
# instead of the default file system for resources and images
|
||||||
|
Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?)
|
||||||
|
@ -33,4 +33,6 @@ Dummy::Application.configure do
|
|||||||
# Print deprecation notices to the stderr
|
# Print deprecation notices to the stderr
|
||||||
config.active_support.deprecation = :stderr
|
config.active_support.deprecation = :stderr
|
||||||
end
|
end
|
||||||
Refinery.rescue_not_found = false
|
Refinery.rescue_not_found = false# When true will use Amazon's Simple Storage Service on your production machine
|
||||||
|
# instead of the default file system for resources and images
|
||||||
|
Refinery.s3_backend = !(ENV['S3_KEY'].nil? || ENV['S3_SECRET'].nil?)
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
class CreateSeoMetaForBlog < ActiveRecord::Migration
|
||||||
|
|
||||||
|
def self.up
|
||||||
|
unless ::SeoMetum.table_exists?
|
||||||
|
create_table ::SeoMetum.table_name do |t|
|
||||||
|
t.integer :seo_meta_id
|
||||||
|
t.string :seo_meta_type
|
||||||
|
|
||||||
|
t.string :browser_title
|
||||||
|
t.string :meta_keywords
|
||||||
|
t.text :meta_description
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index ::SeoMetum.table_name, :id
|
||||||
|
add_index ::SeoMetum.table_name, [:seo_meta_id, :seo_meta_type]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
# can't drop the table because someone else might be using it.
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
11
spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb
Normal file
11
spec/dummy/db/migrate/20110812162202_add_cached_slugs.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class AddCachedSlugs < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :blog_categories, :cached_slug, :string
|
||||||
|
add_column :blog_posts, :cached_slug, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :blog_categories, :cached_slug
|
||||||
|
remove_column :blog_posts, :cached_slug
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
class AddCustomUrlFieldToBlogPosts < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :blog_posts, :custom_url, :string
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :blog_posts, :custom_url
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
class AddCustomTeaserFieldToBlogPosts < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
add_column :blog_posts, :custom_teaser, :text
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :blog_posts, :custom_teaser
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -10,12 +10,13 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20110602094445) do
|
ActiveRecord::Schema.define(:version => 20110812162204) do
|
||||||
|
|
||||||
create_table "blog_categories", :force => true do |t|
|
create_table "blog_categories", :force => true do |t|
|
||||||
t.string "title"
|
t.string "title"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
|
t.string "cached_slug"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "blog_categories", ["id"], :name => "index_blog_categories_on_id"
|
add_index "blog_categories", ["id"], :name => "index_blog_categories_on_id"
|
||||||
@ -48,6 +49,9 @@ ActiveRecord::Schema.define(:version => 20110602094445) do
|
|||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
|
t.string "cached_slug"
|
||||||
|
t.string "custom_url"
|
||||||
|
t.text "custom_teaser"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "blog_posts", ["id"], :name => "index_blog_posts_on_id"
|
add_index "blog_posts", ["id"], :name => "index_blog_posts_on_id"
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
::Page.reset_column_information
|
||||||
|
# Check whether all columns are applied yet by seo_meta.
|
||||||
|
unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
|
||||||
|
::Page.translation_class.instance_methods.include?(k)
|
||||||
|
}
|
||||||
|
# Make pages model seo_meta because not all columns are accessible.
|
||||||
|
::Page.translation_class.send :is_seo_meta
|
||||||
|
end
|
||||||
|
|
||||||
page_position = -1
|
page_position = -1
|
||||||
|
|
||||||
home_page = Page.create(:title => "Home",
|
home_page = Page.create(:title => "Home",
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
User.find(:all).each do |user|
|
::User.find(:all).each do |user|
|
||||||
|
if user.plugins.where(:name => 'refinerycms_blog').blank?
|
||||||
user.plugins.create(:name => "refinerycms_blog",
|
user.plugins.create(:name => "refinerycms_blog",
|
||||||
:position => (user.plugins.maximum(:position) || -1) +1)
|
:position => (user.plugins.maximum(:position) || -1) +1)
|
||||||
end
|
end
|
||||||
|
end if defined?(::User)
|
||||||
|
|
||||||
page = Page.create(
|
if defined?(::Page)
|
||||||
|
page = ::Page.create(
|
||||||
:title => "Blog",
|
:title => "Blog",
|
||||||
:link_url => "/blog",
|
:link_url => "/blog",
|
||||||
:deletable => false,
|
:deletable => false,
|
||||||
@ -11,6 +14,7 @@ page = Page.create(
|
|||||||
:menu_match => "^/blogs?(\/|\/.+?|)$"
|
:menu_match => "^/blogs?(\/|\/.+?|)$"
|
||||||
)
|
)
|
||||||
|
|
||||||
Page.default_parts.each do |default_page_part|
|
::Page.default_parts.each do |default_page_part|
|
||||||
page.parts.create(:title => default_page_part, :body => nil)
|
page.parts.create(:title => default_page_part, :body => nil)
|
||||||
end
|
end
|
||||||
|
end
|
BIN
spec/fixtures/200px-Tux.svg_.png
vendored
Normal file
BIN
spec/fixtures/200px-Tux.svg_.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
92
spec/fixtures/wordpress_dump.xml
vendored
92
spec/fixtures/wordpress_dump.xml
vendored
@ -16,7 +16,7 @@
|
|||||||
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
|
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
|
||||||
<!-- contained in this file into your site. -->
|
<!-- contained in this file into your site. -->
|
||||||
|
|
||||||
<!-- generator="WordPress/3.1.2" created="2011-05-21 12:27" -->
|
<!-- generator="WordPress/3.1.2" created="2011-06-06 18:42" -->
|
||||||
<rss version="2.0"
|
<rss version="2.0"
|
||||||
xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
|
xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
|
||||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||||
@ -29,7 +29,7 @@
|
|||||||
<title>My test blog</title>
|
<title>My test blog</title>
|
||||||
<link>http://localhost/wordpress</link>
|
<link>http://localhost/wordpress</link>
|
||||||
<description>Just another WordPress site</description>
|
<description>Just another WordPress site</description>
|
||||||
<pubDate>Sat, 21 May 2011 12:27:19 +0000</pubDate>
|
<pubDate>Mon, 06 Jun 2011 18:42:09 +0000</pubDate>
|
||||||
<language>en</language>
|
<language>en</language>
|
||||||
<wp:wxr_version>1.1</wp:wxr_version>
|
<wp:wxr_version>1.1</wp:wxr_version>
|
||||||
<wp:base_site_url>http://localhost/wordpress</wp:base_site_url>
|
<wp:base_site_url>http://localhost/wordpress</wp:base_site_url>
|
||||||
@ -69,6 +69,10 @@
|
|||||||
<wp:post_password></wp:post_password>
|
<wp:post_password></wp:post_password>
|
||||||
<wp:is_sticky>0</wp:is_sticky>
|
<wp:is_sticky>0</wp:is_sticky>
|
||||||
<category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
|
<category domain="category" nicename="uncategorized"><![CDATA[Uncategorized]]></category>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_edit_last</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
<wp:comment>
|
<wp:comment>
|
||||||
<wp:comment_id>1</wp:comment_id>
|
<wp:comment_id>1</wp:comment_id>
|
||||||
<wp:comment_author><![CDATA[Mr WordPress]]></wp:comment_author>
|
<wp:comment_author><![CDATA[Mr WordPress]]></wp:comment_author>
|
||||||
@ -92,13 +96,9 @@
|
|||||||
<guid isPermaLink="false">http://localhost/wordpress/?page_id=2</guid>
|
<guid isPermaLink="false">http://localhost/wordpress/?page_id=2</guid>
|
||||||
<description></description>
|
<description></description>
|
||||||
<content:encoded><![CDATA[This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
|
<content:encoded><![CDATA[This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
|
||||||
|
<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote>
|
||||||
<blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my blog. I live in Los Angeles, have a great dog named Jack, and I like piña coladas. (And gettin' caught in the rain.)</blockquote>
|
|
||||||
|
|
||||||
...or something like this:
|
...or something like this:
|
||||||
|
|
||||||
<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
|
<blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickies to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
|
||||||
|
|
||||||
As a new WordPress user, you should go to <a href="http://localhost/wordpress/wp-admin/">your dashboard</a> to delete this page and create new pages for your content. Have fun!]]></content:encoded>
|
As a new WordPress user, you should go to <a href="http://localhost/wordpress/wp-admin/">your dashboard</a> to delete this page and create new pages for your content. Have fun!]]></content:encoded>
|
||||||
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
||||||
<wp:post_id>2</wp:post_id>
|
<wp:post_id>2</wp:post_id>
|
||||||
@ -117,6 +117,10 @@ As a new WordPress user, you should go to <a href="http://localhost/wordpress/wp
|
|||||||
<wp:meta_key>_wp_page_template</wp:meta_key>
|
<wp:meta_key>_wp_page_template</wp:meta_key>
|
||||||
<wp:meta_value><![CDATA[default]]></wp:meta_value>
|
<wp:meta_value><![CDATA[default]]></wp:meta_value>
|
||||||
</wp:postmeta>
|
</wp:postmeta>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_edit_last</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[1]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<title>Second blog post </title>
|
<title>Second blog post </title>
|
||||||
@ -159,8 +163,12 @@ In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibu
|
|||||||
<description></description>
|
<description></description>
|
||||||
<content:encoded><![CDATA[This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.
|
<content:encoded><![CDATA[This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.
|
||||||
|
|
||||||
|
<a href="http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png"><img class="alignnone size-thumbnail wp-image-13" title="200px-Tux.svg" src="http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_-150x150.png" alt="Tux, the Linux mascot" width="150" height="150" /></a>
|
||||||
|
|
||||||
Integer interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus.
|
Integer interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus.
|
||||||
|
|
||||||
|
<a href="http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png"><img class="alignnone size-full wp-image-13" title="200px-Tux.svg" src="http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png" alt="" width="200" height="235" /></a>
|
||||||
|
|
||||||
Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.]]></content:encoded>
|
Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.]]></content:encoded>
|
||||||
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
||||||
<wp:post_id>6</wp:post_id>
|
<wp:post_id>6</wp:post_id>
|
||||||
@ -187,7 +195,7 @@ Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, fel
|
|||||||
<wp:comment_id>2</wp:comment_id>
|
<wp:comment_id>2</wp:comment_id>
|
||||||
<wp:comment_author><![CDATA[admin]]></wp:comment_author>
|
<wp:comment_author><![CDATA[admin]]></wp:comment_author>
|
||||||
<wp:comment_author_email>admin@example.com</wp:comment_author_email>
|
<wp:comment_author_email>admin@example.com</wp:comment_author_email>
|
||||||
<wp:comment_author_url></wp:comment_author_url>
|
<wp:comment_author_url>http://www.example.com/</wp:comment_author_url>
|
||||||
<wp:comment_author_IP>127.0.0.1</wp:comment_author_IP>
|
<wp:comment_author_IP>127.0.0.1</wp:comment_author_IP>
|
||||||
<wp:comment_date>2011-05-21 12:26:24</wp:comment_date>
|
<wp:comment_date>2011-05-21 12:26:24</wp:comment_date>
|
||||||
<wp:comment_date_gmt>2011-05-21 12:26:24</wp:comment_date_gmt>
|
<wp:comment_date_gmt>2011-05-21 12:26:24</wp:comment_date_gmt>
|
||||||
@ -253,6 +261,8 @@ In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibu
|
|||||||
<description></description>
|
<description></description>
|
||||||
<content:encoded><![CDATA[This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat.
|
<content:encoded><![CDATA[This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat.
|
||||||
|
|
||||||
|
<a href="http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt">This is my CV</a>, please download!
|
||||||
|
|
||||||
Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit <strong>viverra</strong>. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus. Integer interdum purus id erat. Duis nec velit vitae dolor mattis euismod.
|
Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit <strong>viverra</strong>. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus. Integer interdum purus id erat. Duis nec velit vitae dolor mattis euismod.
|
||||||
|
|
||||||
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.]]></content:encoded>
|
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.]]></content:encoded>
|
||||||
@ -278,5 +288,71 @@ Class aptent taciti sociosqu ad litora torquent per conubia nostra, per incepto
|
|||||||
<wp:meta_value><![CDATA[default]]></wp:meta_value>
|
<wp:meta_value><![CDATA[default]]></wp:meta_value>
|
||||||
</wp:postmeta>
|
</wp:postmeta>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>200px-Tux.svg</title>
|
||||||
|
<link>http://localhost/wordpress/?attachment_id=13</link>
|
||||||
|
<pubDate>Sun, 05 Jun 2011 15:26:51 +0000</pubDate>
|
||||||
|
<dc:creator>admin</dc:creator>
|
||||||
|
<guid isPermaLink="false">http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png</guid>
|
||||||
|
<description></description>
|
||||||
|
<content:encoded><![CDATA[]]></content:encoded>
|
||||||
|
<excerpt:encoded><![CDATA[]]></excerpt:encoded>
|
||||||
|
<wp:post_id>13</wp:post_id>
|
||||||
|
<wp:post_date>2011-06-05 15:26:51</wp:post_date>
|
||||||
|
<wp:post_date_gmt>2011-06-05 15:26:51</wp:post_date_gmt>
|
||||||
|
<wp:comment_status>open</wp:comment_status>
|
||||||
|
<wp:ping_status>open</wp:ping_status>
|
||||||
|
<wp:post_name>200px-tux-svg</wp:post_name>
|
||||||
|
<wp:status>inherit</wp:status>
|
||||||
|
<wp:post_parent>6</wp:post_parent>
|
||||||
|
<wp:menu_order>0</wp:menu_order>
|
||||||
|
<wp:post_type>attachment</wp:post_type>
|
||||||
|
<wp:post_password></wp:post_password>
|
||||||
|
<wp:is_sticky>0</wp:is_sticky>
|
||||||
|
<wp:attachment_url>http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png</wp:attachment_url>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_wp_attached_file</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[2011/05/200px-Tux.svg_.png]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_wp_attachment_metadata</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[a:6:{s:5:"width";s:3:"200";s:6:"height";s:3:"235";s:14:"hwstring_small";s:22:"height='96' width='81'";s:4:"file";s:26:"2011/05/200px-Tux.svg_.png";s:5:"sizes";a:2:{s:9:"thumbnail";a:3:{s:4:"file";s:26:"200px-Tux.svg_-150x150.png";s:5:"width";s:3:"150";s:6:"height";s:3:"150";}s:14:"post-thumbnail";a:3:{s:4:"file";s:26:"200px-Tux.svg_-200x198.png";s:5:"width";s:3:"200";s:6:"height";s:3:"198";}}s:10:"image_meta";a:10:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";}}]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_wp_attachment_image_alt</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[Tux, the Linux mascot]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<title>cv</title>
|
||||||
|
<link>http://localhost/wordpress/?attachment_id=18</link>
|
||||||
|
<pubDate>Mon, 06 Jun 2011 17:27:50 +0000</pubDate>
|
||||||
|
<dc:creator>admin</dc:creator>
|
||||||
|
<guid isPermaLink="false">http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt</guid>
|
||||||
|
<description></description>
|
||||||
|
<content:encoded><![CDATA[]]></content:encoded>
|
||||||
|
<excerpt:encoded><![CDATA[My CV]]></excerpt:encoded>
|
||||||
|
<wp:post_id>18</wp:post_id>
|
||||||
|
<wp:post_date>2011-06-06 17:27:50</wp:post_date>
|
||||||
|
<wp:post_date_gmt>2011-06-06 17:27:50</wp:post_date_gmt>
|
||||||
|
<wp:comment_status>open</wp:comment_status>
|
||||||
|
<wp:ping_status>open</wp:ping_status>
|
||||||
|
<wp:post_name>cv</wp:post_name>
|
||||||
|
<wp:status>inherit</wp:status>
|
||||||
|
<wp:post_parent>10</wp:post_parent>
|
||||||
|
<wp:menu_order>0</wp:menu_order>
|
||||||
|
<wp:post_type>attachment</wp:post_type>
|
||||||
|
<wp:post_password></wp:post_password>
|
||||||
|
<wp:is_sticky>0</wp:is_sticky>
|
||||||
|
<wp:attachment_url>http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt</wp:attachment_url>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_wp_attached_file</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[2011/05/cv.txt]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
|
<wp:postmeta>
|
||||||
|
<wp:meta_key>_wp_attachment_metadata</wp:meta_key>
|
||||||
|
<wp:meta_value><![CDATA[a:0:{}]]></wp:meta_value>
|
||||||
|
</wp:postmeta>
|
||||||
|
</item>
|
||||||
</channel>
|
</channel>
|
||||||
</rss>
|
</rss>
|
||||||
|
93
spec/lib/wordpress/attachment_spec.rb
Normal file
93
spec/lib/wordpress/attachment_spec.rb
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe WordPressImport::Attachment, :type => :model do
|
||||||
|
context "an image attchment" do
|
||||||
|
let(:attachment) { test_dump.attachments.first }
|
||||||
|
|
||||||
|
specify { attachment.title.should == '200px-Tux.svg' }
|
||||||
|
# doesn't get exported atm. for some reason
|
||||||
|
specify { attachment.description.should == '' }
|
||||||
|
specify { attachment.url.should == 'http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png' }
|
||||||
|
specify { attachment.file_name.should == '200px-Tux.svg_.png' }
|
||||||
|
specify { attachment.post_date.should == DateTime.new(2011, 6, 5, 15, 26, 51) }
|
||||||
|
specify { attachment.should be_an_image }
|
||||||
|
|
||||||
|
describe "#to_refinery" do
|
||||||
|
before do
|
||||||
|
@image = attachment.to_refinery
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should create an Image from the Attachment" do
|
||||||
|
@image.should be_a(Image)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should copy the attributes from Attachment" do
|
||||||
|
@image.created_at.should == attachment.post_date
|
||||||
|
@image.image.url.end_with?(attachment.file_name).should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#replace_url" do
|
||||||
|
let(:post) { BlogPost.first }
|
||||||
|
|
||||||
|
before do
|
||||||
|
test_dump.authors.each(&:to_refinery)
|
||||||
|
test_dump.posts.each(&:to_refinery)
|
||||||
|
|
||||||
|
@image = attachment.to_refinery
|
||||||
|
|
||||||
|
attachment.replace_url
|
||||||
|
end
|
||||||
|
|
||||||
|
specify { post.body.should_not include attachment.url }
|
||||||
|
specify { post.body.should_not include '200px-Tux.svg_-150x150.png' }
|
||||||
|
specify { post.body.should_not include 'wp-content' }
|
||||||
|
|
||||||
|
it "should replace attachment urls in the generated BlogPosts" do
|
||||||
|
post.body.should include(@image.image.url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "a file attachment" do
|
||||||
|
let(:attachment) { test_dump.attachments.last }
|
||||||
|
|
||||||
|
specify { attachment.title.should == 'cv' }
|
||||||
|
specify { attachment.url.should == 'http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt' }
|
||||||
|
specify { attachment.file_name.should == 'cv.txt' }
|
||||||
|
specify { attachment.post_date.should == DateTime.new(2011, 6, 6, 17, 27, 50) }
|
||||||
|
specify { attachment.should_not be_an_image }
|
||||||
|
|
||||||
|
describe '#to_refinery' do
|
||||||
|
before do
|
||||||
|
@resource = attachment.to_refinery
|
||||||
|
end
|
||||||
|
|
||||||
|
specify { Resource.should have(1).record }
|
||||||
|
specify { @resource.should be_a(Resource) }
|
||||||
|
|
||||||
|
it "should copy the attributes from Attachment" do
|
||||||
|
@resource.created_at.should == attachment.post_date
|
||||||
|
@resource.file.url.end_with?(attachment.file_name).should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#replace_resource_url' do
|
||||||
|
let(:page_part) { Page.last.parts.first }
|
||||||
|
|
||||||
|
before do
|
||||||
|
test_dump.pages.each(&:to_refinery)
|
||||||
|
@resource = attachment.to_refinery
|
||||||
|
attachment.replace_url
|
||||||
|
end
|
||||||
|
|
||||||
|
specify { page_part.body.should_not include attachment.url }
|
||||||
|
specify { page_part.body.should_not include 'wp-content' }
|
||||||
|
|
||||||
|
it "should replace attachment urls in the generated BlogPosts" do
|
||||||
|
page_part.body.should include(@resource.file.url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,10 +1,10 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Author, :type => :model do
|
describe WordPressImport::Author, :type => :model do
|
||||||
let(:author) { test_dump.authors.first }
|
let(:author) { test_dump.authors.first }
|
||||||
|
|
||||||
it { author.login.should == 'admin' }
|
specify { author.login.should == 'admin' }
|
||||||
it { author.email.should == 'admin@example.com' }
|
specify { author.email.should == 'admin@example.com' }
|
||||||
|
|
||||||
describe "#to_refinery" do
|
describe "#to_refinery" do
|
||||||
before do
|
before do
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Category, :type => :model do
|
describe WordPressImport::Category, :type => :model do
|
||||||
let(:category) { Refinery::WordPress::Category.new('Rant') }
|
let(:category) { WordPressImport::Category.new('Rant') }
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
specify { category.name.should == 'Rant' }
|
specify { category.name.should == 'Rant' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#==" do
|
describe "#==" do
|
||||||
specify { category.should == Refinery::WordPress::Category.new('Rant') }
|
specify { category.should == WordPressImport::Category.new('Rant') }
|
||||||
specify { category.should_not == Refinery::WordPress::Category.new('Tutorials') }
|
specify { category.should_not == WordPressImport::Category.new('Tutorials') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#to_refinery" do
|
describe "#to_refinery" do
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Dump, :type => :model do
|
describe WordPressImport::Dump, :type => :model do
|
||||||
let(:dump) { test_dump }
|
let(:dump) { test_dump }
|
||||||
|
|
||||||
it "should create a Dump object given a xml file" do
|
it "should create a Dump object given a xml file" do
|
||||||
dump.should be_a Refinery::WordPress::Dump
|
dump.should be_a WordPressImport::Dump
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should include a Nokogiri::XML object" do
|
it "should include a Nokogiri::XML object" do
|
||||||
@ -13,11 +13,12 @@ describe Refinery::WordPress::Dump, :type => :model do
|
|||||||
|
|
||||||
describe "#tags" do
|
describe "#tags" do
|
||||||
let(:tags) do
|
let(:tags) do
|
||||||
[ Refinery::WordPress::Tag.new('css'), Refinery::WordPress::Tag.new('html'),
|
[ WordPressImport::Tag.new('css'), WordPressImport::Tag.new('html'),
|
||||||
Refinery::WordPress::Tag.new('php'), Refinery::WordPress::Tag.new('ruby')]
|
WordPressImport::Tag.new('php'), WordPressImport::Tag.new('ruby')]
|
||||||
end
|
end
|
||||||
|
|
||||||
specify { dump.tags.count == 4 }
|
specify { dump.tags.count == 4 }
|
||||||
|
specify { dump.tags.first.should be_a(WordPressImport::Tag) }
|
||||||
|
|
||||||
it "should return all included tags" do
|
it "should return all included tags" do
|
||||||
tags.each do |tag|
|
tags.each do |tag|
|
||||||
@ -28,11 +29,12 @@ describe Refinery::WordPress::Dump, :type => :model do
|
|||||||
|
|
||||||
describe "#categories" do
|
describe "#categories" do
|
||||||
let(:categories) do
|
let(:categories) do
|
||||||
[ Refinery::WordPress::Category.new('Rant'), Refinery::WordPress::Category.new('Tutorials'),
|
[ WordPressImport::Category.new('Rant'), WordPressImport::Category.new('Tutorials'),
|
||||||
Refinery::WordPress::Category.new('Uncategorized') ]
|
WordPressImport::Category.new('Uncategorized') ]
|
||||||
end
|
end
|
||||||
|
|
||||||
specify { dump.categories.count == 4 }
|
specify { dump.categories.count == 4 }
|
||||||
|
specify { dump.categories.first.should be_a(WordPressImport::Category) }
|
||||||
|
|
||||||
it "should return all included categories" do
|
it "should return all included categories" do
|
||||||
categories.each do |cat|
|
categories.each do |cat|
|
||||||
@ -46,6 +48,8 @@ describe Refinery::WordPress::Dump, :type => :model do
|
|||||||
dump.pages.should have(3).pages
|
dump.pages.should have(3).pages
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify { dump.pages.first.should be_a(WordPressImport::Page) }
|
||||||
|
|
||||||
it "should return only published pages with only_published=true" do
|
it "should return only published pages with only_published=true" do
|
||||||
dump.pages(true).should have(2).pages
|
dump.pages(true).should have(2).pages
|
||||||
end
|
end
|
||||||
@ -55,6 +59,8 @@ describe Refinery::WordPress::Dump, :type => :model do
|
|||||||
it "should return all authors" do
|
it "should return all authors" do
|
||||||
dump.authors.should have(1).author
|
dump.authors.should have(1).author
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify { dump.authors.first.should be_a(WordPressImport::Author) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#posts" do
|
describe "#posts" do
|
||||||
@ -62,8 +68,18 @@ describe Refinery::WordPress::Dump, :type => :model do
|
|||||||
dump.posts.should have(3).posts
|
dump.posts.should have(3).posts
|
||||||
end
|
end
|
||||||
|
|
||||||
|
specify { dump.posts.first.should be_a(WordPressImport::Post) }
|
||||||
|
|
||||||
it "should return only published posts with only_published=true" do
|
it "should return only published posts with only_published=true" do
|
||||||
dump.posts(true).should have(2).posts
|
dump.posts(true).should have(2).posts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#attachments" do
|
||||||
|
it "should return all attachments" do
|
||||||
|
dump.attachments.should have(2).attachments
|
||||||
|
end
|
||||||
|
|
||||||
|
specify { dump.attachments.first.should be_a(WordPressImport::Attachment) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Page, :type => :model do
|
describe WordPressImport::Page, :type => :model do
|
||||||
let(:dump) { test_dump }
|
let(:dump) { test_dump }
|
||||||
|
|
||||||
let(:page) { test_dump.pages.last }
|
let(:page) { test_dump.pages.last }
|
||||||
|
|
||||||
it { page.title.should == 'About me' }
|
specify { page.title.should == 'About me' }
|
||||||
it { page.content.should include('Lorem ipsum dolor sit') }
|
specify { page.content.should include('Lorem ipsum dolor sit') }
|
||||||
it { page.creator.should == 'admin' }
|
specify { page.creator.should == 'admin' }
|
||||||
it { page.post_date.should == DateTime.new(2011, 5, 21, 12, 25, 42) }
|
specify { page.post_date.should == DateTime.new(2011, 5, 21, 12, 25, 42) }
|
||||||
it { page.post_id.should == 10 }
|
specify { page.post_id.should == 10 }
|
||||||
it { page.parent_id.should == 8 }
|
specify { page.parent_id.should == 8 }
|
||||||
|
|
||||||
it { page.should == dump.pages.last }
|
specify { page.should == dump.pages.last }
|
||||||
it { page.should_not == dump.pages.first }
|
specify { page.should_not == dump.pages.first }
|
||||||
|
|
||||||
describe "#to_refinery" do
|
describe "#to_refinery" do
|
||||||
include ::ActionView::Helpers::TagHelper
|
include ::ActionView::Helpers::TagHelper
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Post, :type => :model do
|
describe WordPressImport::Post, :type => :model do
|
||||||
let(:post) { test_dump.posts.last }
|
let(:post) { test_dump.posts.last }
|
||||||
|
|
||||||
it { post.title.should == 'Third blog post' }
|
specify { post.title.should == 'Third blog post' }
|
||||||
it { post.content.should include('Lorem ipsum dolor sit') }
|
specify { post.content.should include('Lorem ipsum dolor sit') }
|
||||||
it { post.content_formatted.should include('Lorem ipsum dolor sit') }
|
specify { post.content_formatted.should include('Lorem ipsum dolor sit') }
|
||||||
it { post.creator.should == 'admin' }
|
specify { post.creator.should == 'admin' }
|
||||||
it { post.post_date.should == DateTime.new(2011, 5, 21, 12, 24, 45) }
|
specify { post.post_date.should == DateTime.new(2011, 5, 21, 12, 24, 45) }
|
||||||
it { post.post_id.should == 6 }
|
specify { post.post_id.should == 6 }
|
||||||
it { post.parent_id.should == nil }
|
specify { post.parent_id.should == nil }
|
||||||
it { post.status.should == 'publish' }
|
specify { post.status.should == 'publish' }
|
||||||
|
|
||||||
it { post.should == test_dump.posts.last }
|
specify { post.should == test_dump.posts.last }
|
||||||
it { post.should_not == test_dump.posts.first }
|
specify { post.should_not == test_dump.posts.first }
|
||||||
|
|
||||||
describe "#categories" do
|
describe "#categories" do
|
||||||
it { post.categories.should have(1).category }
|
specify { post.categories.should have(1).category }
|
||||||
it { post.categories.first.should == Refinery::WordPress::Category.new('Rant') }
|
specify { post.categories.first.should == WordPressImport::Category.new('Rant') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#tags" do
|
describe "#tags" do
|
||||||
it { post.tags.should have(3).tags }
|
specify { post.tags.should have(3).tags }
|
||||||
|
|
||||||
it { post.tags.should include(Refinery::WordPress::Tag.new('css')) }
|
specify { post.tags.should include(WordPressImport::Tag.new('css')) }
|
||||||
it { post.tags.should include(Refinery::WordPress::Tag.new('html')) }
|
specify { post.tags.should include(WordPressImport::Tag.new('html')) }
|
||||||
it { post.tags.should include(Refinery::WordPress::Tag.new('php')) }
|
specify { post.tags.should include(WordPressImport::Tag.new('php')) }
|
||||||
end
|
end
|
||||||
|
|
||||||
it { post.tag_list.should == 'css,html,php' }
|
specify { post.tag_list.should == 'css,html,php' }
|
||||||
|
|
||||||
describe "#comments" do
|
describe "#comments" do
|
||||||
it "should return all attached comments" do
|
it "should return all attached comments" do
|
||||||
@ -38,14 +38,14 @@ describe Refinery::WordPress::Post, :type => :model do
|
|||||||
context "the last comment" do
|
context "the last comment" do
|
||||||
let(:comment) { post.comments.last }
|
let(:comment) { post.comments.last }
|
||||||
|
|
||||||
it { comment.author.should == 'admin' }
|
specify { comment.author.should == 'admin' }
|
||||||
it { comment.email.should == 'admin@example.com' }
|
specify { comment.email.should == 'admin@example.com' }
|
||||||
it { comment.url.should == 'http://www.example.com/' }
|
specify { comment.url.should == 'http://www.example.com/' }
|
||||||
it { comment.date.should == DateTime.new(2011, 5, 21, 12, 26, 30) }
|
specify { comment.date.should == DateTime.new(2011, 5, 21, 12, 26, 30) }
|
||||||
it { comment.content.should include('Another one!') }
|
specify { comment.content.should include('Another one!') }
|
||||||
it { comment.should be_approved }
|
specify { comment.should be_approved }
|
||||||
|
|
||||||
it { comment.should == post.comments.last }
|
specify { comment.should == post.comments.last }
|
||||||
|
|
||||||
describe "#to_refinery" do
|
describe "#to_refinery" do
|
||||||
before do
|
before do
|
||||||
@ -63,6 +63,7 @@ describe Refinery::WordPress::Post, :type => :model do
|
|||||||
@comment.body.should == comment.content
|
@comment.body.should == comment.content
|
||||||
@comment.state.should == 'approved'
|
@comment.state.should == 'approved'
|
||||||
@comment.created_at.should == comment.date
|
@comment.created_at.should == comment.date
|
||||||
|
@comment.created_at.should == comment.date
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -79,16 +80,13 @@ describe Refinery::WordPress::Post, :type => :model do
|
|||||||
@post = post.to_refinery
|
@post = post.to_refinery
|
||||||
end
|
end
|
||||||
|
|
||||||
it { BlogPost.should have(1).record }
|
specify { BlogPost.should have(1).record }
|
||||||
|
|
||||||
it "should copy the attributes from Refinery::WordPress::Post" do
|
specify { @post.title.should == post.title }
|
||||||
@post.title.should == post.title
|
specify { @post.body.should == post.content_formatted }
|
||||||
@post.body.should == post.content_formatted
|
specify { @post.draft.should == post.draft? }
|
||||||
@post.draft.should == post.draft?
|
specify { @post.published_at.should == post.post_date }
|
||||||
@post.published_at.should == post.post_date
|
specify { @post.author.username.should == post.creator }
|
||||||
@post.created_at.should == post.post_date
|
|
||||||
@post.author.username.should == post.creator
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should assign a category for each Refinery::WordPress::Category" do
|
it "should assign a category for each Refinery::WordPress::Category" do
|
||||||
@post.categories.should have(post.categories.count).records
|
@post.categories.should have(post.categories.count).records
|
||||||
@ -106,7 +104,7 @@ describe Refinery::WordPress::Post, :type => :model do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it { BlogPost.should have(2).records }
|
specify { BlogPost.should have(2).records }
|
||||||
|
|
||||||
it "should create the BlogPost with #post_id attached" do
|
it "should create the BlogPost with #post_id attached" do
|
||||||
@post.title.should == "#{post.title}-#{post.post_id}"
|
@post.title.should == "#{post.title}-#{post.post_id}"
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Refinery::WordPress::Tag, :type => :model do
|
describe WordPressImport::Tag, :type => :model do
|
||||||
let(:tag) { Refinery::WordPress::Tag.new('ruby') }
|
let(:tag) { WordPressImport::Tag.new('ruby') }
|
||||||
|
|
||||||
describe "#name" do
|
describe "#name" do
|
||||||
specify { tag.name.should == 'ruby' }
|
specify { tag.name.should == 'ruby' }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#==" do
|
describe "#==" do
|
||||||
specify { tag.should == Refinery::WordPress::Tag.new('ruby') }
|
specify { tag.should == WordPressImport::Tag.new('ruby') }
|
||||||
specify { tag.should_not == Refinery::WordPress::Tag.new('php') }
|
specify { tag.should_not == WordPressImport::Tag.new('php') }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#to_refinery" do
|
describe "#to_refinery" do
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
require 'spec_helper'
|
|
||||||
|
|
||||||
describe Refinery::WordPress do
|
|
||||||
it "should be valid" do
|
|
||||||
Refinery::WordPress.should be_a(Module)
|
|
||||||
end
|
|
||||||
end
|
|
12
spec/support/fakeweb.rb
Normal file
12
spec/support/fakeweb.rb
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
require "fakeweb"
|
||||||
|
|
||||||
|
FakeWeb.allow_net_connect = false
|
||||||
|
|
||||||
|
# Simulating download of wordpress file attachments. The dump expects the files
|
||||||
|
# to be at the given URLs
|
||||||
|
FakeWeb.register_uri(:get,
|
||||||
|
"http://localhost/wordpress/wp-content/uploads/2011/05/200px-Tux.svg_.png",
|
||||||
|
:body => File.new('spec/fixtures/200px-Tux.svg_.png').read,
|
||||||
|
:content_type => "image/png")
|
||||||
|
|
||||||
|
FakeWeb.register_uri(:get, "http://localhost/wordpress/wp-content/uploads/2011/05/cv.txt", :body => "Hello World!", :content_type => "text/plain")
|
@ -1,11 +1,11 @@
|
|||||||
module Refinery::WordPress::SpecHelpers
|
module WordPressImport::SpecHelpers
|
||||||
def test_dump
|
def test_dump
|
||||||
file_name = File.realpath(File.join(File.dirname(__FILE__), '../fixtures/wordpress_dump.xml'))
|
file_name = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/wordpress_dump.xml'))
|
||||||
Refinery::WordPress::Dump.new(file_name)
|
WordPressImport::Dump.new(file_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.include Refinery::WordPress::SpecHelpers
|
config.include WordPressImport::SpecHelpers
|
||||||
end
|
end
|
||||||
|
|
||||||
|
7
spec/wordpress_import_spec.rb
Normal file
7
spec/wordpress_import_spec.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe WordPressImport do
|
||||||
|
it "should be valid" do
|
||||||
|
WordPressImport.should be_a(Module)
|
||||||
|
end
|
||||||
|
end
|
24
support/templates/haml/caption.haml
Normal file
24
support/templates/haml/caption.haml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
-# disabling style_hash for now; setting the width = width+10 doesn't seem to actually be a good thing
|
||||||
|
-# style_hash = {:style => "width: #{@attributes[:width].to_i+10}px"} unless @attributes[:width].blank?
|
||||||
|
- figure_hash = {:class => @attributes[:align], :id => @attributes[:id]}
|
||||||
|
-# figure_hash = figure_hash.merge(style_hash) if style_hash
|
||||||
|
- content_image = Nokogiri::HTML(@content).css("img").to_html
|
||||||
|
- content_caption = Nokogiri::HTML(@content).text + " #{@attributes[:caption]}"
|
||||||
|
- @content = "#{content_image} <figcaption>#{content_caption}</figcaption>" unless content_image.blank?
|
||||||
|
%figure{figure_hash}= @content
|
||||||
|
|
||||||
|
-# sample wordpress-y css to go along with this html:
|
||||||
|
figure {
|
||||||
|
background: #f1f1f1;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 4px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
figure img {
|
||||||
|
margin: 5px 5px 0;
|
||||||
|
}
|
||||||
|
figure figcaption {
|
||||||
|
color: #777;
|
||||||
|
font-size: 12px;
|
||||||
|
margin: 5px 5px 24px;
|
||||||
|
}
|
4
support/templates/haml/column.haml
Normal file
4
support/templates/haml/column.haml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.post_column_1{:style =>"width:#{@attributes[:width]}; float: left; padding: #{@attributes[:padding]} 6% #{@attributes[:padding]} #{@attributes[:padding]}; display: inline;"}= @content
|
||||||
|
|
||||||
|
-#[column width="47%" padding="0"] foo [/column]
|
||||||
|
-# <div class="post_column_1">
|
1
support/templates/haml/end_columns.haml
Normal file
1
support/templates/haml/end_columns.haml
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div style="clear: both;"></div>
|
37
support/templates/haml/google-map-v3.haml
Normal file
37
support/templates/haml/google-map-v3.haml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
- addmarkerlist = @attributes[:addmarkerlist].to_s || ""
|
||||||
|
|
||||||
|
- name = addmarkerlist.split("{}").last
|
||||||
|
- uri_name = URI::encode(name)
|
||||||
|
- uri_address = URI::encode(addmarkerlist.split("{}").first)
|
||||||
|
|
||||||
|
-# google will open up the business page if we pass it a name
|
||||||
|
- uri_address = "#{uri_name},%20#{uri_address}" unless (uri_name == uri_address || name.blank?)
|
||||||
|
|
||||||
|
- gmaps_url = "https://maps.google.com/maps/?q=#{uri_address}&ie=UTF8&t=m"
|
||||||
|
<iframe src="#{gmaps_url}&output=embed" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="#{@attributes[:width]}" height="#{@attributes[:height]}"></iframe>
|
||||||
|
<small>View <a href="#{gmaps_url}">#{name}</a> in a larger map</small>
|
||||||
|
|
||||||
|
|
||||||
|
-# [google-map-v3 width="425"
|
||||||
|
height="350"
|
||||||
|
zoom="12"
|
||||||
|
maptype="roadmap"
|
||||||
|
mapalign="left"
|
||||||
|
directionhint="false"
|
||||||
|
language="default"
|
||||||
|
poweredby="false"
|
||||||
|
maptypecontrol="true"
|
||||||
|
pancontrol="true"
|
||||||
|
zoomcontrol="true"
|
||||||
|
scalecontrol="true"
|
||||||
|
streetviewcontrol="true"
|
||||||
|
scrollwheelcontrol="false"
|
||||||
|
draggable="true"
|
||||||
|
tiltfourtyfive="false"
|
||||||
|
addmarkermashupbubble="false"
|
||||||
|
addmarkermashupbubble="false"
|
||||||
|
addmarkerlist="#1 Dream Manor Dr Globe, AZ{}1-default.png{}Dream Manor Inn"
|
||||||
|
bubbleautopan="true"
|
||||||
|
showbike="false"
|
||||||
|
showtraffic="false"
|
||||||
|
showpanoramio="false"]
|
22
wordpress-import.gemspec
Normal file
22
wordpress-import.gemspec
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Provide a simple gemspec so you can easily use your enginex
|
||||||
|
# project in your rails apps through git.
|
||||||
|
Gem::Specification.new do |s|
|
||||||
|
s.name = "wordpress-import"
|
||||||
|
s.summary = "Import WordPress XML dumps into your Ruby on Rails app."
|
||||||
|
s.description = "This gem imports a WordPress XML dump into Rails (Page, User, BlogPost, BlogCategory, Tag, BlogComment)"
|
||||||
|
s.version = "0.4.4"
|
||||||
|
s.date = "2014-03-17"
|
||||||
|
|
||||||
|
s.authors = ['Will Bradley']
|
||||||
|
s.email = 'bradley.will@gmail.com'
|
||||||
|
s.homepage = 'https://github.com/zyphlar/wordpress-import'
|
||||||
|
|
||||||
|
s.add_dependency 'bundler', '~> 1.0'
|
||||||
|
s.add_dependency 'nokogiri', '~> 1.6.0'
|
||||||
|
s.add_dependency 'shortcode', '~> 0.1.1'
|
||||||
|
|
||||||
|
s.add_development_dependency 'rspec-rails'
|
||||||
|
s.add_development_dependency 'database_cleaner'
|
||||||
|
|
||||||
|
s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user