jekyll 0.1.4 → 0.1.5

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.

@@ -1,3 +1,13 @@
1
+ == 0.1.5 / 2008-12-12
2
+ * Major Features
3
+ * Code highlighting with Pygments if --pygments is specified
4
+ * Disable true LSI by default, enable with --lsi
5
+ * Minor Enhancements
6
+ * Output informative message if RDiscount is not available [github.com/JackDanger]
7
+ * Bug Fixes
8
+ * Prevent Jekyll from picking up the output directory as a source [github.com/JackDanger]
9
+ * Skip related_posts when there is only one post [github.com/JackDanger]
10
+
1
11
  == 0.1.4 / 2008-12-08
2
12
  * Bug Fixes
3
13
  * DATA does not work properly with rubygems
@@ -5,11 +5,12 @@ Rakefile
5
5
  bin/jekyll
6
6
  jekyll.gemspec
7
7
  lib/jekyll.rb
8
- lib/jekyll/convertible.rb
8
+ lib/jekyll/albino.rb
9
+ lib/jekyll/blocks.rb
9
10
  lib/jekyll/converters/csv.rb
10
11
  lib/jekyll/converters/mephisto.rb
12
+ lib/jekyll/convertible.rb
11
13
  lib/jekyll/filters.rb
12
- lib/jekyll/blocks.rb
13
14
  lib/jekyll/layout.rb
14
15
  lib/jekyll/page.rb
15
16
  lib/jekyll/post.rb
@@ -21,6 +22,7 @@ test/source/_posts/2008-10-18-foo-bar.textile
21
22
  test/source/_posts/2008-11-21-complex.textile
22
23
  test/source/css/screen.css
23
24
  test/source/index.html
25
+ test/source/posts/2008-12-03-permalinked-post.textile
24
26
  test/suite.rb
25
27
  test/test_jekyll.rb
26
28
  test/test_post.rb
@@ -38,10 +38,18 @@ h2. Run
38
38
  $ cd /path/to/proto/site
39
39
  $ jekyll
40
40
 
41
- This will generate the site and place it in /path/to/proto/site/_site. There is an autobuild feature that will regenerate your site if any of the files change:
41
+ This will generate the site and place it in /path/to/proto/site/_site.
42
+
43
+ There is an autobuild feature that will regenerate your site if any of the files change:
42
44
 
43
45
  $ jekyll --auto
44
46
 
47
+ By default, the "related posts" functionality will produce crappy results.
48
+ In order to get high quality results with a true LSI algorithm, you must
49
+ enable it (it may take some time to run if you have many posts):
50
+
51
+ $ jekyll --lsi
52
+
45
53
  If you'd like the generated site placed somewhere else:
46
54
 
47
55
  $ jekyll /path/to/place/generated/site
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'lib/jekyll'
5
5
  Hoe.new('jekyll', Jekyll::VERSION) do |p|
6
6
  p.developer('Tom Preston-Werner', 'tom@mojombo.com')
7
7
  p.summary = "Jekyll is a simple, blog aware, static site generator."
8
- p.extra_deps = ['RedCloth', 'liquid', 'classifier', 'rdiscount', 'directory_watcher']
8
+ p.extra_deps = ['RedCloth', 'liquid', 'classifier', 'rdiscount', 'directory_watcher', 'open4']
9
9
  end
10
10
 
11
11
  desc "Open an irb session preloaded with this library"
data/bin/jekyll CHANGED
@@ -24,6 +24,14 @@ opts = OptionParser.new do |opts|
24
24
  opts.on("--auto", "Auto-regenerate") do
25
25
  options[:auto] = true
26
26
  end
27
+
28
+ opts.on("--lsi", "Use LSI for better related posts") do
29
+ Jekyll.lsi = true
30
+ end
31
+
32
+ opts.on("--pygments", "Use pygments to highlight code") do
33
+ Jekyll.pygments = true
34
+ end
27
35
  end
28
36
 
29
37
  opts.parse!
@@ -1,15 +1,15 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{jekyll}
3
- s.version = "0.1.4"
3
+ s.version = "0.1.5"
4
4
 
5
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
6
  s.authors = ["Tom Preston-Werner"]
