Compare commits

...

31 Commits

Author SHA1 Message Date
Mathias Meyer
5eea9d9827 Regenerated gemspec for version 0.4.4 2009-02-16 23:45:50 +01:00
Mathias Meyer
89d98211b1 Version bump to 0.4.4 2009-02-16 23:45:47 +01:00
Mathias Meyer
89330140d9 Added support to set topics through YAML as well. Kinda confusing with topics and categories methinks, but there you go. 2009-02-16 23:45:19 +01:00
Mathias Meyer
4d6f36e97b Updated gemspec. 2009-02-16 17:27:30 +01:00
Mathias Meyer
e11f403aab Version bump to 0.4.3 2009-02-16 17:26:29 +01:00
Mathias Meyer
dba797da04 Ensured that the categories from the yaml also land in the data part. 2009-02-16 17:23:28 +01:00
Mathias Meyer
d8f9a80dbb Merge commit 'mojombo/master'
Conflicts:
	VERSION.yml
	jekyll.gemspec
2009-02-16 16:59:14 +01:00
Mathias Meyer
28c3a3836d Ensured that an empty categories string in the post doesn't fail the whole parsing process. 2009-02-16 16:57:12 +01:00
Mathias Meyer
8efff3f99a Regenerated gemspec for version 0.4.1 2009-02-05 12:21:56 +01:00
Mathias Meyer
d134fbf5ac Version bump to 0.4.1 2009-02-05 12:21:51 +01:00
Mathias Meyer
71a6f8a288 Added support to find the previous and next post for a single post. Useful for blog-style previous/next browsing. 2009-02-05 12:09:06 +01:00
Mathias Meyer
ae7eb14ae4 Fixed missing executable. 2009-02-05 12:08:56 +01:00
Mathias Meyer
8fc41d867a Shortened shortdate functionality. 2009-02-04 20:55:22 +01:00
Mathias Meyer
3df209d8d6 Updated readme for bluecloth. 2009-02-03 21:51:51 +01:00
Mathias Meyer
1eafe90852 Added support for short date permalink format (a la /2008/9/1 instead of /2008/09/01). 2009-02-03 21:43:24 +01:00
Mathias Meyer
b70cfc734a Added support to use BlueCloth for Markdown. 2009-02-03 21:27:44 +01:00
Mathias Meyer
9ee5a36d75 Merge commit 'mojombo/master'
Conflicts:
	History.txt
	jekyll.gemspec
2009-02-03 21:22:49 +01:00
Nick Quaranto
fe71d2b783 Updating README with added options 2009-02-02 22:55:23 -05:00
Nick Quaranto
eac6b03086 Making sure that posts flagged as published: false don't get rendered or copied. 2009-02-02 22:52:19 -05:00
Nick Quaranto
f682c8ffa4 Added publish flag to posts, not preventing it from being in the destination directory yet. 2009-02-02 22:24:51 -05:00
Nick Quaranto
9478f1bb5e Modifying the README a bit more. 2009-01-31 22:29:27 -05:00
Nick Quaranto
7e178fff10 Rewriting history is fun 2009-01-31 22:20:21 -05:00
Nick Quaranto
4a97573465 all done with TODOs 2009-01-31 22:19:58 -05:00
Nick Quaranto
eb60603f51 README 2009-01-31 22:19:24 -05:00
Nick Quaranto
698192122d Adding support for setting post categories through YAML if not specified by directory structure 2009-01-28 09:22:46 -05:00
Nick Quaranto
a8266e3397 Starting on yaml categories 2009-01-27 17:38:35 -05:00
Nick Quaranto
4761d54b93 Making rake test happy on 1.8.7 2009-01-27 17:11:26 -05:00
Nick Quaranto
512e515d15 Merge branch 'mojombo/master' 2009-01-27 16:08:00 -05:00
Nick Quaranto
e53ac7a16c Bumping gemspec for the ampersand fix 2009-01-20 18:58:32 -05:00
Aristotle Pagaltzis
36466f13b8 add minimal tests for xml_escape filter
Signed-off-by: Nick Quaranto <nick@quaran.to>
2009-01-20 20:22:17 +08:00
Aristotle Pagaltzis
d595cd7ee9 entitify ampersands to prevent malformed unescaping output
Signed-off-by: Nick Quaranto <nick@quaran.to>
2009-01-20 20:22:15 +08:00
21 changed files with 227 additions and 30 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,5 @@
test/dest/
*.gem
pkg/
*.swp
*~

