middleman-core 4.0.0.rc.1 → 4.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/Rakefile +0 -1
- data/cucumber.yml +2 -0
- data/features/asset_hash.feature +25 -16
- data/features/asset_host.feature +5 -1
- data/features/chained_templates.feature +8 -5
- data/features/clean_build.feature +18 -0
- data/features/cli/preview_server-hook.feature +17 -0
- data/features/cli/preview_server.feature +533 -0
- data/features/cli_init.feature +3 -3
- data/features/collections.feature +5 -3
- data/features/content_type.feature +3 -0
- data/features/default-layout.feature +90 -0
- data/features/extension_api_deprecations.feature +10 -0
- data/features/front-matter.feature +6 -1
- data/features/i18n_link_to.feature +209 -0
- data/features/import_files.feature +17 -0
- data/features/javascript-testing.feature +18 -0
- data/features/markdown_redcarpet.feature +0 -1
- data/features/markdown_redcarpet_in_haml.feature +0 -1
- data/features/minify_css.feature +87 -5
- data/features/minify_javascript.feature +55 -8
- data/features/move_files.feature +44 -0
- data/features/redirects.feature +1 -0
- data/features/relative_assets.feature +13 -2
- data/features/slim.feature +1 -1
- data/features/stylus.feature +0 -1
- data/features/support/env.rb +5 -1
- data/features/support/preserve_mime_types.rb +7 -0
- data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff +0 -0
- data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 +0 -0
- data/fixtures/asset-hash-app/source/stylesheets/site.css.scss +2 -2
- data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +4 -0
- data/fixtures/asset-host-app/source/asset_host.html.erb +5 -1
- data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +8 -0
- data/fixtures/clean-app/config-hidden-dir-after.rb +5 -0
- data/fixtures/clean-app/config-hidden-dir-before.rb +1 -0
- data/fixtures/content-type-app/source/index.php +1 -0
- data/fixtures/extension-api-deprecations-app/config.rb +11 -0
- data/fixtures/extension-api-deprecations-app/source/index.html.erb +1 -0
- data/fixtures/extension-api-deprecations-app/source/layouts/layout.erb +3 -0
- data/fixtures/frontmatter-app/config.rb +1 -0
- data/fixtures/frontmatter-app/source/front-matter-haml.html.haml +6 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +1 -1
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +1 -1
- data/fixtures/i18n-test-app/source/localizable/partials/index.html.erb +3 -1
- data/fixtures/import-app/bower.json +21 -0
- data/fixtures/import-app/bower_components/jquery/.bower.json +39 -0
- data/fixtures/import-app/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/fixtures/import-app/bower_components/jquery/bower.json +28 -0
- data/fixtures/import-app/bower_components/jquery/dist/jquery.js +9210 -0
- data/fixtures/import-app/bower_components/jquery/dist/jquery.min.js +5 -0
- data/fixtures/import-app/bower_components/jquery/dist/jquery.min.map +1 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax.js +786 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/jsonp.js +89 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/load.js +75 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/parseJSON.js +13 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/parseXML.js +28 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/script.js +64 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/var/nonce.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/var/rquery.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/ajax/xhr.js +136 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes.js +11 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes/attr.js +141 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes/classes.js +158 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes/prop.js +94 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes/support.js +35 -0
- data/fixtures/import-app/bower_components/jquery/src/attributes/val.js +161 -0
- data/fixtures/import-app/bower_components/jquery/src/callbacks.js +205 -0
- data/fixtures/import-app/bower_components/jquery/src/core.js +502 -0
- data/fixtures/import-app/bower_components/jquery/src/core/access.js +60 -0
- data/fixtures/import-app/bower_components/jquery/src/core/init.js +123 -0
- data/fixtures/import-app/bower_components/jquery/src/core/parseHTML.js +39 -0
- data/fixtures/import-app/bower_components/jquery/src/core/ready.js +97 -0
- data/fixtures/import-app/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
- data/fixtures/import-app/bower_components/jquery/src/css.js +450 -0
- data/fixtures/import-app/bower_components/jquery/src/css/addGetHookIf.js +22 -0
- data/fixtures/import-app/bower_components/jquery/src/css/curCSS.js +57 -0
- data/fixtures/import-app/bower_components/jquery/src/css/defaultDisplay.js +70 -0
- data/fixtures/import-app/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
- data/fixtures/import-app/bower_components/jquery/src/css/support.js +96 -0
- data/fixtures/import-app/bower_components/jquery/src/css/swap.js +28 -0
- data/fixtures/import-app/bower_components/jquery/src/css/var/cssExpand.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/css/var/getStyles.js +12 -0
- data/fixtures/import-app/bower_components/jquery/src/css/var/isHidden.js +13 -0
- data/fixtures/import-app/bower_components/jquery/src/css/var/rmargin.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/data.js +178 -0
- data/fixtures/import-app/bower_components/jquery/src/data/Data.js +181 -0
- data/fixtures/import-app/bower_components/jquery/src/data/accepts.js +20 -0
- data/fixtures/import-app/bower_components/jquery/src/data/var/data_priv.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/data/var/data_user.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/deferred.js +149 -0
- data/fixtures/import-app/bower_components/jquery/src/deprecated.js +13 -0
- data/fixtures/import-app/bower_components/jquery/src/dimensions.js +50 -0
- data/fixtures/import-app/bower_components/jquery/src/effects.js +648 -0
- data/fixtures/import-app/bower_components/jquery/src/effects/Tween.js +114 -0
- data/fixtures/import-app/bower_components/jquery/src/effects/animatedSelector.js +13 -0
- data/fixtures/import-app/bower_components/jquery/src/event.js +868 -0
- data/fixtures/import-app/bower_components/jquery/src/event/ajax.js +13 -0
- data/fixtures/import-app/bower_components/jquery/src/event/alias.js +39 -0
- data/fixtures/import-app/bower_components/jquery/src/event/support.js +9 -0
- data/fixtures/import-app/bower_components/jquery/src/exports/amd.js +24 -0
- data/fixtures/import-app/bower_components/jquery/src/exports/global.js +32 -0
- data/fixtures/import-app/bower_components/jquery/src/intro.js +44 -0
- data/fixtures/import-app/bower_components/jquery/src/jquery.js +37 -0
- data/fixtures/import-app/bower_components/jquery/src/manipulation.js +580 -0
- data/fixtures/import-app/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
- data/fixtures/import-app/bower_components/jquery/src/manipulation/support.js +32 -0
- data/fixtures/import-app/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/offset.js +207 -0
- data/fixtures/import-app/bower_components/jquery/src/outro.js +1 -0
- data/fixtures/import-app/bower_components/jquery/src/queue.js +142 -0
- data/fixtures/import-app/bower_components/jquery/src/queue/delay.js +22 -0
- data/fixtures/import-app/bower_components/jquery/src/selector-native.js +172 -0
- data/fixtures/import-app/bower_components/jquery/src/selector-sizzle.js +14 -0
- data/fixtures/import-app/bower_components/jquery/src/selector.js +1 -0
- data/fixtures/import-app/bower_components/jquery/src/serialize.js +111 -0
- data/fixtures/import-app/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
- data/fixtures/import-app/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
- data/fixtures/import-app/bower_components/jquery/src/traversing.js +199 -0
- data/fixtures/import-app/bower_components/jquery/src/traversing/findFilter.js +100 -0
- data/fixtures/import-app/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
- data/fixtures/import-app/bower_components/jquery/src/var/arr.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/var/class2type.js +4 -0
- data/fixtures/import-app/bower_components/jquery/src/var/concat.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/var/hasOwn.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/var/indexOf.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/var/pnum.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/var/push.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/var/rnotwhite.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/var/slice.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/var/strundefined.js +3 -0
- data/fixtures/import-app/bower_components/jquery/src/var/support.js +4 -0
- data/fixtures/import-app/bower_components/jquery/src/var/toString.js +5 -0
- data/fixtures/import-app/bower_components/jquery/src/wrap.js +79 -0
- data/fixtures/import-app/config.rb +7 -0
- data/fixtures/{twitter-bootstrap-app/config.rb → import-app/source/test.html} +0 -0
- data/fixtures/import-app/static.html +1 -0
- data/fixtures/javascript-app/config.rb +0 -0
- data/fixtures/javascript-app/source/index.html +17 -0
- data/fixtures/minify-css-app/source/inline-css.php +8 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_base.scss +15 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_buttons.scss +35 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_forms.scss +90 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_grid-settings.scss +14 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_lists.scss +31 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_tables.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_typography.scss +49 -0
- data/fixtures/minify-css-app/source/stylesheets/base/_variables.scss +42 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/_bourbon-deprecated-upcoming.scss +411 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/_bourbon.scss +87 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_border-color.scss +26 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_border-radius.scss +48 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_border-style.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_border-width.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_buttons.scss +64 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_clearfix.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_ellipsis.scss +30 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_font-stacks.scss +31 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_hide-text.scss +27 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_margin.scss +26 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_padding.scss +26 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_position.scss +48 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_prefixer.scss +66 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_retina-image.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_size.scss +51 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_text-inputs.scss +113 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_timing-functions.scss +34 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_triangle.scss +63 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/addons/_word-wrap.scss +29 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_animation.scss +43 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_appearance.scss +3 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_backface-visibility.scss +3 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_background-image.scss +42 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_background.scss +55 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_border-image.scss +59 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_calc.scss +4 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_columns.scss +47 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_filter.scss +4 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_flex-box.scss +287 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_font-face.scss +24 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_font-feature-settings.scss +4 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_hidpi-media-query.scss +10 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_hyphens.scss +4 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_image-rendering.scss +14 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_keyframes.scss +36 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_linear-gradient.scss +38 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_perspective.scss +8 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_placeholder.scss +8 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_radial-gradient.scss +39 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_selection.scss +42 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_text-decoration.scss +19 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_transform.scss +15 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_transition.scss +71 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/css3/_user-select.scss +3 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_assign-inputs.scss +11 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_contains-falsy.scss +20 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_contains.scss +26 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_is-length.scss +11 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_is-light.scss +21 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_is-number.scss +11 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_is-size.scss +13 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_modular-scale.scss +69 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_px-to-em.scss +13 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_px-to-rem.scss +15 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_shade.scss +24 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_strip-units.scss +17 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_tint.scss +24 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_transition-property-name.scss +22 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/functions/_unpack.scss +27 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_convert-units.scss +21 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_directional-values.scss +96 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_font-source-declaration.scss +43 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_gradient-positions-parser.scss +13 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_linear-angle-parser.scss +25 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_linear-gradient-parser.scss +41 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_linear-positions-parser.scss +61 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_linear-side-corner-parser.scss +31 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_radial-arg-parser.scss +69 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_radial-gradient-parser.scss +50 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_radial-positions-parser.scss +18 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_render-gradients.scss +26 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_shape-size-stripper.scss +10 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/helpers/_str-to-num.scss +50 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/settings/_asset-pipeline.scss +7 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/settings/_prefixer.scss +9 -0
- data/fixtures/minify-css-app/source/stylesheets/bourbon/settings/_px-to-em.scss +1 -0
- data/fixtures/minify-css-app/source/stylesheets/site.xcss.sass +6 -0
- data/fixtures/minify-js-app/source/inline-js.php +22 -0
- data/fixtures/minify-js-app/source/javascripts/js_test.xjs +8 -0
- data/fixtures/partials-app/source/locals.html.erb +1 -1
- data/fixtures/preview-server-app/bin/dns_server.rb +33 -0
- data/fixtures/preview-server-app/config.rb +0 -0
- data/fixtures/preview-server-app/source/index.html.erb +1 -0
- data/fixtures/preview-server-app/source/layout.erb +9 -0
- data/fixtures/preview-server-app/source/layouts/custom.erb +8 -0
- data/fixtures/preview-server-app/source/real.html +1 -0
- data/fixtures/preview-server-app/source/real/index.html.erb +5 -0
- data/fixtures/preview-server-app/source/should_be_ignored.html +1 -0
- data/fixtures/preview-server-app/source/should_be_ignored2.html +1 -0
- data/fixtures/preview-server-app/source/should_be_ignored3.html +1 -0
- data/fixtures/preview-server-app/source/static.html +1 -0
- data/fixtures/preview-server-hook-app/config.rb +19 -0
- data/fixtures/preview-server-hook-app/source/index.html.erb +9 -0
- data/fixtures/related-files-app/config.rb +0 -0
- data/fixtures/related-files-app/source/index.html.erb +0 -0
- data/fixtures/related-files-app/source/partials/_test.erb +0 -0
- data/fixtures/related-files-app/source/partials/_test2.haml +0 -0
- data/fixtures/related-files-app/source/stylesheets/_include3.sass +0 -0
- data/fixtures/related-files-app/source/stylesheets/_include4.scss +0 -0
- data/fixtures/related-files-app/source/stylesheets/include1.css +0 -0
- data/fixtures/related-files-app/source/stylesheets/include2.css.scss +0 -0
- data/fixtures/related-files-app/source/stylesheets/site.css.scss +0 -0
- data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +9 -0
- data/fixtures/relative-assets-app/source/javascripts/app.js +3 -0
- data/fixtures/relative-assets-app/source/relative_image.html.erb +1 -0
- data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +9 -0
- data/lib/middleman-core/application.rb +44 -18
- data/lib/middleman-core/builder.rb +1 -27
- data/lib/middleman-core/callback_manager.rb +3 -3
- data/lib/middleman-core/configuration.rb +1 -1
- data/lib/middleman-core/core_extensions/collections/step_context.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +2 -2
- data/lib/middleman-core/core_extensions/default_helpers.rb +37 -3
- data/lib/middleman-core/core_extensions/external_helpers.rb +2 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +5 -2
- data/lib/middleman-core/core_extensions/i18n.rb +95 -29
- data/lib/middleman-core/core_extensions/routing.rb +2 -2
- data/lib/middleman-core/dns_resolver.rb +73 -0
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +52 -0
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +63 -0
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +44 -0
- data/lib/middleman-core/dns_resolver/network_resolver.rb +42 -0
- data/lib/middleman-core/extension.rb +1 -1
- data/lib/middleman-core/extensions/asset_hash.rb +3 -3
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +9 -1
- data/lib/middleman-core/extensions/minify_css.rb +49 -17
- data/lib/middleman-core/extensions/minify_javascript.rb +60 -30
- data/lib/middleman-core/extensions/relative_assets.rb +13 -0
- data/lib/middleman-core/file_renderer.rb +2 -2
- data/lib/middleman-core/meta_pages.rb +1 -1
- data/lib/middleman-core/preview_server.rb +109 -47
- data/lib/middleman-core/preview_server/checks.rb +81 -0
- data/lib/middleman-core/preview_server/information.rb +273 -0
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +65 -0
- data/lib/middleman-core/preview_server/server_hostname.rb +39 -0
- data/lib/middleman-core/preview_server/server_information.rb +153 -0
- data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +35 -0
- data/lib/middleman-core/preview_server/server_information_validator.rb +18 -0
- data/lib/middleman-core/preview_server/server_ip_address.rb +55 -0
- data/lib/middleman-core/preview_server/server_url.rb +63 -0
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +29 -0
- data/lib/middleman-core/rack.rb +7 -1
- data/lib/middleman-core/renderers/haml.rb +1 -2
- data/lib/middleman-core/renderers/liquid.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +23 -36
- data/lib/middleman-core/renderers/sass_functions.rb +20 -22
- data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -1
- data/lib/middleman-core/sitemap/extensions/import.rb +108 -0
- data/lib/middleman-core/sitemap/extensions/move_file.rb +68 -0
- data/lib/middleman-core/sitemap/extensions/proxies.rb +7 -2
- data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -0
- data/lib/middleman-core/sitemap/resource.rb +3 -7
- data/lib/middleman-core/sitemap/store.rb +22 -19
- data/lib/middleman-core/sources.rb +2 -3
- data/lib/middleman-core/sources/source_watcher.rb +21 -37
- data/lib/middleman-core/step_definitions.rb +1 -0
- data/lib/middleman-core/step_definitions/builder_steps.rb +0 -47
- data/lib/middleman-core/step_definitions/commandline_steps.rb +88 -0
- data/lib/middleman-core/step_definitions/middleman_steps.rb +51 -6
- data/lib/middleman-core/step_definitions/server_steps.rb +21 -53
- data/lib/middleman-core/template_context.rb +14 -13
- data/lib/middleman-core/util.rb +127 -4
- data/lib/middleman-core/util/data.rb +87 -138
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +11 -11
- data/spec/middleman-core/dns_resolver_spec.rb +118 -0
- data/spec/middleman-core/preview_server/server_hostname_spec.rb +39 -0
- data/spec/middleman-core/preview_server/server_ip_address_spec.rb +43 -0
- data/spec/middleman-core/util_spec.rb +111 -3
- data/spec/spec_helper.rb +29 -1
- data/spec/support/given.rb +42 -0
- metadata +528 -221
- data/features/twitter-bootstrap-compile.feature +0 -6
- data/features/working_directory.feature +0 -33
- data/fixtures/collections-app/config.rb +0 -16
- data/fixtures/collections-app/source/index.html.erb +0 -26
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/.gitignore +0 -36
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/.travis.yml +0 -3
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/LICENSE +0 -176
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/README.md +0 -137
- 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 +0 -10
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/README.md +0 -112
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-alert.js +0 -90
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-button.js +0 -96
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-carousel.js +0 -169
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-collapse.js +0 -157
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-dropdown.js +0 -100
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-modal.js +0 -218
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-popover.js +0 -98
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-scrollspy.js +0 -151
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-tab.js +0 -135
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-tooltip.js +0 -275
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-transition.js +0 -61
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/bootstrap-typeahead.js +0 -285
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/index.html +0 -54
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/phantom.js +0 -63
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/server.js +0 -14
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-alert.js +0 -56
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-button.js +0 -77
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-carousel.js +0 -28
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-collapse.js +0 -54
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-dropdown.js +0 -87
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-modal.js +0 -114
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-phantom.js +0 -21
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-popover.js +0 -93
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-scrollspy.js +0 -31
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-tab.js +0 -61
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-tooltip.js +0 -155
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-transition.js +0 -13
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/unit/bootstrap-typeahead.js +0 -148
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/jquery.js +0 -9252
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/qunit.css +0 -232
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/js/tests/vendor/qunit.js +0 -1510
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_accordion.less +0 -33
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_alerts.less +0 -58
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_breadcrumbs.less +0 -24
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_button-groups.less +0 -191
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_buttons.less +0 -191
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_carousel.less +0 -121
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_close.less +0 -29
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_code.less +0 -57
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_component-animations.less +0 -20
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_dropdowns.less +0 -143
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_forms.less +0 -583
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_grid.less +0 -5
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_hero-unit.less +0 -22
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_labels-badges.less +0 -55
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_layouts.less +0 -17
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_mixins.less +0 -646
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_modals.less +0 -90
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_navbar.less +0 -358
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_navs.less +0 -363
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_pager.less +0 -36
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_pagination.less +0 -56
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_popovers.less +0 -49
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_progress-bars.less +0 -117
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_reset.less +0 -131
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-1200px-min.less +0 -26
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-767px-max.less +0 -149
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-768px-979px.less +0 -17
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-navbar.less +0 -153
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_responsive-utilities.less +0 -41
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_scaffolding.less +0 -29
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_sprites.less +0 -191
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_tables.less +0 -176
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_thumbnails.less +0 -47
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_tooltip.less +0 -35
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_type.less +0 -232
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_utilities.less +0 -23
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_variables.less +0 -206
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/_wells.less +0 -27
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/bootstrap.less +0 -62
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/responsive.less +0 -48
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/css-tests.css +0 -52
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/css-tests.html +0 -917
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/forms.html +0 -179
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/less/tests/navbar.html +0 -108
- data/fixtures/twitter-bootstrap-app/source/twitter-bootstrap-ebc6935/package.json +0 -25
- data/lib/middleman-core/cli/server.rb +0 -96
@@ -19,7 +19,8 @@ module Middleman
|
|
19
19
|
|
20
20
|
return unless File.exist?(helpers_path)
|
21
21
|
|
22
|
-
|
22
|
+
glob = File.join(helpers_path, app.config[:helpers_filename_glob])
|
23
|
+
::Middleman::Util.glob_directory(glob).each do |filename|
|
23
24
|
module_name = app.config[:helpers_filename_to_module_name_proc].call(filename)
|
24
25
|
next unless module_name
|
25
26
|
|
@@ -12,7 +12,7 @@ require 'middleman-core/util/data'
|
|
12
12
|
module Middleman::CoreExtensions
|
13
13
|
class FrontMatter < ::Middleman::Extension
|
14
14
|
# Try to run after routing but before directory_indexes
|
15
|
-
self.resource_list_manipulator_priority =
|
15
|
+
self.resource_list_manipulator_priority = 20
|
16
16
|
|
17
17
|
def initialize(app, options_hash={}, &block)
|
18
18
|
super
|
@@ -65,7 +65,10 @@ module Middleman::CoreExtensions
|
|
65
65
|
|
66
66
|
return [{}, nil] unless file
|
67
67
|
|
68
|
-
@cache[file[:full_path]] ||= ::Middleman::Util::Data.parse(
|
68
|
+
@cache[file[:full_path]] ||= ::Middleman::Util::Data.parse(
|
69
|
+
file[:full_path],
|
70
|
+
app.config[:frontmatter_delims]
|
71
|
+
)
|
69
72
|
end
|
70
73
|
|
71
74
|
Contract ArrayOf[IsA['Middleman::SourceFile']], ArrayOf[IsA['Middleman::SourceFile']] => Any
|
@@ -50,9 +50,6 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
50
50
|
@maps = {}
|
51
51
|
@mount_at_root = options[:mount_at_root].nil? ? langs.first : options[:mount_at_root]
|
52
52
|
|
53
|
-
# Don't output localizable files
|
54
|
-
app.ignore File.join(options[:templates_dir], '**')
|
55
|
-
|
56
53
|
configure_i18n
|
57
54
|
|
58
55
|
logger.info "== Locales: #{langs.join(', ')} (Default #{@mount_at_root})"
|
@@ -63,13 +60,40 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
63
60
|
::I18n.t(*args)
|
64
61
|
end
|
65
62
|
|
63
|
+
def url_for(path_or_resource, options={})
|
64
|
+
locale = options.delete(:locale) || ::I18n.locale
|
65
|
+
|
66
|
+
opts = options.dup
|
67
|
+
|
68
|
+
should_relativize = opts.key?(:relative) ? opts[:relative] : config[:relative_links]
|
69
|
+
|
70
|
+
opts[:relative] = false
|
71
|
+
|
72
|
+
href = super(path_or_resource, opts)
|
73
|
+
|
74
|
+
final_path = if result = extensions[:i18n].localized_path(href, locale)
|
75
|
+
result
|
76
|
+
else
|
77
|
+
# Should we log the missing file?
|
78
|
+
href
|
79
|
+
end
|
80
|
+
|
81
|
+
opts[:relative] = should_relativize
|
82
|
+
|
83
|
+
begin
|
84
|
+
super(final_path, opts)
|
85
|
+
rescue RuntimeError
|
86
|
+
super(path_or_resource, options)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
66
90
|
def locate_partial(partial_name, try_static=false)
|
67
91
|
locals_dir = extensions[:i18n].options[:templates_dir]
|
68
92
|
|
69
93
|
# Try /localizable
|
70
94
|
partials_path = File.join(locals_dir, partial_name)
|
71
95
|
|
72
|
-
lang_suffix =
|
96
|
+
lang_suffix = ::I18n.locale
|
73
97
|
|
74
98
|
extname = File.extname(partial_name)
|
75
99
|
maybe_static = extname.length > 0
|
@@ -102,29 +126,56 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
102
126
|
def manipulate_resource_list(resources)
|
103
127
|
new_resources = []
|
104
128
|
|
105
|
-
resources.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
129
|
+
file_extension_resources = resources.select do |resource|
|
130
|
+
parse_locale_extension(resource.path)
|
131
|
+
end
|
132
|
+
|
133
|
+
localizable_folder_resources = resources.select do |resource|
|
134
|
+
!file_extension_resources.include?(resource) && File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path)
|
135
|
+
end
|
136
|
+
|
137
|
+
# If it's a "localizable template"
|
138
|
+
localizable_folder_resources.each do |resource|
|
139
|
+
page_id = File.basename(resource.path, File.extname(resource.path))
|
140
|
+
langs.each do |lang|
|
141
|
+
# Remove folder name
|
142
|
+
path = resource.path.sub(options[:templates_dir], '')
|
143
|
+
new_resources << build_resource(path, resource.path, page_id, lang)
|
118
144
|
end
|
119
145
|
|
146
|
+
resource.ignore!
|
147
|
+
|
120
148
|
# This is for backwards compatibility with the old provides_metadata-based code
|
121
149
|
# that used to be in this extension, but I don't know how much sense it makes.
|
122
|
-
next if resource.options[:lang]
|
150
|
+
# next if resource.options[:lang]
|
123
151
|
|
124
|
-
|
152
|
+
# $stderr.puts "Defaulting #{resource.path} to #{@mount_at_root}"
|
153
|
+
# resource.add_metadata options: { lang: @mount_at_root }, locals: { lang: @mount_at_root }
|
125
154
|
end
|
126
155
|
|
127
|
-
|
156
|
+
# If it uses file extension localization
|
157
|
+
file_extension_resources.each do |resource|
|
158
|
+
result = parse_locale_extension(resource.path)
|
159
|
+
ext_lang, path, page_id = result
|
160
|
+
new_resources << build_resource(path, resource.path, page_id, ext_lang)
|
161
|
+
|
162
|
+
resource.ignore!
|
163
|
+
end
|
164
|
+
|
165
|
+
@lookup = new_resources.each_with_object({}) do |desc, sum|
|
166
|
+
abs_path = desc.source_path.sub(options[:templates_dir], '')
|
167
|
+
sum[abs_path] ||= {}
|
168
|
+
sum[abs_path][desc.lang] = '/' + desc.path
|
169
|
+
end
|
170
|
+
|
171
|
+
resources + new_resources.map { |r| r.to_resource(app) }
|
172
|
+
end
|
173
|
+
|
174
|
+
def localized_path(path, lang)
|
175
|
+
lookup_path = path.dup
|
176
|
+
lookup_path << app.config[:index_file] if lookup_path.end_with?('/')
|
177
|
+
|
178
|
+
@lookup[lookup_path] && @lookup[lookup_path][lang]
|
128
179
|
end
|
129
180
|
|
130
181
|
private
|
@@ -132,12 +183,12 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
132
183
|
def on_file_changed(_updated_files, _removed_files)
|
133
184
|
@_langs = nil # Clear langs cache
|
134
185
|
|
135
|
-
|
186
|
+
::I18n.load_path |= app.files.by_type(:locales).files.map { |p| p[:full_path].to_s }
|
136
187
|
::I18n.reload!
|
137
188
|
end
|
138
189
|
|
139
190
|
def configure_i18n
|
140
|
-
::I18n.load_path
|
191
|
+
::I18n.load_path |= app.files.by_type(:locales).files.map { |p| p[:full_path].to_s }
|
141
192
|
::I18n.reload!
|
142
193
|
|
143
194
|
::I18n.default_locale = @mount_at_root
|
@@ -155,9 +206,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
155
206
|
p[:relative_path].to_s.split(File::SEPARATOR).length == 1
|
156
207
|
end
|
157
208
|
|
158
|
-
known_langs.map
|
209
|
+
known_langs.map do |p|
|
159
210
|
File.basename(p[:relative_path].to_s).sub(/\.ya?ml$/, '').sub(/\.rb$/, '')
|
160
|
-
|
211
|
+
end.sort.map(&:to_sym)
|
161
212
|
end
|
162
213
|
end
|
163
214
|
|
@@ -177,12 +228,29 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
177
228
|
[lang, path, basename]
|
178
229
|
end
|
179
230
|
|
180
|
-
|
231
|
+
LocalizedPageDescriptor = Struct.new(:path, :source_path, :lang) do
|
232
|
+
def to_resource(app)
|
233
|
+
r = ::Middleman::Sitemap::ProxyResource.new(app.sitemap, path, source_path)
|
234
|
+
r.add_metadata options: { lang: lang }
|
235
|
+
r
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
Contract String, String, String, Symbol => LocalizedPageDescriptor
|
181
240
|
def build_resource(path, source_path, page_id, lang)
|
182
241
|
old_locale = ::I18n.locale
|
183
242
|
::I18n.locale = lang
|
184
243
|
localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id, fallback: [])
|
185
244
|
|
245
|
+
partially_localized_path = ''
|
246
|
+
|
247
|
+
File.dirname(path).split('/').each do |path_sub|
|
248
|
+
next if path_sub == ''
|
249
|
+
partially_localized_path = "#{partially_localized_path}/#{(::I18n.t("paths.#{path_sub}", default: path_sub).to_s)}"
|
250
|
+
end
|
251
|
+
|
252
|
+
path = "#{partially_localized_path}/#{File.basename(path)}"
|
253
|
+
|
186
254
|
prefix = if (options[:mount_at_root] == lang) || (options[:mount_at_root].nil? && langs[0] == lang)
|
187
255
|
'/'
|
188
256
|
else
|
@@ -197,10 +265,8 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
|
197
265
|
|
198
266
|
path = path.sub(options[:templates_dir] + '/', '')
|
199
267
|
|
200
|
-
p = ::Middleman::Sitemap::ProxyResource.new(app.sitemap, path, source_path)
|
201
|
-
p.add_metadata locals: { lang: lang, page_id: path }, options: { lang: lang }
|
202
|
-
|
203
268
|
::I18n.locale = old_locale
|
204
|
-
|
269
|
+
|
270
|
+
LocalizedPageDescriptor.new(path, source_path, lang)
|
205
271
|
end
|
206
272
|
end
|
@@ -4,7 +4,7 @@ module Middleman
|
|
4
4
|
class Routing < Extension
|
5
5
|
# This should always run late, but not as late as :directory_indexes,
|
6
6
|
# so it can add metadata to any pages generated by other extensions
|
7
|
-
self.resource_list_manipulator_priority =
|
7
|
+
self.resource_list_manipulator_priority = 10
|
8
8
|
|
9
9
|
# Expose the `page` method to config.
|
10
10
|
expose_to_config :page
|
@@ -28,7 +28,7 @@ module Middleman
|
|
28
28
|
PageDescriptor = Struct.new(:path, :metadata)
|
29
29
|
|
30
30
|
# The page method allows options to be set for a given source path, regex, or glob.
|
31
|
-
# Options that may be set include layout, locals,
|
31
|
+
# Options that may be set include layout, locals, andx ignore.
|
32
32
|
#
|
33
33
|
# @example
|
34
34
|
# page '/about.html', layout: false
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'resolv'
|
2
|
+
require 'middleman-core/dns_resolver/network_resolver'
|
3
|
+
require 'middleman-core/dns_resolver/hosts_resolver'
|
4
|
+
|
5
|
+
module Middleman
|
6
|
+
# This resolves IP address to names and vice versa
|
7
|
+
class DnsResolver
|
8
|
+
private
|
9
|
+
|
10
|
+
attr_reader :resolvers
|
11
|
+
|
12
|
+
public
|
13
|
+
|
14
|
+
# Create resolver
|
15
|
+
#
|
16
|
+
# First the local resolver is used. If environment variable HOSTSRC is
|
17
|
+
# given this file is used for local name lookup.
|
18
|
+
#
|
19
|
+
# @param [#getnames, #getaddresses] network_resolver
|
20
|
+
# The resolver which uses a network name server to resolve ip addresses
|
21
|
+
# and names.
|
22
|
+
#
|
23
|
+
# @param [#getnames, #getaddresses] local_resolver
|
24
|
+
# The resolver uses /etc/hosts on POSIX-systems and
|
25
|
+
# C:\Windows\System32\drivers\etc\hosts on Windows-operating systems to
|
26
|
+
# resolve ip addresses and names.
|
27
|
+
#
|
28
|
+
# First the local resolver is queried. If this raises an error or returns
|
29
|
+
# nil or [] the network resolver is queried.
|
30
|
+
def initialize(opts={})
|
31
|
+
@resolvers = []
|
32
|
+
@resolvers << opts.fetch(:hosts_resolver, HostsResolver.new)
|
33
|
+
|
34
|
+
if RUBY_VERSION >= '2.1'
|
35
|
+
require 'middleman-core/dns_resolver/local_link_resolver'
|
36
|
+
@resolvers << opts.fetch(:local_link_resolver, LocalLinkResolver.new)
|
37
|
+
end
|
38
|
+
|
39
|
+
@resolvers << opts.fetch(:network_resolver, NetworkResolver.new)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get names for given ip
|
43
|
+
#
|
44
|
+
# @param [String] ip
|
45
|
+
# The ip which should be resolved.
|
46
|
+
def names_for(ip)
|
47
|
+
resolvers.each do |r|
|
48
|
+
names = r.getnames(ip)
|
49
|
+
|
50
|
+
return names unless names.nil? || names.empty?
|
51
|
+
end
|
52
|
+
|
53
|
+
[]
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get ips for given name
|
57
|
+
#
|
58
|
+
# First the local resolver is used. On POSIX-systems /etc/hosts is used. On
|
59
|
+
# Windows C:\Windows\System32\drivers\etc\hosts is used.
|
60
|
+
#
|
61
|
+
# @param [String] name
|
62
|
+
# The name which should be resolved.
|
63
|
+
def ips_for(name)
|
64
|
+
resolvers.each do |r|
|
65
|
+
ips = r.getaddresses(name)
|
66
|
+
|
67
|
+
return ips unless ips.nil? || ips.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
[]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Middleman
|
2
|
+
class DnsResolver
|
3
|
+
# Use network name server to resolve ips and names
|
4
|
+
class BasicNetworkResolver
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :resolver, :timeouts
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
def initialize(opts={})
|
12
|
+
@timeouts = opts.fetch(:timeouts, 2)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Get names for ip
|
16
|
+
#
|
17
|
+
# @param [#to_s] ip
|
18
|
+
# The ip to resolve into names
|
19
|
+
#
|
20
|
+
# @return [Array]
|
21
|
+
# Array of Names
|
22
|
+
def getnames(ip)
|
23
|
+
resolver.getnames(ip.to_s).map(&:to_s)
|
24
|
+
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
|
25
|
+
[]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Get ips for name
|
29
|
+
#
|
30
|
+
# @param [#to_s] name
|
31
|
+
# The name to resolve into ips
|
32
|
+
#
|
33
|
+
# @return [Array]
|
34
|
+
# Array of ipaddresses
|
35
|
+
def getaddresses(name)
|
36
|
+
resolver.getaddresses(name.to_s).map(&:to_s)
|
37
|
+
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
|
38
|
+
[]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Set timeout for lookup
|
42
|
+
#
|
43
|
+
# @param [Integer] value
|
44
|
+
# The timeout value
|
45
|
+
def timeouts=(timeouts)
|
46
|
+
return if RUBY_VERSION < '2'
|
47
|
+
|
48
|
+
resolver.timeouts = timeouts
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Middleman
|
2
|
+
class DnsResolver
|
3
|
+
# Use network name server to resolve ips and names
|
4
|
+
class HostsResolver
|
5
|
+
private
|
6
|
+
|
7
|
+
attr_reader :resolver
|
8
|
+
|
9
|
+
public
|
10
|
+
|
11
|
+
def initialize(opts={})
|
12
|
+
# using the splat operator works around a non-existing HOSTSRC variable
|
13
|
+
# using nil as input does not work, but `*[]` does and then Resolv::Hosts
|
14
|
+
# uses its defaults
|
15
|
+
@resolver = opts.fetch(:resolver, Resolv::Hosts.new(*hosts_file))
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get names for ip
|
19
|
+
#
|
20
|
+
# @param [#to_s] ip
|
21
|
+
# The ip to resolve into names
|
22
|
+
#
|
23
|
+
# @return [Array]
|
24
|
+
# Array of Names
|
25
|
+
def getnames(ip)
|
26
|
+
resolver.getnames(ip.to_s).map(&:to_s)
|
27
|
+
rescue Resolv::ResolvError
|
28
|
+
[]
|
29
|
+
end
|
30
|
+
|
31
|
+
# Get ips for name
|
32
|
+
#
|
33
|
+
# @param [#to_s] name
|
34
|
+
# The name to resolve into ips
|
35
|
+
#
|
36
|
+
# @return [Array]
|
37
|
+
# Array of ipaddresses
|
38
|
+
def getaddresses(name)
|
39
|
+
resolver.getaddresses(name.to_s).map(&:to_s)
|
40
|
+
rescue Resolv::ResolvError
|
41
|
+
[]
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Path to hosts file
|
47
|
+
#
|
48
|
+
# This looks for MM_HOSTSRC in your environment
|
49
|
+
#
|
50
|
+
# @return [Array]
|
51
|
+
# This needs to be an array, to make the splat operator work
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# # <ip> <hostname>
|
55
|
+
# 127.0.0.1 localhost.localhost localhost
|
56
|
+
def hosts_file
|
57
|
+
return [ENV['MM_HOSTSRC']] if ENV.key?('MM_HOSTSRC') && File.file?(ENV['MM_HOSTSRC'])
|
58
|
+
|
59
|
+
[]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'middleman-core/dns_resolver/basic_network_resolver'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class DnsResolver
|
5
|
+
# Use network name server to resolve ips and names
|
6
|
+
class LocalLinkResolver < BasicNetworkResolver
|
7
|
+
def initialize(opts={})
|
8
|
+
super
|
9
|
+
|
10
|
+
@timeouts = opts.fetch(:timeouts, 1)
|
11
|
+
@resolver = opts.fetch(:resolver, Resolv::MDNS.new(nameserver_config))
|
12
|
+
|
13
|
+
self.timeouts = timeouts
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
# Hosts + Ports for MDNS resolver
|
19
|
+
#
|
20
|
+
# This looks for MM_MDNSRC in your environment. If you are going to use
|
21
|
+
# IPv6-addresses: Make sure you do not forget to add the port at the end.
|
22
|
+
#
|
23
|
+
# MM_MDNSRC=ip:port ip:port
|
24
|
+
#
|
25
|
+
# @return [Hash]
|
26
|
+
# Returns the configuration for the nameserver
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# export MM_MDNSRC="224.0.0.251:5353 ff02::fb:5353"
|
30
|
+
#
|
31
|
+
def nameserver_config
|
32
|
+
return unless ENV.key?('MM_MDNSRC') && ENV['MM_MDNSRC']
|
33
|
+
|
34
|
+
address, port = ENV['MM_MDNSRC'].split(/:/)
|
35
|
+
|
36
|
+
{
|
37
|
+
nameserver_port: [[address, port.to_i]]
|
38
|
+
}
|
39
|
+
rescue StandardError
|
40
|
+
{}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|