jekyll-import 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73973a4031143ccdeea68fe8cabfc7ca023b4e8b
4
- data.tar.gz: dd7ae5ee74214be7467c7a2ca0ebd92ef2db8178
3
+ metadata.gz: 84a8cd9c3d2ec9d745331b9152cb5cfb13e6c6dd
4
+ data.tar.gz: 897e5994d5344b11b717f7ec28db2cbc88bb8300
5
5
  SHA512:
6
- metadata.gz: fe41f15390fec872bd74c8f232f3b2d2c2f355367dbbfc741e8d75351ae46352f3ddd18cbddd35cfca47cd01ac0ecb9880de1f99d3de371f34aa690b9e88cc6f
7
- data.tar.gz: 9d97135a8616376d69646f72ca81a80f1c452964c681e2722e0ff57bc564e74af445803c2479a52550254215a93e078016724cf574fe150d5e23ab5260aee886
6
+ metadata.gz: e25bcb63ee3d7c082cadb08065d16cea5fa11f3790004156cc7584376e33f4d1fb6cbb70811a89b48f472065b255d9b86af4af0071b7dabe7b02ac9d4a121947
7
+ data.tar.gz: df0d984f949b75c495b1810cdfe1d0e6972a95d5842914fcd395fb8e53daf573218f8ccbd3cc2c6ef2c7f86d3b9f21b6539043b4e3952602b22b86f215479392
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ .DS_Store
21
+ Gemfile.lock
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem install bundler
4
+ rvm:
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ script: bundle exec rake
9
+ notifications:
10
+ irc: "irc.freenode.org#jekyll"
11
+ email:
12
+ on_success: never
13
+ on_failure: never
@@ -10,6 +10,33 @@
10
10
 
11
11
  ### Development Fixes
12
12
 
