qrush-jekyll 0.4.1 → 0.5.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.
@@ -1,10 +1,11 @@
1
1
  module Jekyll
2
-
2
+
3
3
  class HighlightBlock < Liquid::Block
4
4
  include Liquid::StandardFilters
5
+
5
6
  # we need a language, but the linenos argument is optional.
6
7
  SYNTAX = /(\w+)\s?(:?linenos)?\s?/
7
-
8
+
8
9
  def initialize(tag_name, markup, tokens)
9
10
  super
10
11
  if markup =~ SYNTAX
@@ -19,23 +20,25 @@ module Jekyll
19
20
  raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]")
20
21
  end
21
22
  end
22
-
23
+
23
24
  def render(context)
24
- if Jekyll.pygments
25
+ if context.registers[:site].pygments
25
26
  render_pygments(context, super.to_s)
26
27
  else
27
28
  render_codehighlighter(context, super.to_s)
28
29
  end
29
30
  end
30
-
31
+
31
32
  def render_pygments(context, code)
32
- if Jekyll.content_type == :markdown
33
+ if context["content_type"] == :markdown
33
34
  return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
35
+ elsif context["content_type"] == :textile
36
+ return "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
34
37
  else
35
- "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
38
+ return Albino.new(code, @lang).to_s(@options)
36
39
  end
37
40
  end
38
-
41
+
39
42
  def render_codehighlighter(context, code)
40
43
  #The div is required because RDiscount blows ass
41
44
  <<-HTML
@@ -47,7 +50,7 @@ module Jekyll
47
50
  HTML
48
51
  end
49
52
  end
50
-
53
+
51
54
  end
52
55
 
53
56
  Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
@@ -1,17 +1,17 @@
1
1
  module Jekyll
2
-
2
+
3
3
  class IncludeTag < Liquid::Tag
4
4
  def initialize(tag_name, file, tokens)
5
5
  super
6
6
  @file = file.strip
7
7
  end
8
-
8
+
9
9
  def render(context)
10
10
  if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
11
11
  return "Include file '#{@file}' contains invalid characters or sequences"
12
12
  end
13
-
14
- Dir.chdir(File.join(Jekyll.source, '_includes')) do
13
+
14
+ Dir.chdir(File.join(context.registers[:site].source, '_includes')) do
15
15
  choices = Dir['**/*'].reject { |x| File.symlink?(x) }
16
16
  if choices.include?(@file)
17
17
  source = File.read(@file)
@@ -25,7 +25,7 @@ module Jekyll
25
25
  end
26
26
  end
27
27
  end
28
-
28
+
29
29
  end
30
30
 
31
31
  Liquid::Template.register_tag('include', Jekyll::IncludeTag)
data/lib/jekyll.rb CHANGED
@@ -13,22 +13,6 @@ require 'yaml'
13
13
  # 3rd party
14
14
  require 'liquid'
15
15
  require 'redcloth'
16
- begin
17
- require 'maruku'
18
- require 'maruku/ext/math'
19
- # Switch off MathML output
20
- MaRuKu::Globals[:html_math_output_mathml] = false
21
- MaRuKu::Globals[:html_math_engine] = 'none'
22
-
23
- # Turn on math to PNG support with blahtex
24
- # Resulting PNGs stored in `images/latex`
25
- MaRuKu::Globals[:html_math_output_png] = true
26
- MaRuKu::Globals[:html_png_engine] = 'blahtex'
27
- MaRuKu::Globals[:html_png_dir] = 'images/latex'
28
- MaRuKu::Globals[:html_png_url] = '/images/latex/'
29
- rescue LoadError
30
- puts "The maruku gem is required for markdown support!"
31
- end
32
16
 
33
17
  # internal requires
34
18
  require 'jekyll/core_ext'
@@ -43,23 +27,55 @@ require 'jekyll/tags/include'
43
27
  require 'jekyll/albino'
44
28
 
45
29
  module Jekyll
