mirror of
https://github.com/jekyll/jekyll.git
synced 2026-04-28 03:01:03 -04:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eea9d9827 | ||
|
|
89d98211b1 | ||
|
|
89330140d9 | ||
|
|
4d6f36e97b | ||
|
|
e11f403aab | ||
|
|
dba797da04 | ||
|
|
d8f9a80dbb | ||
|
|
28c3a3836d | ||
|
|
8efff3f99a | ||
|
|
d134fbf5ac | ||
|
|
71a6f8a288 | ||
|
|
ae7eb14ae4 | ||
|
|
8fc41d867a | ||
|
|
3df209d8d6 | ||
|
|
1eafe90852 | ||
|
|
b70cfc734a | ||
|
|
9ee5a36d75 | ||
|
|
fe71d2b783 | ||
|
|
eac6b03086 | ||
|
|
f682c8ffa4 | ||
|
|
9478f1bb5e | ||
|
|
7e178fff10 | ||
|
|
4a97573465 | ||
|
|
eb60603f51 | ||
|
|
698192122d | ||
|
|
a8266e3397 | ||
|
|
4761d54b93 | ||
|
|
512e515d15 | ||
|
|
e53ac7a16c | ||
|
|
36466f13b8 | ||
|
|
d595cd7ee9 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
test/dest/
|
||||
*.gem
|
||||
pkg/
|
||||
*.swp
|
||||
*~
|
||||
|
||||
@@ -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
|
||||
|
||||
2
Rakefile
2
Rakefile
@@ -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
6
TODO
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---
|
||||
:minor: 4
|
||||
:patch: 1
|
||||
:major: 0
|
||||
:minor: 4
|
||||
:patch: 4
|
||||
|
||||
10
bin/jekyll
10
bin/jekyll
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
8
test/source/_posts/2008-02-02-not-published.textile
Normal file
8
test/source/_posts/2008-02-02-not-published.textile
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
layout: default
|
||||
title: Not published!
|
||||
published: false
|
||||
category: publish_test
|
||||
---
|
||||
|
||||
This should *not* be published!
|
||||
8
test/source/_posts/2008-02-02-published.textile
Normal file
8
test/source/_posts/2008-02-02-published.textile
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
layout: default
|
||||
title: Publish
|
||||
category: publish_test
|
||||
---
|
||||
|
||||
This should be published.
|
||||
|
||||
7
test/source/_posts/2009-01-27-categories.textile
Normal file
7
test/source/_posts/2009-01-27-categories.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Categories in YAML
|
||||
categories: foo bar baz
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
7
test/source/_posts/2009-01-27-category.textile
Normal file
7
test/source/_posts/2009-01-27-category.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Category in YAML
|
||||
category: foo
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
7
test/source/_posts/2009-01-27-no-categories.textile
Normal file
7
test/source/_posts/2009-01-27-no-categories.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Categories in YAML
|
||||
categories:
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
7
test/source/_posts/2009-01-27-no-topics.textile
Normal file
7
test/source/_posts/2009-01-27-no-topics.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Categories in YAML
|
||||
topics:
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
7
test/source/_posts/2009-01-27-topic.textile
Normal file
7
test/source/_posts/2009-01-27-topic.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Categories in YAML
|
||||
topic: foo
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
7
test/source/_posts/2009-01-27-topics.textile
Normal file
7
test/source/_posts/2009-01-27-topics.textile
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
layout: default
|
||||
title: Categories in YAML
|
||||
topics: foo bar
|
||||
---
|
||||
|
||||
Best *post* ever
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user