jekyll-import 0.1.0.beta2 → 0.1.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YzhiN2U2ZDMwNjA0NTM4ODYxYjViM2E0ZWJkZTMyYzA2MmQxN2E3Mw==
4
+ YjI5ZmY4ODUyNjIxNTdlNmE1YjllMzVlOWJmYTc0Yjg3OGYyMWUwMA==
5
5
  data.tar.gz: !binary |-
6
- OThkMzY2ZjhhYzZiMjQ5MmUyMDU1NTI3ODg3NTFhMTNkMDAxMzFhYg==
6
+ NTg5OWNkNTJmYjVmYzczMzFlYzQ5NDE3MmJlZTgxNmI4YjAwMTAzOQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWY0NWEyOTM2OTRiOTYzNmY2Y2I0ZTMxNWMzMGRhODdlMTg1MWU0OTNmM2Qz
10
- MGU2NDRlMzI2ZDc1MWZmNWU1ZDE1YWJjOTVmYzQ2MWE5ZDlkMDdmOGUxZGUx
11
- YjAxNjg4OTRiYTk5OTUxZmIzMzdjNzVkNzBmMWJmNDI4ODlhM2Y=
9
+ NjhlNzU5ZTVlN2Y1NGJiYmU4N2IxMWMyOWU2MzliMDkyMjdhMWM1NzZjZGZh
10
+ MTViMGE2NDU4MDQyODQ4MWI3M2FhNjNlZGQ2OGQ3MTg0ODc3OGI4NDBkM2U1
11
+ ZmI0Y2E1ZjM3ZjFlMGVjYzZlNTI4YThlOTRhZWFkZGQwMzk0NDc=
12
12
  data.tar.gz: !binary |-
