middleman-core 3.1.0.beta.3 → 3.1.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/asset_hash.feature +135 -0
- data/features/asset_host.feature +56 -0
- data/features/automatic_image_sizes.feature +16 -0
- data/features/cache_buster.feature +42 -0
- data/features/coffee-script.feature +22 -0
- data/features/compass-sprites.feature +6 -0
- data/features/content_for.feature +16 -0
- data/features/directory_index.feature +67 -0
- data/features/fonts.feature +15 -0
- data/features/former_padrino_helpers.feature +27 -0
- data/features/gzip.feature +21 -0
- data/features/helpers_auto_javascript_include_tag.feature +27 -0
- data/features/helpers_auto_stylesheet_link_tag.feature +27 -0
- data/features/helpers_form_tag.feature +26 -0
- data/features/helpers_link_to.feature +152 -0
- data/features/helpers_lorem.feature +6 -0
- data/features/helpers_page_classes.feature +17 -0
- data/features/helpers_url_for.feature +152 -0
- data/features/i18n_builder.feature +148 -0
- data/features/i18n_force_locale.feature +13 -0
- data/features/i18n_preview.feature +230 -0
- data/features/ignore_already_minified.feature +47 -0
- data/features/liquid.feature +11 -0
- data/features/markdown.feature +13 -0
- data/features/markdown_redcarpet.feature +86 -0
- data/features/markdown_redcarpet_in_haml.feature +42 -0
- data/features/minify_css.feature +127 -0
- data/features/minify_javascript.feature +225 -0
- data/features/more-clean_build.feature +14 -0
- data/features/more-extensionless_text_files.feature +28 -0
- data/features/more-frontmatter_page_settings.feature +42 -0
- data/features/more-ignore.feature +62 -0
- data/features/more-implied_extensions.feature +42 -0
- data/features/more-instance_vars.feature +18 -0
- data/features/more-sitemap_traversal.feature +73 -0
- data/features/more-wildcard_page_helper.feature +10 -0
- data/features/nested_layouts.feature +55 -0
- data/features/partials.feature +46 -0
- data/features/partials_dir.feature +30 -0
- data/features/relative_assets.feature +136 -0
- data/features/sass-assets-paths.feature +11 -0
- data/features/sass_cache_path.feature +22 -0
- data/features/sass_partials.feature +54 -0
- data/features/scss-support.feature +12 -0
- data/features/slim.feature +69 -0
- data/features/stylus.feature +55 -0
- data/features/twitter-bootstrap-compile.feature +6 -0
- data/fixtures/asset-hash-app/config.rb +8 -0
- data/fixtures/asset-hash-app/lib/middleware.rb +16 -0
- data/fixtures/asset-hash-app/source/apple-touch-icon.png +0 -0
- data/fixtures/asset-hash-app/source/favicon.ico +0 -0
- data/fixtures/asset-hash-app/source/images/100px.gif +0 -0
- data/fixtures/asset-hash-app/source/images/100px.jpg +0 -0
- data/fixtures/asset-hash-app/source/images/100px.png +0 -0
- data/fixtures/asset-hash-app/source/index.html.erb +311 -0
- data/fixtures/asset-hash-app/source/javascripts/application.js +8 -0
- data/fixtures/asset-hash-app/source/layout.erb +18 -0
- data/fixtures/asset-hash-app/source/other.html.erb +2 -0
- data/fixtures/asset-hash-app/source/partials.html.erb +1 -0
- data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +2 -0
- data/fixtures/asset-hash-app/source/stylesheets/site.css.scss +4 -0
- data/fixtures/asset-hash-app/source/stylesheets/uses_partials.css.sass +4 -0
- data/fixtures/asset-hash-app/source/subdir/index.html.erb +308 -0
- data/fixtures/asset-hash-host-app/config.rb +6 -0
- data/fixtures/asset-hash-host-app/source/images/100px.gif +0 -0
- data/fixtures/asset-hash-host-app/source/images/100px.jpg +0 -0
- data/fixtures/asset-hash-host-app/source/images/100px.png +0 -0
- data/fixtures/asset-hash-host-app/source/index.html.erb +6 -0
- data/fixtures/asset-hash-host-app/source/layout.erb +17 -0
- data/fixtures/asset-hash-host-app/source/other.html.erb +2 -0
- data/fixtures/asset-hash-host-app/source/stylesheets/site.css.scss +4 -0
- data/fixtures/asset-hash-host-app/source/subdir/index.html.erb +6 -0
- data/fixtures/asset-host-app/config.rb +0 -0
- data/fixtures/asset-host-app/source/.htaccess +1 -0
- data/fixtures/asset-host-app/source/asset_host.html.erb +1 -0
- data/fixtures/asset-host-app/source/images/blank.gif +0 -0
- data/fixtures/asset-host-app/source/stylesheets/asset_host.css.sass +3 -0
- data/fixtures/auto-css-app/config.rb +11 -0
- data/fixtures/auto-css-app/source/auto-css/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css/index.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css/sub/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/auto-css.html.erb +1 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/auto-css.css +3 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/index.css +0 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css/sub/auto-css.css +3 -0
- data/fixtures/auto-css-app/source/stylesheets/auto-css.css +3 -0
- data/fixtures/auto-js-app/config.rb +11 -0
- data/fixtures/auto-js-app/source/auto-js/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js/index.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js/sub/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/auto-js.html.erb +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/auto-js.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/index.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js/sub/auto-js.js +1 -0
- data/fixtures/auto-js-app/source/javascripts/auto-js.js +1 -0
- data/fixtures/automatic-image-size-app/config.rb +0 -0
- data/fixtures/automatic-image-size-app/source/auto-image-sizes.html.erb +1 -0
- data/fixtures/automatic-image-size-app/source/images/blank.gif +0 -0
- data/fixtures/cache-buster-app/config.rb +0 -0
- data/fixtures/cache-buster-app/source/cache-buster.html.erb +3 -0
- data/fixtures/cache-buster-app/source/images/blank.gif +0 -0
- data/fixtures/cache-buster-app/source/stylesheets/relative_assets.css.sass +3 -0
- data/fixtures/cache-buster-app/source/stylesheets/site.css.sass +1 -0
- data/fixtures/clean-dir-app/config.rb +2 -0
- data/fixtures/clean-dir-app/source/about.html +1 -0
- data/fixtures/coffeescript-app/config.rb +0 -0
- data/fixtures/coffeescript-app/source/inline-coffeescript.html.haml +3 -0
- data/fixtures/coffeescript-app/source/javascripts/broken-coffee.js.coffee +3 -0
- data/fixtures/coffeescript-app/source/javascripts/coffee_test.js.coffee +3 -0
- data/fixtures/compass-sprites-app/config.rb +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_down.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_left.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_right.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_up.png +0 -0
- data/fixtures/compass-sprites-app/source/stylesheets/site.css.scss +3 -0
- data/fixtures/content-for-app/config.rb +7 -0
- data/fixtures/content-for-app/source/content_for_erb.html.erb +5 -0
- data/fixtures/content-for-app/source/content_for_haml.html.haml +4 -0
- data/fixtures/content-for-app/source/content_for_slim.html.slim +4 -0
- data/fixtures/content-for-app/source/layouts/content_for.erb +4 -0
- data/fixtures/default-partials-dir-app/source/_partial.html.erb +1 -0
- data/fixtures/default-partials-dir-app/source/index.html.erb +2 -0
- data/fixtures/different-engine-layout/source/index.html.str +1 -0
- data/fixtures/different-engine-partial/config.rb +0 -0
- data/fixtures/different-engine-partial/source/index.html.erb +1 -0
- data/fixtures/different-engine-partial/source/layouts/layout.erb +7 -0
- data/fixtures/different-engine-partial/source/shared/_footer.str +1 -0
- data/fixtures/different-engine-partial/source/shared/_header.erb +1 -0
- data/fixtures/fonts-app/config.rb +0 -0
- data/fixtures/fonts-app/source/fonts/StMarie-Thin.otf +0 -0
- data/fixtures/fonts-app/source/fonts/blank/blank.otf +0 -0
- data/fixtures/fonts-app/source/stylesheets/fonts.css.sass +5 -0
- data/fixtures/gzip-app/config.rb +1 -0
- data/fixtures/gzip-app/source/index.html +0 -0
- data/fixtures/gzip-app/source/javascripts/test.js +1 -0
- data/fixtures/gzip-app/source/stylesheets/test.css +1 -0
- data/fixtures/i18n-alt-root-app/locales/en.yml +4 -0
- data/fixtures/i18n-alt-root-app/locales/es.yml +7 -0
- data/fixtures/i18n-alt-root-app/source/lang_data/hello.html.erb +1 -0
- data/fixtures/i18n-alt-root-app/source/lang_data/index.html.erb +1 -0
- data/fixtures/i18n-alt-root-app/source/layout.erb +1 -0
- data/fixtures/i18n-default-app/locales/en.yml +4 -0
- data/fixtures/i18n-default-app/locales/es.yml +8 -0
- data/fixtures/i18n-default-app/source/localizable/index.html.erb +5 -0
- data/fixtures/i18n-force-locale/config.rb +13 -0
- data/fixtures/i18n-force-locale/locales/en.yml +3 -0
- data/fixtures/i18n-force-locale/locales/es.yml +3 -0
- data/fixtures/i18n-force-locale/locales/fr.yml +3 -0
- data/fixtures/i18n-force-locale/source/index.haml +2 -0
- data/fixtures/i18n-test-app/locales/en.yml +4 -0
- data/fixtures/i18n-test-app/locales/es.yml +8 -0
- data/fixtures/i18n-test-app/source/CNAME +1 -0
- data/fixtures/i18n-test-app/source/layout.erb +8 -0
- data/fixtures/i18n-test-app/source/localizable/hello.html.erb +1 -0
- data/fixtures/i18n-test-app/source/localizable/index.html.erb +1 -0
- data/fixtures/i18n-test-app/source/morning.en.html.erb +1 -0
- data/fixtures/i18n-test-app/source/morning.es.html.erb +1 -0
- data/fixtures/i18n-test-app/source/password.txt +1 -0
- data/fixtures/i18n-test-app/source/stylesheets/site.css +3 -0
- data/fixtures/indexable-app/config.rb +4 -0
- data/fixtures/indexable-app/source/.htpasswd +1 -0
- data/fixtures/liquid-app/config.rb +0 -0
- data/fixtures/liquid-app/data/test.yml +4 -0
- data/fixtures/liquid-app/data/test2.json +4 -0
- data/fixtures/liquid-app/source/_liquid_partial.liquid +1 -0
- data/fixtures/liquid-app/source/data2.html.liquid +2 -0
- data/fixtures/liquid-app/source/liquid_master.html.liquid +1 -0
- data/fixtures/lorem-app/config.rb +1 -0
- data/fixtures/lorem-app/source/lorem.html.erb +13 -0
- data/fixtures/markdown-app/config.rb +1 -0
- data/fixtures/markdown-app/source/autolink.html.markdown +5 -0
- data/fixtures/markdown-app/source/fenced_code_blocks.html.markdown +7 -0
- data/fixtures/markdown-app/source/hard_wrap.html.markdown +2 -0
- data/fixtures/markdown-app/source/images/blank.gif +0 -0
- data/fixtures/markdown-app/source/index.html.markdown +4 -0
- data/fixtures/markdown-app/source/no_intra_emphasis.html.markdown +5 -0
- data/fixtures/markdown-app/source/smarty_pants.html.markdown +5 -0
- data/fixtures/markdown-app/source/space_after_headers.html.markdown +5 -0
- data/fixtures/markdown-app/source/strikethrough.html.markdown +5 -0
- data/fixtures/markdown-app/source/superscript.html.markdown +5 -0
- data/fixtures/markdown-app/source/tables.html.markdown +8 -0
- data/fixtures/markdown-app/source/with_toc_data.html.markdown +3 -0
- data/fixtures/markdown-frontmatter-options-app/config.rb +1 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-default.html.markdown +5 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-off.html.markdown +7 -0
- data/fixtures/markdown-frontmatter-options-app/source/smarty_pants-on.html.markdown +7 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-default.html.markdown +8 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-off.html.markdown +10 -0
- data/fixtures/markdown-frontmatter-options-app/source/tables-on.html.markdown +10 -0
- data/fixtures/markdown-in-haml-app/config.rb +0 -0
- data/fixtures/markdown-in-haml-app/source/images/blank.gif +0 -0
- data/fixtures/markdown-in-haml-app/source/link_target.html.markdown +4 -0
- data/fixtures/minify-css-app/source/inline-css.html.haml +5 -0
- data/fixtures/minify-css-app/source/more-css/site.css +3 -0
- data/fixtures/minify-css-app/source/stylesheets/report.css +1 -0
- data/fixtures/minify-css-app/source/stylesheets/site.css.sass +5 -0
- data/fixtures/minify-js-app/config.rb +0 -0
- data/fixtures/minify-js-app/source/inline-coffeescript.html.haml +3 -0
- data/fixtures/minify-js-app/source/inline-js.html.haml +28 -0
- data/fixtures/minify-js-app/source/javascripts/coffee_test.js.coffee +3 -0
- data/fixtures/minify-js-app/source/javascripts/js_test.js +8 -0
- data/fixtures/minify-js-app/source/more-js/other.js +8 -0
- data/fixtures/more-extensionless-text-files-app/config.rb +1 -0
- data/fixtures/more-extensionless-text-files-app/source/CNAME +1 -0
- data/fixtures/more-extensionless-text-files-app/source/LICENSE +1 -0
- data/fixtures/more-extensionless-text-files-app/source/README +1 -0
- data/fixtures/more-extensionless-text-files-app/source/index.html +1 -0
- data/fixtures/more-frontmatter-settings-app/config.rb +4 -0
- data/fixtures/more-frontmatter-settings-app/source/alternate_layout.html.erb +5 -0
- data/fixtures/more-frontmatter-settings-app/source/ignored.html.erb +5 -0
- data/fixtures/more-frontmatter-settings-app/source/layouts/alternate.erb +3 -0
- data/fixtures/more-frontmatter-settings-app/source/no_index.html.erb +5 -0
- data/fixtures/more-ignore-app/source/about.html.erb +1 -0
- data/fixtures/more-ignore-app/source/images/icon/messages.png +0 -0
- data/fixtures/more-ignore-app/source/images/pic.png +0 -0
- data/fixtures/more-ignore-app/source/images/portrait.jpg +0 -0
- data/fixtures/more-ignore-app/source/index.html.erb +0 -0
- data/fixtures/more-ignore-app/source/plain.html +1 -0
- data/fixtures/more-ignore-app/source/reports/another.html +0 -0
- data/fixtures/more-ignore-app/source/reports/index.html +0 -0
- data/fixtures/more-implied-extensions-app/config.rb +0 -0
- data/fixtures/more-implied-extensions-app/source/javascripts/app.coffee +1 -0
- data/fixtures/more-implied-extensions-app/source/stylesheets/style.scss +3 -0
- data/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass +3 -0
- data/fixtures/more-implied-extensions-app/source/stylesheets/style3.less +4 -0
- data/fixtures/more-implied-extensions-app/source/test.haml +4 -0
- data/fixtures/more-implied-extensions-app/source/test2.markdown +3 -0
- data/fixtures/more-implied-extensions-app/source/test3.slim +3 -0
- data/fixtures/more-implied-extensions-app/source/test4.liquid +1 -0
- data/fixtures/more-instance-vars-app/config.rb +0 -0
- data/fixtures/more-instance-vars-app/source/_vartial.erb +5 -0
- data/fixtures/more-instance-vars-app/source/instance-var-set.html.erb +2 -0
- data/fixtures/more-instance-vars-app/source/layout.erb +3 -0
- data/fixtures/more-instance-vars-app/source/no-instance-var.html.erb +1 -0
- data/fixtures/more-preview-app/config.rb +0 -0
- data/fixtures/more-preview-app/source/content.html.erb +1 -0
- data/fixtures/more-preview-app/source/layout.erb +1 -0
- data/fixtures/more-preview-app/source/stylesheets/_partial.sass +2 -0
- data/fixtures/more-preview-app/source/stylesheets/_partial2.css.sass +2 -0
- data/fixtures/more-preview-app/source/stylesheets/main.css.sass +4 -0
- data/fixtures/more-preview-app/source/stylesheets/main2.css.sass +4 -0
- data/fixtures/more-preview-app/source/stylesheets/plain.css.sass +2 -0
- data/fixtures/more-traversal-app/config.rb +7 -0
- data/fixtures/more-traversal-app/source/directory-indexed/sibling.html.erb +3 -0
- data/fixtures/more-traversal-app/source/directory-indexed/sibling2.html.erb +3 -0
- data/fixtures/more-traversal-app/source/directory-indexed/sub2/index.html.erb +0 -0
- data/fixtures/more-traversal-app/source/directory-indexed/sub3/deep.html.erb +0 -0
- data/fixtures/more-traversal-app/source/directory-indexed.html.erb +0 -0
- data/fixtures/more-traversal-app/source/index.html.erb +0 -0
- data/fixtures/more-traversal-app/source/layout.erb +21 -0
- data/fixtures/more-traversal-app/source/proxied.html.erb +0 -0
- data/fixtures/more-traversal-app/source/root.html.erb +0 -0
- data/fixtures/more-traversal-app/source/sub/index.html.erb +0 -0
- data/fixtures/more-traversal-app/source/sub/sibling.html.erb +0 -0
- data/fixtures/more-traversal-app/source/sub/sibling2.html.erb +0 -0
- data/fixtures/more-traversal-app/source/sub/sub2/index.html.erb +0 -0
- data/fixtures/more-traversal-app/source/sub/sub3/deep.html.erb +0 -0
- data/fixtures/nested-layout-app/config.rb +1 -0
- data/fixtures/nested-layout-app/source/another.html.markdown +7 -0
- data/fixtures/nested-layout-app/source/data-one.html.erb +5 -0
- data/fixtures/nested-layout-app/source/data-two.html.erb +5 -0
- data/fixtures/nested-layout-app/source/haml-test.html.markdown +7 -0
- data/fixtures/nested-layout-app/source/index.html.erb +6 -0
- data/fixtures/nested-layout-app/source/layouts/inner.erb +4 -0
- data/fixtures/nested-layout-app/source/layouts/inner_haml.haml +3 -0
- data/fixtures/nested-layout-app/source/layouts/inner_slim.slim +3 -0
- data/fixtures/nested-layout-app/source/layouts/master.erb +3 -0
- data/fixtures/nested-layout-app/source/layouts/master_haml.haml +3 -0
- data/fixtures/nested-layout-app/source/layouts/master_slim.slim +3 -0
- data/fixtures/nested-layout-app/source/layouts/outer.erb +4 -0
- data/fixtures/nested-layout-app/source/layouts/outer_haml.haml +3 -0
- data/fixtures/nested-layout-app/source/layouts/outer_slim.slim +3 -0
- data/fixtures/nested-layout-app/source/slim-test.html.markdown +7 -0
- data/fixtures/padrino-helpers-app/config.rb +0 -0
- data/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb +6 -0
- data/fixtures/page-classes-app/config.rb +4 -0
- data/fixtures/page-classes-app/source/page-classes.html.erb +1 -0
- data/fixtures/page-classes-app/source/sub1/page-classes.html.erb +1 -0
- data/fixtures/page-classes-app/source/sub1/sub2/page-classes.html.erb +1 -0
- data/fixtures/partials-app/config.rb +0 -0
- data/fixtures/partials-app/source/_locals.erb +1 -0
- data/fixtures/partials-app/source/_main.erb +1 -0
- data/fixtures/partials-app/source/_main.str +1 -0
- data/fixtures/partials-app/source/index.html.erb +3 -0
- data/fixtures/partials-app/source/locals.html.erb +1 -0
- data/fixtures/partials-app/source/second.html.str +3 -0
- data/fixtures/partials-app/source/shared/_footer.erb +1 -0
- data/fixtures/partials-app/source/shared/_header.erb +1 -0
- data/fixtures/partials-app/source/shared/snippet.erb +1 -0
- data/fixtures/partials-app/source/sub/_local.erb +1 -0
- data/fixtures/partials-app/source/sub/index.html.erb +3 -0
- data/fixtures/partials-app/source/using_snippet.html.erb +1 -0
- data/fixtures/partials-dir-app/source/index.html.erb +2 -0
- data/fixtures/partials-dir-app/source/nested/partials/_partial.html.erb +1 -0
- data/fixtures/partials-dir-app/source/partials/_partial.html.erb +1 -0
- data/fixtures/passthrough-app/source/.htaccess +1 -0
- data/fixtures/passthrough-app/source/inline-coffeescript.html.haml +3 -0
- data/fixtures/passthrough-app/source/inline-css.html.haml +4 -0
- data/fixtures/passthrough-app/source/inline-js.html.haml +28 -0
- data/fixtures/passthrough-app/source/javascripts/coffee_test.js.coffee +3 -0
- data/fixtures/passthrough-app/source/javascripts/js_test.js +8 -0
- data/fixtures/passthrough-app/source/stylesheets/site.css.sass +1 -0
- data/fixtures/relative-app/config.rb +0 -0
- data/fixtures/relative-app/source/images/blank.gif +0 -0
- data/fixtures/relative-app/source/stylesheets/relative_assets.css.sass +3 -0
- data/fixtures/relative-assets-app/config.rb +1 -0
- data/fixtures/relative-assets-app/source/images/blank.gif +0 -0
- data/fixtures/relative-assets-app/source/img/blank.gif +0 -0
- data/fixtures/relative-assets-app/source/relative_image.html.erb +8 -0
- data/fixtures/relative-assets-app/source/stylesheets/relative_assets.css.sass +3 -0
- data/fixtures/sass-assets-path-app/assets/stylesheets/_shared-asset-sass.sass +1 -0
- data/fixtures/sass-assets-path-app/assets/stylesheets/_shared-asset.scss +1 -0
- data/fixtures/sass-assets-path-app/config.rb +4 -0
- data/fixtures/sass-assets-path-app/my-vendor/stylesheets/_partial.sass +2 -0
- data/fixtures/sass-assets-path-app/source/stylesheets/plain.css.sass +16 -0
- data/fixtures/sass-cache-path-custom-app/config.rb +3 -0
- data/fixtures/sass-cache-path-custom-app/source/stylesheets/plain.css.sass +4 -0
- data/fixtures/sass-cache-path-default-app/config.rb +3 -0
- data/fixtures/sass-cache-path-default-app/source/stylesheets/plain.css.sass +4 -0
- data/fixtures/scss-app/config.rb +0 -0
- data/fixtures/scss-app/source/stylesheets/layout.css.sass +2 -0
- data/fixtures/scss-app/source/stylesheets/site_scss.css.scss +1 -0
- data/fixtures/stylus-preview-app/config.rb +0 -0
- data/fixtures/stylus-preview-app/source/content.html.erb +1 -0
- data/fixtures/stylus-preview-app/source/layout.erb +1 -0
- data/fixtures/stylus-preview-app/source/stylesheets/_partial.styl +2 -0
- data/fixtures/stylus-preview-app/source/stylesheets/_partial2.css.styl +2 -0
- data/fixtures/stylus-preview-app/source/stylesheets/main.css.styl +4 -0
- data/fixtures/stylus-preview-app/source/stylesheets/main2.css.styl +4 -0
- data/fixtures/stylus-preview-app/source/stylesheets/plain.css.styl +2 -0
- data/fixtures/twitter-bootstrap-app/config.rb +0 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/.gitignore +36 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/.travis.yml +3 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/LICENSE +176 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/README.md +137 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/img/glyphicons-halflings-white.png +0 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/img/glyphicons-halflings.png +0 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/.jshintrc +10 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/README.md +112 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-alert.js +90 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-button.js +96 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-carousel.js +169 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-collapse.js +157 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-dropdown.js +100 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-modal.js +218 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-popover.js +98 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-scrollspy.js +151 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-tab.js +135 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-tooltip.js +275 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-transition.js +61 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-typeahead.js +285 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/index.html +54 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/phantom.js +63 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/server.js +14 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-alert.js +56 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-button.js +77 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-carousel.js +28 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-collapse.js +54 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-dropdown.js +87 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-modal.js +114 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-phantom.js +21 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-popover.js +93 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-scrollspy.js +31 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-tab.js +61 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-tooltip.js +155 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-transition.js +13 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-typeahead.js +148 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/jquery.js +9252 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/qunit.css +232 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/qunit.js +1510 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_accordion.less +33 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_alerts.less +58 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_breadcrumbs.less +24 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_button-groups.less +191 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_buttons.less +191 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_carousel.less +121 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_close.less +29 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_code.less +57 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_component-animations.less +20 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_dropdowns.less +143 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_forms.less +583 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_grid.less +5 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_hero-unit.less +22 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_labels-badges.less +55 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_layouts.less +17 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_mixins.less +646 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_modals.less +90 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_navbar.less +358 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_navs.less +363 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_pager.less +36 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_pagination.less +56 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_popovers.less +49 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_progress-bars.less +117 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_reset.less +131 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-1200px-min.less +26 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-767px-max.less +149 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-768px-979px.less +17 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-navbar.less +153 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-utilities.less +41 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_scaffolding.less +29 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_sprites.less +191 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_tables.less +176 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_thumbnails.less +47 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_tooltip.less +35 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_type.less +232 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_utilities.less +23 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_variables.less +206 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_wells.less +27 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/bootstrap.less +62 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/responsive.less +48 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/css-tests.css +52 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/css-tests.html +917 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/forms.html +179 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/navbar.html +108 -0
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/package.json +25 -0
- data/fixtures/wildcard-directory-index-app/config.rb +2 -0
- data/fixtures/wildcard-directory-index-app/source/admin/index.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/admin/page.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/index.html.erb +1 -0
- data/fixtures/wildcard-directory-index-app/source/layouts/admin.erb +2 -0
- data/fixtures/wildcard-directory-index-app/source/layouts/layout.erb +2 -0
- data/lib/middleman-core/cli/build.rb +8 -5
- data/lib/middleman-core/extensions.rb +0 -5
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
- data/lib/middleman-core/preview_server.rb +1 -1
- data/lib/middleman-core/templates/shared/Gemfile.tt +1 -1
- data/lib/middleman-core/util.rb +9 -7
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman-core.rb +1 -0
- data/lib/middleman-more/core_extensions/compass.rb +75 -0
- data/lib/middleman-more/core_extensions/default_helpers.rb +235 -0
- data/lib/middleman-more/core_extensions/i18n.rb +182 -0
- data/lib/middleman-more/extensions/asset_hash.rb +114 -0
- data/lib/middleman-more/extensions/asset_host.rb +50 -0
- data/lib/middleman-more/extensions/automatic_image_sizes/fastimage.rb +287 -0
- data/lib/middleman-more/extensions/automatic_image_sizes.rb +42 -0
- data/lib/middleman-more/extensions/cache_buster.rb +56 -0
- data/lib/middleman-more/extensions/directory_indexes.rb +24 -0
- data/lib/middleman-more/extensions/gzip.rb +75 -0
- data/lib/middleman-more/extensions/lorem.rb +176 -0
- data/lib/middleman-more/extensions/minify_css.rb +77 -0
- data/lib/middleman-more/extensions/minify_javascript.rb +83 -0
- data/lib/middleman-more/extensions/relative_assets.rb +29 -0
- data/lib/middleman-more/templates/smacss/source/_footer.haml +1 -0
- data/lib/middleman-more/templates/smacss/source/index.html.haml +1 -0
- data/lib/middleman-more/templates/smacss/source/layouts/layout.haml +13 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown +11 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss +1 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss +375 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown +9 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown +9 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown +12 -0
- data/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss +12 -0
- data/lib/middleman-more/templates/smacss.rb +30 -0
- data/lib/middleman-more.rb +102 -0
- data/middleman-core.gemspec +4 -1
- metadata +885 -7
- data/.cane +0 -2
- data/.cane-exclusions.yml +0 -5
@@ -0,0 +1,235 @@
|
|
1
|
+
class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
2
|
+
|
3
|
+
def initialize(app, options_hash={}, &block)
|
4
|
+
super
|
5
|
+
|
6
|
+
require 'active_support/core_ext/object/to_query'
|
7
|
+
require 'padrino-helpers'
|
8
|
+
|
9
|
+
app.helpers ::Padrino::Helpers::OutputHelpers
|
10
|
+
app.helpers ::Padrino::Helpers::TagHelpers
|
11
|
+
app.helpers ::Padrino::Helpers::AssetTagHelpers
|
12
|
+
app.helpers ::Padrino::Helpers::FormHelpers
|
13
|
+
app.helpers ::Padrino::Helpers::FormatHelpers
|
14
|
+
app.helpers ::Padrino::Helpers::RenderHelpers
|
15
|
+
app.helpers ::Padrino::Helpers::NumberHelpers
|
16
|
+
# app.helpers ::Padrino::Helpers::TranslationHelpers
|
17
|
+
# app.helpers ::Padrino::Helpers::Breadcrumbs
|
18
|
+
|
19
|
+
app.config.define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
|
20
|
+
end
|
21
|
+
|
22
|
+
# The helpers
|
23
|
+
helpers do
|
24
|
+
# Disable Padrino cache buster
|
25
|
+
def asset_stamp
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
# Output a stylesheet link tag based on the current path
|
30
|
+
#
|
31
|
+
# @return [String]
|
32
|
+
def auto_stylesheet_link_tag
|
33
|
+
auto_tag(:css) do |path|
|
34
|
+
stylesheet_link_tag path
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Output a javascript tag based on the current path
|
39
|
+
#
|
40
|
+
# @return [String]
|
41
|
+
def auto_javascript_include_tag
|
42
|
+
auto_tag(:js) do |path|
|
43
|
+
javascript_include_tag path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Output a stylesheet link tag based on the current path
|
48
|
+
#
|
49
|
+
# @param [Symbol] asset_ext The type of asset
|
50
|
+
# @param [String] asset_dir Where to look for assets
|
51
|
+
# @return [void]
|
52
|
+
def auto_tag(asset_ext, asset_dir=nil)
|
53
|
+
if asset_dir.nil?
|
54
|
+
asset_dir = case asset_ext
|
55
|
+
when :js then js_dir
|
56
|
+
when :css then css_dir
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# If the basename of the request as no extension, assume we are serving a
|
61
|
+
# directory and join index_file to the path.
|
62
|
+
path = File.join(asset_dir, current_path)
|
63
|
+
path = path.sub(/#{File.extname(path)}$/, ".#{asset_ext}")
|
64
|
+
|
65
|
+
yield path if sitemap.find_resource_by_path(path)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Generate body css classes based on the current path
|
69
|
+
#
|
70
|
+
# @return [String]
|
71
|
+
def page_classes
|
72
|
+
path = current_path.dup
|
73
|
+
path << index_file if path.end_with?('/')
|
74
|
+
path = ::Middleman::Util.strip_leading_slash(path)
|
75
|
+
|
76
|
+
classes = []
|
77
|
+
parts = path.split('.').first.split('/')
|
78
|
+
parts.each_with_index { |path, i| classes << parts.first(i+1).join('_') }
|
79
|
+
|
80
|
+
classes.join(' ')
|
81
|
+
end
|
82
|
+
|
83
|
+
# Get the path of a file of a given type
|
84
|
+
#
|
85
|
+
# @param [Symbol] kind The type of file
|
86
|
+
# @param [String] source The path to the file
|
87
|
+
# @return [String]
|
88
|
+
def asset_path(kind, source)
|
89
|
+
return source if source.to_s.include?('//')
|
90
|
+
asset_folder = case kind
|
91
|
+
when :css then css_dir
|
92
|
+
when :js then js_dir
|
93
|
+
when :images then images_dir
|
94
|
+
when :fonts then fonts_dir
|
95
|
+
else kind.to_s
|
96
|
+
end
|
97
|
+
source = source.to_s.tr(' ', '')
|
98
|
+
ignore_extension = (kind == :images || kind == :fonts) # don't append extension
|
99
|
+
source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
|
100
|
+
asset_folder = "" if source.start_with?('/') # absolute path
|
101
|
+
|
102
|
+
asset_url(source, asset_folder)
|
103
|
+
end
|
104
|
+
|
105
|
+
# Get the URL of an asset given a type/prefix
|
106
|
+
#
|
107
|
+
# @param [String] path The path (such as "photo.jpg")
|
108
|
+
# @param [String] prefix The type prefix (such as "images")
|
109
|
+
# @return [String] The fully qualified asset url
|
110
|
+
def asset_url(path, prefix="")
|
111
|
+
# Don't touch assets which already have a full path
|
112
|
+
if path.include?("//")
|
113
|
+
path
|
114
|
+
else # rewrite paths to use their destination path
|
115
|
+
path = File.join(prefix, path)
|
116
|
+
if resource = sitemap.find_resource_by_path(path)
|
117
|
+
resource.url
|
118
|
+
else
|
119
|
+
File.join(config[:http_prefix], path)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
# Given a source path (referenced either absolutely or relatively)
|
125
|
+
# or a Resource, this will produce the nice URL configured for that
|
126
|
+
# path, respecting :relative_links, directory indexes, etc.
|
127
|
+
def url_for(path_or_resource, options={})
|
128
|
+
# Handle Resources and other things which define their own url method
|
129
|
+
url = path_or_resource.respond_to?(:url) ? path_or_resource.url : path_or_resource
|
130
|
+
|
131
|
+
begin
|
132
|
+
uri = URI(url)
|
133
|
+
rescue URI::InvalidURIError
|
134
|
+
# Nothing we can do with it, it's not really a URI
|
135
|
+
return url
|
136
|
+
end
|
137
|
+
|
138
|
+
relative = options.delete(:relative)
|
139
|
+
raise "Can't use the relative option with an external URL" if relative && uri.host
|
140
|
+
|
141
|
+
# Allow people to turn on relative paths for all links with
|
142
|
+
# set :relative_links, true
|
143
|
+
# but still override on a case by case basis with the :relative parameter.
|
144
|
+
effective_relative = relative || false
|
145
|
+
effective_relative = true if relative.nil? && config[:relative_links]
|
146
|
+
|
147
|
+
# Try to find a sitemap resource corresponding to the desired path
|
148
|
+
this_resource = current_resource # store in a local var to save work
|
149
|
+
if path_or_resource.is_a?(::Middleman::Sitemap::Resource)
|
150
|
+
resource = path_or_resource
|
151
|
+
resource_url = url
|
152
|
+
elsif this_resource && uri.path
|
153
|
+
# Handle relative urls
|
154
|
+
url_path = Pathname(uri.path)
|
155
|
+
current_source_dir = Pathname('/' + this_resource.path).dirname
|
156
|
+
url_path = current_source_dir.join(url_path) if url_path.relative?
|
157
|
+
resource = sitemap.find_resource_by_path(url_path.to_s)
|
158
|
+
resource_url = resource.url if resource
|
159
|
+
end
|
160
|
+
|
161
|
+
if resource
|
162
|
+
# Switch to the relative path between this_resource and the given resource
|
163
|
+
# if we've been asked to.
|
164
|
+
if effective_relative
|
165
|
+
# Output urls relative to the destination path, not the source path
|
166
|
+
current_dir = Pathname('/' + this_resource.destination_path).dirname
|
167
|
+
relative_path = Pathname(resource_url).relative_path_from(current_dir).to_s
|
168
|
+
|
169
|
+
# Put back the trailing slash to avoid unnecessary Apache redirects
|
170
|
+
if resource_url.end_with?('/') && !relative_path.end_with?('/')
|
171
|
+
relative_path << '/'
|
172
|
+
end
|
173
|
+
|
174
|
+
uri.path = relative_path
|
175
|
+
else
|
176
|
+
uri.path = resource_url
|
177
|
+
end
|
178
|
+
else
|
179
|
+
# If they explicitly asked for relative links but we can't find a resource...
|
180
|
+
raise "No resource exists at #{url}" if relative
|
181
|
+
end
|
182
|
+
|
183
|
+
# Support a :query option that can be a string or hash
|
184
|
+
if query = options.delete(:query)
|
185
|
+
uri.query = query.respond_to?(:to_param) ? query.to_param : query.to_s
|
186
|
+
end
|
187
|
+
|
188
|
+
# Support a :fragment or :anchor option just like Padrino
|
189
|
+
fragment = options.delete(:anchor) || options.delete(:fragment)
|
190
|
+
uri.fragment = fragment.to_s if fragment
|
191
|
+
|
192
|
+
# Finally make the URL back into a string
|
193
|
+
uri.to_s
|
194
|
+
end
|
195
|
+
|
196
|
+
# Overload the regular link_to to be sitemap-aware - if you
|
197
|
+
# reference a source path, either absolutely or relatively,
|
198
|
+
# you'll get that resource's nice URL. Also, there is a
|
199
|
+
# :relative option which, if set to true, will produce
|
200
|
+
# relative URLs instead of absolute URLs. You can also add
|
201
|
+
#
|
202
|
+
# config[:relative_links] = true
|
203
|
+
#
|
204
|
+
# to config.rb to have all links default to relative.
|
205
|
+
#
|
206
|
+
# There is also a :query option that can be used to append a
|
207
|
+
# query string, which can be expressed as either a String,
|
208
|
+
# or a Hash which will be turned into URL parameters.
|
209
|
+
def link_to(*args, &block)
|
210
|
+
url_arg_index = block_given? ? 0 : 1
|
211
|
+
options_index = block_given? ? 1 : 2
|
212
|
+
|
213
|
+
if block_given? && args.size > 2
|
214
|
+
raise ArgumentError.new("Too many arguments to link_to(url, options={}, &block)")
|
215
|
+
end
|
216
|
+
|
217
|
+
if url = args[url_arg_index]
|
218
|
+
options = args[options_index] || {}
|
219
|
+
raise ArgumentError.new("Options must be a hash") unless options.is_a?(Hash)
|
220
|
+
|
221
|
+
# Transform the url through our magic url_for method
|
222
|
+
args[url_arg_index] = url_for(url, options)
|
223
|
+
end
|
224
|
+
|
225
|
+
super(*args, &block)
|
226
|
+
end
|
227
|
+
|
228
|
+
# Modified Padrino form_for that uses Middleman's url_for
|
229
|
+
# to transform the URL.
|
230
|
+
def form_tag(url, options={}, &block)
|
231
|
+
url = url_for(url, options)
|
232
|
+
super
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,182 @@
|
|
1
|
+
class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
2
|
+
option :no_fallbacks, false, "Disable I18n fallbacks"
|
3
|
+
option :langs, nil, "List of langs, will autodiscover by default"
|
4
|
+
option :lang_map, {}, "Language shortname map"
|
5
|
+
option :path, "/:locale/", "URL prefix path"
|
6
|
+
option :templates_dir, "localizable", "Location of templates to be localized"
|
7
|
+
option :mount_at_root, nil, "Mount a specific language at the root of the site"
|
8
|
+
option :data, "locales", "The directory holding your locale configurations"
|
9
|
+
|
10
|
+
def initialize(app, options_hash={}, &block)
|
11
|
+
super
|
12
|
+
|
13
|
+
# See https://github.com/svenfuchs/i18n/wiki/Fallbacks
|
14
|
+
unless options[:no_fallbacks]
|
15
|
+
require "i18n/backend/fallbacks"
|
16
|
+
::I18n::Backend::Simple.send(:include, ::I18n::Backend::Fallbacks)
|
17
|
+
end
|
18
|
+
|
19
|
+
app.config.define_setting :locales_dir, "locales", 'The directory holding your locale configurations'
|
20
|
+
|
21
|
+
app.send :include, LocaleHelpers
|
22
|
+
end
|
23
|
+
|
24
|
+
def after_configuration
|
25
|
+
@locales_glob = File.join(app.config[:locals_dir] || options[:data], "**", "*.{rb,yml,yaml}")
|
26
|
+
|
27
|
+
# File.fnmatch doesn't support brackets: {rb,yml,yaml}
|
28
|
+
regex = @locales_glob.sub(/\./, '\.').sub(File.join("**", "*"), ".*").sub(/\//, '\/').sub("{rb,yml,yaml}", "rb|ya?ml")
|
29
|
+
@locales_regex = %r{^#{regex}}
|
30
|
+
|
31
|
+
@maps = {}
|
32
|
+
|
33
|
+
::I18n.load_path += Dir[File.join(app.root, @locales_glob)]
|
34
|
+
::I18n.reload!
|
35
|
+
|
36
|
+
@mount_at_root = options[:mount_at_root].nil? ? langs.first : options[:mount_at_root]
|
37
|
+
|
38
|
+
::I18n.default_locale = @mount_at_root
|
39
|
+
# Reset fallbacks to fall back to our new default
|
40
|
+
if ::I18n.respond_to? :fallbacks
|
41
|
+
::I18n.fallbacks = ::I18n::Locale::Fallbacks.new
|
42
|
+
end
|
43
|
+
|
44
|
+
if !app.build?
|
45
|
+
logger.info "== Locales: #{langs.join(", ")} (Default #{@mount_at_root})"
|
46
|
+
end
|
47
|
+
|
48
|
+
# Don't output localizable files
|
49
|
+
app.ignore File.join(options[:templates_dir], "**")
|
50
|
+
|
51
|
+
app.sitemap.provides_metadata_for_path do |url|
|
52
|
+
if d = get_localization_data(url)
|
53
|
+
lang, page_id = d
|
54
|
+
else
|
55
|
+
# Default to the @mount_at_root lang
|
56
|
+
page_id = nil
|
57
|
+
lang = @mount_at_root
|
58
|
+
end
|
59
|
+
|
60
|
+
instance_vars = Proc.new do
|
61
|
+
@lang = lang
|
62
|
+
@page_id = page_id
|
63
|
+
end
|
64
|
+
|
65
|
+
locals = { :lang => lang,
|
66
|
+
:page_id => page_id }
|
67
|
+
{ :blocks => [instance_vars],
|
68
|
+
:locals => locals,
|
69
|
+
:options => { :lang => lang } }
|
70
|
+
end
|
71
|
+
|
72
|
+
app.files.changed(&method(:on_file_changed))
|
73
|
+
app.files.deleted(&method(:on_file_changed))
|
74
|
+
end
|
75
|
+
|
76
|
+
helpers do
|
77
|
+
def t(*args)
|
78
|
+
::I18n.t(*args)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
delegate :logger, :to => :app
|
83
|
+
|
84
|
+
def on_file_changed(file)
|
85
|
+
if @locales_regex =~ file
|
86
|
+
::I18n.reload!
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def langs
|
91
|
+
if options[:langs]
|
92
|
+
Array(options[:langs]).map(&:to_sym)
|
93
|
+
else
|
94
|
+
Dir[File.join(app.root, @locales_glob)].map { |file|
|
95
|
+
File.basename(file).sub(/\.ya?ml$/, "").sub(/\.rb$/, "")
|
96
|
+
}.sort.map(&:to_sym)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def get_localization_data(path)
|
101
|
+
@_localization_data ||= {}
|
102
|
+
@_localization_data[path]
|
103
|
+
end
|
104
|
+
|
105
|
+
# Update the main sitemap resource list
|
106
|
+
# @return [void]
|
107
|
+
def manipulate_resource_list(resources)
|
108
|
+
@_localization_data = {}
|
109
|
+
|
110
|
+
new_resources = []
|
111
|
+
|
112
|
+
resources.each do |resource|
|
113
|
+
# If it's a "localizable template"
|
114
|
+
if File.fnmatch?(File.join(options[:templates_dir], "**"), resource.path)
|
115
|
+
page_id = File.basename(resource.path, File.extname(resource.path))
|
116
|
+
langs.each do |lang|
|
117
|
+
# Remove folder name
|
118
|
+
path = resource.path.sub(options[:templates_dir], "")
|
119
|
+
new_resources << build_resource(path, resource.path, page_id, lang)
|
120
|
+
end
|
121
|
+
elsif result = parse_locale_extension(resource.path)
|
122
|
+
lang, path, page_id = result
|
123
|
+
new_resources << build_resource(path, resource.path, page_id, lang)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
resources + new_resources
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
# Parse locale extension filename
|
133
|
+
# @return [lang, path, basename]
|
134
|
+
# will return +nil+ if no locale extension
|
135
|
+
def parse_locale_extension(path)
|
136
|
+
path_bits = path.split('.')
|
137
|
+
return nil if path_bits.size < 3
|
138
|
+
|
139
|
+
lang = path_bits.delete_at(-2).to_sym
|
140
|
+
return nil unless langs.include?(lang)
|
141
|
+
|
142
|
+
path = path_bits.join('.')
|
143
|
+
basename = File.basename(path_bits[0..-2].join('.'))
|
144
|
+
|
145
|
+
[lang, path, basename]
|
146
|
+
end
|
147
|
+
|
148
|
+
def build_resource(path, source_path, page_id, lang)
|
149
|
+
old_locale = ::I18n.locale
|
150
|
+
::I18n.locale = lang
|
151
|
+
|
152
|
+
localized_page_id = ::I18n.t("paths.#{page_id}", :default => page_id, :fallback => [])
|
153
|
+
|
154
|
+
if @mount_at_root == lang
|
155
|
+
prefix = "/"
|
156
|
+
else
|
157
|
+
replacement = options[:lang_map].fetch(lang, lang)
|
158
|
+
prefix = options[:path].sub(":locale", replacement.to_s)
|
159
|
+
end
|
160
|
+
|
161
|
+
path = ::Middleman::Util.normalize_path(
|
162
|
+
File.join(prefix, path.sub(page_id, localized_page_id))
|
163
|
+
)
|
164
|
+
|
165
|
+
@_localization_data[path] = [lang, path, localized_page_id]
|
166
|
+
|
167
|
+
p = ::Middleman::Sitemap::Resource.new(app.sitemap, path)
|
168
|
+
p.proxy_to(source_path)
|
169
|
+
|
170
|
+
::I18n.locale = old_locale
|
171
|
+
|
172
|
+
p
|
173
|
+
end
|
174
|
+
|
175
|
+
module LocaleHelpers
|
176
|
+
# Access the list of languages supported by this Middleman application
|
177
|
+
# @return [Array<Symbol>]
|
178
|
+
def langs
|
179
|
+
extensions[:i18n].langs
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
2
|
+
option :exts, %w(.jpg .jpeg .png .gif .js .css .otf .woff .eot .ttf .svg), "List of extensions that get asset hashes appended to them."
|
3
|
+
option :ignore, [], "Regexes of filenames to skip adding asset hashes to"
|
4
|
+
|
5
|
+
def initialize(app, options_hash={}, &block)
|
6
|
+
super
|
7
|
+
|
8
|
+
require 'digest/sha1'
|
9
|
+
require 'rack/test'
|
10
|
+
require 'uri'
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_configuration
|
14
|
+
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
15
|
+
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
|
16
|
+
|
17
|
+
app.use Middleware, :exts => options.exts, :middleman_app => app, :ignore => @ignore
|
18
|
+
end
|
19
|
+
|
20
|
+
# Update the main sitemap resource list
|
21
|
+
# @return [void]
|
22
|
+
def manipulate_resource_list(resources)
|
23
|
+
# Process resources in order: binary images and fonts, then SVG, then JS/CSS.
|
24
|
+
# This is so by the time we get around to the text files (which may reference
|
25
|
+
# images and fonts) the static assets' hashes are already calculated.
|
26
|
+
rack_client = ::Rack::Test::Session.new(app.class.to_rack_app)
|
27
|
+
resources.sort_by do |a|
|
28
|
+
if %w(.svg).include? a.ext
|
29
|
+
0
|
30
|
+
elsif %w(.js .css).include? a.ext
|
31
|
+
1
|
32
|
+
else
|
33
|
+
-1
|
34
|
+
end
|
35
|
+
end.each do |resource|
|
36
|
+
next unless options.exts.include? resource.ext
|
37
|
+
next if @ignore.any? { |ignore| Middleman::Util.path_match(ignore, resource.destination_path) }
|
38
|
+
|
39
|
+
# Render through the Rack interface so middleware and mounted apps get a shot
|
40
|
+
response = rack_client.get(URI.escape(resource.destination_path), {}, { "bypass_asset_hash" => "true" })
|
41
|
+
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
|
42
|
+
|
43
|
+
digest = Digest::SHA1.hexdigest(response.body)[0..7]
|
44
|
+
|
45
|
+
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# The asset hash middleware is responsible for rewriting references to
|
50
|
+
# assets to include their new, hashed name.
|
51
|
+
class Middleware
|
52
|
+
def initialize(app, options={})
|
53
|
+
@rack_app = app
|
54
|
+
@exts = options[:exts]
|
55
|
+
@ignore = options[:ignore]
|
56
|
+
@exts_regex_text = @exts.map {|e| Regexp.escape(e) }.join('|')
|
57
|
+
@middleman_app = options[:middleman_app]
|
58
|
+
end
|
59
|
+
|
60
|
+
def call(env)
|
61
|
+
status, headers, response = @rack_app.call(env)
|
62
|
+
|
63
|
+
# We don't want to use this middleware when rendering files to figure out their hash!
|
64
|
+
return [status, headers, response] if env["bypass_asset_hash"] == 'true'
|
65
|
+
|
66
|
+
path = @middleman_app.full_path(env["PATH_INFO"])
|
67
|
+
dirpath = Pathname.new(File.dirname(path))
|
68
|
+
|
69
|
+
if path =~ /(^\/$)|(\.(htm|html|php|css|js)$)/
|
70
|
+
body = ::Middleman::Util.extract_response_text(response)
|
71
|
+
|
72
|
+
if body
|
73
|
+
# TODO: This regex will change some paths in plan HTML (not in a tag) - is that OK?
|
74
|
+
body.gsub!(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{@exts_regex_text}))/) do |match|
|
75
|
+
opening_character = $1
|
76
|
+
asset_path = $2
|
77
|
+
|
78
|
+
relative_path = Pathname.new(asset_path).relative?
|
79
|
+
|
80
|
+
asset_path = dirpath.join(asset_path).to_s if relative_path
|
81
|
+
|
82
|
+
if @ignore.any? { |r| asset_path.match(r) }
|
83
|
+
match
|
84
|
+
elsif asset_page = @middleman_app.sitemap.find_resource_by_path(asset_path)
|
85
|
+
replacement_path = "/#{asset_page.destination_path}"
|
86
|
+
replacement_path = Pathname.new(replacement_path).relative_path_from(dirpath).to_s if relative_path
|
87
|
+
|
88
|
+
"#{opening_character}#{replacement_path}"
|
89
|
+
else
|
90
|
+
match
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
status, headers, response = Rack::Response.new(body, status, headers).finish
|
95
|
+
end
|
96
|
+
end
|
97
|
+
[status, headers, response]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
# =================Temp Generate Test data==============================
|
104
|
+
# ["jpg", "png", "gif"].each do |ext|
|
105
|
+
# [["<p>", "</p>"], ["<p><img src=", " /></p>"], ["<p>background-image:url(", ");</p>"]].each do |outer|
|
106
|
+
# [["",""], ["'", "'"], ['"','"']].each do |inner|
|
107
|
+
# [["", ""], ["/", ""], ["../", ""], ["../../", ""], ["../../../", ""], ["http://example.com/", ""], ["a","a"], ["1","1"], [".", "."], ["-","-"], ["_","_"]].each do |path_parts|
|
108
|
+
# name = 'images/100px.'
|
109
|
+
# puts outer[0] + inner[0] + path_parts[0] + name + ext + path_parts[1] + inner[1] + outer[1]
|
110
|
+
# end
|
111
|
+
# end
|
112
|
+
# end
|
113
|
+
# puts "<br /><br /><br />"
|
114
|
+
# end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
|
2
|
+
# Asset Host module
|
3
|
+
class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
4
|
+
option :host, nil, 'The asset host to use, or false for no asset host, or a Proc to determine asset host'
|
5
|
+
|
6
|
+
def initialize(app, options_hash={}, &block)
|
7
|
+
super
|
8
|
+
|
9
|
+
# Backwards compatible API
|
10
|
+
app.config.define_setting :asset_host, nil, 'The asset host to use, or false for no asset host, or a Proc to determine asset host'
|
11
|
+
|
12
|
+
app.compass_config do |config|
|
13
|
+
if asset_host = extensions[:asset_host].host
|
14
|
+
if asset_host.is_a?(Proc)
|
15
|
+
config.asset_host(&asset_host)
|
16
|
+
else
|
17
|
+
config.asset_host do |asset|
|
18
|
+
asset_host
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end if app.respond_to?(:compass_config)
|
23
|
+
end
|
24
|
+
|
25
|
+
def host
|
26
|
+
app.config[:asset_host] || options[:host]
|
27
|
+
end
|
28
|
+
|
29
|
+
helpers do
|
30
|
+
# Override default asset url helper to include asset hosts
|
31
|
+
#
|
32
|
+
# @param [String] path
|
33
|
+
# @param [String] prefix
|
34
|
+
# @return [String]
|
35
|
+
def asset_url(path, prefix="")
|
36
|
+
controller = extensions[:asset_host]
|
37
|
+
|
38
|
+
original_output = super
|
39
|
+
return original_output unless controller.host
|
40
|
+
|
41
|
+
asset_prefix = if controller.host.is_a?(Proc)
|
42
|
+
controller.host.call(original_output)
|
43
|
+
elsif controller.host.is_a?(String)
|
44
|
+
controller.host
|
45
|
+
end
|
46
|
+
|
47
|
+
File.join(asset_prefix, original_output)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|