View File

@@ -1,4 +1,4 @@
h1. Jekyll
h1. Jekyll LOL
Jekyll is a simple, blog aware, static site generator. It takes a template
directory (representing the raw form of a website), runs it through Textile or
@@ -7,6 +7,8 @@ suitable for serving with Apache or your favorite web server. Visit
"http://tom.preston-werner.com":http://tom.preston-werner.com to see an
example of a Jekyll generated blog.
Some more changes...
To understand how this all works, open up my
"TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be
referencing the code there.
@@ -136,6 +138,11 @@ compilation), you must install it (gem install rdiscount) and then you can
have it used instead:
$ jekyll --rdiscount
As another alternative, just because to make it a hat trick, you can also
use BlueCloth (gem install bluecloth).
$ jekyll --bluecloth
When previewing complex sites locally, simply opening the site in a web
browser (using file://) can cause problems with links that are relative to
@@ -152,6 +159,8 @@ the filename is used. For example, with the permalink style set to 'none' the
file '2009-01-01-happy-new-year.markdown' will have a permalink like
'http://yoursite.com/happy-new-year.html'. The date of the post will still be
read from the filename (and is required!) to be used elsewhere in Jekyll.
Also supported is the permalink format shortdate, which will use the YYYY/M/D
for days and months < 10.
Example usage:
$ jekyll --permalink none
@@ -255,6 +264,16 @@ h3. Predefined Post Variables
/year/month/day/title.html then you can set this variable and it will
be used as the final URL.
category/categories
Don't want to use the directory structure for categories, but you still
want to publish with categories? No problem, just add a category or
categories option in and it will get processed as if it was in a folder
for a category.
published
Set this to false if you don't want the post to show up in the _site
directory when jekyll runs.
h3. Custom Variables
Any variables in the front matter that are not predefined are mixed into the

View File

@@ -12,12 +12,14 @@ begin
s.description = "Jekyll is a simple, blog aware, static site generator."
s.authors = ["Tom Preston-Werner"]
s.rubyforge_project = "jekyll"
s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
s.add_dependency('RedCloth', '>= 4.0.4')
s.add_dependency('liquid', '>= 1.9.0')
s.add_dependency('classifier', '>= 1.3.1')
s.add_dependency('maruku', '>= 0.5.9')
s.add_dependency('directory_watcher', '>= 1.1.1')
s.add_dependency('open4', '>= 0.9.6')
s.executables = "jekyll"
end
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"

6
TODO
View File

@@ -1,3 +1,3 @@
[ ] Easier configuration of Maruka and blahtex directories [mdreid]
[ ] Accurate "related posts" calculator
[ ] Autobuild
[x] Easier configuration of Maruka and blahtex directories [mdreid]
[x] Accurate "related posts" calculator
[x] Autobuild

View File

@@ -1,4 +1,4 @@
---
:minor: 4
:patch: 1
:major: 0
:minor: 4
:patch: 4

View File

@@ -47,6 +47,16 @@ opts = OptionParser.new do |opts|
puts 'You must have the rdiscount gem installed first'
end
end
opts.on("--bluecloth", "Use bluecloth gem for Markdown") do
begin
require 'bluecloth'
Jekyll.markdown_proc = Proc.new { |x| BlueCloth.new(x).to_html }
puts 'Using BlueCloth for Markdown'
rescue LoadError
puts 'You must have the BlueCloth gem installed first'
end
end
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
Jekyll.permalink_style = (style || 'date').to_sym

View File

@@ -2,22 +2,22 @@
Gem::Specification.new do |s|
s.name = %q{jekyll}
s.version = "0.4.1"
s.version = "0.4.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Tom Preston-Werner"]
s.date = %q{2009-02-10}
s.date = %q{2009-02-16}
s.default_executable = %q{jekyll}
s.description = %q{Jekyll is a simple, blog aware, static site generator.}
s.email = %q{tom@mojombo.com}
s.executables = ["jekyll"]
s.files = ["History.txt", "README.textile", "VERSION.yml", "bin/jekyll", "lib/jekyll", "lib/jekyll/albino.rb", "lib/jekyll/converters", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/converters/mt.rb", "lib/jekyll/converters/textpattern.rb", "lib/jekyll/converters/typo.rb", "lib/jekyll/converters/wordpress.rb", "lib/jekyll/convertible.rb", "lib/jekyll/core_ext.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "lib/jekyll/tags", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "lib/jekyll.rb", "test/dest", "test/dest/2008", "test/dest/2008/10", "test/dest/2008/10/18", "test/dest/2008/10/18/foo-bar.html", "test/dest/2008/11", "test/dest/2008/11/21", "test/dest/2008/11/21/complex.html", "test/dest/2008/12", "test/dest/2008/12/13", "test/dest/2008/12/13/include.html", "test/dest/_posts", "test/dest/_posts/2008-10-18-foo-bar.html", "test/dest/_posts/2008-11-21-complex.html", "test/dest/_posts/2008-12-03-permalinked-post.html", "test/dest/_posts/2008-12-13-include.html", "test/dest/category", "test/dest/category/2008", "test/dest/category/2008/09", "test/dest/category/2008/09/23", "test/dest/category/2008/09/23/categories.html", "test/dest/category/_posts", "test/dest/category/_posts/2008-9-23-categories.html", "test/dest/css", "test/dest/css/screen.css", "test/dest/foo", "test/dest/foo/2008", "test/dest/foo/2008/12", "test/dest/foo/2008/12/12", "test/dest/foo/2008/12/12/topical-post.html", "test/dest/foo/_posts", "test/dest/foo/_posts/bar", "test/dest/foo/_posts/bar/2008-12-12-topical-post.html", "test/dest/index.html", "test/dest/my_category", "test/dest/my_category/permalinked-post", "test/dest/z_category", "test/dest/z_category/2008", "test/dest/z_category/2008/09", "test/dest/z_category/2008/09/23", "test/dest/z_category/2008/09/23/categories.html", "test/dest/z_category/_posts", "test/dest/z_category/_posts/2008-9-23-categories.html", "test/helper.rb", "test/source", "test/source/_includes", "test/source/_includes/sig.markdown", "test/source/_layouts", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/_posts/2008-12-03-permalinked-post.textile", "test/source/_posts/2008-12-13-include.markdown", "test/source/category", "test/source/category/_posts", "test/source/category/_posts/2008-9-23-categories.textile", "test/source/css", "test/source/css/screen.css", "test/source/foo", "test/source/foo/_posts", "test/source/foo/_posts/bar", "test/source/foo/_posts/bar/2008-12-12-topical-post.textile", "test/source/index.html", "test/source/z_category", "test/source/z_category/_posts", "test/source/z_category/_posts/2008-9-23-categories.textile", "test/suite.rb", "test/test_filters.rb", "test/test_generated_site.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb", "test/test_tags.rb"]
s.files = ["History.txt", "Rakefile", "README.textile", "TODO", "VERSION.yml", "bin/jekyll", "lib/jekyll", "lib/jekyll/albino.rb", "lib/jekyll/converters", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/converters/mt.rb", "lib/jekyll/converters/textpattern.rb", "lib/jekyll/converters/typo.rb", "lib/jekyll/converters/wordpress.rb", "lib/jekyll/convertible.rb", "lib/jekyll/core_ext.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "lib/jekyll/tags", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "lib/jekyll.rb", "test/dest", "test/dest/2008", "test/dest/2008/10", "test/dest/2008/10/18", "test/dest/2008/10/18/foo-bar.html", "test/dest/2008/11", "test/dest/2008/11/21", "test/dest/2008/11/21/complex.html", "test/dest/2008/12", "test/dest/2008/12/13", "test/dest/2008/12/13/include.html", "test/dest/2009", "test/dest/2009/01", "test/dest/2009/01/27", "test/dest/2009/01/27/no-categories.html", "test/dest/2009/01/27/no-topics.html", "test/dest/2009/01/27/topic.html", "test/dest/2009/01/27/topics.html", "test/dest/_posts", "test/dest/_posts/2008-02-02-not-published.html", "test/dest/_posts/2008-02-02-published.html", "test/dest/_posts/2008-10-18-foo-bar.html", "test/dest/_posts/2008-11-21-complex.html", "test/dest/_posts/2008-12-03-permalinked-post.html", "test/dest/_posts/2008-12-13-include.html", "test/dest/_posts/2009-01-27-categories.html", "test/dest/_posts/2009-01-27-category.html", "test/dest/_posts/2009-01-27-no-categories.html", "test/dest/_posts/2009-01-27-no-topics.html", "test/dest/_posts/2009-01-27-topic.html", "test/dest/_posts/2009-01-27-topics.html", "test/dest/category", "test/dest/category/2008", "test/dest/category/2008/09", "test/dest/category/2008/09/23", "test/dest/category/2008/09/23/categories.html", "test/dest/category/_posts", "test/dest/category/_posts/2008-9-23-categories.html", "test/dest/css", "test/dest/css/screen.css", "test/dest/foo", "test/dest/foo/2008", "test/dest/foo/2008/12", "test/dest/foo/2008/12/12", "test/dest/foo/2008/12/12/topical-post.html", "test/dest/foo/2009", "test/dest/foo/2009/01", "test/dest/foo/2009/01/27", "test/dest/foo/2009/01/27/category.html", "test/dest/foo/_posts", "test/dest/foo/_posts/bar", "test/dest/foo/_posts/bar/2008-12-12-topical-post.html", "test/dest/foo/bar", "test/dest/foo/bar/baz", "test/dest/foo/bar/baz/2009", "test/dest/foo/bar/baz/2009/01", "test/dest/foo/bar/baz/2009/01/27", "test/dest/foo/bar/baz/2009/01/27/categories.html", "test/dest/index.html", "test/dest/my_category", "test/dest/my_category/permalinked-post", "test/dest/publish_test", "test/dest/publish_test/2008", "test/dest/publish_test/2008/02", "test/dest/publish_test/2008/02/02", "test/dest/publish_test/2008/02/02/published.html", "test/dest/z_category", "test/dest/z_category/2008", "test/dest/z_category/2008/09", "test/dest/z_category/2008/09/23", "test/dest/z_category/2008/09/23/categories.html", "test/dest/z_category/_posts", "test/dest/z_category/_posts/2008-9-23-categories.html", "test/helper.rb", "test/source", "test/source/_includes", "test/source/_includes/sig.markdown", "test/source/_layouts", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts", "test/source/_posts/2008-02-02-not-published.textile", "test/source/_posts/2008-02-02-published.textile", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/_posts/2008-12-03-permalinked-post.textile", "test/source/_posts/2008-12-13-include.markdown", "test/source/_posts/2009-01-27-categories.textile", "test/source/_posts/2009-01-27-category.textile", "test/source/_posts/2009-01-27-no-categories.textile", "test/source/_posts/2009-01-27-no-topics.textile", "test/source/_posts/2009-01-27-topic.textile", "test/source/_posts/2009-01-27-topics.textile", "test/source/category", "test/source/category/_posts", "test/source/category/_posts/2008-9-23-categories.textile", "test/source/css", "test/source/css/screen.css", "test/source/foo", "test/source/foo/_posts", "test/source/foo/_posts/bar", "test/source/foo/_posts/bar/2008-12-12-topical-post.textile", "test/source/index.html", "test/source/z_category", "test/source/z_category/_posts", "test/source/z_category/_posts/2008-9-23-categories.textile", "test/suite.rb", "test/test_filters.rb", "test/test_generated_site.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb", "test/test_tags.rb"]
s.has_rdoc = true
s.homepage = %q{http://github.com/mojombo/jekyll}
s.rdoc_options = ["--inline-source", "--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubyforge_project = %q{jekyll}
s.rubygems_version = %q{1.3.0}
s.rubygems_version = %q{1.3.1}
s.summary = %q{Jekyll is a simple, blog aware, static site generator.}
if s.respond_to? :specification_version then

View File

@@ -18,8 +18,9 @@ module Jekyll
name =~ MATCHER
end
attr_accessor :date, :slug, :ext, :categories, :topics
attr_accessor :date, :slug, :ext, :categories, :topics, :published
attr_accessor :data, :content, :output
attr_accessor :previous, :next
# Initialize this Post instance.
# +base+ is the String path to the dir containing the post file
@@ -38,6 +39,28 @@ module Jekyll
self.process(name)
self.read_yaml(@base, name)
if self.data.has_key?('published') && self.data['published'] == false
self.published = false
else
self.published = true
end
self.data['topics'] = if self.topics.empty?
if self.data.has_key?('topic')
self.topics << self.data['topic']
elsif self.data.has_key?('topics')
self.topics = (self.data['topics'] || "").split
end
end
self.data['categories'] = if self.categories.empty?
if self.data.has_key?('category')
self.categories << self.data['category']
elsif self.data.has_key?('categories')
self.categories = (self.data['categories'] || "").split
end
end
end
# Spaceship is based on Post#date
@@ -69,8 +92,11 @@ module Jekyll
permalink.to_s.split("/")[0..-2].join("/") + '/'
else
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
if Jekyll.permalink_style == :date
case Jekyll.permalink_style
when :date
prefix + date.strftime("/%Y/%m/%d/")
when :shortdate
prefix + "/#{date.year}/#{date.month}/#{date.day}/"
else
prefix + '/'
end
@@ -134,7 +160,9 @@ module Jekyll
payload =
{
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
"page" => self.to_liquid
"page" => self.to_liquid,
"previous" => self.previous,
"next" => self.next
}
payload = payload.deep_merge(site_payload)

View File

@@ -63,17 +63,23 @@ module Jekyll
entries.each do |f|
if Post.valid?(f)
post = Post.new(self.source, dir, f)
self.posts << post
post.categories.each { |c| self.categories[c] << post }
if post.published
self.posts << post
post.categories.each { |c| self.categories[c] << post }
end
end
end
self.posts.sort!
# second pass renders each post now that full site payload is available
self.posts.each do |post|
self.posts.each_with_index do |post, idx|
post.previous = posts[idx - 1] unless idx - 1 < 0
post.next = posts[idx + 1] unless idx + 1 >= posts.size
post.render(self.layouts, site_payload)
end
self.posts.sort!
self.categories.values.map { |cats| cats.sort! { |a, b| b <=> a} }
rescue Errno::ENOENT => e
# ignore missing layout dir

View File

@@ -1,6 +1,7 @@
require File.join(File.dirname(__FILE__), *%w[.. lib jekyll])
require 'test/unit'
require 'redgreen'
include Jekyll
@@ -10,4 +11,4 @@ end
def clear_dest
FileUtils.rm_rf(dest_dir)
end
end

View File

@@ -0,0 +1,8 @@
---
layout: default
title: Not published!
published: false
category: publish_test
---
This should *not* be published!

View File

@@ -0,0 +1,8 @@
---
layout: default
title: Publish
category: publish_test
---
This should be published.

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Categories in YAML
categories: foo bar baz
---
Best *post* ever

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Category in YAML
category: foo
---
Best *post* ever

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Categories in YAML
categories:
---
Best *post* ever

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Categories in YAML
topics:
---
Best *post* ever

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Categories in YAML
topic: foo
---
Best *post* ever

View File

@@ -0,0 +1,7 @@
---
layout: default
title: Categories in YAML
topics: foo bar
---
Best *post* ever

View File

@@ -3,20 +3,30 @@ require File.dirname(__FILE__) + '/helper'
class TestGeneratedSite < Test::Unit::TestCase
def setup
clear_dest
source = File.join(File.dirname(__FILE__), *%w[source])
@s = Site.new(source, dest_dir)
@source = File.join(File.dirname(__FILE__), *%w[source])
@s = Site.new(@source, dest_dir)
@s.process
@index = File.read(File.join(dest_dir, 'index.html'))
end
def test_site_posts_in_index
# confirm that {{ site.posts }} is working
puts @s.posts.size
assert @index.include?("#{@s.posts.size} Posts")
end
def test_post_content_in_index
# confirm that the {{ post.content }} is rendered OK
assert @index.include?('<p>This <em>is</em> cool</p>')
latest_post = Dir[File.join(@source, '_posts/*')].last
post = Post.new(@source, '', File.basename(latest_post))
Jekyll.content_type = post.determine_content_type
post.transform
assert @index.include?(post.content)
end
def test_unpublished_posts_are_hidden
published = Dir[File.join(dest_dir, 'publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
assert_equal 1, published.size
assert_equal "published.html", published.first
end
end

View File

@@ -70,6 +70,55 @@ class TestPost < Test::Unit::TestCase
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
end
def test_published
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-published.textile")
assert_equal true, p.published
end
def test_not_published
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-not-published.textile")
assert_equal false, p.published
end
def test_yaml_category
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-category.textile")
assert p.categories.include?('foo')
assert p.data['categories'].include?('foo')
end
def test_yaml_categories
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-categories.textile")
assert p.categories.include?('foo')
assert p.categories.include?('bar')
assert p.categories.include?('baz')
assert p.data['categories'].include?('foo')
end
def test_empty_yaml_categories
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-no-categories.textile")
assert p.categories.empty?
assert p.data['categories'].empty?
end
def test_yaml_topic
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-topic.textile")
assert p.topics.include?('foo')
assert p.data['topics'].include?('foo')
end
def test_yaml_topics
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-topics.textile")
assert p.topics.include?('foo')
assert p.topics.include?('bar')
assert p.data['topics'].include?('foo')
end
def test_empty_yaml_topics
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-no-topics.textile")
assert p.topics.empty?
assert p.data['topics'].empty?
end
def test_render
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-10-18-foo-bar.textile")
@@ -110,4 +159,13 @@ class TestPost < Test::Unit::TestCase
assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", p.output
end
end
def test_dir_with_short_date_permalink_type
Jekyll.permalink_style = :shortdate
p = Post.allocate
p.process("2008-02-03-permalinked-post.textile")
p.categories = []
assert_equal "/2008/2/3/", p.dir
Jekyll.permalink_style = :date
end
end

View File

@@ -2,8 +2,8 @@ require File.dirname(__FILE__) + '/helper'
class TestSite < Test::Unit::TestCase
def setup
source = File.join(File.dirname(__FILE__), *%w[source])
@s = Site.new(source, dest_dir)
@source = File.join(File.dirname(__FILE__), *%w[source])
@s = Site.new(@source, dest_dir)
end
def test_site_init
@@ -18,16 +18,19 @@ class TestSite < Test::Unit::TestCase
def test_read_posts
@s.read_posts('')
assert_equal 4, @s.posts.size
posts = Dir[File.join(@source, '_posts/*')]
assert_equal posts.size - 1, @s.posts.size
end
def test_site_payload
clear_dest
@s.process
assert_equal 7, @s.posts.length
assert_equal ["category", "foo", "z_category"].sort, @s.categories.keys.sort
assert_equal 1, @s.categories['foo'].length
posts = Dir[File.join(@source, "**", "_posts/*")]
categories = %w(bar baz category foo z_category publish_test).sort
assert_equal posts.size - 1, @s.posts.size
assert_equal categories, @s.categories.keys.sort
assert_equal 3, @s.categories['foo'].size
end
end