From b2ab24583569623ddc0681be56bcfac31fa89754 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sat, 4 Jun 2011 21:35:04 -0400 Subject: [PATCH 1/4] gave the assertion a failure message --- features/step_definitions/jekyll_steps.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 27239bd5..29abccec 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -121,7 +121,7 @@ When /^I change "(.*)" to contain "(.*)"$/ do |file, text| end Then /^the (.*) directory should exist$/ do |dir| - assert File.directory?(dir) + assert File.directory?(dir), "The directory \"#{dir}\" does not exist" end Then /^I should see "(.*)" in "(.*)"$/ do |text, file| From 2b8017dfdc3d1a237bc7aa63427228701bbe01f7 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sat, 4 Jun 2011 21:36:29 -0400 Subject: [PATCH 2/4] can now set a custom pagination location with pagination_path --- features/pagination.feature | 29 ++++++++++++++++++++++++++++- lib/jekyll/generators/pagination.rb | 8 +++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/features/pagination.feature b/features/pagination.feature index 90b10578..cc3cf4d6 100644 --- a/features/pagination.feature +++ b/features/pagination.feature @@ -19,9 +19,36 @@ Feature: Site pagination And the "_site/page/index.html" file should exist And I should see "" in "_site/page/index.html" And the "_site/page/index.html" file should not exist - + Examples: | num | exist | posts | not_exist | | 1 | 4 | 1 | 5 | | 2 | 2 | 2 | 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- directory should exist + And the "_site/blog/page-/index.html" file should exist + And I should see "" in "_site/blog/page-/index.html" + And the "_site/blog/page-/index.html" file should not exist + + Examples: + | exist | posts | not_exist | + | 2 | 1 | 5 | + | 3 | 1 | 6 | + | 4 | 1 | 7 | diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index 847de4f8..6fb8a3a5 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -37,13 +37,19 @@ module Jekyll if num_page > 1 newpage = Page.new(site, site.source, page.dir, page.name) 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 else page.pager = pager end end end + + private + def paginate_path(site, num_page) + format = site.config['paginate_path'] || "page:num" + format.sub(':num', num_page.to_s) + end end class Pager From 58d8fef7ecd3f8b900130dee003f328dfc563884 Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sun, 5 Jun 2011 15:11:35 -0400 Subject: [PATCH 3/4] added command-line option --paginate_path --- bin/jekyll | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/jekyll b/bin/jekyll index 2e33f377..515db603 100755 --- a/bin/jekyll +++ b/bin/jekyll @@ -102,7 +102,7 @@ opts = OptionParser.new do |opts| opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style| options['permalink'] = style unless style.nil? end - + opts.on("--paginate [POSTS_PER_PAGE]", "Paginate a blog's posts") do |per_page| begin options['paginate'] = per_page.to_i @@ -113,6 +113,16 @@ opts = OptionParser.new do |opts| end end + opts.on("--paginate_path [PAGINATED_URL_FORMAT]", "Leave blank for /page") 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| begin options['limit_posts'] = limit_posts.to_i @@ -148,12 +158,12 @@ if ARGV.size > 0 else migrator = migrator.downcase end - + cmd_options = [] ['file', 'dbname', 'user', 'pass', 'host', 'site'].each do |p| cmd_options << "\"#{options[p]}\"" unless options[p].nil? end - + # It's import time puts "Importing..." From 316cc8559c78cd3aac8683d301d2baaff6cf454f Mon Sep 17 00:00:00 2001 From: Dane Harrigan Date: Sun, 26 Feb 2012 20:58:14 -0800 Subject: [PATCH 4/4] moved paginate_path to default config --- lib/jekyll.rb | 21 +++++++++++---------- lib/jekyll/generators/pagination.rb | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/jekyll.rb b/lib/jekyll.rb index 36642a26..b434ea29 100644 --- a/lib/jekyll.rb +++ b/lib/jekyll.rb @@ -51,21 +51,22 @@ module Jekyll # Default options. Overriden by values in _config.yml or command-line opts. # (Strings rather symbols used for compatability with YAML). DEFAULTS = { - 'safe' => false, - 'auto' => false, - 'server' => false, - 'server_port' => 4000, + 'safe' => false, + 'auto' => false, + 'server' => false, + 'server_port' => 4000, 'source' => Dir.pwd, 'destination' => File.join(Dir.pwd, '_site'), 'plugins' => File.join(Dir.pwd, '_plugins'), - 'future' => true, - 'lsi' => false, - 'pygments' => false, - 'markdown' => 'maruku', - 'permalink' => 'date', - + 'future' => true, + 'lsi' => false, + 'pygments' => false, + 'markdown' => 'maruku', + 'permalink' => 'date', + 'paginate_path' => 'page:num', + 'markdown_ext' => 'markdown,mkd,mkdn,md', 'textile_ext' => 'textile', diff --git a/lib/jekyll/generators/pagination.rb b/lib/jekyll/generators/pagination.rb index 6fb8a3a5..dee5ad54 100644 --- a/lib/jekyll/generators/pagination.rb +++ b/lib/jekyll/generators/pagination.rb @@ -47,7 +47,7 @@ module Jekyll private def paginate_path(site, num_page) - format = site.config['paginate_path'] || "page:num" + format = site.config['paginate_path'] format.sub(':num', num_page.to_s) end end