13
- MGQwODAyZjgwNDBjOTExNjU5NDNlNTFiYmVkMGQzNTc2YmY2MjAyNzQ1Yzli
14
- MTM3MmNkNWU3ZWY4ZjVlMWVlNmFjYjE1YjZjN2UyZjBkMjg1NGVmY2QwY2Mz
15
- ZWY2NGYwY2I5YjMxMjc3ZDMyYmUzY2I1ZjI1OWZlNDkwNThmOGE=
13
+ YjVkY2UyYmY3NzFkOGMwYjY0MzE1NzBiNTk5ODgwYTFmMDg3ZDI3MjExNDM3
14
+ ZWMyMGMzZmRmN2IwNTcxMmYwMGIzYWMxMjcyNTJlM2QwZjk2ZTg2YmMzYTgw
15
+ YTNiOTM1NjdmZGZlM2Q4ZDRjYTcxMzlhYjViOGRmMTNlMzZiZGE=
data/History.markdown CHANGED
@@ -4,11 +4,19 @@
4
4
  * Add the optional ability to include images in a posterous migration (#5)
5
5
  * Posterous archive (unzipped directory) importer added (#12)
6
6
  * Improve MovableType importer (#13)
7
+ * Add an importer for Google Reader blog exports (#36)
8
+ * Remove dependency on html2text in the tumblr importer (#33)
9
+
7
10
  ### Minor Enhancements
8
11
  * Various Tumblr Enhancements (#27)
9
12
  * Adding tags to Typo and forcing their encoding to UTF-8 (#11)
10
13
  * S9Y Importer: specify data source using --source option (#18)
11
14
  * Add taxonomy (`tags`) to Drupal6 migration (#15)
15
+ * Differentiate between categories and tags in the WordpressDotCom
16
+ importer (#31)
17
+ * Use tumblr slug for post is available, use that instead (#39, #40)
18
+ * Drupal 7 importer should use latest revision of a post (#38)
19
+
12
20
  ### Bug Fixes
13
21
  * Remove usage of `Hash#at` in Tumblr importer (#14)
14
22
  * Force encoding of Drupal 6.x titles to UTF-8 (#22)
@@ -16,6 +24,11 @@
16
24
  * Use MySQL2 adapter for WordPress importer to fix broken front-matter (#20)
17
25
  * Fix WordPress import initialize parameters due to new Jekyll setup (#19)
18
26
  * Fixed misspelling in method name (#17)
27
+ * Fix Drupal 7 importer so it compares node ID's properly between `node` and
28
+ `field_data_body` tables (#38)
29
+ * Fix prefix replacement for Drupal6 (#41)
30
+
19
31
  ### Site Enhancements
32
+
20
33
  ### Development Fixes
21
34
  * Update usage docs in RSS importer (#35)
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
5
5
  s.required_ruby_version = '>= 1.9.2'
6
6
 
7
7
  s.name = 'jekyll-import'
8
- s.version = '0.1.0.beta2'
9
- s.date = '2013-07-01'
8
+ s.version = '0.1.0.beta3'
9
+ s.date = '2013-07-14'
10
10
  s.rubyforge_project = 'jekyll-import'
11
11
 
12
12
  s.summary = "Import command for Jekyll (static site generator)."
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
59
59
  lib/jekyll/jekyll-import/drupal6.rb
60
60
  lib/jekyll/jekyll-import/drupal7.rb
61
61
  lib/jekyll/jekyll-import/enki.rb
62
+ lib/jekyll/jekyll-import/google_reader.rb
62
63
  lib/jekyll/jekyll-import/joomla.rb
63
64
  lib/jekyll/jekyll-import/marley.rb
64
65
  lib/jekyll/jekyll-import/mephisto.rb
@@ -10,6 +10,7 @@ module Jekyll
10
10
  :drupal7 => 'Drupal7',
11
11
  :enki => 'Enki',
12
12
  :joomla => 'Joomla',
13
+ :google_reader => 'GoogleReader',
13
14
  :marley => 'Marley',
14
15
  :mephisto => 'Mephisto',
15
16
  :mt => 'MT',
@@ -33,6 +33,8 @@ module JekyllImport
33
33
  if prefix != ''
34
34
  QUERY[" node "] = " " + prefix + "node "
35
35
  QUERY[" node_revisions "] = " " + prefix + "node_revisions "
36
+ QUERY[" term_node "] = " " + prefix + "term_node "
37
+ QUERY[" term_data "] = " " + prefix + "term_data "
36
38
  end
37
39
 
38
40
  FileUtils.mkdir_p "_posts"
@@ -22,7 +22,8 @@ module JekyllImport
22
22
  FROM node AS n, \
23
23
  field_data_body AS fdb \
24
24
  WHERE (n.type = 'blog' OR n.type = 'story') \
25
- AND n.vid = fdb.entity_id"
25
+ AND n.nid = fdb.entity_id \
26
+ AND n.vid = fdb.revision_id"
26
27
 
27
28
  def self.process(dbname, user, pass, host = 'localhost', prefix = '')
28
29
  db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
@@ -0,0 +1,61 @@
1
+ # Usage:
2
+ # (Local file)
3
+ # ruby -r 'jekyll/jekyll-import/rss' -e "JekyllImport::GoogleReader.process(:source => './somefile/on/your/computer.xml')"
4
+
5
+ require 'rss'
6
+ require 'open-uri'
7
+ require 'fileutils'
8
+ require 'safe_yaml'
9
+
10
+ require 'rexml/document'
11
+ require 'date'
12
+
13
+ module JekyllImport
14
+ module GoogleReader
15
+ def self.validate(options)
16
+ if !options[:source]
17
+ abort "Missing mandatory option --source."
18
+ end
19
+ end
20
+
21
+ # Process the import.
22
+ #
23
+ # source - a URL or a local file String.
24
+ #
25
+ # Returns nothing.
26
+ def self.process(options)
27
+ validate(options)
28
+
29
+ source = options[:source]
30
+
31
+ open(source) do |content|
32
+ feed = RSS::Parser.parse(content)
33
+
34
+ raise "There doesn't appear to be any RSS items at the source (#{source}) provided." unless feed
35
+
36
+ feed.items.each do |item|
37
+ title = item.title.content.to_s
38
+ formatted_date = Date.parse(item.published.to_s)
39
+ post_name = title.split(%r{ |!|/|:|&|-|$|,}).map do |i|
40
+ i.downcase if i != ''
41
+ end.compact.join('-')
42
+ name = "#{formatted_date}-#{post_name}"
43
+
44
+ header = {
45
+ 'layout' => 'post',
46
+ 'title' => title
47
+ }
48
+
49
+ FileUtils.mkdir_p("_posts")
50
+
51
+ File.open("_posts/#{name}.html", "w") do |f|
52
+ f.puts header.to_yaml
53
+ f.puts "---\n\n"
54
+ f.puts item.content.content.to_s
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+
@@ -110,8 +110,12 @@ module JekyllImport
110
110
  end
111
111
  date = Date.parse(post['date']).to_s
112
112
  title = Nokogiri::HTML(title).text
113
- slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
114
- slug = slug.slice(0..200) if slug.length > 200
113
+ slug = if post["slug"] && post["slug"].strip != ""
114
+ post["slug"]
115
+ else
116
+ slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
117
+ slug.length > 200 ? slug.slice(0..200) : slug
118
+ end
115
119
  {
116
120
  :name => "#{date}-#{slug}.#{format}",
117
121
  :header => {
@@ -177,15 +181,14 @@ module JekyllImport
177
181
  }
178
182
  end
179
183
 
180
- # Uses Python's html2text to convert a post's content to
181
- # markdown. Preserve HTML tables as per the markdown docs.
184
+ # Convert preserving HTML tables as per the markdown docs.
182
185
  def self.html_to_markdown(content)
183
186
  preserve = ["table", "tr", "th", "td"]
184
187
  preserve.each do |tag|
185
188
  content.gsub!(/<#{tag}/i, "$$" + tag)
186
189
  content.gsub!(/<\/#{tag}/i, "||" + tag)
187
190
  end
188
- content = %x[echo '#{content.gsub("'", "''")}' | html2text]
191
+ content = Nokogiri::HTML(content.gsub("'", "''")).text
189
192
  preserve.each do |tag|
190
193
  content.gsub!("$$" + tag, "<" + tag)
191
194
  content.gsub!("||" + tag, "</" + tag)
@@ -32,7 +32,8 @@ module JekyllImport
32
32
  end
33
33
 
34
34
  type = item.at('wp:post_type').inner_text
35
- tags = (item/:category).map{|c| c.inner_text}.reject{|c| c == 'Uncategorized'}.uniq
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
36
37
 
37
38
  metas = Hash.new
38
39
  item.search("wp:postmeta").each do |meta|
@@ -45,6 +46,7 @@ module JekyllImport
45
46
  header = {
46
47
  'layout' => type,
47
48
  'title' => title,
49
+ 'categories' => categories,
48
50
  'tags' => tags,
49
51
  'status' => status,
50
52
  'type' => type,
data/lib/jekyll-import.rb CHANGED
@@ -3,5 +3,5 @@ require 'rubygems'
3
3
  require 'jekyll/commands/import'
4
4
 
5
5
  module JekyllImport
6
- VERSION = '0.1.0.beta2'
6
+ VERSION = '0.1.0.beta3'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-import
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta2
4
+ version: 0.1.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-01 00:00:00.000000000 Z
11
+ date: 2013-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -268,6 +268,7 @@ files:
268
268
  - lib/jekyll/jekyll-import/drupal6.rb
269
269
  - lib/jekyll/jekyll-import/drupal7.rb
270
270
  - lib/jekyll/jekyll-import/enki.rb
271
+ - lib/jekyll/jekyll-import/google_reader.rb
271
272
  - lib/jekyll/jekyll-import/joomla.rb
272
273
  - lib/jekyll/jekyll-import/marley.rb
273
274
  - lib/jekyll/jekyll-import/mephisto.rb