7
- s.date = %q{2008-12-06}
7
+ s.date = %q{2008-12-12}
8
8
  s.default_executable = %q{jekyll}
9
9
  s.email = ["tom@mojombo.com"]
10
10
  s.executables = ["jekyll"]
11
11
  s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
12
- s.files = ["History.txt", "Manifest.txt", "README.textile", "Rakefile", "bin/jekyll", "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/convertible.rb", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/filters.rb", "lib/jekyll/blocks.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "test/helper.rb", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/css/screen.css", "test/source/index.html", "test/suite.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
12
+ s.files = ["History.txt", "Manifest.txt", "README.textile", "Rakefile", "bin/jekyll", "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/blocks.rb", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/convertible.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "test/helper.rb", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/css/screen.css", "test/source/index.html", "test/source/posts/2008-12-03-permalinked-post.textile", "test/suite.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
13
13
  s.has_rdoc = true
14
14
  s.rdoc_options = ["--main", "README.txt"]
15
15
  s.require_paths = ["lib"]
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  s.add_runtime_dependency(%q<classifier>, [">= 0"])
29
29
  s.add_runtime_dependency(%q<rdiscount>, [">= 0"])
30
30
  s.add_runtime_dependency(%q<directory_watcher>, [">= 0"])
31
+ s.add_runtime_dependency(%q<open4>, [">= 0"])
31
32
  s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
32
33
  else
33
34
  s.add_dependency(%q<RedCloth>, [">= 0"])
@@ -35,6 +36,7 @@ Gem::Specification.new do |s|
35
36
  s.add_dependency(%q<classifier>, [">= 0"])
36
37
  s.add_dependency(%q<rdiscount>, [">= 0"])
37
38
  s.add_dependency(%q<directory_watcher>, [">= 0"])
39
+ s.add_dependency(%q<open4>, [">= 0"])
38
40
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
39
41
  end
40
42
  else
@@ -43,6 +45,7 @@ Gem::Specification.new do |s|
43
45
  s.add_dependency(%q<classifier>, [">= 0"])
44
46
  s.add_dependency(%q<rdiscount>, [">= 0"])
45
47
  s.add_dependency(%q<directory_watcher>, [">= 0"])
48
+ s.add_dependency(%q<open4>, [">= 0"])
46
49
  s.add_dependency(%q<hoe>, [">= 1.8.0"])
47
50
  end
48
51
  end
@@ -12,7 +12,11 @@ require 'time'
12
12
  # 3rd party
13
13
  require 'liquid'
14
14
  require 'redcloth'
15
- require 'rdiscount' rescue puts "The rdiscount gem is required for markdown support!"
15
+ begin
16
+ require 'rdiscount'
17
+ rescue LoadError
18
+ puts "The rdiscount gem is required for markdown support!"
19
+ end
16
20
  require 'classifier'
17
21
  require 'directory_watcher'
18
22
 
@@ -24,11 +28,19 @@ require 'jekyll/page'
24
28
  require 'jekyll/post'
25
29
  require 'jekyll/filters'
26
30
  require 'jekyll/blocks'
31
+ require 'jekyll/albino'
27
32
 
28
33
  module Jekyll
29
- VERSION = '0.1.4'
34
+ VERSION = '0.1.5'
35
+
36
+ class << self
37
+ attr_accessor :lsi, :pygments
38
+ end
39
+
40
+ Jekyll.lsi = false
41
+ Jekyll.pygments = false
30
42
 
31
43
  def self.process(source, dest)
32
44
  Jekyll::Site.new(source, dest).process
33
45
  end
34
- end
46
+ end
@@ -0,0 +1,116 @@
1
+ ##
2
+ # Wrapper for the Pygments command line tool, pygmentize.
3
+ #
4
+ # Pygments: http://pygments.org/
5
+ #
6
+ # Assumes pygmentize is in the path. If not, set its location
7
+ # with Albino.bin = '/path/to/pygmentize'
8
+ #
9
+ # Use like so:
10
+ #
11
+ # @syntaxer = Albino.new('/some/file.rb', :ruby)
12
+ # puts @syntaxer.colorize
13
+ #
14
+ # This'll print out an HTMLized, Ruby-highlighted version
15
+ # of '/some/file.rb'.
16
+ #
17
+ # To use another formatter, pass it as the third argument:
18
+ #
19
+ # @syntaxer = Albino.new('/some/file.rb', :ruby, :bbcode)
20
+ # puts @syntaxer.colorize
21
+ #
22
+ # You can also use the #colorize class method:
23
+ #
24
+ # puts Albino.colorize('/some/file.rb', :ruby)
25
+ #
26
+ # Another also: you get a #to_s, for somewhat nicer use in Rails views.
27
+ #
28
+ # ... helper file ...
29
+ # def highlight(text)
30
+ # Albino.new(text, :ruby)
31
+ # end
32
+ #
33
+ # ... view file ...
34
+ # <%= highlight text %>
35
+ #
36
+ # The default lexer is 'text'. You need to specify a lexer yourself;
37
+ # because we are using STDIN there is no auto-detect.
38
+ #
39
+ # To see all lexers and formatters available, run `pygmentize -L`.
40
+ #
41
+ # Chris Wanstrath // chris@ozmm.org
42
+ # GitHub // http://github.com
43
+ #
44
+ require 'open4'
45
+
46
+ class Albino
47
+ @@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
48
+
49
+ def self.bin=(path)
50
+ @@bin = path
51
+ end
52
+
53
+ def self.colorize(*args)
54
+ new(*args).colorize
55
+ end
56
+
57
+ def initialize(target, lexer = :text, format = :html)
58
+ @target = File.exists?(target) ? File.read(target) : target rescue target
59
+ @options = { :l => lexer, :f => format }
60
+ end
61
+
62
+ def execute(command)
63
+ pid, stdin, stdout, stderr = Open4.popen4(command)
64
+ stdin.puts @target
65
+ stdin.close
66
+ stdout.read.strip
67
+ end
68
+
69
+ def colorize(options = {})
70
+ execute @@bin + convert_options(options)
71
+ end
72
+ alias_method :to_s, :colorize
73
+
74
+ def convert_options(options = {})
75
+ @options.merge(options).inject('') do |string, (flag, value)|
76
+ string + " -#{flag} #{value}"
77
+ end
78
+ end
79
+ end
80
+
81
+ if $0 == __FILE__
82
+ require 'rubygems'
83
+ require 'test/spec'
84
+ require 'mocha'
85
+ begin require 'redgreen'; rescue LoadError; end
86
+
87
+ context "Albino" do
88
+ setup do
89
+ @syntaxer = Albino.new(__FILE__, :ruby)
90
+ end
91
+
92
+ specify "defaults to text" do
93
+ syntaxer = Albino.new(__FILE__)
94
+ syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
95
+ syntaxer.colorize
96
+ end
97
+
98
+ specify "accepts options" do
99
+ @syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
100
+ @syntaxer.colorize
101
+ end
102
+
103
+ specify "works with strings" do
104
+ syntaxer = Albino.new('class New; end', :ruby)
105
+ assert_match %r(highlight), syntaxer.colorize
106
+ end
107
+
108
+ specify "aliases to_s" do
109
+ assert_equal @syntaxer.colorize, @syntaxer.to_s
110
+ end
111
+
112
+ specify "class method colorize" do
113
+ assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
114
+ end
115
+ end
116
+ end
@@ -1,4 +1,5 @@
1
1
  module Jekyll
2
+
2
3
  class Highlight < Liquid::Block
3
4
  include Liquid::StandardFilters
4
5
 
@@ -8,15 +9,29 @@ module Jekyll
8
9
  end
9
10
 
10
11
  def render(context)
11
- #The div is required because RDiscount blows ass
12
+ if Jekyll.pygments
13
+ render_pygments(context, super.to_s)
14
+ else
15
+ render_codehighlighter(context, super.to_s)
16
+ end
17
+ end
18
+
19
+ def render_pygments(context, code)
20
+ "<notextile>" + Albino.new(code, @lang).to_s + "</notextile>"
21
+ end
22
+
23
+ def render_codehighlighter(context, code)
24
+ #The div is required because RDiscount blows ass
12
25
  <<-HTML
13
26
  <div>
14
27
  <pre>
15
- <code class='#{@lang}'>#{h(super.to_s).strip}</code>
28
+ <code class='#{@lang}'>#{h(code).strip}</code>
16
29
  </pre>
17
30
  </div>
18
31
  HTML
19
- end
32
+ end
20
33
  end
34
+
21
35
  end
36
+
22
37
  Liquid::Template.register_tag('highlight', Jekyll::Highlight)
@@ -34,7 +34,7 @@ module Jekyll
34
34
  end
35
35
  end
36
36
 
37
- # Add any necessary layouts to this post
37
+ # Add any necessary layouts to this convertible document
38
38
  # +layouts+ is a Hash of {"name" => "layout"}
39
39
  # +site_payload+ is the site payload hash
40
40
  #
@@ -42,7 +42,6 @@ module Jekyll
42
42
  def do_layout(payload, layouts, site_payload)
43
43
  # construct payload
44
44
  payload = payload.merge(site_payload)
45
-
46
45
  # render content
47
46
  self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
48
47
  self.transform
@@ -60,4 +59,4 @@ module Jekyll
60
59
  end
61
60
  end
62
61
  end
63
- end
62
+ end
@@ -9,7 +9,7 @@ module Jekyll
9
9
  # Initialize a new Page.
10
10
  # +base+ is the String path to the <source>
11
11
  # +dir+ is the String path between <source> and the file
12
- # +name+ is the String filename of the post file
12
+ # +name+ is the String filename of the file
13
13
  #
14
14
  # Returns <Page>
15
15
  def initialize(base, dir, name)
@@ -24,8 +24,8 @@ module Jekyll
24
24
  #self.transform
25
25
  end
26
26
 
27
- # Extract information from the post filename
28
- # +name+ is the String filename of the post file
27
+ # Extract information from the page filename
28
+ # +name+ is the String filename of the page file
29
29
  #
30
30
  # Returns nothing
31
31
  def process(name)
@@ -96,16 +96,22 @@ module Jekyll
96
96
  #
97
97
  # Returns [<Post>]
98
98
  def related_posts(posts)
99
- self.class.lsi ||= begin
100
- puts "Running the classifier... this could take a while."
101
- lsi = Classifier::LSI.new
102
- posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) }
103
- puts ""
104
- lsi
105
- end
99
+ return [] unless posts.size > 1
100
+
101
+ if Jekyll.lsi
102
+ self.class.lsi ||= begin
103
+ puts "Running the classifier... this could take a while."
104
+ lsi = Classifier::LSI.new
105
+ posts.each { |x| $stdout.print(".");$stdout.flush;lsi.add_item(x) }
106
+ puts ""
107
+ lsi
108
+ end
106
109
 
