codeslinger-jekyll 0.5.1 → 0.5.2
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.
- data/.gitignore +6 -0
- data/History.txt +17 -1
- data/README.textile +2 -1
- data/Rakefile +2 -2
- data/VERSION.yml +1 -1
- data/features/create_sites.feature +46 -0
- data/features/embed_filters.feature +60 -0
- data/features/pagination.feature +40 -0
- data/features/permalinks.feature +63 -0
- data/features/post_data.feature +153 -0
- data/features/site_configuration.feature +63 -0
- data/features/site_data.feature +82 -0
- data/features/step_definitions/jekyll_steps.rb +136 -0
- data/features/support/env.rb +16 -0
- data/jekyll.gemspec +134 -0
- data/lib/jekyll.rb +5 -4
- data/lib/jekyll/convertible.rb +6 -4
- data/lib/jekyll/core_ext.rb +9 -1
- data/lib/jekyll/page.rb +52 -10
- data/lib/jekyll/pager.rb +45 -0
- data/lib/jekyll/post.rb +24 -16
- data/lib/jekyll/site.rb +17 -16
- data/test/helper.rb +1 -1
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/about.html +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_generated_site.rb +7 -5
- data/test/test_page.rb +87 -0
- data/test/test_pager.rb +47 -0
- data/test/test_post.rb +37 -4
- data/test/test_site.rb +21 -1
- metadata +31 -6
@@ -0,0 +1,82 @@
|
|
1
|
+
Feature: Site data
|
2
|
+
As a hacker who likes to blog
|
3
|
+
I want to be able to embed data into my site
|
4
|
+
In order to make the site slightly dynamic
|
5
|
+
|
6
|
+
Scenario: Use page variable in a page
|
7
|
+
Given I have an "contact.html" page with title "Contact" that contains "{{ page.title }}: email@me.com"
|
8
|
+
When I run jekyll
|
9
|
+
Then the _site directory should exist
|
10
|
+
And I should see "Contact: email@me.com" in "_site/contact.html"
|
11
|
+
|
12
|
+
Scenario: Use site.time variable
|
13
|
+
Given I have an "index.html" page that contains "{{ site.time }}"
|
14
|
+
When I run jekyll
|
15
|
+
Then the _site directory should exist
|
16
|
+
And I should see today's time in "_site/index.html"
|
17
|
+
|
18
|
+
Scenario: Use site.posts variable for latest post
|
19
|
+
Given I have a _posts directory
|
20
|
+
And I have an "index.html" page that contains "{{ site.posts.first.title }}: {{ site.posts.first.url }}"
|
21
|
+
And I have the following posts:
|
22
|
+
| title | date | content |
|
23
|
+
| First Post | 3/25/2009 | My First Post |
|
24
|
+
| Second Post | 3/26/2009 | My Second Post |
|
25
|
+
| Third Post | 3/27/2009 | My Third Post |
|
26
|
+
When I run jekyll
|
27
|
+
Then the _site directory should exist
|
28
|
+
And I should see "Third Post: /2009/03/27/third-post.html" in "_site/index.html"
|
29
|
+
|
30
|
+
Scenario: Use site.posts variable in a loop
|
31
|
+
Given I have a _posts directory
|
32
|
+
And I have an "index.html" page that contains "{% for post in site.posts %} {{ post.title }} {% endfor %}"
|
33
|
+
And I have the following posts:
|
34
|
+
| title | date | content |
|
35
|
+
| First Post | 3/25/2009 | My First Post |
|
36
|
+
| Second Post | 3/26/2009 | My Second Post |
|
37
|
+
| Third Post | 3/27/2009 | My Third Post |
|
38
|
+
When I run jekyll
|
39
|
+
Then the _site directory should exist
|
40
|
+
And I should see "Third Post Second Post First Post" in "_site/index.html"
|
41
|
+
|
42
|
+
Scenario: Use site.categories.code variable
|
43
|
+
Given I have a _posts directory
|
44
|
+
And I have an "index.html" page that contains "{% for post in site.categories.code %} {{ post.title }} {% endfor %}"
|
45
|
+
And I have the following posts:
|
46
|
+
| title | date | category | content |
|
47
|
+
| Awesome Hack | 3/26/2009 | code | puts 'Hello World' |
|
48
|
+
| Delicious Beer | 3/26/2009 | food | 1) Yuengling |
|
49
|
+
When I run jekyll
|
50
|
+
Then the _site directory should exist
|
51
|
+
And I should see "Awesome Hack" in "_site/index.html"
|
52
|
+
|
53
|
+
Scenario: Use site.tags variable
|
54
|
+
Given I have a _posts directory
|
55
|
+
And I have an "index.html" page that contains "{% for post in site.tags.beer %} {{ post.content }} {% endfor %}"
|
56
|
+
And I have the following posts:
|
57
|
+
| title | date | tag | content |
|
58
|
+
| Delicious Beer | 3/26/2009 | beer | 1) Yuengling |
|
59
|
+
When I run jekyll
|
60
|
+
Then the _site directory should exist
|
61
|
+
And I should see "Yuengling" in "_site/index.html"
|
62
|
+
|
63
|
+
Scenario: Order Posts by name when on the same date
|
64
|
+
Given I have a _posts directory
|
65
|
+
And I have an "index.html" page that contains "{% for post in site.posts %}{{ post.title }}:{{ post.previous.title}},{{ post.next.title}} {% endfor %}"
|
66
|
+
And I have the following posts:
|
67
|
+
| title | date | content |
|
68
|
+
| first | 2/26/2009 | first |
|
69
|
+
| A | 3/26/2009 | A |
|
70
|
+
| B | 3/26/2009 | B |
|
71
|
+
| C | 3/26/2009 | C |
|
72
|
+
| last | 4/26/2009 | last |
|
73
|
+
When I run jekyll
|
74
|
+
Then the _site directory should exist
|
75
|
+
And I should see "last:C, C:B,last B:A,C A:first,B first:,A" in "_site/index.html"
|
76
|
+
|
77
|
+
Scenario: Use configuration date in site payload
|
78
|
+
Given I have an "index.html" page that contains "{{ site.url }}"
|
79
|
+
And I have a configuration file with "url" set to "http://mysite.com"
|
80
|
+
When I run jekyll
|
81
|
+
Then the _site directory should exist
|
82
|
+
And I should see "http://mysite.com" in "_site/index.html"
|
@@ -0,0 +1,136 @@
|
|
1
|
+
Before do
|
2
|
+
FileUtils.mkdir(TEST_DIR)
|
3
|
+
Dir.chdir(TEST_DIR)
|
4
|
+
end
|
5
|
+
|
6
|
+
After do
|
7
|
+
Dir.chdir(TEST_DIR)
|
8
|
+
FileUtils.rm_rf(TEST_DIR)
|
9
|
+
end
|
10
|
+
|
11
|
+
Given /^I have a blank site in "(.*)"$/ do |path|
|
12
|
+
FileUtils.mkdir(path)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Like "I have a foo file" but gives a yaml front matter so jekyll actually processes it
|
16
|
+
Given /^I have an "(.*)" page(?: with (.*) "(.*)")? that contains "(.*)"$/ do |file, key, value, text|
|
17
|
+
File.open(file, 'w') do |f|
|
18
|
+
f.write <<EOF
|
19
|
+
---
|
20
|
+
#{key || 'layout'}: #{value || 'nil'}
|
21
|
+
---
|
22
|
+
#{text}
|
23
|
+
EOF
|
24
|
+
f.close
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Given /^I have an "(.*)" file that contains "(.*)"$/ do |file, text|
|
29
|
+
File.open(file, 'w') do |f|
|
30
|
+
f.write(text)
|
31
|
+
f.close
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Given /^I have a (.*) layout that contains "(.*)"$/ do |layout, text|
|
36
|
+
File.open(File.join('_layouts', layout + '.html'), 'w') do |f|
|
37
|
+
f.write(text)
|
38
|
+
f.close
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
Given /^I have a (.*) directory$/ do |dir|
|
43
|
+
FileUtils.mkdir(dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
Given /^I have the following posts?(?: (.*) "(.*)")?:$/ do |direction, folder, table|
|
47
|
+
table.hashes.each do |post|
|
48
|
+
date = Date.parse(post['date']).strftime('%Y-%m-%d')
|
49
|
+
title = post['title'].downcase.gsub(/[^\w]/, " ").strip.gsub(/\s+/, '-')
|
50
|
+
|
51
|
+
if direction && direction == "in"
|
52
|
+
before = folder || '.'
|
53
|
+
elsif direction && direction == "under"
|
54
|
+
after = folder || '.'
|
55
|
+
end
|
56
|
+
|
57
|
+
path = File.join(before || '.', '_posts', after || '.', "#{date}-#{title}.#{post['type'] || 'textile'}")
|
58
|
+
|
59
|
+
matter_hash = {}
|
60
|
+
%w(title layout tag tags category categories published author).each do |key|
|
61
|
+
matter_hash[key] = post[key] if post[key]
|
62
|
+
end
|
63
|
+
matter = matter_hash.map { |k, v| "#{k}: #{v}\n" }.join.chomp
|
64
|
+
|
65
|
+
content = post['content']
|
66
|
+
if post['input'] && post['filter']
|
67
|
+
content = "{{ #{post['input']} | #{post['filter']} }}"
|
68
|
+
end
|
69
|
+
|
70
|
+
File.open(path, 'w') do |f|
|
71
|
+
f.write <<EOF
|
72
|
+
---
|
73
|
+
#{matter}
|
74
|
+
---
|
75
|
+
#{content}
|
76
|
+
EOF
|
77
|
+
f.close
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
Given /^I have a configuration file with "(.*)" set to "(.*)"$/ do |key, value|
|
83
|
+
File.open('_config.yml', 'w') do |f|
|
84
|
+
f.write("#{key}: #{value}")
|
85
|
+
f.close
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Given /^I have a configuration file with "([^\"]*)" set to:$/ do |key, table|
|
90
|
+
File.open('_config.yml', 'w') do |f|
|
91
|
+
f.write("#{key}:\n")
|
92
|
+
table.hashes.each do |row|
|
93
|
+
f.write("- #{row["Value"]}\n")
|
94
|
+
end
|
95
|
+
f.close
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
When /^I run jekyll$/ do
|
101
|
+
run_jekyll
|
102
|
+
end
|
103
|
+
|
104
|
+
When /^I debug jekyll$/ do
|
105
|
+
run_jekyll(:debug => true)
|
106
|
+
end
|
107
|
+
|
108
|
+
When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
109
|
+
File.open(file, 'a') do |f|
|
110
|
+
f.write(text)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
Then /^the (.*) directory should exist$/ do |dir|
|
115
|
+
assert File.directory?(dir)
|
116
|
+
end
|
117
|
+
|
118
|
+
Then /^the (.*) file should exist$/ do |file|
|
119
|
+
assert File.file?(file)
|
120
|
+
end
|
121
|
+
|
122
|
+
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
123
|
+
assert_match Regexp.new(text), File.open(file).readlines.join
|
124
|
+
end
|
125
|
+
|
126
|
+
Then /^the "(.*)" file should not exist$/ do |file|
|
127
|
+
assert !File.exists?(file)
|
128
|
+
end
|
129
|
+
|
130
|
+
Then /^I should see today's time in "(.*)"$/ do |file|
|
131
|
+
assert_match Regexp.new(Regexp.escape(Time.now.to_s)), File.open(file).readlines.join
|
132
|
+
end
|
133
|
+
|
134
|
+
Then /^I should see today's date in "(.*)"$/ do |file|
|
135
|
+
assert_match Regexp.new(Date.today.to_s), File.open(file).readlines.join
|
136
|
+
end
|
@@ -0,0 +1,16 @@
|
|
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
|
data/jekyll.gemspec
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{jekyll}
|
5
|
+
s.version = "0.5.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Tom Preston-Werner"]
|
9
|
+
s.date = %q{2009-06-24}
|
10
|
+
s.default_executable = %q{jekyll}
|
11
|
+
s.description = %q{Jekyll is a simple, blog aware, static site generator.}
|
12
|
+
s.email = %q{tom@mojombo.com}
|
13
|
+
s.executables = ["jekyll"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.textile"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"History.txt",
|
20
|
+
"README.textile",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"bin/jekyll",
|
24
|
+
"features/create_sites.feature",
|
25
|
+
"features/embed_filters.feature",
|
26
|
+
"features/pagination.feature",
|
27
|
+
"features/permalinks.feature",
|
28
|
+
"features/post_data.feature",
|
29
|
+
"features/site_configuration.feature",
|
30
|
+
"features/site_data.feature",
|
31
|
+
"features/step_definitions/jekyll_steps.rb",
|
32
|
+
"features/support/env.rb",
|
33
|
+
"jekyll.gemspec",
|
34
|
+
"lib/jekyll.rb",
|
35
|
+
"lib/jekyll/albino.rb",
|
36
|
+
"lib/jekyll/converters/csv.rb",
|
37
|
+
"lib/jekyll/converters/mephisto.rb",
|
38
|
+
"lib/jekyll/converters/mt.rb",
|
39
|
+
"lib/jekyll/converters/textpattern.rb",
|
40
|
+
"lib/jekyll/converters/typo.rb",
|
41
|
+
"lib/jekyll/converters/wordpress.rb",
|
42
|
+
"lib/jekyll/convertible.rb",
|
43
|
+
"lib/jekyll/core_ext.rb",
|
44
|
+
"lib/jekyll/filters.rb",
|
45
|
+
"lib/jekyll/layout.rb",
|
46
|
+
"lib/jekyll/page.rb",
|
47
|
+
"lib/jekyll/pager.rb",
|
48
|
+
"lib/jekyll/post.rb",
|
49
|
+
"lib/jekyll/site.rb",
|
50
|
+
"lib/jekyll/tags/highlight.rb",
|
51
|
+
"lib/jekyll/tags/include.rb",
|
52
|
+
"test/helper.rb",
|
53
|
+
"test/source/_includes/sig.markdown",
|
54
|
+
"test/source/_layouts/default.html",
|
55
|
+
"test/source/_layouts/simple.html",
|
56
|
+
"test/source/_posts/2008-02-02-not-published.textile",
|
57
|
+
"test/source/_posts/2008-02-02-published.textile",
|
58
|
+
"test/source/_posts/2008-10-18-foo-bar.textile",
|
59
|
+
"test/source/_posts/2008-11-21-complex.textile",
|
60
|
+
"test/source/_posts/2008-12-03-permalinked-post.textile",
|
61
|
+
"test/source/_posts/2008-12-13-include.markdown",
|
62
|
+
"test/source/_posts/2009-01-27-array-categories.textile",
|
63
|
+
"test/source/_posts/2009-01-27-categories.textile",
|
64
|
+
"test/source/_posts/2009-01-27-category.textile",
|
65
|
+
"test/source/_posts/2009-03-12-hash-#1.markdown",
|
66
|
+
"test/source/_posts/2009-05-18-tag.textile",
|
67
|
+
"test/source/_posts/2009-05-18-tags.textile",
|
68
|
+
"test/source/_posts/2009-06-22-empty-yaml.textile",
|
69
|
+
"test/source/_posts/2009-06-22-no-yaml.textile",
|
70
|
+
"test/source/about.html",
|
71
|
+
"test/source/category/_posts/2008-9-23-categories.textile",
|
72
|
+
"test/source/contacts.html",
|
73
|
+
"test/source/css/screen.css",
|
74
|
+
"test/source/foo/_posts/bar/2008-12-12-topical-post.textile",
|
75
|
+
"test/source/index.html",
|
76
|
+
"test/source/win/_posts/2009-05-24-yaml-linebreak.markdown",
|
77
|
+
"test/source/z_category/_posts/2008-9-23-categories.textile",
|
78
|
+
"test/suite.rb",
|
79
|
+
"test/test_configuration.rb",
|
80
|
+
"test/test_filters.rb",
|
81
|
+
"test/test_generated_site.rb",
|
82
|
+
"test/test_page.rb",
|
83
|
+
"test/test_pager.rb",
|
84
|
+
"test/test_post.rb",
|
85
|
+
"test/test_site.rb",
|
86
|
+
"test/test_tags.rb"
|
87
|
+
]
|
88
|
+
s.homepage = %q{http://github.com/mojombo/jekyll}
|
89
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
90
|
+
s.require_paths = ["lib"]
|
91
|
+
s.rubyforge_project = %q{jekyll}
|
92
|
+
s.rubygems_version = %q{1.3.4}
|
93
|
+
s.summary = %q{Jekyll is a simple, blog aware, static site generator.}
|
94
|
+
s.test_files = [
|
95
|
+
"test/helper.rb",
|
96
|
+
"test/suite.rb",
|
97
|
+
"test/test_configuration.rb",
|
98
|
+
"test/test_filters.rb",
|
99
|
+
"test/test_generated_site.rb",
|
100
|
+
"test/test_page.rb",
|
101
|
+
"test/test_pager.rb",
|
102
|
+
"test/test_post.rb",
|
103
|
+
"test/test_site.rb",
|
104
|
+
"test/test_tags.rb"
|
105
|
+
]
|
106
|
+
|
107
|
+
if s.respond_to? :specification_version then
|
108
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
109
|
+
s.specification_version = 3
|
110
|
+
|
111
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
112
|
+
s.add_runtime_dependency(%q<RedCloth>, [">= 4.2.1"])
|
113
|
+
s.add_runtime_dependency(%q<liquid>, [">= 1.9.0"])
|
114
|
+
s.add_runtime_dependency(%q<classifier>, [">= 1.3.1"])
|
115
|
+
s.add_runtime_dependency(%q<maruku>, [">= 0.5.9"])
|
116
|
+
s.add_runtime_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
117
|
+
s.add_runtime_dependency(%q<open4>, [">= 0.9.6"])
|
118
|
+
else
|
119
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.1"])
|
120
|
+
s.add_dependency(%q<liquid>, [">= 1.9.0"])
|
121
|
+
s.add_dependency(%q<classifier>, [">= 1.3.1"])
|
122
|
+
s.add_dependency(%q<maruku>, [">= 0.5.9"])
|
123
|
+
s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
124
|
+
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
125
|
+
end
|
126
|
+
else
|
127
|
+
s.add_dependency(%q<RedCloth>, [">= 4.2.1"])
|
128
|
+
s.add_dependency(%q<liquid>, [">= 1.9.0"])
|
129
|
+
s.add_dependency(%q<classifier>, [">= 1.3.1"])
|
130
|
+
s.add_dependency(%q<maruku>, [">= 0.5.9"])
|
131
|
+
s.add_dependency(%q<directory_watcher>, [">= 1.1.1"])
|
132
|
+
s.add_dependency(%q<open4>, [">= 0.9.6"])
|
133
|
+
end
|
134
|
+
end
|
data/lib/jekyll.rb
CHANGED
@@ -63,14 +63,15 @@ module Jekyll
|
|
63
63
|
source = override['source'] || Jekyll::DEFAULTS['source']
|
64
64
|
|
65
65
|
# Get configuration from <source>/_config.yml
|
66
|
-
config = {}
|
67
66
|
config_file = File.join(source, '_config.yml')
|
68
67
|
begin
|
69
68
|
config = YAML.load_file(config_file)
|
70
|
-
|
69
|
+
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
70
|
+
STDOUT.puts "Configuration from #{config_file}"
|
71
71
|
rescue => err
|
72
|
-
puts "WARNING: Could not read configuration. Using defaults (and options)."
|
73
|
-
puts "\t" + err
|
72
|
+
STDERR.puts "WARNING: Could not read configuration. Using defaults (and options)."
|
73
|
+
STDERR.puts "\t" + err.to_s
|
74
|
+
config = {}
|
74
75
|
end
|
75
76
|
|
76
77
|
# Merge DEFAULTS < _config.yml < override
|
data/lib/jekyll/convertible.rb
CHANGED
@@ -17,12 +17,14 @@ module Jekyll
|
|
17
17
|
# Returns nothing
|
18
18
|
def read_yaml(base, name)
|
19
19
|
self.content = File.read(File.join(base, name))
|
20
|
-
|
21
|
-
if self.content =~ /^(---\s*\n
|
22
|
-
self.content = self.content[($1.size +
|
23
|
-
|
20
|
+
|
21
|
+
if self.content =~ /^(---\s*\n.*?\n?)(---.*?\n)/m
|
22
|
+
self.content = self.content[($1.size + $2.size)..-1]
|
23
|
+
|
24
24
|
self.data = YAML.load($1)
|
25
25
|
end
|
26
|
+
|
27
|
+
self.data ||= {}
|
26
28
|
end
|
27
29
|
|
28
30
|
# Transform the contents based on the file extension.
|
data/lib/jekyll/core_ext.rb
CHANGED
data/lib/jekyll/page.rb
CHANGED
@@ -4,7 +4,7 @@ module Jekyll
|
|
4
4
|
include Convertible
|
5
5
|
|
6
6
|
attr_accessor :site
|
7
|
-
attr_accessor :ext
|
7
|
+
attr_accessor :name, :ext, :basename
|
8
8
|
attr_accessor :data, :content, :output
|
9
9
|
|
10
10
|
# Initialize a new Page.
|
@@ -17,14 +17,47 @@ module Jekyll
|
|
17
17
|
def initialize(site, base, dir, name)
|
18
18
|
@site = site
|
19
19
|
@base = base
|
20
|
-
@dir
|
20
|
+
@dir = dir
|
21
21
|
@name = name
|
22
22
|
|
23
|
-
self.data = {}
|
24
|
-
|
25
23
|
self.process(name)
|
26
24
|
self.read_yaml(File.join(base, dir), name)
|
27
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
# The generated directory into which the page will be placed
|
28
|
+
# upon generation. This is derived from the permalink or, if
|
29
|
+
# permalink is absent, set to '/'
|
30
|
+
#
|
31
|
+
# Returns <String>
|
32
|
+
def dir
|
33
|
+
url[-1, 1] == '/' ? url : File.dirname(url)
|
34
|
+
end
|
35
|
+
|
36
|
+
# The full path and filename of the post.
|
37
|
+
# Defined in the YAML of the post body
|
38
|
+
# (Optional)
|
39
|
+
#
|
40
|
+
# Returns <String>
|
41
|
+
def permalink
|
42
|
+
self.data && self.data['permalink']
|
43
|
+
end
|
44
|
+
|
45
|
+
def template
|
46
|
+
if self.site.permalink_style == :pretty && !index?
|
47
|
+
"/:name/"
|
48
|
+
else
|
49
|
+
"/:name.html"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# The generated relative url of this page
|
54
|
+
# e.g. /about.html
|
55
|
+
#
|
56
|
+
# Returns <String>
|
57
|
+
def url
|
58
|
+
return permalink if permalink
|
59
|
+
|
60
|
+
@url ||= template.gsub(':name', basename)
|
28
61
|
end
|
29
62
|
|
30
63
|
# Extract information from the page filename
|
@@ -33,6 +66,7 @@ module Jekyll
|
|
33
66
|
# Returns nothing
|
34
67
|
def process(name)
|
35
68
|
self.ext = File.extname(name)
|
69
|
+
self.basename = name.split('.')[0..-2].first
|
36
70
|
end
|
37
71
|
|
38
72
|
# Add any necessary layouts to this post
|
@@ -55,16 +89,24 @@ module Jekyll
|
|
55
89
|
dest = File.join(dest, dest_suffix) if dest_suffix
|
56
90
|
FileUtils.mkdir_p(dest)
|
57
91
|
|
58
|
-
|
59
|
-
|
60
|
-
|
92
|
+
# The url needs to be unescaped in order to preserve the correct filename
|
93
|
+
path = File.join(dest, CGI.unescape(self.url))
|
94
|
+
if self.url[/\.html$/].nil?
|
95
|
+
FileUtils.mkdir_p(path)
|
96
|
+
path = File.join(path, "index.html")
|
61
97
|
end
|
62
98
|
|
63
|
-
path = File.join(dest, name)
|
64
99
|
File.open(path, 'w') do |f|
|
65
100
|
f.write(self.output)
|
66
101
|
end
|
67
102
|
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def index?
|
107
|
+
basename == 'index'
|
108
|
+
end
|
109
|
+
|
68
110
|
end
|
69
111
|
|
70
|
-
end
|
112
|
+
end
|