From eccda125e597229d0854994dac19a7bae12c73fb Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 8 Jan 2013 10:22:52 -0800 Subject: [PATCH] Remove Tilt mappings for missing libraries. Fixes #713 --- .../features/missing-tilt-lib.feature | 20 +++++++++++++++++++ .../missing-tilt-library-app/config.rb | 2 ++ .../source/danger-zone/more-wiki.html.wiki | 1 + .../source/safe-zone/my-wiki.html.wiki | 1 + .../source/textile-source.html.textile | 1 + .../source/wiki-source.html.wiki | 1 + .../core_extensions/rendering.rb | 13 ++++++++++++ 7 files changed, 39 insertions(+) create mode 100644 middleman-core/features/missing-tilt-lib.feature create mode 100644 middleman-core/fixtures/missing-tilt-library-app/config.rb create mode 100644 middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki create mode 100644 middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki create mode 100644 middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile create mode 100644 middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki diff --git a/middleman-core/features/missing-tilt-lib.feature b/middleman-core/features/missing-tilt-lib.feature new file mode 100644 index 00000000..95b7ba5a --- /dev/null +++ b/middleman-core/features/missing-tilt-lib.feature @@ -0,0 +1,20 @@ +Feature: Tilt missing support libraries + + Scenario: Rendering Textile and Wiki files + Given the Server is running at "missing-tilt-library-app" + When I go to "/danger-zone/more-wiki.html.wiki" + Then I should see "File Not Found" + When I go to "/danger-zone/more-wiki.html" + Then I should see "File Not Found" + When I go to "/safe-zone/my-wiki.html.wiki" + Then I should see "Safe" + When I go to "/safe-zone/my-wiki.html" + Then I should see "File Not Found" + When I go to "/textile-source.html.textile" + Then I should see "File Not Found" + When I go to "/textile-source.html" + Then I should see "File Not Found" + When I go to "/wiki-source.html.wiki" + Then I should see "Hola" + When I go to "/wiki-source.html" + Then I should see "File Not Found" \ No newline at end of file diff --git a/middleman-core/fixtures/missing-tilt-library-app/config.rb b/middleman-core/fixtures/missing-tilt-library-app/config.rb new file mode 100644 index 00000000..4fcf66d7 --- /dev/null +++ b/middleman-core/fixtures/missing-tilt-library-app/config.rb @@ -0,0 +1,2 @@ +ignore "danger-zone/*" +ignore "*.textile" \ No newline at end of file diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki new file mode 100644 index 00000000..32a18237 --- /dev/null +++ b/middleman-core/fixtures/missing-tilt-library-app/source/danger-zone/more-wiki.html.wiki @@ -0,0 +1 @@ +More \ No newline at end of file diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki new file mode 100644 index 00000000..dc30e052 --- /dev/null +++ b/middleman-core/fixtures/missing-tilt-library-app/source/safe-zone/my-wiki.html.wiki @@ -0,0 +1 @@ +Safe \ No newline at end of file diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile b/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile new file mode 100644 index 00000000..04e4284f --- /dev/null +++ b/middleman-core/fixtures/missing-tilt-library-app/source/textile-source.html.textile @@ -0,0 +1 @@ +Textx \ No newline at end of file diff --git a/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki b/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki new file mode 100644 index 00000000..af5a0623 --- /dev/null +++ b/middleman-core/fixtures/missing-tilt-library-app/source/wiki-source.html.wiki @@ -0,0 +1 @@ +Hola \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index d3d72216..4f1ade6c 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -75,6 +75,19 @@ module Middleman app.register Middleman::Renderers::Stylus rescue LoadError end + + # Clean up missing Tilt exts + app.after_configuration do + Tilt.mappings.each do |key, klasses| + begin + Tilt[".#{key}"] + rescue LoadError + Tilt.mappings.delete(key) + rescue NameError + Tilt.mappings.delete(key) + end + end + end end alias :included :registered