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
@@ -10,6 +10,7 @@ module Jekyll
10
10
  :drupal7 => 'Drupal7',
11
11
  :enki => 'Enki',
12
12
  :joomla => 'Joomla',
13
+ :jrnl => 'Jrnl',
13
14
  :google_reader => 'GoogleReader',
14
15
  :marley => 'Marley',
15
16
  :mephisto => 'Mephisto',
data/test/helper.rb CHANGED
@@ -15,10 +15,12 @@ unless defined?(Test::Unit::AssertionFailedError)
15
15
  end
16
16
  end
17
17
 
18
- Dir.glob(File.expand_path('../../lib/jekyll/jekyll-import/*', __FILE__)).each do |f|
18
+ Dir.glob(File.expand_path('../../lib/*.rb', __FILE__)).each do |f|
19
19
  require f
20
20
  end
21
21
 
22
+ include JekyllImport
23
+
22
24
  # Send STDERR into the void to suppress program output messages
23
25
  STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
24
26
 
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+ require 'time'
3
+
4
+ class TestJrnlMigrator < Test::Unit::TestCase
5
+
6
+ context "jrnl" do
7
+ setup do
8
+ @journal = "2013-09-24 11:36 jrnl test case 1.\nThis is a test case for jekyll-import."
9
+ @entries = @journal.split("\n\n")
10
+ @entry = @entries.first.split("\n")
11
+ @date_length = Time.now().strftime("%Y-%m-%d %H:%M").length
12
+ end
13
+
14
+ should "have posts" do
15
+ assert_equal(1, @entries.size)
16
+ end
17
+
18
+ should "have content" do
19
+ assert_equal("This is a test case for jekyll-import.", Importers::Jrnl.get_post_content(@entry))
20
+ end
21
+
22
+ should "have date" do
23
+ assert_equal("2013-09-24 11:36", Importers::Jrnl.get_date(@entry[0], @date_length))
24
+ end
25
+
26
+ should "have title" do
27
+ assert_equal("jrnl test case 1.", Importers::Jrnl.get_title(@entry[0], @date_length))
28
+ end
29
+
30
+ should "have slug" do
31
+ assert_equal("jrnl-test-case-1", Importers::Jrnl.create_slug(Importers::Jrnl.get_title(@entry[0], @date_length)))
32
+ end
33
+
34
+ should "have filename" do
35
+ assert_equal("2013-09-24-jrnl-test-case-1.md", Importers::Jrnl.create_filename(Importers::Jrnl.get_date(@entry[0], @date_length), Importers::Jrnl.create_slug(Importers::Jrnl.get_title(@entry[0], @date_length)), 'md'))
36
+ end
37
+
38
+ end
39
+ end
@@ -8,7 +8,7 @@ class TestMTMigrator < Test::Unit::TestCase
8
8
  {
9
9
  :entry_id => 1,
10
10
  :entry_blog_id => 1,
11
- :entry_status => JekyllImport::MT::STATUS_PUBLISHED,
11
+ :entry_status => Importers::MT::STATUS_PUBLISHED,
12
12
  :entry_author_id => 1,
13
13
  :entry_allow_comments => 0,
14
14
  :entry_allow_pings => 0,
@@ -38,67 +38,67 @@ class TestMTMigrator < Test::Unit::TestCase
38
38
  end
39
39
 
40
40
  should "set layout to post" do
41
- assert_equal("post", JekyllImport::MT.post_metadata(stub_entry_row)["layout"])
41
+ assert_equal("post", Importers::MT.post_metadata(stub_entry_row)["layout"])
42
42
  end
43
43
 
44
44
  should "extract authored_on as date, formatted as 'YYYY-MM-DD HH:MM:SS Z'" do
45
45
  post = stub_entry_row
46
46
  expected_date = post[:entry_authored_on].strftime('%Y-%m-%d %H:%M:%S %z')
47
- assert_equal(expected_date, JekyllImport::MT.post_metadata(post)["date"])
47
+ assert_equal(expected_date, Importers::MT.post_metadata(post)["date"])
48
48
  end
49
49
 
50
50
  should "extract entry_excerpt as excerpt" do
51
51
  post = stub_entry_row
52
- assert_equal(post[:entry_excerpt], JekyllImport::MT.post_metadata(post)["excerpt"])
52
+ assert_equal(post[:entry_excerpt], Importers::MT.post_metadata(post)["excerpt"])
53
53
  end
54
54
 
55
55
  should "extract entry_id as mt_id" do
56
56
  post = stub_entry_row(:entry_id => 123)
57
- assert_equal(123, JekyllImport::MT.post_metadata(post)["mt_id"])
57
+ assert_equal(123, Importers::MT.post_metadata(post)["mt_id"])
58
58
  end
59
59
 
60
60
  should "extract entry_title as title" do
61
61
  post = stub_entry_row
62
- assert_equal(post[:entry_title], JekyllImport::MT.post_metadata(post)["title"])
62
+ assert_equal(post[:entry_title], Importers::MT.post_metadata(post)["title"])
63
63
  end
64
64
 
65
65
  should "set published to false if entry_status is not published" do
66
- post = stub_entry_row(:entry_status => JekyllImport::MT::STATUS_DRAFT)
67
- assert_equal(false, JekyllImport::MT.post_metadata(post)["published"])
66
+ post = stub_entry_row(:entry_status => Importers::MT::STATUS_DRAFT)
67
+ assert_equal(false, Importers::MT.post_metadata(post)["published"])
68
68
  end
69
69
 
70
70
  should "not set published if entry_status is published" do
71
- post = stub_entry_row(:entry_status => JekyllImport::MT::STATUS_PUBLISHED)
72
- assert_equal(nil, JekyllImport::MT.post_metadata(post)["published"])
71
+ post = stub_entry_row(:entry_status => Importers::MT::STATUS_PUBLISHED)
72
+ assert_equal(nil, Importers::MT.post_metadata(post)["published"])
73
73
  end
74
74
 
75
75
  should "include entry_text" do
76
76
  post = stub_entry_row
77
- assert JekyllImport::MT.post_content(post).include?(post[:entry_text])
77
+ assert Importers::MT.post_content(post).include?(post[:entry_text])
78
78
  end
79
79
 
80
80
  should "include entry_text_more" do
81
81
  post = stub_entry_row
82
- assert JekyllImport::MT.post_content(post).include?(post[:entry_text_more])
82
+ assert Importers::MT.post_content(post).include?(post[:entry_text_more])
83
83
  end
84
84
 
85
85
  should "include a <!--MORE--> separator when there is entry_text_more" do
86
86
  post = stub_entry_row(:entry_text_more => "Some more entry")
87
- assert JekyllImport::MT.post_content(post).include?(JekyllImport::MT::MORE_CONTENT_SEPARATOR)
87
+ assert Importers::MT.post_content(post).include?(Importers::MT::MORE_CONTENT_SEPARATOR)
88
88
  end
89
89
 
90
90
  should "not include a <!--MORE--> separator when there is no entry_text_more" do
91
91
  post = stub_entry_row(:entry_text_more => "")
92
- assert !JekyllImport::MT.post_content(post).include?(JekyllImport::MT::MORE_CONTENT_SEPARATOR)
92
+ assert !Importers::MT.post_content(post).include?(Importers::MT::MORE_CONTENT_SEPARATOR)
93
93
  end
94
94
 
95
95
  should "include the entry_authored_on date in the file name" do
96
96
  post = stub_entry_row(:entry_authored_on => Time.parse("2013-01-02 00:00:00 -00:00").utc)
97
- assert JekyllImport::MT.post_file_name(post).include?("2013-01-02")
97
+ assert Importers::MT.post_file_name(post).include?("2013-01-02")
98
98
  end
99
99
 
100
100
  should "include entry_basename in the file name" do
101
101
  post = stub_entry_row(:entry_basename => "my_blog-entry")
102
- assert JekyllImport::MT.post_file_name(post).include?("my_blog-entry")
102
+ assert Importers::MT.post_file_name(post).include?("my_blog-entry")
103
103
  end
104
104
  end
@@ -0,0 +1,61 @@
1
+ require 'helper'
2
+ require 'json'
3
+
4
+ class TestTumblrImporter < Test::Unit::TestCase
5
+
6
+ context "A Tumblr blog" do
7
+ setup do
8
+ Importers::Tumblr.require_deps
9
+ @jsonPayload = '{"tumblelog":{"title":"JekyllImport","description":"Jekyll Importer Test.","name":"JekyllImport","timezone":"Canada\/Atlantic","cname":"https://github.com/jekyll/jekyll-import/","feeds":[]},"posts-start":0,"posts-total":"1","posts-type":false,"posts":[{"id":54759400073,"url":"https:\/\/github.com\/post\/54759400073","url-with-slug":"http:\/\/github.com\/post\/54759400073\/jekyll-test","type":"regular","date-gmt":"2013-07-06 16:27:23 GMT","date":"Sat, 06 Jul 2013 13:27:23","bookmarklet":null,"mobile":null,"feed-item":"","from-feed-id":0,"unix-timestamp":1373128043,"format":"html","reblog-key":"0L6yPcHr","slug":"jekyll-test","regular-title":"Jekyll: Test","regular-body":"<p>Testing...<\/p>","tags":["jekyll"]}]}'
10
+ @posts = JSON.parse(@jsonPayload)
11
+ end
12
+
13
+ should "have a post" do
14
+ assert_equal(1, @posts["posts"].size)
15
+ end
16
+
17
+ should "have a regular post" do
18
+ assert_equal("regular", @posts['posts'][0]['type'])
19
+ end
20
+
21
+ should "convert post into hash" do
22
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
23
+ refute_nil(batch, "a batch with a valid post should exist")
24
+ end
25
+
26
+ should "have a hash with a valid name" do
27
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
28
+ assert_equal("2013-07-06-jekyll-test.html", batch[0][:name])
29
+ end
30
+
31
+ should "have a hash with a valid layout" do
32
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
33
+ assert_equal("post", batch[0][:header]['layout'])
34
+ end
35
+
36
+ should "have a hash with a valid title" do
37
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
38
+ assert_equal("Jekyll: Test", batch[0][:header]['title'])
39
+ end
40
+
41
+ should "have a hash with valid tags" do
42
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
43
+ assert_equal("jekyll", batch[0][:header]['tags'][0])
44
+ end
45
+
46
+ should "have a hash with valid content" do
47
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
48
+ assert_equal("<p>Testing...</p>", batch[0][:content])
49
+ end
50
+
51
+ should "have a hash with a valid url" do
52
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
53
+ assert_equal("https://github.com/post/54759400073", batch[0][:url])
54
+ end
55
+
56
+ should "have a hash with a valid slug" do
57
+ batch = @posts["posts"].map { |post| Importers::Tumblr.post_to_hash(post, 'html') }
58
+ assert_equal("http://github.com/post/54759400073/jekyll-test", batch[0][:slug])
59
+ end
60
+ end
61
+ end
@@ -4,6 +4,6 @@ require 'htmlentities'
4
4
  class TestWordpressMigrator < Test::Unit::TestCase
5
5
  should "clean slashes from slugs" do
6
6
  test_title = "blogs part 1/2"
7
- assert_equal("blogs-part-1-2", JekyllImport::WordPress.sluggify(test_title))
7
+ assert_equal("blogs-part-1-2", Importers::WordPress.sluggify(test_title))
8
8
  end
9
9
  end
@@ -3,6 +3,6 @@ require 'helper'
3
3
  class TestWordpressDotComMigrator < Test::Unit::TestCase
4
4
  should "clean slashes from slugs" do
5
5
  test_title = "blogs part 1/2"
6
- assert_equal("blogs-part-1-2", JekyllImport::WordpressDotCom.sluggify(test_title))
6
+ assert_equal("blogs-part-1-2", Importers::WordpressDotCom.sluggify(test_title))
7
7
  end
8
8
  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.beta3
4
+ version: 0.1.0.beta4
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-14 00:00:00.000000000 Z
11
+ date: 2013-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,40 +16,40 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fastercsv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 0.7.0
61
+ version: 0.9.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 0.7.0
68
+ version: 0.9.7
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: 10.0.3
75
+ version: 10.1.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
- version: 10.0.3
82
+ version: 10.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rdoc
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - ~>
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0.12'
251
+ - !ruby/object:Gem::Dependency
252
+ name: mysql2
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ~>
256
+ - !ruby/object:Gem::Version
257
+ version: '0.3'
258
+ type: :development
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - ~>
263
+ - !ruby/object:Gem::Version
264
+ version: '0.3'
251
265
  description: Provides the Import command for Jekyll.
252
266
  email: tom@mojombo.com
253
267
  executables: []
@@ -263,29 +277,34 @@ files:
263
277
  - Rakefile
264
278
  - jekyll-import.gemspec
265
279
  - lib/jekyll-import.rb
280
+ - lib/jekyll-import/importer.rb
281
+ - lib/jekyll-import/importers.rb
282
+ - lib/jekyll-import/importers/csv.rb
283
+ - lib/jekyll-import/importers/drupal6.rb
284
+ - lib/jekyll-import/importers/drupal7.rb
285
+ - lib/jekyll-import/importers/enki.rb
286
+ - lib/jekyll-import/importers/google_reader.rb
287
+ - lib/jekyll-import/importers/joomla.rb
288
+ - lib/jekyll-import/importers/jrnl.rb
289
+ - lib/jekyll-import/importers/marley.rb
290
+ - lib/jekyll-import/importers/mephisto.rb
291
+ - lib/jekyll-import/importers/mt.rb
292
+ - lib/jekyll-import/importers/posterous.rb
293
+ - lib/jekyll-import/importers/rss.rb
294
+ - lib/jekyll-import/importers/s9y.rb
295
+ - lib/jekyll-import/importers/textpattern.rb
296
+ - lib/jekyll-import/importers/tumblr.rb
297
+ - lib/jekyll-import/importers/typo.rb
298
+ - lib/jekyll-import/importers/wordpress.rb
299
+ - lib/jekyll-import/importers/wordpressdotcom.rb
266
300
  - lib/jekyll/commands/import.rb
267
- - lib/jekyll/jekyll-import/csv.rb
268
- - lib/jekyll/jekyll-import/drupal6.rb
269
- - lib/jekyll/jekyll-import/drupal7.rb
270
- - lib/jekyll/jekyll-import/enki.rb
271
- - lib/jekyll/jekyll-import/google_reader.rb
272
- - lib/jekyll/jekyll-import/joomla.rb
273
- - lib/jekyll/jekyll-import/marley.rb
274
- - lib/jekyll/jekyll-import/mephisto.rb
275
- - lib/jekyll/jekyll-import/mt.rb
276
- - lib/jekyll/jekyll-import/posterous.rb
277
- - lib/jekyll/jekyll-import/rss.rb
278
- - lib/jekyll/jekyll-import/s9y.rb
279
- - lib/jekyll/jekyll-import/textpattern.rb
280
- - lib/jekyll/jekyll-import/tumblr.rb
281
- - lib/jekyll/jekyll-import/typo.rb
282
- - lib/jekyll/jekyll-import/wordpress.rb
283
- - lib/jekyll/jekyll-import/wordpressdotcom.rb
284
301
  - test/helper.rb
302
+ - test/test_jrnl_importer.rb
285
303
  - test/test_mt_importer.rb
304
+ - test/test_tumblr_importer.rb
286
305
  - test/test_wordpress_importer.rb
287
306
  - test/test_wordpressdotcom_importer.rb
288
- homepage: http://github.com/mojombo/jekyll-import
307
+ homepage: http://github.com/jekyll/jekyll-import
289
308
  licenses: []
290
309
  metadata: {}
291
310
  post_install_message:
@@ -295,12 +314,12 @@ require_paths:
295
314
  - lib
296
315
  required_ruby_version: !ruby/object:Gem::Requirement
297
316
  requirements:
298
- - - ! '>='
317
+ - - '>='
299
318
  - !ruby/object:Gem::Version
300
319
  version: 1.9.2
301
320
  required_rubygems_version: !ruby/object:Gem::Requirement
302
321
  requirements:
303
- - - ! '>'
322
+ - - '>'
304
323
  - !ruby/object:Gem::Version
305
324
  version: 1.3.1
306
325
  requirements: []
@@ -310,6 +329,8 @@ signing_key:
310
329
  specification_version: 2
311
330
  summary: Import command for Jekyll (static site generator).
312
331
  test_files:
332
+ - test/test_jrnl_importer.rb
313
333
  - test/test_mt_importer.rb
334
+ - test/test_tumblr_importer.rb
314
335
  - test/test_wordpress_importer.rb
315
336
  - test/test_wordpressdotcom_importer.rb
@@ -1,30 +0,0 @@
1
- require "csv"
2
-
3
- module JekyllImport
4
- module CSV
5
- # Reads a csv with title, permalink, body, published_at, and filter.
6
- # It creates a post file for each row in the csv
7
- def self.process(options)
8
- file = options[:file] || "posts.csv"
9
- FileUtils.mkdir_p "_posts"
10
- posts = 0
11
- abort "Cannot find the file '#{file}'. Aborting." unless File.file?(file)
12
- ::CSV.foreach(file) do |row|
13
- next if row[0] == "title"
14
- posts += 1
15
- name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
16
- File.open("_posts/#{name}", "w") do |f|
17
- f.puts <<-HEADER
18
- ---
19
- layout: post
20
- title: #{row[0]}
21
- ---
22
-
23
- HEADER
24
- f.puts row[2]
25
- end
26
- end
27
- "Created #{posts} posts!"
28
- end
29
- end
30
- end