jekyll 0.3.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

Files changed (44) hide show
  1. data/History.txt +25 -0
  2. data/README.textile +93 -23
  3. data/VERSION.yml +4 -0
  4. data/bin/jekyll +9 -0
  5. data/lib/jekyll.rb +7 -3
  6. data/lib/jekyll/converters/mephisto.rb +56 -1
  7. data/lib/jekyll/converters/mt.rb +1 -1
  8. data/lib/jekyll/converters/textpattern.rb +50 -0
  9. data/lib/jekyll/converters/typo.rb +49 -0
  10. data/lib/jekyll/converters/wordpress.rb +9 -8
  11. data/lib/jekyll/convertible.rb +14 -3
  12. data/lib/jekyll/filters.rb +18 -3
  13. data/lib/jekyll/post.rb +9 -5
  14. data/lib/jekyll/site.rb +45 -28
  15. data/lib/jekyll/tags/highlight.rb +20 -4
  16. data/lib/jekyll/tags/include.rb +6 -2
  17. data/test/dest/2008/10/18/foo-bar.html +28 -0
  18. data/test/dest/2008/11/21/complex.html +29 -0
  19. data/test/dest/2008/12/13/include.html +30 -0
  20. data/test/dest/_posts/2008-10-18-foo-bar.html +28 -0
  21. data/test/dest/_posts/2008-11-21-complex.html +29 -0
  22. data/test/dest/_posts/2008-12-03-permalinked-post.html +2 -0
  23. data/test/dest/_posts/2008-12-13-include.html +30 -0
  24. data/test/dest/category/2008/09/23/categories.html +27 -0
  25. data/test/dest/category/_posts/2008-9-23-categories.html +27 -0
  26. data/test/dest/css/screen.css +76 -0
  27. data/test/dest/foo/2008/12/12/topical-post.html +28 -0
  28. data/test/dest/foo/_posts/bar/2008-12-12-topical-post.html +28 -0
  29. data/test/dest/index.html +60 -0
  30. data/test/dest/my_category/permalinked-post +2 -0
  31. data/test/dest/z_category/2008/09/23/categories.html +27 -0
  32. data/test/dest/z_category/_posts/2008-9-23-categories.html +27 -0
  33. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  34. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  35. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  36. data/test/test_filters.rb +37 -0
  37. data/test/test_generated_site.rb +1 -0
  38. data/test/test_post.rb +15 -1
  39. data/test/test_site.rb +5 -2
  40. data/test/test_tags.rb +31 -0
  41. metadata +85 -37
  42. data/Manifest.txt +0 -36
  43. data/Rakefile +0 -24
  44. data/jekyll.gemspec +0 -51
data/History.txt CHANGED
@@ -1,3 +1,28 @@
1
+ ==
2
+ * Minor Enhancements
3
+ * Changed date format on wordpress converter (zeropadding) [github.com/dysinger]
4
+ * Bug Fixes
5
+ * Add jekyll binary as executable to gemspec [github.com/dysinger]
6
+
7
+ == 0.4.0 / 2009-02-03
8
+ * Major Enhancements
9
+ * Switch to Jeweler for packaging tasks
10
+ * Minor Enhancements
11
+ * Type importer [github.com/codeslinger]
12
+ * site.topics accessor [github.com/baz]
13
+ * Add array_to_sentence_string filter [github.com/mchung]
14
+ * Add a converter for textpattern [github.com/PerfectlyNormal]
15
+ * Add a working Mephisto / MySQL converter [github.com/ivey]
16
+ * Allowing .htaccess files to be copied over into the generated site [github.com/briandoll]
17
+ * Add option to not put file date in permalink URL [github.com/mreid]
18
+ * Add line number capabilities to highlight blocks [github.com/jcon]
19
+ * Bug Fixes
20
+ * Fix permalink behavior [github.com/cavalle]
21
+ * Fixed an issue with pygments, markdown, and newlines [github.com/zpinter]
22
+ * Ampersands need to be escaped [github.com/pufuwozu, github.com/ap]
23
+ * Test and fix the site.categories hash [github.com/zzot]
24
+ * Fix site payload available to files [github.com/matrix9180]
25
+
1
26
  == 0.3.0 / 2008-12-24
2
27
  * Major Enhancements
