├── test ├── source │ ├── _layouts │ │ ├── simple.html │ │ └── default.html │ ├── _posts │ │ ├── 2009-06-22-no-yaml.textile │ │ ├── 2009-06-22-empty-yaml.textile │ │ ├── 2009-05-18-tag.textile │ │ ├── 2009-03-12-hash-#1.markdown │ │ ├── 2008-10-18-foo-bar.textile │ │ ├── 2008-12-13-include.markdown │ │ ├── 2009-01-27-category.textile │ │ ├── 2009-05-18-tags.textile │ │ ├── 2009-01-27-categories.textile │ │ ├── 2008-02-02-published.textile │ │ ├── 2008-11-21-complex.textile │ │ ├── 2008-02-02-not-published.textile │ │ ├── 2009-01-27-array-categories.textile │ │ └── 2008-12-03-permalinked-post.textile │ ├── _includes │ │ └── sig.markdown │ ├── about.html │ ├── contacts.html │ ├── category │ │ └── _posts │ │ │ └── 2008-9-23-categories.textile │ ├── win │ │ └── _posts │ │ │ └── 2009-05-24-yaml-linebreak.markdown │ ├── z_category │ │ └── _posts │ │ │ └── 2008-9-23-categories.textile │ ├── foo │ │ └── _posts │ │ │ └── bar │ │ │ └── 2008-12-12-topical-post.textile │ ├── index.html │ ├── sitemap.xml │ └── css │ │ └── screen.css ├── suite.rb ├── helper.rb ├── test_configuration.rb ├── test_generated_site.rb ├── test_pager.rb ├── test_filters.rb ├── test_site.rb ├── test_page.rb ├── test_tags.rb └── test_post.rb ├── VERSION.yml ├── .gitignore ├── features ├── support │ └── env.rb ├── pagination.feature ├── create_sites.feature ├── embed_filters.feature ├── site_configuration.feature ├── permalinks.feature ├── step_definitions │ └── jekyll_steps.rb ├── site_data.feature └── post_data.feature ├── lib ├── jekyll │ ├── converters │ │ ├── csv.rb │ │ ├── typo.rb │ │ ├── textpattern.rb │ │ ├── wordpress.rb │ │ ├── mt.rb │ │ └── mephisto.rb │ ├── core_ext.rb │ ├── layout.rb │ ├── tags │ │ ├── include.rb │ │ └── highlight.rb │ ├── filters.rb │ ├── pager.rb │ ├── convertible.rb │ ├── page.rb │ ├── albino.rb │ ├── post.rb │ └── site.rb └── jekyll.rb ├── Rakefile ├── README.textile ├── bin └── jekyll ├── jekyll.gemspec └── History.txt /test/source/_layouts/simple.html: -------------------------------------------------------------------------------- 1 | <<< {{ content }} >>> -------------------------------------------------------------------------------- /test/source/_posts/2009-06-22-no-yaml.textile: -------------------------------------------------------------------------------- 1 | No YAML. -------------------------------------------------------------------------------- /VERSION.yml: -------------------------------------------------------------------------------- 1 | --- 2 | :patch: 4 3 | :major: 0 4 | :minor: 5 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/dest 2 | *.gem 3 | pkg/ 4 | *.swp 5 | *~ 6 | _site/ 7 | -------------------------------------------------------------------------------- /test/source/_posts/2009-06-22-empty-yaml.textile: -------------------------------------------------------------------------------- 1 | --- 2 | --- 3 | Empty YAML. -------------------------------------------------------------------------------- /test/source/_includes/sig.markdown: -------------------------------------------------------------------------------- 1 | -- 2 | Tom Preston-Werner 3 | github.com/mojombo -------------------------------------------------------------------------------- /test/source/_posts/2009-05-18-tag.textile: -------------------------------------------------------------------------------- 1 | --- 2 | title: A Tag 3 | tag: code 4 | --- 5 | 6 | Whoa. 7 | -------------------------------------------------------------------------------- /test/source/about.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: About 3 | permalink: /about/ 4 | --- 5 | 6 | About the site 7 | -------------------------------------------------------------------------------- /test/source/contacts.html: -------------------------------------------------------------------------------- 1 | --- 2 | title: Contact Information 3 | --- 4 | 5 | Contact Information 6 | -------------------------------------------------------------------------------- /test/source/_posts/2009-03-12-hash-#1.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Hash #1 4 | --- 5 | 6 | Hashes are nice 7 | -------------------------------------------------------------------------------- /test/source/category/_posts/2008-9-23-categories.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Categories 4 | --- 5 | 6 | Categories _should_ work -------------------------------------------------------------------------------- /test/source/_posts/2008-10-18-foo-bar.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Foo Bar 4 | --- 5 | 6 | h1. {{ page.title }} 7 | 8 | Best *post* ever -------------------------------------------------------------------------------- /test/source/_posts/2008-12-13-include.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Include 4 | --- 5 | 6 | {% include sig.markdown %} 7 | 8 | This _is_ cool -------------------------------------------------------------------------------- /test/source/_posts/2009-01-27-category.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Category in YAML 4 | category: foo 5 | --- 6 | 7 | Best *post* ever 8 | -------------------------------------------------------------------------------- /test/source/_posts/2009-05-18-tags.textile: -------------------------------------------------------------------------------- 1 | --- 2 | title: Some Tags 3 | tags: 4 | - food 5 | - cooking 6 | - pizza 7 | --- 8 | 9 | Awesome! 10 | -------------------------------------------------------------------------------- /test/source/win/_posts/2009-05-24-yaml-linebreak.markdown: -------------------------------------------------------------------------------- 1 | --- 2 | layout: post 3 | title: "Test title" 4 | tag: "Ruby" 5 | --- 6 | 7 | This is the content -------------------------------------------------------------------------------- /test/source/_posts/2009-01-27-categories.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Categories in YAML 4 | categories: foo bar baz 5 | --- 6 | 7 | Best *post* ever 8 | -------------------------------------------------------------------------------- /test/source/_posts/2008-02-02-published.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Publish 4 | category: publish_test 5 | --- 6 | 7 | This should be published. 8 | 9 | -------------------------------------------------------------------------------- /test/source/_posts/2008-11-21-complex.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Complex 4 | --- 5 | 6 | url: {{ page.url }} 7 | date: {{ page.date }} 8 | id: {{ page.id }} -------------------------------------------------------------------------------- /test/source/z_category/_posts/2008-9-23-categories.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Categories 4 | --- 5 | 6 | Categories _should_ work. Even if ordered after index. -------------------------------------------------------------------------------- /test/source/foo/_posts/bar/2008-12-12-topical-post.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Topical Post 4 | --- 5 | 6 | h1. {{ page.title }} 7 | 8 | This post has a topic. 9 | -------------------------------------------------------------------------------- /test/source/_posts/2008-02-02-not-published.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Not published! 4 | published: false 5 | category: publish_test 6 | --- 7 | 8 | This should *not* be published! 9 | -------------------------------------------------------------------------------- /test/source/_posts/2009-01-27-array-categories.textile: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Array categories in YAML 4 | categories: 5 | - foo 6 | - bar 7 | - baz 8 | --- 9 | 10 | Best *post* ever 11 | -------------------------------------------------------------------------------- /test/source/_posts/2008-12-03-permalinked-post.textile: -------------------------------------------------------------------------------- 1 | --- 2 | title: Post with Permalink 3 | permalink: my_category/permalinked-post 4 | --- 5 | 6 | h1. {{ page.title }} 7 | 8 | 9 |
Best post ever
-------------------------------------------------------------------------------- /test/suite.rb: -------------------------------------------------------------------------------- 1 | require 'test/unit' 2 | 3 | # for some reason these tests fail when run via TextMate 4 | # but succeed when run on the command line. 5 | 6 | tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"] 7 | tests.each do |file| 8 | require file 9 | end -------------------------------------------------------------------------------- /features/support/env.rb: -------------------------------------------------------------------------------- 1 | require 'fileutils' 2 | require 'rr' 3 | require 'test/unit' 4 | 5 | World do 6 | include Test::Unit::Assertions 7 | end 8 | 9 | TEST_DIR = File.join('/', 'tmp', 'jekyll') 10 | JEKYLL_PATH = File.join(ENV['PWD'], 'bin', 'jekyll') 11 | 12 | def run_jekyll(opts = {}) 13 | command = JEKYLL_PATH 14 | command << " >> /dev/null 2>&1" if opts[:debug].nil? 15 | system command 16 | end 17 | -------------------------------------------------------------------------------- /test/source/index.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Tom Preston-Werner 4 | --- 5 | 6 | h1. Welcome to my site 7 | 8 | h2. Please read our {{ site.posts | size }} Posts 9 | 10 |
47 | #{h(code).strip}
48 |
49 | something really simple
", @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&T", @filter.xml_escape("AT&T") 38 | assert_equal "<code>command <filename></code>", @filter.xml_escape("command <filename>")
39 | end
40 |
41 | should "escape space as plus" do
42 | assert_equal "my+things", @filter.cgi_escape("my things")
43 | end
44 |
45 | should "escape special characters" do
46 | assert_equal "hey%21", @filter.cgi_escape("hey!")
47 | end
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/lib/jekyll/converters/textpattern.rb:
--------------------------------------------------------------------------------
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
--------------------------------------------------------------------------------
/lib/jekyll/converters/wordpress.rb:
--------------------------------------------------------------------------------
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 WordPress
13 |
14 | # Reads a MySQL database via Sequel and creates a post file for each
15 | # post in wp_posts that has post_status = 'publish'.
16 | # This restriction is made because 'draft' posts are not guaranteed to
17 | # have valid dates.
18 | QUERY = "select post_title, post_name, post_date, post_content, post_excerpt, ID, guid from wp_posts where post_status = 'publish' and post_type = 'post'"
19 |
20 | def self.process(dbname, user, pass, host = 'localhost')
21 | db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
22 |
23 | FileUtils.mkdir_p "_posts"
24 |
25 | db[QUERY].each do |post|
26 | # Get required fields and construct Jekyll compatible name
27 | title = post[:post_title]
28 | slug = post[:post_name]
29 | date = post[:post_date]
30 | content = post[:post_content]
31 | name = "%02d-%02d-%02d-%s.markdown" % [date.year, date.month, date.day,
32 | slug]
33 |
34 | # Get the relevant fields as a hash, delete empty fields and convert
35 | # to YAML for the header
36 | data = {
37 | 'layout' => 'post',
38 | 'title' => title.to_s,
39 | 'excerpt' => post[:post_excerpt].to_s,
40 | 'wordpress_id' => post[:ID],
41 | 'wordpress_url' => post[:guid]
42 | }.delete_if { |k,v| v.nil? || v == ''}.to_yaml
43 |
44 | # Write out the data and content to file
45 | File.open("_posts/#{name}", "w") do |f|
46 | f.puts data
47 | f.puts "---"
48 | f.puts content
49 | end
50 | end
51 |
52 | end
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/features/create_sites.feature:
--------------------------------------------------------------------------------
1 | Feature: Create sites
2 | As a hacker who likes to blog
3 | I want to be able to make a static site
4 | In order to share my awesome ideas with the interwebs
5 |
6 | Scenario: Basic site
7 | Given I have an "index.html" file that contains "Basic Site"
8 | When I run jekyll
9 | Then the _site directory should exist
10 | And I should see "Basic Site" in "_site/index.html"
11 |
12 | Scenario: Basic site with a post
13 | Given I have a _posts directory
14 | And I have the following post:
15 | | title | date | content |
16 | | Hackers | 3/27/2009 | My First Exploit |
17 | When I run jekyll
18 | Then the _site directory should exist
19 | And I should see "My First Exploit" in "_site/2009/03/27/hackers.html"
20 |
21 | Scenario: Basic site with layout and a page
22 | Given I have a _layouts directory
23 | And I have an "index.html" page with layout "default" that contains "Basic Site with Layout"
24 | And I have a default layout that contains "Page Layout: {{ content }}"
25 | When I run jekyll
26 | Then the _site directory should exist
27 | And I should see "Page Layout: Basic Site with Layout" in "_site/index.html"
28 |
29 | Scenario: Basic site with layout and a post
30 | Given I have a _layouts directory
31 | And I have a _posts directory
32 | And I have the following post:
33 | | title | date | layout | content |
34 | | Wargames | 3/27/2009 | default | The only winning move is not to play. |
35 | And I have a default layout that contains "Post Layout: {{ content }}"
36 | When I run jekyll
37 | Then the _site directory should exist
38 | And I should see "Post Layout: The only winning move is not to play.
" in "_site/2009/03/27/wargames.html" 39 | 40 | Scenario: Basic site with include tag 41 | Given I have a _includes directory 42 | And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}" 43 | And I have an "_includes/about.textile" file that contains "Generated by Jekyll" 44 | When I run jekyll 45 | Then the _site directory should exist 46 | And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html" 47 | -------------------------------------------------------------------------------- /lib/jekyll/converters/mt.rb: -------------------------------------------------------------------------------- 1 | # Created by Nick Gerakines, open source and publically available under the 2 | # MIT license. Use this module at your own risk. 3 | # I'm an Erlang/Perl/C++ guy so please forgive my dirty ruby. 4 | 5 | require 'rubygems' 6 | require 'sequel' 7 | require 'fileutils' 8 | 9 | # NOTE: This converter requires Sequel and the MySQL gems. 10 | # The MySQL gem can be difficult to install on OS X. Once you have MySQL 11 | # installed, running the following commands should work: 12 | # $ sudo gem install sequel 13 | # $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config 14 | 15 | module Jekyll 16 | module MT 17 | # This query will pull blog posts from all entries across all blogs. If 18 | # you've got unpublished, deleted or otherwise hidden posts please sift 19 | # through the created posts to make sure nothing is accidently published. 20 | QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more, entry_created_on, entry_title FROM mt_entry" 21 | 22 | def self.process(dbname, user, pass, host = 'localhost') 23 | db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host) 24 | 25 | FileUtils.mkdir_p "_posts" 26 | 27 | db[QUERY].each do |post| 28 | title = post[:entry_title] 29 | slug = post[:entry_basename] 30 | date = post[:entry_created_on] 31 | content = post[:entry_text] 32 | more_content = post[:entry_text_more] 33 | 34 | # Be sure to include the body and extended body. 35 | if more_content != nil 36 | content = content + " \n" + more_content 37 | end 38 | 39 | # Ideally, this script would determine the post format (markdown, html 40 | # , etc) and create files with proper extensions. At this point it 41 | # just assumes that markdown will be acceptable. 42 | name = [date.year, date.month, date.day, slug].join('-') + ".markdown" 43 | 44 | data = { 45 | 'layout' => 'post', 46 | 'title' => title.to_s, 47 | 'mt_id' => post[:entry_id], 48 | }.delete_if { |k,v| v.nil? || v == ''}.to_yaml 49 | 50 | File.open("_posts/#{name}", "w") do |f| 51 | f.puts data 52 | f.puts "---" 53 | f.puts content 54 | end 55 | end 56 | 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/jekyll.rb: -------------------------------------------------------------------------------- 1 | $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed 2 | 3 | # rubygems 4 | require 'rubygems' 5 | 6 | # core 7 | require 'fileutils' 8 | require 'time' 9 | require 'yaml' 10 | 11 | # stdlib 12 | 13 | # 3rd party 14 | require 'liquid' 15 | require 'redcloth' 16 | 17 | # internal requires 18 | require 'jekyll/core_ext' 19 | require 'jekyll/pager' 20 | require 'jekyll/site' 21 | require 'jekyll/convertible' 22 | require 'jekyll/layout' 23 | require 'jekyll/page' 24 | require 'jekyll/post' 25 | require 'jekyll/filters' 26 | require 'jekyll/tags/highlight' 27 | require 'jekyll/tags/include' 28 | require 'jekyll/albino' 29 | 30 | module Jekyll 31 | # Default options. Overriden by values in _config.yml or command-line opts. 32 | # (Strings rather symbols used for compatability with YAML) 33 | DEFAULTS = { 34 | 'auto' => false, 35 | 'server' => false, 36 | 'server_port' => 4000, 37 | 38 | 'source' => '.', 39 | 'destination' => File.join('.', '_site'), 40 | 41 | 'lsi' => false, 42 | 'pygments' => false, 43 | 'markdown' => 'maruku', 44 | 'permalink' => 'date', 45 | 46 | 'maruku' => { 47 | 'use_tex' => false, 48 | 'use_divs' => false, 49 | 'png_engine' => 'blahtex', 50 | 'png_dir' => 'images/latex', 51 | 'png_url' => '/images/latex' 52 | } 53 | } 54 | 55 | # Generate a Jekyll configuration Hash by merging the default options 56 | # with anything in _config.yml, and adding the given options on top 57 | # +override+ is a Hash of config directives 58 | # 59 | # Returns Hash 60 | def self.configuration(override) 61 | # _config.yml may override default source location, but until 62 | # then, we need to know where to look for _config.yml 63 | source = override['source'] || Jekyll::DEFAULTS['source'] 64 | 65 | # Get configuration fromÆ\n}, @result 63 | end 64 | end 65 | 66 | context "simple post with markdown and pre tags" do 67 | setup do 68 | @content = <
Obi-wan
" in "_site/2009/03/27/star-wars.html" 60 | 61 | -------------------------------------------------------------------------------- /features/site_configuration.feature: -------------------------------------------------------------------------------- 1 | Feature: Site configuration 2 | As a hacker who likes to blog 3 | I want to be able to configure jekyll 4 | In order to make setting up a site easier 5 | 6 | Scenario: Change destination directory 7 | Given I have a blank site in "_sourcedir" 8 | And I have an "_sourcedir/index.html" file that contains "Changing source directory" 9 | And I have a configuration file with "source" set to "_sourcedir" 10 | When I run jekyll 11 | Then the _site directory should exist 12 | And I should see "Changing source directory" in "_site/index.html" 13 | 14 | Scenario: Change destination directory 15 | Given I have an "index.html" file that contains "Changing destination directory" 16 | And I have a configuration file with "destination" set to "_mysite" 17 | When I run jekyll 18 | Then the _mysite directory should exist 19 | And I should see "Changing destination directory" in "_mysite/index.html" 20 | 21 | Scenario: Exclude files inline 22 | Given I have an "Rakefile" file that contains "I want to be excluded" 23 | And I have an "README" file that contains "I want to be excluded" 24 | And I have an "index.html" file that contains "I want to be included" 25 | And I have a configuration file with "exclude" set to "Rakefile", "README" 26 | When I run jekyll 27 | Then I should see "I want to be included" in "_site/index.html" 28 | And the "_site/Rakefile" file should not exist 29 | And the "_site/README" file should not exist 30 | 31 | Scenario: Exclude files with YAML array 32 | Given I have an "Rakefile" file that contains "I want to be excluded" 33 | And I have an "README" file that contains "I want to be excluded" 34 | And I have an "index.html" file that contains "I want to be included" 35 | And I have a configuration file with "exclude" set to: 36 | | Value | 37 | | README | 38 | | Rakefile | 39 | When I run jekyll 40 | Then I should see "I want to be included" in "_site/index.html" 41 | And the "_site/Rakefile" file should not exist 42 | And the "_site/README" file should not exist 43 | 44 | Scenario: Use RDiscount for markup 45 | Given I have an "index.markdown" page that contains "[Google](http://google.com)" 46 | And I have a configuration file with "markdown" set to "rdiscount" 47 | When I run jekyll 48 | Then the _site directory should exist 49 | And I should see "Google" in "_site/index.html" 50 | 51 | Scenario: Use Maruku for markup 52 | Given I have an "index.markdown" page that contains "[Google](http://google.com)" 53 | And I have a configuration file with "markdown" set to "maruku" 54 | When I run jekyll 55 | Then the _site directory should exist 56 | And I should see "Google" in "_site/index.html" 57 | 58 | Scenario: Highlight code with pygments 59 | Given I have an "index.html" file that contains "{% highlight ruby %} puts 'Hello world!' {% endhighlight %}" 60 | And I have a configuration file with "pygments" set to "true" 61 | When I run jekyll 62 | Then the _site directory should exist 63 | And I should see "puts 'Hello world!'" in "_site/index.html" 64 | -------------------------------------------------------------------------------- /lib/jekyll/page.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | 3 | class Page 4 | include Convertible 5 | 6 | attr_accessor :site 7 | attr_accessor :name, :ext, :basename 8 | attr_accessor :data, :content, :output 9 | 10 | # Initialize a new Page. 11 | # +site+ is the Site 12 | # +base+ is the String path to theLuke, I am your father.
" in "_site/2009/03/27/star-wars.html" 60 | 61 | Scenario: Use post.categories variable when category is in a folder 62 | Given I have a movies directory 63 | And I have a movies/_posts directory 64 | And I have a _layouts directory 65 | And I have the following post in "movies": 66 | | title | date | layout | content | 67 | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | 68 | And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" 69 | When I run jekyll 70 | Then the _site directory should exist 71 | And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" 72 | 73 | Scenario: Use post.tags variable 74 | Given I have a _posts directory 75 | And I have a _layouts directory 76 | And I have the following post: 77 | | title | date | layout | tag | content | 78 | | Star Wars | 5/18/2009 | simple | twist | Luke, I am your father. | 79 | And I have a simple layout that contains "Post tags: {{ site.posts.first.tags }}" 80 | When I run jekyll 81 | Then the _site directory should exist 82 | And I should see "Post tags: twist" in "_site/2009/05/18/star-wars.html" 83 | 84 | Scenario: Use post.categories variable when categories are in folders 85 | Given I have a movies directory 86 | And I have a movies/scifi directory 87 | And I have a movies/scifi/_posts directory 88 | And I have a _layouts directory 89 | And I have the following post in "movies/scifi": 90 | | title | date | layout | content | 91 | | Star Wars | 3/27/2009 | simple | Luke, I am your father. | 92 | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" 93 | When I run jekyll 94 | Then the _site directory should exist 95 | And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" 96 | 97 | Scenario: Use post.categories variable when category is in YAML 98 | Given I have a _posts directory 99 | And I have a _layouts directory 100 | And I have the following post: 101 | | title | date | layout | category | content | 102 | | Star Wars | 3/27/2009 | simple | movies | Luke, I am your father. | 103 | And I have a simple layout that contains "Post category: {{ site.posts.first.categories }}" 104 | When I run jekyll 105 | Then the _site directory should exist 106 | And I should see "Post category: movies" in "_site/movies/2009/03/27/star-wars.html" 107 | 108 | Scenario: Use post.categories variable when categories are in YAML 109 | Given I have a _posts directory 110 | And I have a _layouts directory 111 | And I have the following post: 112 | | title | date | layout | categories | content | 113 | | Star Wars | 3/27/2009 | simple | ['movies', 'scifi'] | Luke, I am your father. | 114 | And I have a simple layout that contains "Post categories: {{ site.posts.first.categories | array_to_sentence_string }}" 115 | When I run jekyll 116 | Then the _site directory should exist 117 | And I should see "Post categories: movies and scifi" in "_site/movies/scifi/2009/03/27/star-wars.html" 118 | 119 | Scenario: Disable a post from being published 120 | Given I have a _posts directory 121 | And I have an "index.html" file that contains "Published!" 122 | And I have the following post: 123 | | title | date | layout | published | content | 124 | | Star Wars | 3/27/2009 | simple | false | Luke, I am your father. | 125 | When I run jekyll 126 | Then the _site directory should exist 127 | And the "_site/2009/03/27/star-wars.html" file should not exist 128 | And I should see "Published!" in "_site/index.html" 129 | 130 | Scenario: Use a custom variable 131 | Given I have a _posts directory 132 | And I have a _layouts directory 133 | And I have the following post: 134 | | title | date | layout | author | content | 135 | | Star Wars | 3/27/2009 | simple | Darth Vader | Luke, I am your father. | 136 | And I have a simple layout that contains "Post author: {{ site.posts.first.author }}" 137 | When I run jekyll 138 | Then the _site directory should exist 139 | And I should see "Post author: Darth Vader" in "_site/2009/03/27/star-wars.html" 140 | 141 | Scenario: Previous and next posts title 142 | Given I have a _posts directory 143 | And I have a _layouts directory 144 | And I have the following posts: 145 | | title | date | layout | author | content | 146 | | Star Wars | 3/27/2009 | ordered | Darth Vader | Luke, I am your father. | 147 | | Some like it hot | 4/27/2009 | ordered | Osgood | Nobody is perfect. | 148 | | Terminator | 5/27/2009 | ordered | Arnold | Sayonara, baby | 149 | And I have a ordered layout that contains "Previous post: {{ page.previous.title }} and next post: {{ page.next.title }}" 150 | When I run jekyll 151 | Then the _site directory should exist 152 | And I should see "next post: Some like it hot" in "_site/2009/03/27/star-wars.html" 153 | And I should see "Previous post: Some like it hot" in "_site/2009/05/27/terminator.html" 154 | -------------------------------------------------------------------------------- /lib/jekyll/site.rb: -------------------------------------------------------------------------------- 1 | module Jekyll 2 | 3 | class Site 4 | attr_accessor :config, :layouts, :posts, :categories, :exclude, 5 | :source, :dest, :lsi, :pygments, :permalink_style, :tags 6 | 7 | # Initialize the site 8 | # +config+ is a Hash containing site configurations details 9 | # 10 | # Returns