jekyll-import 0.1.0.beta3 → 0.1.0.beta4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +6 -14
  2. data/History.markdown +18 -0
  3. data/README.markdown +12 -1
  4. data/jekyll-import.gemspec +31 -25
  5. data/lib/jekyll-import.rb +50 -1
  6. data/lib/jekyll-import/importer.rb +11 -0
  7. data/lib/jekyll-import/importers.rb +10 -0
  8. data/lib/jekyll-import/importers/csv.rb +50 -0
  9. data/lib/jekyll-import/importers/drupal6.rb +139 -0
  10. data/lib/jekyll-import/importers/drupal7.rb +102 -0
  11. data/lib/jekyll-import/importers/enki.rb +76 -0
  12. data/lib/jekyll-import/importers/google_reader.rb +68 -0
  13. data/lib/jekyll-import/importers/joomla.rb +83 -0
  14. data/lib/jekyll-import/importers/jrnl.rb +127 -0
  15. data/lib/jekyll-import/importers/marley.rb +72 -0
  16. data/lib/jekyll-import/importers/mephisto.rb +109 -0
  17. data/lib/jekyll-import/importers/mt.rb +169 -0
  18. data/lib/jekyll-import/importers/posterous.rb +139 -0
  19. data/lib/jekyll-import/importers/rss.rb +71 -0
  20. data/lib/jekyll-import/importers/s9y.rb +67 -0
  21. data/lib/jekyll-import/importers/textpattern.rb +76 -0
  22. data/lib/jekyll-import/importers/tumblr.rb +265 -0
  23. data/lib/jekyll-import/importers/typo.rb +89 -0
  24. data/lib/jekyll-import/importers/wordpress.rb +323 -0
  25. data/lib/jekyll-import/importers/wordpressdotcom.rb +97 -0
  26. data/lib/jekyll/commands/import.rb +1 -0
  27. data/test/helper.rb +3 -1
  28. data/test/test_jrnl_importer.rb +39 -0
  29. data/test/test_mt_importer.rb +16 -16
  30. data/test/test_tumblr_importer.rb +61 -0
  31. data/test/test_wordpress_importer.rb +1 -1
  32. data/test/test_wordpressdotcom_importer.rb +1 -1
  33. metadata +53 -32
  34. data/lib/jekyll/jekyll-import/csv.rb +0 -30
  35. data/lib/jekyll/jekyll-import/drupal6.rb +0 -112
  36. data/lib/jekyll/jekyll-import/drupal7.rb +0 -74
  37. data/lib/jekyll/jekyll-import/enki.rb +0 -49
  38. data/lib/jekyll/jekyll-import/google_reader.rb +0 -61
  39. data/lib/jekyll/jekyll-import/joomla.rb +0 -53
  40. data/lib/jekyll/jekyll-import/marley.rb +0 -52
  41. data/lib/jekyll/jekyll-import/mephisto.rb +0 -84
  42. data/lib/jekyll/jekyll-import/mt.rb +0 -142
  43. data/lib/jekyll/jekyll-import/posterous.rb +0 -122
  44. data/lib/jekyll/jekyll-import/rss.rb +0 -63
  45. data/lib/jekyll/jekyll-import/s9y.rb +0 -59
  46. data/lib/jekyll/jekyll-import/textpattern.rb +0 -58
  47. data/lib/jekyll/jekyll-import/tumblr.rb +0 -242
  48. data/lib/jekyll/jekyll-import/typo.rb +0 -69
  49. data/lib/jekyll/jekyll-import/wordpress.rb +0 -299
  50. data/lib/jekyll/jekyll-import/wordpressdotcom.rb +0 -84
@@ -1,84 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'rubygems'
4
- require 'hpricot'
5
- require 'fileutils'
6
- require 'safe_yaml'
7
- require 'time'
8
-
9
- module JekyllImport
10
- # This importer takes a wordpress.xml file, which can be exported from your
11
- # wordpress.com blog (/wp-admin/export.php).
12
- module WordpressDotCom
13
- def self.process(filename = {:source => "wordpress.xml"})
14
- import_count = Hash.new(0)
15
- doc = Hpricot::XML(File.read(filename[:source]))
16
-
17
- (doc/:channel/:item).each do |item|
18
- title = item.at(:title).inner_text.strip
19
- permalink_title = item.at('wp:post_name').inner_text
20
- # Fallback to "prettified" title if post_name is empty (can happen)
21
- if permalink_title == ""
22
- permalink_title = sluggify(title)
23
- end
24
-
25
- date = Time.parse(item.at('wp:post_date').inner_text)
26
- status = item.at('wp:status').inner_text
27
-
28
- if status == "publish"
29
- published = true
30
- else
31
- published = false
32
- end
33
-
34
- type = item.at('wp:post_type').inner_text
35
- categories = item.search('category[@domain="category"]').map{|c| c.inner_text}.reject{|c| c == 'Uncategorized'}.uniq
36
- tags = item.search('category[@domain="post_tag"]').map{|t| t.inner_text}.uniq
37
-
38
- metas = Hash.new
39
- item.search("wp:postmeta").each do |meta|
40
- key = meta.at('wp:meta_key').inner_text
41
- value = meta.at('wp:meta_value').inner_text
42
- metas[key] = value;
43
- end
44
-
45
- name = "#{date.strftime('%Y-%m-%d')}-#{permalink_title}.html"
46
- header = {
47
- 'layout' => type,
48
- 'title' => title,
49
- 'categories' => categories,
50
- 'tags' => tags,
51
- 'status' => status,
52
- 'type' => type,
53
- 'published' => published,
54
- 'meta' => metas
55
- }
56
-
57
- begin
58
- FileUtils.mkdir_p "_#{type}s"
59
- File.open("_#{type}s/#{name}", "w") do |f|
60
- f.puts header.to_yaml
61
- f.puts '---'
62
- f.puts item.at('content:encoded').inner_text
63
- end
64
- rescue => e
65
- puts "Couldn't import post!"
66
- puts "Title: #{title}"
67
- puts "Name/Slug: #{name}\n"
68
- puts "Error: #{e.message}"
69
- next
70
- end
71
-
72
- import_count[type] += 1
73
- end
74
-
75
- import_count.each do |key, value|
76
- puts "Imported #{value} #{key}s"
77
- end
78
- end
79
-
80
- def self.sluggify(title)
81
- title.gsub(/[^[:alnum:]]+/, '-').downcase
82
- end
83
- end
84
- end