3
28
  * Added --server option to start a simple WEBrick server on destination directory [github.com/johnreilly and github.com/mchung]
data/README.textile CHANGED
@@ -34,7 +34,7 @@ fields such as <code>title</code> and <code>date</code>.
34
34
  Jekyll gets the list of blog posts by parsing the files in any
35
35
  "_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
36
36
  subdirectories below the root.
37
- Each post's filename contains the publishing date and slug (what shows up in the
37
+ Each post's filename contains (by default) the publishing date and slug (what shows up in the
38
38
  URL) that the final HTML file should have. Open up the file corresponding to a
39
39
  blog post:
40
40
  "2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
@@ -145,6 +145,17 @@ Default port is 4000:
145
145
 
146
146
  $ jekyll --server [PORT]
147
147
 
148
+ By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
149
+ format. If you do not wish to have the date appear in the URL of each post,
150
+ you can change the permalink style to 'none' so that only the 'slug' part of
151
+ the filename is used. For example, with the permalink style set to 'none' the
152
+ file '2009-01-01-happy-new-year.markdown' will have a permalink like
153
+ 'http://yoursite.com/happy-new-year.html'. The date of the post will still be
154
+ read from the filename (and is required!) to be used elsewhere in Jekyll.
155
+ Example usage:
156
+
157
+ $ jekyll --permalink none
158
+
148
159
  h2. Data
149
160
 
150
161
  Jekyll traverses your site looking for files to process. Any files with YAML
@@ -286,6 +297,16 @@ becomes
286
297
 
287
298
  1337
288
299
 
300
+ h3. Array to Sentence String
301
+
302
+ Convert an array into a sentence.
303
+
304
+ {{ page.tags | array_to_sentence_string }}
305
+
306
+ becomes
307
+
308
+ foo, bar, and baz
309
+
289
310
  h3. Include (Tag)
290
311
 
291
312
  If you have small page fragments that you wish to include in multiple places
@@ -321,17 +342,33 @@ The argument to <code>highlight</code> is the language identifier. To find the
321
342
  appropriate identifier to use for your favorite language, look for the "short
322
343
  name" on the "Lexers":http://pygments.org/docs/lexers/ page.
323
344
 
345
+ There is a second argument to <code>highlight</code> called
346
+ <code>linenos</code> that is optional. Including the <code>linenos</code>
347
+ argument will force the highlighted code to include line numbers. For
348
+ instance, the following code block would include line numbers next to each
349
+ line:
350
+
351
+ <pre>
352
+ {% highlight ruby linenos %}
353
+ def foo
354
+ puts 'foo'
355
+ end
356
+ {% endhighlight %}
357
+ </pre>
358
+
324
359
  In order for the highlighting to show up, you'll need to include a
325
360
  highlighting stylesheet. For an example stylesheet you can look at
326
361
  "syntax.css":http://github.com/mojombo/tpw/tree/master/css/syntax.css. These
327
362
  are the same styles as used by GitHub and you are free to use them for your
328
- own site.
363
+ own site. If you use linenos, you might want to include an additional CSS
364
+ class definition for <code>lineno</code> in syntax.css to distinguish the line
365
+ numbers from the highlighted code.
329
366
 
330
367
  h2. Categories
331
368
 
332
- Posts are placed into categories based on the directory structure they are found
333
- within (see above for an example). The categories can be accessed from within
334
- a Liquid template as follows:
369
+ Posts are placed into categories based on the directory structure they are
370
+ found within (see above for an example). The categories can be accessed from
371
+ within a Liquid template as follows:
335
372
 
336
373
  <pre>
337
374
  {% for post in site.categories.foo %}
@@ -343,24 +380,6 @@ This would list all the posts in the category 'foo' by date and title.
343
380
 
344
381
  The posts within each category are sorted in reverse chronological order.
345
382
 
346
- h2. Contribute
347
-
348
- If you'd like to hack on Jekyll, grab the source from GitHub. To get
349
- all of the dependencies, install the gem first.
350
-
351
- $ git clone git://github.com/mojombo/jekyll
352
-
353
- The best way to get your changes merged back into core is as follows:
354
-
355
- # Fork mojombo/jekyll on GitHub
356
- # Clone down your fork
357
- # Create a topic branch to contain your change
358
- # Hack away
359
- # Do not change the version number, I will do that on my end
360
- # If necessary, rebase your commits into logical chunks, without errors
361
- # Push the branch up to GitHub
362
- # Send me (mojombo) a pull request for your branch
363
-
364
383
  h2. Blog migrations
