From c4de43c866741317a73963c5115096bc8032929c Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Wed, 25 Feb 2015 18:24:23 +0100 Subject: [PATCH] fix #55 this time add add tests to prove it --- features/bibtex.feature | 2 +- features/details.feature | 44 ++++++++++++++++++++++ features/step_definitions/jekyll_steps.rb | 4 +- features/step_definitions/scholar_steps.rb | 11 +----- lib/jekyll/scholar/generators/details.rb | 3 +- lib/jekyll/scholar/utilities.rb | 2 +- 6 files changed, 51 insertions(+), 15 deletions(-) diff --git a/features/bibtex.feature b/features/bibtex.feature index 7a6c98d..cca5010 100644 --- a/features/bibtex.feature +++ b/features/bibtex.feature @@ -63,7 +63,7 @@ Feature: BibTeX And the "_site/references.html" file should exist And I should see "Look, an umlaut: ΓΌ!" in "_site/references.html" - @tags @bibtex @wip + @tags @bibtex Scenario: Embedded BibTeX Given I have a scholar configuration with: | key | value | diff --git a/features/details.feature b/features/details.feature index 4884702..0b7eff9 100644 --- a/features/details.feature +++ b/features/details.feature @@ -139,4 +139,48 @@ Feature: Details When I run jekyll Then the _site directory should exist And the "_site/scholar.html" file should exist + And the "_site/bibliography/ruby.html" file should exist And I should see "]+href=\"/bibliography/ruby.html\">" in "_site/scholar.html" + + @tags @details @wip + Scenario: Links to Detail Pages Work With Pretty URLs + Given I have a configuration file with "permalink" set to "pretty" + And I have a scholar configuration with: + | key | value | + | source | ./_bibliography | + | bibliogaphy | references | + | details_layout | details.html | + And I have a "_bibliography" directory + And I have a file "_bibliography/references.bib": + """ + @book{ruby, + title = {The Ruby Programming Language}, + author = {Flanagan, David and Matsumoto, Yukihiro}, + year = {2008}, + publisher = {O'Reilly Media} + } + """ + And I have a "_layouts" directory + And I have a file "_layouts/details.html": + """ + --- + --- + + + + {{ page.entry.title }} + + + """ + And I have a page "scholar.html": + """ + --- + --- + {% bibliography %} + """ + When I run jekyll + Then the _site directory should exist + And I should see "pretty" in "_config.yml" + And the "_site/scholar/index.html" file should exist + And I should see "]+href=\"/bibliography/ruby/index.html\">" in "_site/scholar/index.html" + And the "_site/bibliography/ruby/index.html" file should exist diff --git a/features/step_definitions/jekyll_steps.rb b/features/step_definitions/jekyll_steps.rb index 20fef1b..866bc21 100644 --- a/features/step_definitions/jekyll_steps.rb +++ b/features/step_definitions/jekyll_steps.rb @@ -20,14 +20,14 @@ Given(/^I have an? "(.*)" file that contains "(.*)"$/) do |file, text| end Given(/^I have a configuration file with "(.*)" set to "(.*)"$/) do |key, value| - File.open('_config.yml', 'w') do |f| + File.open('_config.yml', 'a') do |f| f.write("#{key}: #{value}\n") f.close end end Given(/^I have a configuration file with:$/) do |table| - File.open('_config.yml', 'w') do |f| + File.open('_config.yml', 'a') do |f| table.hashes.each do |row| f.write("#{row["key"]}: #{row["value"]}\n") end diff --git a/features/step_definitions/scholar_steps.rb b/features/step_definitions/scholar_steps.rb index 7cac358..059fa56 100644 --- a/features/step_definitions/scholar_steps.rb +++ b/features/step_definitions/scholar_steps.rb @@ -9,17 +9,8 @@ Given(/^I have a (?:page|file) "([^"]*)":$/) do |file, string| end end -Given(/^I have a configuration file with "([^\"]*)" set to:$/) do |key, table| - File.open('_config.yml', 'w') do |f| - f.write("#{key}:\n") - table.hashes.each do |row| - f.write(" #{row["key"]}: #{row["value"]}\n") - end - end -end - Given(/^I have a scholar configuration with:$/) do |table| - File.open('_config.yml', 'w') do |f| + File.open('_config.yml', 'a') do |f| f.write("scholar:\n") table.hashes.each do |row| f.write(" #{row["key"]}: #{row["value"]}\n") diff --git a/lib/jekyll/scholar/generators/details.rb b/lib/jekyll/scholar/generators/details.rb index c77581f..24c7624 100644 --- a/lib/jekyll/scholar/generators/details.rb +++ b/lib/jekyll/scholar/generators/details.rb @@ -9,7 +9,8 @@ module Jekyll @config = Scholar.defaults.merge(site.config['scholar'] || {}) - @name = details_file_for(entry) + @name = entry.key.to_s.gsub(/[:\s]+/, '_') + @name << '.html' process(@name) read_yaml(File.join(base, '_layouts'), config['details_layout']) diff --git a/lib/jekyll/scholar/utilities.rb b/lib/jekyll/scholar/utilities.rb index 5c8fbef..08b8c88 100644 --- a/lib/jekyll/scholar/utilities.rb +++ b/lib/jekyll/scholar/utilities.rb @@ -321,7 +321,7 @@ module Jekyll name.gsub!(/[:\s]+/, '_') if site.config['permalink'] == 'pretty' - name << 'index/index.html' + name << '/index.html' else name << '.html' end -- GitLab