107
- related = self.class.lsi.find_related(self.content, 11)
108
- related - [self]
110
+ related = self.class.lsi.find_related(self.content, 11)
111
+ related - [self]
112
+ else
113
+ (posts - [self])[0..9]
114
+ end
109
115
  end
110
116
 
111
117
  # Add any necessary layouts to this post
@@ -145,4 +151,4 @@ module Jekyll
145
151
  end
146
152
  end
147
153
 
148
- end
154
+ end
@@ -54,7 +54,7 @@ module Jekyll
54
54
  base = File.join(self.source, "_posts")
55
55
  entries = Dir.entries(base)
56
56
  entries = entries.reject { |e| File.directory?(e) }
57
-
57
+
58
58
  entries.each do |f|
59
59
  self.posts << Post.new(base, f) if Post.valid?(f)
60
60
  end
@@ -74,26 +74,31 @@ module Jekyll
74
74
  end
75
75
  end
76
76
 
77
- # Recursively transform and write all non-post pages to <dest>/
78
- # +dir+ is the String path part representing the path from
79
- # <source> to the currently processing dir (default '')
77
+ # Copy all regular files from <source> to <dest>/ ignoring
78
+ # any files/directories that are hidden (start with ".") or contain
79
+ # site content (start with "_")
80
+ # The +dir+ String is a relative path used to call this method
81
+ # recursively as it descends through directories
80
82
  #