365
384
 
366
385
  h3. Movable Type
@@ -379,6 +398,57 @@ You may need to adjust the SQL query used to retrieve MT entries. Left alone,
379
398
  it will attempt to pull all entries across all blogs regardless of status.
380
399
  Please check the results and verify the posts before publishing.
381
400
 
401
+ h3. Typo 4+
402
+
403
+ To migrate your Typo blog into Jekyll, you'll need read access to the MySQL
404
+ database. The lib/jekyll/converters/typo.rb module provides a simple convert
405
+ to create .html, .textile, or .markdown files in a _posts directory based on
406
+ the entries contained therein.
407
+
408
+ $ export DB=my_typo_db
409
+ $ export USER=dbuser
410
+ $ export PASS=dbpass
411
+ $ ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process( \
412
+ "#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
413
+
414
+ You may need to adjust the code used to filter Typo entries. Left alone,
415
+ it will attempt to pull all entries across all blogs that were published.
416
+ This code also has only been tested with Typo version 4+. Previous versions
417
+ of Typo may not convert correctly. Please check the results and verify the
418
+ posts before publishing.
419
+
420
+ h3. TextPattern 4
421
+
422
+ To migrate your TextPattern blog into Jekyll, you'll need read access to the MySQL
423
+ database. The lib/jekyll/converters/textpattern.rb module provides a simple convert to create .textile files in a _posts directory based on
424
+ the entries contained therein.
425
+
426
+ $ ruby -r './lib/jekyll/converters/textpattern' -e 'Jekyll::TextPattern.process( \
427
+ "database_name", "username", "password", "hostname")'
428
+
429
+ The hostname defaults to _localhost_, all other variables are needed
430
+ You may need to adjust the code used to filter entries. Left alone,
431
+ it will attempt to pull all entries that are live or sticky.
432
+
433
+ h2. Contribute
434
+
435
+ If you'd like to hack on Jekyll, start by forking my repo on GitHub:
436
+
437
+ http://github.com/mojombo/jekyll
438
+
439
+ To get all of the dependencies, install the gem first. The best way to get
440
+ your changes merged back into core is as follows:
441
+
442
+ # Clone down your fork
443
+ # Create a topic branch to contain your change
444
+ # Hack away
445
+ # Add tests and make sure everything still passes by running `rake`
446
+ # If you are adding new functionality, document it in README.textile
447
+ # Do not change the version number, I will do that on my end
448
+ # If necessary, rebase your commits into logical chunks, without errors
449
+ # Push the branch up to GitHub
450
+ # Send me (mojombo) a pull request for your branch
451
+
382
452
  h2. License
383
453
 
384
454
  (The MIT License)
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 4
3
+ :patch: 1
4
+ :major: 0
data/bin/jekyll CHANGED
@@ -47,6 +47,15 @@ opts = OptionParser.new do |opts|
47
47
  puts 'You must have the rdiscount gem installed first'
48
48
  end
49
49
  end
50
+
51
+ opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
52
+ Jekyll.permalink_style = (style || 'date').to_sym
53
+ end
54
+
55
+ opts.on("--version", "Display current version") do
56
+ puts "Jekyll " + Jekyll.version
57
+ exit 0
58
+ end
50
59
  end
51
60
 
52
61
  opts.parse!
data/lib/jekyll.rb CHANGED
@@ -43,15 +43,14 @@ require 'jekyll/tags/include'
43
43
  require 'jekyll/albino'
44
44
 
45
45
  module Jekyll
46
- VERSION = '0.3.0'
47
-
48
46
  class << self
49
- attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
47
+ attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc, :content_type, :permalink_style
50
48
  end
51
49
 
52
50
  Jekyll.lsi = false
53
51
  Jekyll.pygments = false
54
52
  Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
53
+ Jekyll.permalink_style = :date
55
54
 
56
55
  def self.process(source, dest)
57
56
  require 'classifier' if Jekyll.lsi
@@ -60,4 +59,9 @@ module Jekyll
60
59
  Jekyll.dest = dest