46
- class << self
47
- attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc, :content_type, :permalink_style
48
- end
49
-
50
- Jekyll.lsi = false
51
- Jekyll.pygments = false
52
- Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
53
- Jekyll.permalink_style = :date
54
-
55
- def self.process(source, dest)
56
- require 'classifier' if Jekyll.lsi
57
-
58
- Jekyll.source = source
59
- Jekyll.dest = dest
60
- Jekyll::Site.new(source, dest).process
30
+ # Default options. Overriden by values in _config.yaml or command-line opts.
31
+ # (Strings rather symbols used for compatability with YAML)
32
+ DEFAULTS = {
33
+ 'auto' => false,
34
+ 'server' => false,
35
+ 'server_port' => 4000,
36
+
37
+ 'source' => '.',
38
+ 'destination' => File.join('.', '_site'),
39
+
40
+ 'lsi' => false,
41
+ 'pygments' => false,
42
+ 'markdown' => 'maruku',
43
+ 'permalink' => 'date',
44
+
45
+ 'maruku' => {
46
+ 'use_tex' => false,
47
+ 'use_divs' => false,
48
+ 'png_engine' => 'blahtex',
49
+ 'png_dir' => 'images/latex',
50
+ 'png_url' => '/images/latex'
51
+ }
52
+ }
53
+
54
+ # Generate a Jekyll configuration Hash by merging the default options
55
+ # with anything in _config.yml, and adding the given options on top
56
+ # +override+ is a Hash of config directives
57
+ #
58
+ # Returns Hash
59
+ def self.configuration(override)
60
+ # _config.yml may override default source location, but until
61
+ # then, we need to know where to look for _config.yml
62
+ source = override['source'] || Jekyll::DEFAULTS['source']
63
+
64
+ # Get configuration from <source>/_config.yaml
65
+ config = {}
66
+ config_file = File.join(source, '_config.yml')
67
+ begin
68
+ config = YAML.load_file(config_file)
69
+ puts "Configuration from #{config_file}"
70
+ rescue => err
71
+ puts "WARNING: Could not read configuration. Using defaults (and options)."
72
+ puts "\t" + err
73
+ end
74
+
75
+ # Merge DEFAULTS < _config.yml < override
76
+ Jekyll::DEFAULTS.deep_merge(config).deep_merge(override)
61
77
  end
62
-
78
+
63
79
  def self.version
64
80
  yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
65
81
  "#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
data/test/helper.rb CHANGED
@@ -2,13 +2,23 @@ require File.join(File.dirname(__FILE__), *%w[.. lib jekyll])
2
2
 
3
3
  require 'test/unit'
4
4
  require 'redgreen'
5
+ require 'shoulda'
6
+ require 'rr'
5
7
 
6
8
  include Jekyll
7
9
 
8
- def dest_dir
9
- File.join(File.dirname(__FILE__), *%w[dest])
10
- end
10
+ class Test::Unit::TestCase
11
+ include RR::Adapters::TestUnit
12
+
13
+ def dest_dir(*subdirs)
14
+ File.join(File.dirname(__FILE__), 'dest', *subdirs)
15
+ end
16
+
17
+ def source_dir(*subdirs)
18
+ File.join(File.dirname(__FILE__), 'source', *subdirs)
19
+ end
11
20
 
12
- def clear_dest
13
- FileUtils.rm_rf(dest_dir)
21
+ def clear_dest
22
+ FileUtils.rm_rf(dest_dir)
23
+ end
14
24
  end
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Not published!
4
+ published: false
5
+ category: publish_test
6
+ ---
7
+
8
+ This should *not* be published!
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Publish
4
+ category: publish_test
5
+ ---
6
+
7
+ This should be published.
8
+
@@ -0,0 +1,10 @@
1
+ ---
2
+ layout: default
3
+ title: Array categories in YAML
4
+ categories:
5
+ - foo
6
+ - bar
7
+ - baz
8
+ ---
9
+
10
+ Best *post* ever
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ title: Categories in YAML
4
+ categories: foo bar baz
5
+ ---
6
+
7
+ Best *post* ever
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ title: Category in YAML
4
+ category: foo
5
+ ---
6
+
7
+ Best *post* ever
data/test/test_filters.rb CHANGED
@@ -1,37 +1,41 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestFilters < Test::Unit::TestCase
4
-
5
4
  class JekyllFilter
6
5
  include Jekyll::Filters
7
6
  end
8
-
9
- def setup
10
- @filter = JekyllFilter.new
11
- end
12
7
 