81
83
  # Returns nothing
82
84
  def transform_pages(dir = '')
83
85
  base = File.join(self.source, dir)
84
86
  entries = Dir.entries(base)
85
87
  entries = entries.reject { |e| ['.', '_'].include?(e[0..0]) }
86
-
88
+
87
89
  entries.each do |f|
88
90
  if File.directory?(File.join(base, f))
91
+ next if self.dest.sub(/\/$/, '') == File.join(base, f)
89
92
  transform_pages(File.join(dir, f))
90
93
  else
91
94
  first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }
92
95
 
96
+ # if the file appears to have a YAML header then process it as a page
93
97
  if first3 == "---"
94
98
  page = Page.new(self.source, dir, f)
95
99
  page.add_layout(self.layouts, site_payload)
96
100
  page.write(self.dest)
101
+ # otherwise copy the file without transforming it
97
102
  else
98
103
  FileUtils.mkdir_p(File.join(self.dest, dir))
99
104
  FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))
@@ -110,4 +115,4 @@ module Jekyll
110
115
  end
111
116
  end
112
117
 
113
- end
118
+ end
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Post with Permalink
3
+ permalink: my_category/permalinked-post
4
+ ---
5
+
6
+ h1. {{ page.title }}
7
+
8
+
9
+ <p>Best <strong>post</strong> ever</p>
@@ -1,6 +1,9 @@
1
1
  require 'test/unit'
