Merge branch 'master' of https://github.com/daneharrigan/jekyll into daneharrigan-master
Conflicts: lib/jekyll.rb
This commit is contained in:
commit
4533e60489
10
bin/jekyll
10
bin/jekyll
|
@ -117,6 +117,16 @@ opts = OptionParser.new do |opts|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("--paginate_path [PAGINATED_URL_FORMAT]", "Leave blank for /page<num>") do |paginate_path|
|
||||||
|
begin
|
||||||
|
options['paginate_path'] = paginate_path
|
||||||
|
raise ArgumentError if options['paginate_path'].nil?
|
||||||
|
rescue
|
||||||
|
puts 'You must specify a pagination url format'
|
||||||
|
exit 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("--limit_posts [MAX_POSTS]", "Limit the number of posts to publish") do |limit_posts|
|
opts.on("--limit_posts [MAX_POSTS]", "Limit the number of posts to publish") do |limit_posts|
|
||||||
begin
|
begin
|
||||||
options['limit_posts'] = limit_posts.to_i
|
options['limit_posts'] = limit_posts.to_i
|
||||||
|
|
|
@ -25,3 +25,30 @@ Feature: Site pagination
|
||||||
| 1 | 4 | 1 | 5 |
|
| 1 | 4 | 1 | 5 |
|
||||||
| 2 | 2 | 2 | 3 |
|
| 2 | 2 | 2 | 3 |
|
||||||
| 3 | 2 | 1 | 3 |
|
| 3 | 2 | 1 | 3 |
|
||||||
|
|
||||||
|
Scenario Outline: Setting a custom pagination path
|
||||||
|
Given I have a configuration file with:
|
||||||
|
| key | value |
|
||||||
|
| paginate | 1 |
|
||||||
|
| paginate_path | /blog/page-:num |
|
||||||
|
| permalink | /blog/:year/:month/:day/:title |
|
||||||
|
And I have a _layouts directory
|
||||||
|
And I have an "index.html" page that contains "{{ paginator.posts.size }}"
|
||||||
|
And I have a _posts directory
|
||||||
|
And I have the following post:
|
||||||
|
| title | date | layout | content |
|
||||||
|
| Wargames | 3/27/2009 | default | The only winning move is not to play. |
|
||||||
|
| Wargames2 | 4/27/2009 | default | The only winning move is not to play2. |
|
||||||
|
| Wargames3 | 5/27/2009 | default | The only winning move is not to play3. |
|
||||||
|
| Wargames4 | 6/27/2009 | default | The only winning move is not to play4. |
|
||||||
|
When I run jekyll
|
||||||
|
Then the _site/blog/page-<exist> directory should exist
|
||||||
|
And the "_site/blog/page-<exist>/index.html" file should exist
|
||||||
|
And I should see "<posts>" in "_site/blog/page-<exist>/index.html"
|
||||||
|
And the "_site/blog/page-<not_exist>/index.html" file should not exist
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| exist | posts | not_exist |
|
||||||
|
| 2 | 1 | 5 |
|
||||||
|
| 3 | 1 | 6 |
|
||||||
|
| 4 | 1 | 7 |
|
||||||
|
|
|
@ -121,7 +121,7 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the (.*) directory should exist$/ do |dir|
|
Then /^the (.*) directory should exist$/ do |dir|
|
||||||
assert File.directory?(dir)
|
assert File.directory?(dir), "The directory \"#{dir}\" does not exist"
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
Then /^I should see "(.*)" in "(.*)"$/ do |text, file|
|
||||||
|
|
|
@ -51,10 +51,10 @@ module Jekyll
|
||||||
# Default options. Overriden by values in _config.yml or command-line opts.
|
# Default options. Overriden by values in _config.yml or command-line opts.
|
||||||
# (Strings rather symbols used for compatability with YAML).
|
# (Strings rather symbols used for compatability with YAML).
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
'safe' => false,
|
'safe' => false,
|
||||||
'auto' => false,
|
'auto' => false,
|
||||||
'server' => false,
|
'server' => false,
|
||||||
'server_port' => 4000,
|
'server_port' => 4000,
|
||||||
|
|
||||||
'source' => Dir.pwd,
|
'source' => Dir.pwd,
|
||||||
'destination' => File.join(Dir.pwd, '_site'),
|
'destination' => File.join(Dir.pwd, '_site'),
|
||||||
|
@ -66,6 +66,7 @@ module Jekyll
|
||||||
'markdown' => 'maruku',
|
'markdown' => 'maruku',
|
||||||
'permalink' => 'date',
|
'permalink' => 'date',
|
||||||
'include' => ['.htaccess'],
|
'include' => ['.htaccess'],
|
||||||
|
'paginate_path' => 'page:num',
|
||||||
|
|
||||||
'markdown_ext' => 'markdown,mkd,mkdn,md',
|
'markdown_ext' => 'markdown,mkd,mkdn,md',
|
||||||
'textile_ext' => 'textile',
|
'textile_ext' => 'textile',
|
||||||
|
|
|
@ -37,13 +37,19 @@ module Jekyll
|
||||||
if num_page > 1
|
if num_page > 1
|
||||||
newpage = Page.new(site, site.source, page.dir, page.name)
|
newpage = Page.new(site, site.source, page.dir, page.name)
|
||||||
newpage.pager = pager
|
newpage.pager = pager
|
||||||
newpage.dir = File.join(page.dir, "page#{num_page}")
|
newpage.dir = File.join(page.dir, paginate_path(site, num_page))
|
||||||
site.pages << newpage
|
site.pages << newpage
|
||||||
else
|
else
|
||||||
page.pager = pager
|
page.pager = pager
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def paginate_path(site, num_page)
|
||||||
|
format = site.config['paginate_path']
|
||||||
|
format.sub(':num', num_page.to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Pager
|
class Pager
|
||||||
|
|
Loading…
Reference in New Issue