13
- def test_array_to_sentence_string_with_no_args
14
- assert_equal "", @filter.array_to_sentence_string([])
15
- end
8
+ context "filters" do
9
+ setup do
10
+ @filter = JekyllFilter.new
11
+ end
16
12
 
17
- def test_array_to_sentence_string_with_one_arg
18
- assert_equal "1", @filter.array_to_sentence_string([1])
19
- assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
20
- end
21
-
22
- def test_array_to_sentence_string_with_two_args
23
- assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
24
- assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
25
- end
26
-
27
- def test_array_to_sentence_string_with_multiple_args
28
- assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
29
- assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
30
- end
31
-
32
- def test_xml_escape_with_ampersands
33
- assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
34
- assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
13
+ should "textilize with simple string" do
14
+ assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
15
+ end
16
+
17
+ should "convert array to sentence string with no args" do
18
+ assert_equal "", @filter.array_to_sentence_string([])
19
+ end
20
+
21
+ should "convert array to sentence string with one arg" do
22
+ assert_equal "1", @filter.array_to_sentence_string([1])
23
+ assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
24
+ end
25
+
26
+ should "convert array to sentence string with two args" do
27
+ assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
28
+ assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
29
+ end
30
+
31
+ should "convert array to sentence string with multiple args" do
32
+ assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
33
+ assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
34
+ end
35
+
36
+ should "escape xml with ampersands" do
37
+ assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
38
+ assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
39
+ end
35
40
  end
36
-
37
41
  end
@@ -1,32 +1,38 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestGeneratedSite < Test::Unit::TestCase
4
- def setup
5
- clear_dest
6
- @source = File.join(File.dirname(__FILE__), *%w[source])
7
- @s = Site.new(@source, dest_dir)
8
- @s.process
9
- @index = File.read(File.join(dest_dir, 'index.html'))
10
- end
11
-
12
- def test_site_posts_in_index
13
- # confirm that {{ site.posts }} is working
14
- assert @index.include?("#{@s.posts.size} Posts")
15
- end
4
+ context "generated sites" do
5
+ setup do
6
+ clear_dest
7
+ stub(Jekyll).configuration do
8
+ Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
9
+ end
16
10
 
17
- def test_post_content_in_index
18
- # confirm that the {{ post.content }} is rendered OK
19
- latest_post = Dir[File.join(@source, '_posts/*')].last
20
- post = Post.new(@source, '', File.basename(latest_post))
21
- Jekyll.content_type = post.determine_content_type
22
- post.transform
23
- assert @index.include?(post.content)
24
- end
11
+ @site = Site.new(Jekyll.configuration)
12
+ @site.process
13
+ @index = File.read(dest_dir('index.html'))
14
+ end
15
+
16
+ should "insert site.posts into the index" do
17
+ assert @index.include?("#{@site.posts.size} Posts")
18
+ end
19
+
20
+ should "render post.content" do
21
+ latest_post = Dir[source_dir('_posts', '*')].last
22
+ post = Post.new(@site, source_dir, '', File.basename(latest_post))
23
+ post.transform
24
+ assert @index.include?(post.content)
25
+ end
26
+
27
+ should "hide unpublished posts" do
28
+ published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
29
+
30
+ assert_equal 1, published.size
31
+ assert_equal "published.html", published.first
32
+ end
25
33
 