13
+ ## 0.2.0 / 2014-03-16
14
+
15
+ ### Major Enhancements
16
+ * Add comments to MovableType importer (#66)
17
+ * Support auto-paragraph Wordpress convention (#125)
18
+
19
+ ### Minor Enhancements
20
+ * Extract author info from wordpress XML files (#131)
21
+
22
+ ### Bug Fixes
23
+ * Require YAML library in Enki importer (#112)
24
+ * Fix !ruby/string:Sequel::SQL::Blob error in MT excerpts (#113)
25
+ * Drupal6: Ensure post "tags" is "", never nil (#117)
26
+ * Fixes a bug where the Tumblr importer would write posts with `nil`
27
+ content (#118)
28
+ * Change Drupal7 layout to `post` rather than `default` (#124)
29
+ * WordPress: Use explicit `#to_s` when outputting post dates (#129)
30
+
31
+ ### Site Enhancements
32
+ * Fixed error in quickstart code, added required design changes/reflow (#120)
33
+ * Fix example parameter names for Tumblr importer (#122)
34
+ * Add note to WordPress installer docs page that indicates what the importer
35
+ does and doesn't do. (#127)
36
+
37
+ ### Development Fixes
38
+ * Bring gemspec into the 2010's (#130)
39
+
13
40
  ## 0.1.0 / 2013-12-18
14
41
 
15
42
  ### Major Enhancements
data/Rakefile CHANGED
@@ -1,12 +1,5 @@
1
1
  # require 'rake/testtask'
2
2
 
3
- # Rake::TestTask.new do |t|
4
- # t.libs << 'test'
5
- # end
6
-
7
- # desc "Run tests"
8
- # task :default => :test
9
-
10
3
  require 'rubygems'
11
4
  require 'rake'
12
5
  require 'rdoc'
@@ -24,16 +17,7 @@ def name
24
17
  end
25
18
 
26
19
  def version
27
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
28
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
29
- end
30
-
31
- def date
32
- Date.today.to_s
33
- end
34
-
35
- def rubyforge_project
36
- name
20
+ JekyllImport::VERSION
37
21
  end
38
22
 
39
23
  def gemspec_file
@@ -44,10 +28,6 @@ def gem_file
44
28
  "#{name}-#{version}.gem"
45
29
  end
46
30
 
47
- def replace_header(head, header_name)
48
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
49
- end
50
-
51
31
  def normalize_bullets(markdown)
52
32
  markdown.gsub(/\s{2}\*{1}/, "-")
53
33
  end
@@ -165,8 +145,12 @@ namespace :site do
165
145
  file.write(converted_history(history_file))
166
146
  end
167
147
  end
168
- sh "git add site/docs/history.md"
169
- sh "git commit -m 'Updated generated history.md file in the site.'"
148
+ unless `git diff site/docs/history.md`.strip.empty?
149
+ sh "git add site/docs/history.md"
150
+ sh "git commit -m 'Updated generated history.md file in the site.'"
151
+ else
152
+ puts "No updates to commit at this time. Skipping..."
153
+ end
170
154
  else
171
155
  abort "You seem to have misplaced your History.markdown file. I can haz?"
172
156
  end
@@ -218,37 +202,8 @@ task :release => :build do
218
202
  end
219
203
 
220
204
  desc "Build #{gem_file} into the pkg directory"
221
- task :build => :gemspec do
205
+ task :build do
222
206
  sh "mkdir -p pkg"
223
207
  sh "gem build #{gemspec_file}"
224
208
  sh "mv #{gem_file} pkg"
225
209
  end
226
-
227
- desc "Generate #{gemspec_file}"
228
- task :gemspec do
229
- # read spec file and split out manifest section
230
- spec = File.read(gemspec_file)
231
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
232
-
233
- # replace name version and date
234
- replace_header(head, :name)
235
- replace_header(head, :version)
236
- replace_header(head, :date)
237
- #comment this out if your rubyforge_project has a different name
238
- replace_header(head, :rubyforge_project)
239
-
240
- # determine file list from git ls-files
241
- files = `git ls-files`.
242
- split("\n").
243
- sort.
244
- reject { |file| file =~ /^\./ }.
245
- reject { |file| file =~ /^(rdoc|pkg)/ }.
246
- map { |file| " #{file}" }.
247
- join("\n")
248
-
249
- # piece file back together and write
250
- manifest = " s.files = %w[\n#{files}\n ]\n"
251
- spec = [head, manifest, tail].join(" # = MANIFEST =\n")
252
- File.open(gemspec_file, 'w') { |io| io.write(spec) }
253
- puts "Updated #{gemspec_file}"
254
- end
@@ -1,13 +1,17 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jekyll-import/version'
5
+
1
6
  Gem::Specification.new do |s|
2
7
  s.specification_version = 2 if s.respond_to? :specification_version=
3
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
- s.rubygems_version = '1.3.5'
5
- s.required_ruby_version = '>= 1.9.2'
9
+ s.rubygems_version = '2.2.2'
10
+ s.required_ruby_version = '>= 1.9.3'
6
11
 
7
- s.name = 'jekyll-import'
8
- s.version = '0.1.0'
9
- s.date = '2013-12-18'
10
- s.rubyforge_project = 'jekyll-import'
12
+ s.name = 'jekyll-import'
13
+ s.version = JekyllImport::VERSION
14
+ s.license = 'MIT'
11
15
 
12
16
  s.summary = "Import command for Jekyll (static site generator)."
13
17
  s.description = "Provides the Import command for Jekyll."
@@ -15,17 +19,19 @@ Gem::Specification.new do |s|
15
19
  s.authors = ["Tom Preston-Werner"]
16
20
  s.email = 'tom@mojombo.com'
17
21
  s.homepage = 'http://github.com/jekyll/jekyll-import'
18
- s.license = 'MIT'
19
22
 
23
+ s.files = `git ls-files`.split($/)
24
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
26
  s.require_paths = %w[lib]
21
27
 
22
28
  s.rdoc_options = ["--charset=UTF-8"]
23
29
  s.extra_rdoc_files = %w[README.markdown LICENSE]
24
30
 
25
- s.add_runtime_dependency('jekyll', '~> 1.3')
31
+ # runtime dependencies
32
+ s.add_runtime_dependency('jekyll', '~> 1.4')
26
33
  s.add_runtime_dependency('fastercsv')
27
34
  s.add_runtime_dependency('nokogiri')
28
- s.add_runtime_dependency('safe_yaml', '~> 0.9.7')
29
35
 
30
36
  # development dependencies
31
37
  s.add_development_dependency('rake', "~> 10.1.0")
@@ -46,115 +52,8 @@ Gem::Specification.new do |s|
46
52
  s.add_development_dependency('mysql', "~> 2.8")
47
53
  s.add_development_dependency('pg', "~> 0.12")
48
54
  s.add_development_dependency('mysql2', "~> 0.3")
49
- s.add_development_dependency('behance', "~> 0.3.0")
50
-
51
- # = MANIFEST =
52
- s.files = %w[
53
- Gemfile
54
- History.markdown
55
- LICENSE
56
- README.markdown
57
- Rakefile
58
- jekyll-import.gemspec
59
- lib/jekyll-import.rb
60
- lib/jekyll-import/importer.rb
61
- lib/jekyll-import/importers.rb
62
- lib/jekyll-import/importers/behance.rb
63
- lib/jekyll-import/importers/csv.rb
64
- lib/jekyll-import/importers/drupal6.rb
65
- lib/jekyll-import/importers/drupal7.rb
66
- lib/jekyll-import/importers/enki.rb
67
- lib/jekyll-import/importers/ghost.rb
68
- lib/jekyll-import/importers/google_reader.rb
69
- lib/jekyll-import/importers/joomla.rb
70
- lib/jekyll-import/importers/jrnl.rb
71
- lib/jekyll-import/importers/marley.rb
72
- lib/jekyll-import/importers/mephisto.rb
73
- lib/jekyll-import/importers/mt.rb
74
- lib/jekyll-import/importers/posterous.rb
75
- lib/jekyll-import/importers/rss.rb
76
- lib/jekyll-import/importers/s9y.rb
77
- lib/jekyll-import/importers/textpattern.rb
78
- lib/jekyll-import/importers/tumblr.rb
79
- lib/jekyll-import/importers/typo.rb
80
- lib/jekyll-import/importers/wordpress.rb
81
- lib/jekyll-import/importers/wordpressdotcom.rb
82
- lib/jekyll/commands/import.rb
83
- site/.gitignore
84
- site/CNAME
85
- site/README
86
- site/_config.yml
87
- site/_includes/analytics.html
88
- site/_includes/docs_contents.html
89
- site/_includes/docs_contents_mobile.html
90
- site/_includes/docs_option.html
91
- site/_includes/docs_ul.html
92
- site/_includes/footer.html
93
- site/_includes/header.html
94
- site/_includes/news_contents.html
95
- site/_includes/news_contents_mobile.html
96
- site/_includes/news_item.html
97
- site/_includes/primary-nav-items.html
98
- site/_includes/section_nav.html
99
- site/_includes/top.html
100
- site/_layouts/default.html
101
- site/_layouts/docs.html
102
- site/_layouts/news.html
103
- site/_layouts/news_item.html
104
- site/_posts/2013-11-09-jekyll-import-0-1-0-beta4-release.markdown
105
- site/_posts/2013-11-18-jekyll-import-0-1-0-rc1-released.markdown
106
- site/_posts/2013-12-17-jekyll-import-0-1-0-released.markdown
107
- site/css/gridism.css
108
- site/css/normalize.css
109
- site/css/pygments.css
110
- site/css/style.css
111
- site/docs/behance.md
112
- site/docs/contributing.md
113
- site/docs/csv.md
114
- site/docs/drupal6.md
115
- site/docs/drupal7.md
116
- site/docs/enki.md
117
- site/docs/ghost.md
118
- site/docs/google_reader.md
119
- site/docs/history.md
120
- site/docs/index.md
121
- site/docs/installation.md
122
- site/docs/joomla.md
123
- site/docs/jrnl.md
124
- site/docs/marley.md
125
- site/docs/mephisto.md
126
- site/docs/mt.md
127
- site/docs/posterous.md
128
- site/docs/rss.md
129
- site/docs/s9y.md
130
- site/docs/textpattern.md
131
- site/docs/third-party.md
132
- site/docs/tumblr.md
133
- site/docs/typo.md
134
- site/docs/usage.md
135
- site/docs/wordpress.md
136
- site/docs/wordpressdotcom.md
137
- site/favicon.png
138
- site/feed.xml
139
- site/img/article-footer.png
140
- site/img/footer-arrow.png
141
- site/img/footer-logo.png
142
- site/img/logo-2x.png
143
- site/img/octojekyll.png
144
- site/img/tube.png
145
- site/img/tube1x.png
146
- site/index.html
147
- site/js/modernizr-2.5.3.min.js
148
- site/news/index.html
149
- site/news/releases/index.html
150
- test/helper.rb
151
- test/test_jrnl_importer.rb
152
- test/test_mt_importer.rb
153
- test/test_tumblr_importer.rb
154
- test/test_wordpress_importer.rb
155
- test/test_wordpressdotcom_importer.rb
156
- ]
157
- # = MANIFEST =
55
+ s.add_development_dependency('behance', "~> 0.3")
158
56
 
159
- s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
57
+ # site dependencies:
58
+ s.add_development_dependency('launchy', '~> 2.4')
160
59
  end
@@ -6,10 +6,9 @@ require 'colorator'
6
6
 
7
7
  require 'jekyll-import/importer'
8
8
  require 'jekyll-import/importers'
9
+ require 'jekyll-import/util'
9
10
 
10
11
  module JekyllImport
11
- VERSION = '0.1.0'
12
-
13
12
  def self.logger
14
13
  @logger ||= Jekyll::Stevenson.new
15
14
  end
@@ -25,7 +24,7 @@ module JekyllImport
25
24
  name = importer.to_s.split("::").last.downcase
26
25
  commands << name
27
26
  cmd.command(name.to_sym) do |c|
28
- c.syntax "jekyll import #{name} [options]"
27
+ c.syntax "#{name} [options]"
29
28
  importer.specify_options(c)
30
29
  c.action do |_, options|
31
30
  importer.run(options)
@@ -17,10 +17,10 @@ module JekyllImport
17
17
  end
18
18
 
19
19
  def self.run(options = {})
20
- options = stringify_keys(options)
20
+ opts = stringify_keys(options)
21
21
  self.require_deps
22
- self.validate(options) if self.respond_to?(:validate)
23
- self.process(options)
22
+ self.validate(opts) if self.respond_to?(:validate)
23
+ self.process(opts)
24
24
  end
25
25
  end
26
26
  end
@@ -87,7 +87,7 @@ EOF
87
87
  node_id = post[:nid]
88
88
  title = post[:title]
89
89
  content = post[:body]
90
- tags = post.fetch(:tags, '').downcase.strip
90
+ tags = (post[:tags] || '').downcase.strip
91
91
  created = post[:created]
92
92
  time = Time.at(created)
93
93
  is_published = post[:status] == 1
@@ -78,7 +78,7 @@ module JekyllImport
78
78
  # Get the relevant fields as a hash, delete empty fields and convert
79
79
  # to YAML for the header
80
80
  data = {
81
- 'layout' => 'default',
81
+ 'layout' => 'post',
82
82
  'title' => title.to_s,
83
83
  'created' => created,
84
84
  }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
@@ -35,6 +35,7 @@ EOS
35
35
  sequel
36
36
  fileutils
37
37
  pg
38
+ yaml
38
39
  ])
39
40
  end
40
41
 
@@ -18,10 +18,11 @@ module JekyllImport
18
18
 
19
19
  def self.default_options
20
20
  {
21
- :blog_id => nil,
22
- :categories => true,
23
- :dest_encoding => 'utf-8',
24
- :src_encoding => 'utf-8'
21
+ 'blog_id' => nil,
22
+ 'categories' => true,
23
+ 'dest_encoding' => 'utf-8',
24
+ 'src_encoding' => 'utf-8',
25
+ 'comments' => false
25
26
  }
26
27
  end
27
28
 
@@ -54,21 +55,26 @@ module JekyllImport
54
55
  #
55
56
  # Supported options are:
56
57
  #
57
- # :blog_id:: Specify a single MovableType blog to export by providing blog_id.
58
+ # blog_id:: Specify a single MovableType blog to export by providing blog_id.
58
59
  # Default: nil, importer will include posts for all blogs.
59
- # :categories:: If true, save the post's categories in its
60
+ # categories:: If true, save the post's categories in its
60
61
  # YAML front matter. Default: true
61
- # :src_encoding:: Encoding of strings from the database. Default: UTF-8
62
+ # src_encoding:: Encoding of strings from the database. Default: UTF-8
62
63
  # If your output contains mangled characters, set src_encoding to
63
64
  # something appropriate for your database charset.
64
- # :dest_encoding:: Encoding of output strings. Default: UTF-8
65
+ # dest_encoding:: Encoding of output strings. Default: UTF-8
66
+ # comments:: If true, output comments in _comments directory, like the one
67
+ # mentioned at https://github.com/mpalmer/jekyll-static-comments/
65
68
  def self.process(options)
66
- dbname = options.fetch('dbname')
67
- user = options.fetch('user')
68
- pass = options.fetch('password', "")
69
- host = options.fetch('host', "localhost")
69
+ options = default_options.merge(options)
70
70
 
71
- options = default_options.merge(options)
71
+ dbname = options.fetch('dbname')
72
+ user = options.fetch('user')
73
+ pass = options.fetch('password', "")
74
+ host = options.fetch('host', "localhost")
75
+ comments = options.fetch('comments')
76
+
77
+ posts_name_by_id = { } if comments
72
78
 
73
79
  db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
74
80
  post_categories = db[:mt_placement].join(:mt_category, :category_id => :placement_category_id)
@@ -76,7 +82,7 @@ module JekyllImport
76
82
  FileUtils.mkdir_p "_posts"
77
83
 
78
84
  posts = db[:mt_entry]
79
- posts = posts.filter(:entry_blog_id => options[:blog_id]) if options[:blog_id]
85
+ posts = posts.filter(:entry_blog_id => options['blog_id']) if options['blog_id']
80
86
  posts.each do |post|
81
87
  categories = post_categories.filter(
82
88
  :mt_placement__placement_entry_id => post[:entry_id]
@@ -85,9 +91,12 @@ module JekyllImport
85
91
  file_name = post_file_name(post, options)
86
92
 
87
93
  data = post_metadata(post, options)
88
- data['categories'] = categories if !categories.empty? && options[:categories]
94
+ data['categories'] = categories if !categories.empty? && options['categories']
89
95
  yaml_front_matter = data.delete_if { |k,v| v.nil? || v == '' }.to_yaml
90
96
 
97
+ # save post path for comment processing
98
+ posts_name_by_id[data['post_id']] = file_name if comments
99
+
91
100
  content = post_content(post, options)
92
101
 
93
102
  File.open("_posts/#{file_name}", "w") do |f|
@@ -96,6 +105,30 @@ module JekyllImport
96
105
  f.puts encode(content, options)
97
106
  end
98
107
  end
108
+
109
+ # process comment output, if enabled
110
+ if comments
111
+ FileUtils.mkdir_p "_comments"
112
+
113
+ comments = db[:mt_comment]
114
+ comments.each do |comment|
115
+ if posts_name_by_id.has_key?(comment[:comment_entry_id]) # if the entry exists
116
+ dir_name, base_name = comment_file_dir_and_base_name(posts_name_by_id, comment, options)
117
+ FileUtils.mkdir_p "_comments/#{dir_name}"
118
+
119
+ data = comment_metadata(comment, options)
120
+ content = comment_content(comment, options)
121
+ yaml_front_matter = data.delete_if { |k,v| v.nil? || v == '' }.to_yaml
122
+
123
+ File.open("_comments/#{dir_name}/#{base_name}", "w") do |f|
124
+ f.puts yaml_front_matter
125
+ f.puts "---"
126
+ f.puts encode(content, options)
127
+ end
128
+ end
129
+ end
130
+ end
131
+
99
132
  end
100
133
 
101
134
  # Extracts metadata for YAML front matter from post
@@ -104,8 +137,11 @@ module JekyllImport
104
137
  'layout' => 'post',
105
138
  'title' => encode(post[:entry_title], options),
106
139
  'date' => post_date(post).strftime("%Y-%m-%d %H:%M:%S %z"),
107
- 'excerpt' => encode(post[:entry_excerpt], options),
108
- 'mt_id' => post[:entry_id]
140
+ 'excerpt' => encode(post[:entry_excerpt].to_s, options),
141
+ 'mt_id' => post[:entry_id],
142
+ 'blog_id' => post[:entry_blog_id],
143
+ 'post_id' => post[:entry_id], # for link with comments
144
+ 'basename' => post[:entry_basename]
109
145
  }
110
146
  metadata['published'] = false if post[:entry_status] != STATUS_PUBLISHED
111
147
  metadata
@@ -137,9 +173,42 @@ module JekyllImport
137
173
  "#{date.strftime('%Y-%m-%d')}-#{slug}.#{file_ext}"
138
174
  end
139
175
 
176
+ # Extracts metadata for YAML front matter from comment
177
+ def self.comment_metadata(comment, options = default_options)
178
+ metadata = {
179
+ 'layout' => 'comment',
180
+ 'comment_id' => comment[:comment_id],
181
+ 'post_id' => comment[:comment_entry_id],
182
+ 'author' => encode(comment[:comment_author], options),
183
+ 'email' => comment[:comment_email],
184
+ 'commenter_id' => comment[:comment_commenter_id],
185
+ 'date' => comment_date(comment).strftime("%Y-%m-%d %H:%M:%S %z"),
186
+ 'visible' => comment[:comment_visible] == 1,
187
+ 'ip' => comment[:comment_ip],
188
+ 'url' => comment[:comment_url]
189
+ }
190
+ metadata
191
+ end
192
+
193
+ # Different versions of MT used different column names
194
+ def self.comment_date(comment)
195
+ comment[:comment_modified_on] || comment[:comment_created_on]
196
+ end
197
+
198
+ def self.comment_content(comment, options = default_options)
199
+ comment[:comment_text]
200
+ end
201
+
202
+ def self.comment_file_dir_and_base_name(posts_name_by_id, comment, options = default_options)
203
+ post_basename = posts_name_by_id[comment[:comment_entry_id]].sub(/\.\w+$/, '')
204
+ comment_id = comment[:comment_id]
205
+
206
+ [post_basename, "#{comment_id}.markdown"]
207
+ end
208
+
140
209
  def self.encode(str, options = default_options)
141
210
  if str.respond_to?(:encoding)
142
- str.encode(options[:dest_encoding], options[:src_encoding])
211
+ str.encode(options['dest_encoding'], options['src_encoding'])
143
212
  else
144
213
  str
145
214
  end