61
60
  Jekyll::Site.new(source, dest).process
62
61
  end
62
+
63
+ def self.version
64
+ yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
65
+ "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
66
+ end
63
67
  end
@@ -1,7 +1,19 @@
1
+ # Quickly hacked together my Michael Ivey
2
+ # Based on mt.rb by Nick Gerakines, open source and publically
3
+ # available under the MIT license. Use this module at your own risk.
4
+
1
5
  require 'rubygems'
6
+ require 'sequel'
2
7
  require 'fastercsv'
3
8
  require 'fileutils'
4
9
  require File.join(File.dirname(__FILE__),"csv.rb")
10
+
11
+ # NOTE: This converter requires Sequel and the MySQL gems.
12
+ # The MySQL gem can be difficult to install on OS X. Once you have MySQL
13
+ # installed, running the following commands should work:
14
+ # $ sudo gem install sequel
15
+ # $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
16
+
5
17
  module Jekyll
6
18
  module Mephisto
7
19
  #Accepts a hash with database config variables, exports mephisto posts into a csv
@@ -20,5 +32,48 @@ module Jekyll
20
32
  `#{command}`
21
33
  CSV.process
22
34
  end
35
+
36
+ # This query will pull blog posts from all entries across all blogs. If
37
+ # you've got unpublished, deleted or otherwise hidden posts please sift
38
+ # through the created posts to make sure nothing is accidently published.
39
+
40
+ QUERY = "SELECT id, permalink, body, published_at, title FROM contents WHERE user_id = 1 AND type = 'Article' AND published_at IS NOT NULL ORDER BY published_at"
41
+
42
+ def self.process(dbname, user, pass, host = 'localhost')
43
+ db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
44
+
45
+ FileUtils.mkdir_p "_posts"
46
+
47
+ db[QUERY].each do |post|
48
+ title = post[:title]
49
+ slug = post[:permalink]
50
+ date = post[:published_at]
51
+ content = post[:body]
52
+ # more_content = ''
53
+
54
+ # Be sure to include the body and extended body.
55
+ # if more_content != nil
56
+ # content = content + " \n" + more_content
57
+ # end
58
+
59
+ # Ideally, this script would determine the post format (markdown, html
60
+ # , etc) and create files with proper extensions. At this point it
61
+ # just assumes that markdown will be acceptable.
62
+ name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
63
+
64
+ data = {
65
+ 'layout' => 'post',
66
+ 'title' => title.to_s,
67
+ 'mt_id' => post[:entry_id],
68
+ }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
69
+
70
+ File.open("_posts/#{name}", "w") do |f|
71
+ f.puts data
72
+ f.puts "---"
73
+ f.puts content
74
+ end
75
+ end
76
+
77
+ end
23
78
  end
24
- end
79
+ end
@@ -33,7 +33,7 @@ module Jekyll
33
33
 
34
34
  # Be sure to include the body and extended body.
35
35
  if more_content != nil
36
- conent = content + " \n" + more_content
36
+ content = content + " \n" + more_content
37
37
  end
38
38
 
39
39
  # Ideally, this script would determine the post format (markdown, html
