From 16c19ecd190b7cb26e4a4e4f97c204f300a3ce65 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 9 Sep 2010 09:37:51 +0200 Subject: [PATCH 1/2] Add a failing test for rendering dotfiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test uses a simple ".htaccess" file that needs to be rendered as any other page, like the sitemap.xml, … --- test/source/.htaccess | 8 ++++++++ test/test_page.rb | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/source/.htaccess diff --git a/test/source/.htaccess b/test/source/.htaccess new file mode 100644 index 00000000..294fb14a --- /dev/null +++ b/test/source/.htaccess @@ -0,0 +1,8 @@ +--- +layout: nil +--- +ErrorDocument 404 /404.html +ErrorDocument 500 /500.html +{% for post in site.posts %} + # {{ post.url }} +{% endfor %} \ No newline at end of file diff --git a/test/test_page.rb b/test/test_page.rb index 6fbb003d..36d38087 100644 --- a/test/test_page.rb +++ b/test/test_page.rb @@ -92,6 +92,15 @@ class TestPage < Test::Unit::TestCase assert File.directory?(dest_dir) assert File.exists?(File.join(dest_dir,'sitemap.xml')) end + + should "write dotfiles properly" do + page = setup_page('.htaccess') + do_render(page) + page.write(dest_dir) + + assert File.directory?(dest_dir) + assert File.exists?(File.join(dest_dir, '.htaccess')) + end end end From e9cf7b46368ede7dc67a5a7318323d6a73728b5b Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Thu, 9 Sep 2010 09:40:47 +0200 Subject: [PATCH 2/2] Treat dotfiles as files without extension If the file starts with a dot, the whole filename is considered the basename and there is not extension. --- lib/jekyll/page.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/jekyll/page.rb b/lib/jekyll/page.rb index 3cdce5df..16053b77 100644 --- a/lib/jekyll/page.rb +++ b/lib/jekyll/page.rb @@ -70,8 +70,14 @@ module Jekyll # # Returns nothing def process(name) - self.ext = File.extname(name) - self.basename = name.split('.')[0..-2].first + # Is it a dotfile ? + if name[/^\./] + self.ext = '' + self.basename = name + else + self.ext = File.extname(name) + self.basename = name.split('.')[0..-2].first + end end # Add any necessary layouts to this post