2
2
 
3
+ # for some reason these tests fail when run via TextMate
4
+ # but succeed when run on the command line.
5
+
3
6
  tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
4
7
  tests.each do |file|
5
8
  require file
6
- end
9
+ end
@@ -56,7 +56,7 @@ class TestPost < Test::Unit::TestCase
56
56
  p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-10-18-foo-bar.textile")
57
57
  p.transform
58
58
 
59
- assert_equal "<h1>{{ page.title }}</h1>\n\n\n\t<p>Best <strong>post</strong> ever</p>", p.content
59
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
60
60
  end
61
61
 
62
62
  def test_add_layout
@@ -64,7 +64,7 @@ class TestPost < Test::Unit::TestCase
64
64
  layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
65
65
  p.add_layout(layouts, {"site" => {"posts" => []}})
66
66
 
67
- assert_equal "<<< <h1>Foo Bar</h1>\n\n\n\t<p>Best <strong>post</strong> ever</p> >>>", p.output
67
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", p.output
68
68
  end
69
69
 
70
70
  def test_write
@@ -81,6 +81,6 @@ class TestPost < Test::Unit::TestCase
81
81
  layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
82
82
  p.add_layout(layouts, {"site" => {"posts" => []}})
83
83
 
84
- assert_equal "<<< <p>url: /2008/11/21/complex.html\ndate: Fri Nov 21 00:00:00 -0800 2008\nid: /2008/11/21/complex</p> >>>", p.output
84
+ assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: Fri Nov 21 00:00:00 -0800 2008<br />\nid: /2008/11/21/complex</p> >>>", p.output
85
85
  end
86
86
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-08 00:00:00 -08:00
12
+ date: 2008-12-12 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -62,6 +62,16 @@ dependencies:
62
62
  - !ruby/object:Gem::Version
63
63
  version: "0"
64
64
  version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: open4
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
65
75
  - !ruby/object:Gem::Dependency
66
76
  name: hoe
67
77
  type: :development
@@ -90,11 +100,12 @@ files:
90
100
  - bin/jekyll
91
101
  - jekyll.gemspec
92
102
  - lib/jekyll.rb
93
- - lib/jekyll/convertible.rb
103
+ - lib/jekyll/albino.rb
104
+ - lib/jekyll/blocks.rb
94
105
  - lib/jekyll/converters/csv.rb
95
106
  - lib/jekyll/converters/mephisto.rb
107
+ - lib/jekyll/convertible.rb
96
108
  - lib/jekyll/filters.rb
97
- - lib/jekyll/blocks.rb
98
109
  - lib/jekyll/layout.rb
99
110
  - lib/jekyll/page.rb
100
111
  - lib/jekyll/post.rb
@@ -106,6 +117,7 @@ files:
106
117
  - test/source/_posts/2008-11-21-complex.textile
107
118
  - test/source/css/screen.css
108
119
  - test/source/index.html
120
+ - test/source/posts/2008-12-03-permalinked-post.textile
109
121
  - test/suite.rb
110
122
  - test/test_jekyll.rb
111
123
  - test/test_post.rb