@@ -0,0 +1,50 @@
1
+ require 'rubygems'
2
+ require 'sequel'
3
+ require 'fileutils'
4
+
5
+ # NOTE: This converter requires Sequel and the MySQL gems.
6
+ # The MySQL gem can be difficult to install on OS X. Once you have MySQL
7
+ # installed, running the following commands should work:
8
+ # $ sudo gem install sequel
9
+ # $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
10
+
11
+ module Jekyll
12
+ module TextPattern
13
+ # Reads a MySQL database via Sequel and creates a post file for each post.
14
+ # The only posts selected are those with a status of 4 or 5, which means "live"
15
+ # and "sticky" respectively.
16
+ # Other statuses is 1 => draft, 2 => hidden and 3 => pending
17
+ QUERY = "select Title, url_title, Posted, Body, Keywords from textpattern where Status = '4' or Status = '5'"
18
+
19
+ def self.process(dbname, user, pass, host = 'localhost')
20
+ db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
21
+
22
+ FileUtils.mkdir_p "_posts"
23
+
24
+ db[QUERY].each do |post|
25
+ # Get required fields and construct Jekyll compatible name
26
+ title = post[:Title]
27
+ slug = post[:url_title]
28
+ date = post[:Posted]
29
+ content = post[:Body]
30
+
31
+ name = [date.strftime("%Y-%m-%d"), slug].join('-') + ".textile"
32
+
33
+ # Get the relevant fields as a hash, delete empty fields and convert
34
+ # to YAML for the header
35
+ data = {
36
+ 'layout' => 'post',
37
+ 'title' => title.to_s,
38
+ 'tags' => post[:Keywords].split(',')
39
+ }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
40
+
41
+ # Write out the data and content to file
42
+ File.open("_posts/#{name}", "w") do |f|
43
+ f.puts data
44
+ f.puts "---"
45
+ f.puts content
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,49 @@
1
+ # Author: Toby DiPasquale <toby@cbcg.net>
2
+ require 'fileutils'
3
+ require 'rubygems'
4
+ require 'sequel'
5
+
6
+ module Jekyll
7
+ module Typo
8
+ # this SQL *should* work for both MySQL and PostgreSQL, but I haven't
9
+ # tested PostgreSQL yet (as of 2008-12-16)
10
+ SQL = <<-EOS
11
+ SELECT c.id id,
12
+ c.title title,
13
+ c.permalink slug,
14
+ c.body body,
15
+ c.published_at date,
16
+ c.state state,
17
+ COALESCE(tf.name, 'html') filter
18
+ FROM contents c
19
+ LEFT OUTER JOIN text_filters tf
20
+ ON c.text_filter_id = tf.id
21
+ EOS
22
+
23
+ def self.process dbname, user, pass, host='localhost'
24
+ FileUtils.mkdir_p '_posts'
25
+ db = Sequel.mysql dbname, :user => user, :password => pass, :host => host
26
+ db[SQL].each do |post|
27
+ next unless post[:state] =~ /Published/
28
+
29
+ name = [ sprintf("%.04d", post[:date].year),
30
+ sprintf("%.02d", post[:date].month),
31
+ sprintf("%.02d", post[:date].day),
32
+ post[:slug].strip ].join('-')
33
+ # Can have more than one text filter in this field, but we just want
34
+ # the first one for this
35
+ name += '.' + post[:filter].split(' ')[0]
36
+
37
+ File.open("_posts/#{name}", 'w') do |f|
38
+ f.puts({ 'layout' => 'post',
39
+ 'title' => post[:title].to_s,
40
+ 'typo_id' => post[:id]
41
+ }.delete_if { |k, v| v.nil? || v == '' }.to_yaml)
42
+ f.puts '---'
43
+ f.puts post[:body].delete("\r")
44
+ end
45
+ end
46
+ end
47
+
48
+ end # module Typo
49
+ end # module Jekyll
@@ -10,8 +10,8 @@ require 'fileutils'
10
10
 
11
11
  module Jekyll
12
12
  module WordPress
13
-
14
- # Reads a MySQL database via Sequel and creates a post file for each
13
+
14
+ # Reads a MySQL database via Sequel and creates a post file for each
15
15
  # post in wp_posts that has post_status = 'publish'.
16
16
  # This restriction is made because 'draft' posts are not guaranteed to
17
17
  # have valid dates.
@@ -19,20 +19,21 @@ module Jekyll
19
19
 
20
20
  def self.process(dbname, user, pass, host = 'localhost')
21
21
  db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
22
-
22
+
23
23
  FileUtils.mkdir_p "_posts"
24
-
24
+
25
25
  db[QUERY].each do |post|
26
26
  # Get required fields and construct Jekyll compatible name
27
27
  title = post[:post_title]
28
28
  slug = post[:post_name]
29
29
  date = post[:post_date]
30
30
  content = post[:post_content]
31
-
32
- name = [date.year, date.month, date.day, slug].join('-') + ".markdown"
31
+
32
+ name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
33
+ slug]
33
34
 
34
35
  # Get the relevant fields as a hash, delete empty fields and convert
35
- # to YAML for the header
36
+ # to YAML for the header
36
37
  data = {
37
38
  'layout' => 'post',
38
39
  'title' => title.to_s,
@@ -51,4 +52,4 @@ module Jekyll
51
52
 
52
53
  end
53
54
  end
54
- end
55
+ end