26
- def test_unpublished_posts_are_hidden
27
- published = Dir[File.join(dest_dir, 'publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
28
-
29
- assert_equal 1, published.size
30
- assert_equal "published.html", published.first
34
+ should "not copy _posts directory" do
35
+ assert !File.exist?(dest_dir('_posts'))
36
+ end
31
37
  end
32
38
  end
data/test/test_post.rb CHANGED
@@ -1,135 +1,171 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  class TestPost < Test::Unit::TestCase
4
- def setup
5
-
4
+ def setup_post(file)
5
+ Post.new(@site, source_dir, '', file)
6
6
  end
7
-
8
- def test_valid
9
- assert Post.valid?("2008-10-19-foo-bar.textile")
10
- assert Post.valid?("foo/bar/2008-10-19-foo-bar.textile")
11
-
12
- assert !Post.valid?("lol2008-10-19-foo-bar.textile")
13
- assert !Post.valid?("blah")
14
- end
15
-
16
- def test_process
17
- p = Post.allocate
18
- p.process("2008-10-19-foo-bar.textile")
19
-
20
- assert_equal Time.parse("2008-10-19"), p.date
21
- assert_equal "foo-bar", p.slug
22
- assert_equal ".textile", p.ext
23
- end
24
-
25
- def test_url
26
- p = Post.allocate
27
- p.categories = []
28
- p.process("2008-10-19-foo-bar.textile")
29
-
30
- assert_equal "/2008/10/19/foo-bar.html", p.url
31
- end
32
-
33
- def test_permalink
34
- p = Post.allocate
35
- p.process("2008-12-03-permalinked-post.textile")
36
- p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile")
37
7
 
38
- assert_equal "my_category/permalinked-post", p.permalink
8
+ def do_render(post)
9
+ layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
10
+ post.render(layouts, {"site" => {"posts" => []}})
39
11
  end
40
12
 
41
- def test_dir_respects_permalink
42
- p = Post.allocate
43
- p.process("2008-12-03-permalinked-post.textile")
44
- p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile")
13
+ context "A Post" do
14
+ setup do
15
+ clear_dest
16
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
17
+ @site = Site.new(Jekyll.configuration)
18
+ end
45
19
 
46
- assert_equal "my_category/", p.dir
47
- end
48
-
49
- def test_url_respects_permalink
50
- p = Post.allocate
51
- p.process("2008-12-03-permalinked-post.textile")
52
- p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile")
20
+ should "ensure valid posts are valid" do
21
+ assert Post.valid?("2008-10-19-foo-bar.textile")
22
+ assert Post.valid?("foo/bar/2008-10-19-foo-bar.textile")
53
23
 
54
- assert_equal "my_category/permalinked-post", p.url
55
- end
24
+ assert !Post.valid?("lol2008-10-19-foo-bar.textile")
25
+ assert !Post.valid?("blah")
26
+ end
56
27
 
57
- def test_read_yaml
58
- p = Post.allocate
59
- p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-10-18-foo-bar.textile")
60
-
61
- assert_equal({"title" => "Foo Bar", "layout" => "default"}, p.data)
62
- assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", p.content
63
- end
64
-
65
- def test_transform
66
- p = Post.allocate
67
- p.process("2008-10-18-foo-bar.textile")
68
- p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-10-18-foo-bar.textile")
69
- p.transform
70
-
71
- assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
72
- end
28
+ context "processing posts" do
29
+ setup do
30
+ @post = Post.allocate
31
+ @post.site = @site
73
32
 
74
- def test_published
75
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-published.textile")
76
- assert_equal true, p.published
77
- end
33
+ @real_file = "2008-10-18-foo-bar.textile"
34
+ @fake_file = "2008-10-19-foo-bar.textile"
35
+ @source = source_dir('_posts')
36
+ end
78
37
 
79
- def test_not_published
80
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-not-published.textile")
81
- assert_equal false, p.published
82
- end
38
+ should "keep date, title, and markup type" do
39
+ @post.process(@fake_file)
83
40
 
84
- def test_yaml_category
85
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-category.textile")
86
- assert p.categories.include?('foo')
87
- end
41
+ assert_equal Time.parse("2008-10-19"), @post.date
42
+ assert_equal "foo-bar", @post.slug
43
+ assert_equal ".textile", @post.ext
44
+ end
45
+
46
+ should "create url based on date and title" do
47
+ @post.categories = []
48
+ @post.process(@fake_file)
49
+ assert_equal "/2008/10/19/foo-bar.html", @post.url
50
+ end
51
+
52
+ should "respect permalink" do
53
+ file = "2008-12-03-permalinked-post.textile"
54
+ @post.process(file)
55
+ @post.read_yaml(@source, file)
56
+
57
+ assert_equal "my_category/permalinked-post", @post.permalink
58
+ assert_equal "my_category/", @post.dir
59
+ assert_equal "my_category/permalinked-post", @post.url
60
+ end
61
+
62
+ should "read yaml front-matter" do
63
+ @post.read_yaml(@source, @real_file)
64
+
65
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
66
+ assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content
67
+ end
68
+
69
+ should "transform textile" do
70
+ @post.process(@real_file)
71
+ @post.read_yaml(@source, @real_file)
72
+ @post.transform
73
+
74
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
75
+ end
76
+ end
77
+
78
+ context "when in a site" do
79
+ setup do
80
+ clear_dest
81
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
82
+ @site = Site.new(Jekyll.configuration)
83
+ @site.posts = [setup_post('2008-02-02-published.textile'),
84
+ setup_post('2009-01-27-categories.textile')]
85
+ end
86
+
87
+ should "have next post" do
88
+ assert_equal(@site.posts.last, @site.posts.first.next)
89
+ end
90
+
91
+ should "have previous post" do
92
+ assert_equal(@site.posts.first, @site.posts.last.previous)
93
+ end
94
+
95
+ should "not have previous post if first" do
96
+ assert_equal(nil, @site.posts.first.previous)
97
+ end
98
+
99
+ should "not have next post if last" do
100
+ assert_equal(nil, @site.posts.last.next)
101
+ end
102
+ end
103
+
104
+ context "initializing posts" do
105
+ should "publish when published yaml is no specified" do
106
+ post = setup_post("2008-02-02-published.textile")
107
+ assert_equal true, post.published
108
+ end
109
+
110
+ should "not published when published yaml is false" do
111
+ post = setup_post("2008-02-02-not-published.textile")
112
+ assert_equal false, post.published
113
+ end
114
+
115
+ should "recognize category in yaml" do
116
+ post = setup_post("2009-01-27-category.textile")
117
+ assert post.categories.include?('foo')
118
+ end
119
+
120
+ should "recognize several categories in yaml" do
121
+ post = setup_post("2009-01-27-categories.textile")
122
+ assert post.categories.include?('foo')
123
+ assert post.categories.include?('bar')
124
+ assert post.categories.include?('baz')
125
+ end
126
+
127
+ context "rendering" do
128
+ setup do
129
+ clear_dest
130
+ end
131
+
132
+ should "render properly" do
133
+ post = setup_post("2008-10-18-foo-bar.textile")
134
+ do_render(post)
135
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
136
+ end
137
+
138
+ should "write properly" do
139
+ post = setup_post("2008-10-18-foo-bar.textile")
140
+ do_render(post)
141
+ post.write(dest_dir)
142
+
143
+ assert File.directory?(dest_dir)
144
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
145
+ end
146
+
147
+ should "insert data" do
148
+ post = setup_post("2008-11-21-complex.textile")
149
+ do_render(post)
150
+
151
+ assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", post.output
152
+ end
153
+
154
+ should "include templates" do
155
+ post = setup_post("2008-12-13-include.markdown")
156
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
157
+ do_render(post)
158
+
159
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
160
+ end
161
+ end
162
+ end
163
+
164
+ should "generate categories and topics" do
165
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
166
+ assert_equal ['foo'], post.categories
167
+ assert_equal ['bar'], post.topics
168
+ end
88
169
 
89
- def test_yaml_categories
90
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-categories.textile")
91
- assert p.categories.include?('foo')
92
- assert p.categories.include?('bar')
93
- assert p.categories.include?('baz')
94
- end
95
-
96
- def test_render
97
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-10-18-foo-bar.textile")
98
- layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
99
- p.render(layouts, {"site" => {"posts" => []}})
100
-
101
- assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", p.output
102
- end
103
-
104
- def test_write
105
- clear_dest
106
-
107
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-10-18-foo-bar.textile")
108
- layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
109
- p.render(layouts, {"site" => {"posts" => []}})
110
- p.write(dest_dir)
111
- end
112
-
113
- def test_data
114
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-11-21-complex.textile")
115
- layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
116
- p.render(layouts, {"site" => {"posts" => []}})
117
-
118
- assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", p.output
119
- end
120
-
121
- def test_categories_and_topics
122
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
123
- assert_equal ['foo'], p.categories
124
- assert_equal ['bar'], p.topics
125
- end
126
-
127
- def test_include
128
- Jekyll.source = File.join(File.dirname(__FILE__), *%w[source])
129
- p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-12-13-include.markdown")
130
- layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
131
- p.render(layouts, {"site" => {"posts" => []}})
132
-
133
- assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", p.output
134
170
  end
135
171
  end