middleman 2.0.16.1 → 3.0.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/CHANGELOG +16 -8
- data/features/builder.feature +2 -5
- data/features/cache_buster.feature +1 -1
- data/features/clean_build.feature +0 -1
- data/features/coffee-script.feature +3 -3
- data/features/custom_layout_engines.feature +10 -0
- data/features/directory_index.feature +0 -1
- data/features/dynamic_pages.feature +0 -1
- data/features/fonts.feature +0 -1
- data/features/{padrino_helpers.feature → former_padrino_helpers.feature} +1 -1
- data/features/sprockets.feature +34 -5
- data/features/sprockets_gems.feature +7 -4
- data/features/step_definitions/asset_host_steps.rb +7 -6
- data/features/step_definitions/builder_steps.rb +4 -0
- data/features/step_definitions/middleman_steps.rb +22 -16
- data/features/step_definitions/page_layout_steps.rb +10 -8
- data/fixtures/custom-layout-app/config.rb +1 -0
- data/fixtures/custom-layout-app/source/index.html.erb +1 -0
- data/fixtures/custom-layout-app/source/layout.haml +6 -0
- data/fixtures/sprockets-app/config.rb +2 -1
- data/fixtures/sprockets-app/source/library/css/bootstrap_include.css.scss +1 -0
- data/fixtures/sprockets-app/source/library/css/plain.css +3 -0
- data/fixtures/sprockets-app/source/library/css/sprockets_base1.css.scss +1 -0
- data/fixtures/sprockets-app/source/library/css/sprockets_base2.css.scss +1 -0
- data/fixtures/sprockets-app/source/library/css/sprockets_sub.css.scss +1 -0
- data/fixtures/sprockets-app/source/{jquery_include.js → library/js/jquery_include.js} +0 -0
- data/fixtures/sprockets-app/source/library/js/plain.js +3 -0
- data/fixtures/sprockets-app/source/library/{javascripts → js}/sprockets_base.js +0 -0
- data/fixtures/sprockets-app/source/library/{javascripts → js}/sprockets_sub.js +0 -0
- data/fixtures/test-app/config.rb +5 -4
- data/fixtures/test-app/source/{padrino_test.html.haml → former_padrino_test.html.haml} +0 -0
- data/fixtures/test-app/source/stylesheets/sprockets_base1.css.scss +1 -0
- data/fixtures/test-app/source/stylesheets/sprockets_base2.css.scss +1 -0
- data/fixtures/test-app/source/stylesheets/sprockets_sub.css.scss +1 -0
- data/lib/middleman.rb +27 -25
- data/lib/middleman/base.rb +408 -166
- data/lib/middleman/builder.rb +78 -162
- data/lib/middleman/cli.rb +61 -32
- data/lib/middleman/core_extensions/assets.rb +4 -44
- data/lib/middleman/core_extensions/builder.rb +12 -16
- data/lib/middleman/core_extensions/compass.rb +28 -57
- data/lib/middleman/core_extensions/data.rb +65 -49
- data/lib/middleman/core_extensions/default_helpers.rb +33 -18
- data/lib/middleman/core_extensions/features.rb +48 -26
- data/lib/middleman/core_extensions/file_watcher.rb +66 -0
- data/lib/middleman/core_extensions/front_matter.rb +91 -86
- data/lib/middleman/core_extensions/rendering.rb +9 -8
- data/lib/middleman/core_extensions/routing.rb +19 -53
- data/lib/middleman/core_extensions/sitemap.rb +229 -0
- data/lib/middleman/core_extensions/sprockets.rb +53 -37
- data/lib/middleman/features/asset_host.rb +20 -10
- data/lib/middleman/features/automatic_image_sizes.rb +12 -9
- data/lib/middleman/features/cache_buster.rb +38 -25
- data/lib/middleman/features/directory_indexes.rb +31 -28
- data/lib/middleman/features/minify_css.rb +3 -2
- data/lib/middleman/features/minify_css/cssmin.rb +55 -0
- data/lib/middleman/features/minify_javascript.rb +12 -5
- data/lib/middleman/features/relative_assets.rb +28 -25
- data/lib/middleman/features/sitemap_tree.rb +34 -0
- data/lib/middleman/guard.rb +57 -23
- data/lib/middleman/renderers/erb.rb +29 -0
- data/lib/middleman/renderers/liquid.rb +3 -12
- data/lib/middleman/renderers/markdown.rb +16 -15
- data/lib/middleman/renderers/sass.rb +34 -38
- data/lib/middleman/vendor/hooks-0.2.0/CHANGES.textile +9 -0
- data/lib/middleman/vendor/hooks-0.2.0/Gemfile +3 -0
- data/lib/middleman/vendor/hooks-0.2.0/README.rdoc +107 -0
- data/lib/middleman/vendor/hooks-0.2.0/Rakefile +12 -0
- data/lib/middleman/vendor/hooks-0.2.0/hooks.gemspec +22 -0
- data/lib/middleman/vendor/hooks-0.2.0/lib/hooks.rb +109 -0
- data/lib/middleman/vendor/hooks-0.2.0/lib/hooks/inheritable_attribute.rb +33 -0
- data/lib/middleman/vendor/hooks-0.2.0/test/hooks_test.rb +141 -0
- data/lib/middleman/vendor/hooks-0.2.0/test/inheritable_attribute_test.rb +55 -0
- data/lib/middleman/vendor/hooks-0.2.0/test/test_helper.rb +10 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/.document +5 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/.gitignore +22 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/.yardopts +1 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/LICENSE.txt +20 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/README.rdoc +294 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/Rakefile +5 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/bin/padrino +9 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core.rb +167 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application.rb +270 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/rendering.rb +292 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/routing.rb +934 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/application/showexceptions.rb +20 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/caller.rb +53 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/adapter.rb +24 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/base.rb +151 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/console.rb +20 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake.rb +24 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/cli/rake_tasks.rb +59 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/command.rb +38 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/404.png +0 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/images/500.png +0 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/loader.rb +210 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/cs.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/da.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/de.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/en.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/es.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/fr.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/hu.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/it.yml +40 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ja.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/lv.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/nl.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/no.yml +35 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pl.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/pt_br.yml +40 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/ru.yml +35 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/tr.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/uk.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_cn.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/locale/zh_tw.yml +34 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/logger.rb +345 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/mounter.rb +224 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/reloader.rb +254 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/router.rb +98 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/server.rb +79 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/support_lite.rb +199 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/tasks.rb +21 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/lib/padrino-core/version.rb +20 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/padrino-core.gemspec +38 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.components +6 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/.gitignore +7 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/complex.rb +32 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/apps/simple.rb +33 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/a.rb +9 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/b.rb +4 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/c.rb +1 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/e.rb +13 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/f.rb +2 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/circular/g.rb +2 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/fixtures/dependencies/d.rb +4 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/helper.rb +81 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/mini_shoulda.rb +45 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_application.rb +108 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_core.rb +79 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_dependencies.rb +44 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_filters.rb +278 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_locale.rb +21 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_logger.rb +100 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_mounter.rb +177 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_complex.rb +75 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_reloader_simple.rb +98 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_rendering.rb +461 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_restful_routing.rb +33 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_router.rb +146 -0
- data/lib/middleman/vendor/padrino-core-0.10.5/test/test_routing.rb +1673 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/.document +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/.gitignore +21 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/.yardopts +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/LICENSE.txt +20 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/README.rdoc +239 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/Rakefile +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers.rb +58 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/asset_tag_helpers.rb +420 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/abstract_form_builder.rb +220 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_builder/standard_form_builder.rb +43 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/form_helpers.rb +602 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/format_helpers.rb +381 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/cs.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/da.yml +91 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/de.yml +81 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/en.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/es.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/fr.yml +80 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/hu.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/it.yml +89 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ja.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/lv.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/nl.yml +82 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/no.yml +91 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pl.yml +95 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/pt_br.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/ru.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/tr.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/uk.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_cn.yml +104 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/locale/zh_tw.yml +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/number_helpers.rb +288 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers.rb +175 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/abstract_handler.rb +98 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/erb_handler.rb +79 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/haml_handler.rb +63 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/output_helpers/slim_handler.rb +81 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/render_helpers.rb +60 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/tag_helpers.rb +103 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/lib/padrino-helpers/translation_helpers.rb +38 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/padrino-helpers.gemspec +27 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/app.rb +73 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.erb +14 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.haml +12 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/capture_concat.slim +13 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.erb +14 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.haml +12 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_for.slim +12 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.erb +11 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.haml +9 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/content_tag.slim +9 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.erb +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.haml +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/current_engine.slim +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.erb +20 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.haml +15 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/fields_for.slim +15 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.erb +56 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.haml +47 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_for.slim +47 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.erb +56 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.haml +45 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/form_tag.slim +45 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.erb +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.haml +4 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/link_to.slim +4 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.erb +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.haml +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/mail_to.slim +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.erb +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.haml +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/meta_tag.slim +3 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_erb.erb +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_haml.haml +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/partials/_slim.slim +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.erb +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.haml +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/markup_app/views/simple_partial.slim +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/app.rb +50 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engine.haml +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_erb.erb +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_haml.haml +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/current_engines/_slim.slim +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/erb/test.erb +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/explicit_engine.haml +5 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/haml/test.haml +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/_user.haml +7 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/haml_template.haml +1 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/fixtures/render_app/views/template/some_template.haml +2 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/helper.rb +66 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_asset_tag_helpers.rb +320 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_builder.rb +996 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_form_helpers.rb +645 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_format_helpers.rb +227 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_locale.rb +20 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_number_helpers.rb +136 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_output_helpers.rb +153 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_render_helpers.rb +76 -0
- data/lib/middleman/vendor/padrino-helpers-0.10.5/test/test_tag_helpers.rb +105 -0
- data/lib/middleman/version.rb +1 -1
- data/middleman-x86-mingw32.gemspec +16 -33
- data/middleman.gemspec +16 -31
- metadata +590 -349
- data/features/sinatra.feature +0 -6
- data/lib/middleman/core_extensions/rack_map.rb +0 -35
- data/lib/middleman/renderers/coffee_script.rb +0 -8
- data/lib/middleman/renderers/haml.rb +0 -31
- data/lib/middleman/renderers/slim.rb +0 -8
data/lib/middleman/base.rb
CHANGED
@@ -1,137 +1,70 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "rack"
|
2
|
+
require "tilt"
|
3
3
|
require "i18n"
|
4
|
-
|
4
|
+
require "middleman/vendor/hooks-0.2.0/lib/hooks"
|
5
|
+
|
5
6
|
require "active_support"
|
6
7
|
require "active_support/json"
|
7
|
-
require "active_support/core_ext/
|
8
|
+
require "active_support/core_ext/string/inflections"
|
8
9
|
|
9
|
-
|
10
|
+
class Middleman::Base
|
11
|
+
include Hooks
|
12
|
+
define_hook :before
|
13
|
+
define_hook :ready
|
14
|
+
define_hook :initialized
|
15
|
+
|
10
16
|
class << self
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
app.
|
32
|
-
|
33
|
-
app.set :build_dir, "build" # Which folder are builds output to
|
34
|
-
app.set :http_prefix, nil # During build, add a prefix for absolute paths
|
35
|
-
|
36
|
-
# Pass all request to Middleman, even "static" files
|
37
|
-
app.set :static, false
|
38
|
-
|
39
|
-
app.set :views, "source"
|
40
|
-
|
41
|
-
# Add Builder Callbacks
|
42
|
-
app.register Middleman::CoreExtensions::Builder
|
43
|
-
|
44
|
-
# Add Rack::Builder.map to Sinatra
|
45
|
-
app.register Middleman::CoreExtensions::RackMap
|
46
|
-
|
47
|
-
# Activate custom features
|
48
|
-
app.register Middleman::CoreExtensions::Features
|
49
|
-
|
50
|
-
# Activate Yaml Data package
|
51
|
-
app.register Middleman::CoreExtensions::Data
|
52
|
-
|
53
|
-
# Setup custom rendering
|
54
|
-
app.register Middleman::CoreExtensions::Rendering
|
55
|
-
|
56
|
-
# Compass framework
|
57
|
-
app.register Middleman::CoreExtensions::Compass
|
58
|
-
|
59
|
-
# Sprockets asset handling
|
60
|
-
app.register Middleman::CoreExtensions::Sprockets
|
61
|
-
|
62
|
-
# Setup asset path pipeline
|
63
|
-
app.register Middleman::CoreExtensions::Assets
|
64
|
-
|
65
|
-
# Activate built-in helpers
|
66
|
-
app.register Middleman::CoreExtensions::DefaultHelpers
|
67
|
-
|
68
|
-
# with_layout and page routing
|
69
|
-
app.register Middleman::CoreExtensions::Routing
|
70
|
-
|
71
|
-
# Parse YAML from templates
|
72
|
-
app.register Middleman::CoreExtensions::FrontMatter
|
73
|
-
|
74
|
-
app.set :default_features, [
|
75
|
-
:lorem
|
76
|
-
]
|
77
|
-
|
78
|
-
# Default layout name
|
79
|
-
app.set :layout, :layout
|
80
|
-
|
81
|
-
# This will match all requests not overridden in the project's config.rb
|
82
|
-
app.not_found do
|
83
|
-
process_request
|
84
|
-
end
|
85
|
-
|
86
|
-
# Custom 404 handler (to be styled)
|
87
|
-
app.error Sinatra::NotFound do
|
88
|
-
content_type 'text/html'
|
89
|
-
"<html><body><h1>File Not Found</h1><p>#{request.path_info}</p></body>"
|
90
|
-
end
|
91
|
-
|
92
|
-
# See if Tilt cannot handle this file
|
93
|
-
app.before_processing(:base) do |result|
|
94
|
-
request_path = request.path_info.gsub("%20", " ")
|
95
|
-
should_be_ignored = !(request["is_proxy"]) && settings.excluded_paths.include?("/#{request_path}")
|
96
|
-
|
97
|
-
if result && !should_be_ignored
|
98
|
-
extensionless_path, template_engine = result
|
17
|
+
def reset!
|
18
|
+
@app = nil
|
19
|
+
@prototype = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def app
|
23
|
+
@app ||= Rack::Builder.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def inst(&block)
|
27
|
+
@inst ||= new(&block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_rack_app(&block)
|
31
|
+
inner_app = inst(&block)
|
32
|
+
app.map("/") { run inner_app }
|
33
|
+
app
|
34
|
+
end
|
35
|
+
|
36
|
+
def prototype
|
37
|
+
@prototype ||= app.to_app
|
38
|
+
end
|
99
39
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
send_file File.join(settings.views, request_path)
|
107
|
-
false
|
108
|
-
else
|
109
|
-
true
|
110
|
-
end
|
111
|
-
else
|
112
|
-
if !%w(favicon.ico).include?(request_path)
|
113
|
-
$stderr.puts "File not found: #{request_path}"
|
114
|
-
end
|
115
|
-
|
116
|
-
status 404
|
117
|
-
false
|
118
|
-
end
|
119
|
-
end
|
40
|
+
def call(env)
|
41
|
+
prototype.call(env)
|
42
|
+
end
|
43
|
+
|
44
|
+
def use(middleware, *args, &block)
|
45
|
+
app.use(middleware, *args, &block)
|
120
46
|
end
|
121
|
-
alias :included :registered
|
122
|
-
end
|
123
|
-
|
124
|
-
module ClassMethods
|
125
|
-
# Override Sinatra's set to accept a block
|
126
|
-
# Specifically for the asset_host feature
|
127
|
-
def set(option, value = (not_set = true), ignore_setter = false, &block)
|
128
|
-
if block_given?
|
129
|
-
value = Proc.new { block }
|
130
|
-
end
|
131
47
|
|
132
|
-
|
48
|
+
def map(map, &block)
|
49
|
+
app.map(map, &block)
|
133
50
|
end
|
134
51
|
|
52
|
+
def helpers(*extensions, &block)
|
53
|
+
class_eval(&block) if block_given?
|
54
|
+
include(*extensions) if extensions.any?
|
55
|
+
end
|
56
|
+
|
57
|
+
def defaults
|
58
|
+
@defaults ||= {}
|
59
|
+
end
|
60
|
+
|
61
|
+
def set(key, value)
|
62
|
+
@defaults ||= {}
|
63
|
+
@defaults[key] = value
|
64
|
+
end
|
65
|
+
|
66
|
+
def asset_stamp; false; end
|
67
|
+
|
135
68
|
def before_processing(name=:unnamed, idx=-1, &block)
|
136
69
|
@before_processes ||= []
|
137
70
|
@before_processes.insert(idx, [name, block])
|
@@ -144,64 +77,373 @@ module Middleman::Base
|
|
144
77
|
inst.instance_exec(resolved_template, &block)
|
145
78
|
end
|
146
79
|
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def set(key, value=nil, &block)
|
83
|
+
setter = "#{key}=".to_sym
|
84
|
+
self.class.send(:attr_accessor, key) if !respond_to?(setter)
|
85
|
+
value = block if block_given?
|
86
|
+
send(setter, value)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Basic Sinatra config
|
90
|
+
set :root, Dir.pwd
|
91
|
+
set :source, "source"
|
92
|
+
set :environment, (ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development
|
93
|
+
set :logging, false
|
94
|
+
|
95
|
+
# Middleman-specific options
|
96
|
+
set :index_file, "index.html" # What file responds to folder requests
|
97
|
+
# Such as the homepage (/) or subfolders (/about/)
|
98
|
+
|
99
|
+
# These directories are passed directly to Compass
|
100
|
+
set :js_dir, "javascripts" # Where to look for javascript files
|
101
|
+
set :css_dir, "stylesheets" # Where to look for CSS files
|
102
|
+
set :images_dir, "images" # Where to look for images
|
103
|
+
|
104
|
+
set :build_dir, "build" # Which folder are builds output to
|
105
|
+
set :http_prefix, nil # During build, add a prefix for absolute paths
|
106
|
+
|
107
|
+
set :views, "source"
|
108
|
+
|
109
|
+
set :default_features, [
|
110
|
+
:lorem,
|
111
|
+
# :sitemap_tree
|
112
|
+
]
|
113
|
+
|
114
|
+
# Default layout name
|
115
|
+
set :layout, :layout
|
116
|
+
|
117
|
+
# Activate custom features and extensions
|
118
|
+
include Middleman::CoreExtensions::Features
|
119
|
+
|
120
|
+
# Add Builder Callbacks
|
121
|
+
register Middleman::CoreExtensions::Builder
|
122
|
+
|
123
|
+
# Add Guard Callbacks
|
124
|
+
register Middleman::CoreExtensions::FileWatcher
|
125
|
+
|
126
|
+
# Sitemap
|
127
|
+
register Middleman::CoreExtensions::Sitemap
|
128
|
+
|
129
|
+
# Activate Data package
|
130
|
+
register Middleman::CoreExtensions::Data
|
131
|
+
|
132
|
+
# Setup custom rendering
|
133
|
+
register Middleman::CoreExtensions::Rendering
|
134
|
+
|
135
|
+
# Compass framework
|
136
|
+
register Middleman::CoreExtensions::Compass
|
137
|
+
|
138
|
+
# Sprockets asset handling
|
139
|
+
register Middleman::CoreExtensions::Sprockets
|
140
|
+
|
141
|
+
# Setup asset path pipeline
|
142
|
+
register Middleman::CoreExtensions::Assets
|
143
|
+
|
144
|
+
# Activate built-in helpers
|
145
|
+
register Middleman::CoreExtensions::DefaultHelpers
|
146
|
+
|
147
|
+
# with_layout and page routing
|
148
|
+
register Middleman::CoreExtensions::Routing
|
149
|
+
|
150
|
+
# Parse YAML from templates
|
151
|
+
register Middleman::CoreExtensions::FrontMatter
|
152
|
+
|
153
|
+
def initialize(&block)
|
154
|
+
self.class.superclass.defaults.each do |k, v|
|
155
|
+
set(k, v)
|
156
|
+
end
|
157
|
+
|
158
|
+
instance_exec(&block) if block_given?
|
159
|
+
|
160
|
+
set :source_dir, File.join(root, source)
|
161
|
+
|
162
|
+
super
|
147
163
|
|
148
|
-
|
149
|
-
def build?; environment == :build; end
|
164
|
+
run_hook :initialized
|
150
165
|
end
|
151
166
|
|
152
|
-
|
153
|
-
|
154
|
-
|
167
|
+
attr :env
|
168
|
+
attr :req
|
169
|
+
attr :res
|
170
|
+
attr :options
|
171
|
+
attr :locals
|
172
|
+
|
173
|
+
def call(env)
|
174
|
+
@env = env
|
175
|
+
@req = Rack::Request.new(env)
|
176
|
+
@res = Rack::Response.new
|
177
|
+
|
178
|
+
catch(:halt) do
|
179
|
+
process_request
|
180
|
+
|
181
|
+
res.status = 404
|
182
|
+
res.finish
|
155
183
|
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def halt(response)
|
187
|
+
throw :halt, response
|
188
|
+
end
|
189
|
+
|
190
|
+
# Convenience methods to check if we're in a mode
|
191
|
+
def development?; environment == :development; end
|
192
|
+
def build?; environment == :build; end
|
156
193
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
194
|
+
# Internal method to look for templates and evaluate them if found
|
195
|
+
def process_request
|
196
|
+
# Normalize the path and add index if we're looking at a directory
|
197
|
+
@original_path = env["PATH_INFO"].dup
|
198
|
+
@request_path = full_path(env["PATH_INFO"].gsub("%20", " "))
|
199
|
+
|
200
|
+
run_hook :before
|
201
|
+
|
202
|
+
return not_found if sitemap.ignored_path?(@request_path)
|
203
|
+
|
204
|
+
if sitemap.path_is_proxy?(@request_path)
|
205
|
+
@request_path = "/" + sitemap.path_target(@request_path)
|
206
|
+
end
|
207
|
+
|
208
|
+
found_template = resolve_template(@request_path)
|
209
|
+
return not_found unless found_template
|
210
|
+
|
211
|
+
@current_path = @request_path.dup
|
212
|
+
path, engine = found_template
|
213
|
+
|
214
|
+
# Static File
|
215
|
+
return send_file(path) if engine.nil?
|
216
|
+
|
217
|
+
return unless self.class.execute_before_processing!(self, found_template)
|
218
|
+
|
219
|
+
context = sitemap.get_context(full_path(@original_path.gsub("%20", " "))) || {}
|
220
|
+
|
221
|
+
@options = context.has_key?(:options) ? context[:options] : {}
|
222
|
+
@locals = context.has_key?(:locals) ? context[:locals] : {}
|
223
|
+
|
224
|
+
provides_metadata.each do |callback, matcher|
|
225
|
+
next if !matcher.nil? && !path.match(matcher)
|
226
|
+
instance_exec(path, &callback)
|
227
|
+
end
|
228
|
+
|
229
|
+
local_layout = if options.has_key?(:layout)
|
230
|
+
options[:layout]
|
231
|
+
elsif %w(.js .css .txt).include?(File.extname(@request_path))
|
232
|
+
false
|
233
|
+
else
|
234
|
+
layout
|
235
|
+
end
|
236
|
+
|
237
|
+
if context.has_key?(:block) && context[:block]
|
238
|
+
instance_eval(&context[:block])
|
239
|
+
end
|
240
|
+
|
241
|
+
output = if local_layout
|
242
|
+
engine_options = respond_to?(engine.to_sym) ? send(engine.to_sym) : {}
|
162
243
|
|
163
|
-
|
164
|
-
|
244
|
+
layout_engine = if options.has_key?(:layout_engine)
|
245
|
+
options[:layout_engine]
|
246
|
+
elsif engine_options.has_key?(:layout_engine)
|
247
|
+
engine_options[:layout_engine]
|
248
|
+
else
|
249
|
+
engine
|
250
|
+
end
|
165
251
|
|
166
|
-
|
167
|
-
found_template = resolve_template(request_path, :raise_exceptions => false)
|
168
|
-
return status(404) unless found_template
|
169
|
-
return unless settings.execute_before_processing!(self, found_template)
|
252
|
+
layout_path, *etc = resolve_template(local_layout, :preferred_engine => layout_engine)
|
170
253
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
254
|
+
if !layout_path
|
255
|
+
local_layout = File.join("layouts", local_layout.to_s)
|
256
|
+
layout_path, *etc = resolve_template(local_layout, :preferred_engine => layout_engine)
|
257
|
+
end
|
258
|
+
|
259
|
+
throw "Could not locate layout: #{local_layout}" unless layout_path
|
260
|
+
|
261
|
+
render(layout_path, locals, options) do
|
262
|
+
render(path, locals, options)
|
263
|
+
end
|
264
|
+
else
|
265
|
+
render(path, locals)
|
266
|
+
end
|
267
|
+
|
268
|
+
content_type mime_type(File.extname(@request_path))
|
269
|
+
res.status = 200
|
270
|
+
res.write output
|
271
|
+
halt res.finish
|
272
|
+
end
|
273
|
+
|
274
|
+
public
|
275
|
+
def extensionless_path(file)
|
276
|
+
@_extensionless_path_cache ||= {}
|
277
|
+
|
278
|
+
if @_extensionless_path_cache.has_key?(file)
|
279
|
+
@_extensionless_path_cache[file]
|
280
|
+
else
|
281
|
+
path = file.dup
|
282
|
+
end_of_the_line = false
|
283
|
+
while !end_of_the_line
|
284
|
+
if !Tilt[path].nil?
|
285
|
+
path = path.sub(File.extname(path), "")
|
179
286
|
else
|
180
|
-
|
287
|
+
end_of_the_line = true
|
181
288
|
end
|
182
|
-
else
|
183
|
-
false
|
184
289
|
end
|
290
|
+
|
291
|
+
@_extensionless_path_cache[file] = path
|
292
|
+
path
|
293
|
+
end
|
294
|
+
end
|
185
295
|
|
186
|
-
|
187
|
-
|
296
|
+
def logging?
|
297
|
+
logging
|
298
|
+
end
|
299
|
+
|
300
|
+
def current_path
|
301
|
+
@current_path || nil
|
302
|
+
end
|
303
|
+
|
304
|
+
def raw_templates_cache
|
305
|
+
@_raw_templates_cache ||= {}
|
306
|
+
end
|
307
|
+
|
308
|
+
def read_raw_template(path)
|
309
|
+
if raw_templates_cache.has_key?(path)
|
310
|
+
raw_templates_cache[path]
|
311
|
+
else
|
312
|
+
File.read(path)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def map(map, &block)
|
317
|
+
self.class.map(map, &block)
|
318
|
+
end
|
319
|
+
|
320
|
+
def full_path(path)
|
321
|
+
parts = path ? path.split('/') : []
|
322
|
+
if parts.last.nil? || parts.last.split('.').length == 1
|
323
|
+
path = File.join(path, index_file)
|
324
|
+
end
|
325
|
+
"/" + path.sub(%r{^/}, '')
|
326
|
+
end
|
327
|
+
|
328
|
+
def not_found
|
329
|
+
@res.status == 404
|
330
|
+
@res.write "<html><body><h1>File Not Found</h1><p>#{@request_path}</p></body>"
|
331
|
+
@res.finish
|
332
|
+
end
|
333
|
+
|
334
|
+
def resolve_template(request_path, options={})
|
335
|
+
request_path = request_path.to_s
|
336
|
+
@_resolved_templates ||= {}
|
337
|
+
if !@_resolved_templates.has_key?(request_path)
|
338
|
+
relative_path = request_path.sub(%r{^/}, "")
|
339
|
+
on_disk_path = File.expand_path(relative_path, source_dir)
|
188
340
|
|
189
|
-
|
190
|
-
|
341
|
+
preferred_engine = if options.has_key?(:preferred_engine)
|
342
|
+
extension_class = Tilt[options[:preferred_engine]]
|
343
|
+
matched_exts = []
|
344
|
+
|
345
|
+
# TODO: Cache this
|
346
|
+
Tilt.mappings.each do |ext, engines|
|
347
|
+
next unless engines.include? extension_class
|
348
|
+
matched_exts << ext
|
349
|
+
end
|
350
|
+
|
351
|
+
"{" + matched_exts.join(",") + "}"
|
352
|
+
else
|
353
|
+
"*"
|
354
|
+
end
|
191
355
|
|
192
|
-
|
193
|
-
|
356
|
+
path_with_ext = on_disk_path + "." + preferred_engine
|
357
|
+
|
358
|
+
found_path = Dir[path_with_ext].find do |path|
|
359
|
+
::Tilt[path]
|
360
|
+
end
|
361
|
+
|
362
|
+
result = if found_path || File.exists?(on_disk_path)
|
363
|
+
engine = found_path ? File.extname(found_path)[1..-1].to_sym : nil
|
364
|
+
[ found_path || on_disk_path, engine ]
|
365
|
+
else
|
366
|
+
false
|
367
|
+
end
|
194
368
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
369
|
+
@_resolved_templates[request_path] = result
|
370
|
+
end
|
371
|
+
|
372
|
+
@_resolved_templates[request_path]
|
373
|
+
end
|
374
|
+
|
375
|
+
def send_file(path)
|
376
|
+
matched_mime = mime_type(File.extname(path))
|
377
|
+
matched_mime = "application/octet-stream" if matched_mime.nil?
|
378
|
+
content_type matched_mime
|
379
|
+
|
380
|
+
file = ::Rack::File.new nil
|
381
|
+
file.path = path
|
382
|
+
halt file.serving(env)
|
383
|
+
end
|
384
|
+
|
385
|
+
def render(path, locals = {}, options = {}, &block)
|
386
|
+
path = path.to_s
|
387
|
+
|
388
|
+
options.merge!(options_for_ext(File.extname(path)))
|
389
|
+
|
390
|
+
body = read_raw_template(path)
|
391
|
+
template = ::Tilt.new(path, 1, options) { body }
|
392
|
+
template.render(self, locals, &block)
|
393
|
+
end
|
394
|
+
|
395
|
+
def options_for_ext(ext)
|
396
|
+
@_options_for_ext_cache ||= {}
|
397
|
+
|
398
|
+
if !@_options_for_ext_cache.has_key?(ext)
|
399
|
+
options = {}
|
400
|
+
extension_class = Tilt[ext]
|
401
|
+
matched_exts = []
|
402
|
+
Tilt.mappings.each do |ext, engines|
|
403
|
+
next unless engines.include? extension_class
|
404
|
+
engine_options = respond_to?(ext.to_sym) ? send(ext.to_sym) : {}
|
405
|
+
options.merge!(engine_options)
|
204
406
|
end
|
407
|
+
|
408
|
+
@_options_for_ext_cache[ext] = options
|
409
|
+
end
|
410
|
+
|
411
|
+
@_options_for_ext_cache[ext]
|
412
|
+
end
|
413
|
+
|
414
|
+
def mime_type(type, value=nil)
|
415
|
+
return type if type.nil? || type.to_s.include?('/')
|
416
|
+
type = ".#{type}" unless type.to_s[0] == ?.
|
417
|
+
return ::Rack::Mime.mime_type(type, nil) unless value
|
418
|
+
::Rack::Mime::MIME_TYPES[type] = value
|
419
|
+
end
|
420
|
+
|
421
|
+
def content_type(type = nil, params={})
|
422
|
+
return res['Content-Type'] unless type
|
423
|
+
default = params.delete :default
|
424
|
+
mime_type = mime_type(type) || default
|
425
|
+
throw "Unknown media type: %p" % type if mime_type.nil?
|
426
|
+
mime_type = mime_type.dup
|
427
|
+
unless params.include? :charset
|
428
|
+
params[:charset] = params.delete('charset') || "utf-8"
|
429
|
+
end
|
430
|
+
params.delete :charset if mime_type.include? 'charset'
|
431
|
+
unless params.empty?
|
432
|
+
mime_type << (mime_type.include?(';') ? ', ' : ';')
|
433
|
+
mime_type << params.map { |kv| kv.join('=') }.join(', ')
|
205
434
|
end
|
435
|
+
res['Content-Type'] = mime_type
|
436
|
+
end
|
437
|
+
|
438
|
+
def helpers(*extensions, &block)
|
439
|
+
self.class.helpers(*extensions, &block)
|
440
|
+
end
|
441
|
+
|
442
|
+
def use(middleware, *args, &block)
|
443
|
+
self.class.use(middleware, *args, &block)
|
444
|
+
end
|
445
|
+
|
446
|
+
def map(map, &block)
|
447
|
+
self.class.map(map, &block)
|
206
448
|
end
|
207
449
|
end
|