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
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class PreviewServer
|
5
|
+
# Checks for input of preview server
|
6
|
+
module Checks
|
7
|
+
# This one will get all default setup
|
8
|
+
class BasicCheck; end
|
9
|
+
|
10
|
+
# This checks if the server name resolves to the bind_address
|
11
|
+
#
|
12
|
+
# If the users enters:
|
13
|
+
#
|
14
|
+
# 1. server_name: www.example.com (10.0.0.1)
|
15
|
+
# 2. bind_address: 127.0.0.01
|
16
|
+
#
|
17
|
+
# This validation will fail
|
18
|
+
class ServerNameResolvesToBindAddress < BasicCheck
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :resolver
|
22
|
+
|
23
|
+
public
|
24
|
+
|
25
|
+
def initialize
|
26
|
+
@resolver = DnsResolver.new
|
27
|
+
end
|
28
|
+
|
29
|
+
# Validate
|
30
|
+
#
|
31
|
+
# @param [Information] information
|
32
|
+
# The information to be validated
|
33
|
+
def validate(information)
|
34
|
+
return if resolver.ips_for(information.server_name).include? information.bind_address
|
35
|
+
|
36
|
+
information.valid = false
|
37
|
+
information.reason = format('Server name "%s" does not resolve to bind address "%s"', information.server_name, information.bind_address)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# This validation fails if the user chooses to use an ip address which is
|
42
|
+
# not available on his/her system
|
43
|
+
class InterfaceIsAvailableOnSystem < BasicCheck
|
44
|
+
# Validate
|
45
|
+
#
|
46
|
+
# @param [Information] information
|
47
|
+
# The information to be validated
|
48
|
+
def validate(information)
|
49
|
+
return if information.bind_address.blank? || information.local_network_interfaces.include?(information.bind_address.to_s) || %w(0.0.0.0 ::).any? { |b| information.bind_address == b } || IPAddr.new('127.0.0.0/8').include?(information.bind_address.to_s)
|
50
|
+
|
51
|
+
information.valid = false
|
52
|
+
information.reason = format('Bind address "%s" is not available on your system. Please use one of %s', information.bind_address, information.local_network_interfaces.map { |i| %("#{i}") }.join(', '))
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# This one requires a bind address if the user entered a server name
|
57
|
+
#
|
58
|
+
# If the `bind_address` is blank this check will fail
|
59
|
+
class RequiresBindAddressIfServerNameIsGiven < BasicCheck
|
60
|
+
def validate(information)
|
61
|
+
return unless information.bind_address.blank?
|
62
|
+
|
63
|
+
information.valid = false
|
64
|
+
information.reason = format('Server name "%s" does not resolve to an ip address', information.server_name)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# This validation always fails
|
69
|
+
class DenyAnyAny < BasicCheck
|
70
|
+
# Validate
|
71
|
+
#
|
72
|
+
# @param [Information] information
|
73
|
+
# The information to be validated
|
74
|
+
def validate(information)
|
75
|
+
information.valid = false
|
76
|
+
information.reason = 'Undefined combination of options "--server-name" and "--bind-address". If you think this is wrong, please file a bug at "https://github.com/middleman/middleman"'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'active_support/core_ext/object/blank'
|
3
|
+
require 'middleman-core/preview_server/checks'
|
4
|
+
require 'middleman-core/preview_server/server_hostname'
|
5
|
+
require 'middleman-core/preview_server/server_ip_address'
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
class PreviewServer
|
9
|
+
# Basic information class to wrap common behaviour
|
10
|
+
class BasicInformation
|
11
|
+
private
|
12
|
+
|
13
|
+
attr_reader :checks, :network_interfaces_inventory
|
14
|
+
|
15
|
+
public
|
16
|
+
|
17
|
+
attr_accessor :bind_address, :server_name, :port, :reason, :valid
|
18
|
+
attr_reader :listeners, :site_addresses
|
19
|
+
|
20
|
+
# Create instance
|
21
|
+
#
|
22
|
+
# @param [String] bind_address
|
23
|
+
# The bind address of the server
|
24
|
+
#
|
25
|
+
# @param [String] server_name
|
26
|
+
# The name of the server
|
27
|
+
#
|
28
|
+
# @param [Integer] port
|
29
|
+
# The port to listen on
|
30
|
+
def initialize(opts={})
|
31
|
+
@bind_address = ServerIpAddress.new(opts[:bind_address])
|
32
|
+
@server_name = ServerHostname.new(opts[:server_name])
|
33
|
+
@port = opts[:port]
|
34
|
+
@valid = true
|
35
|
+
|
36
|
+
@site_addresses = []
|
37
|
+
@listeners = []
|
38
|
+
@checks = []
|
39
|
+
|
40
|
+
# This needs to be check for each use case. Otherwise `Webrick` will
|
41
|
+
# complain about that.
|
42
|
+
@checks << Checks::InterfaceIsAvailableOnSystem.new
|
43
|
+
end
|
44
|
+
|
45
|
+
# Is the given information valid?
|
46
|
+
def valid?
|
47
|
+
valid == true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Pass "self" to validator
|
51
|
+
#
|
52
|
+
# @param [#validate] validator
|
53
|
+
# The validator
|
54
|
+
def validate_me(validator)
|
55
|
+
validator.validate self, checks
|
56
|
+
end
|
57
|
+
|
58
|
+
def resolve_me(*)
|
59
|
+
fail NoMethodError
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get network information
|
63
|
+
#
|
64
|
+
# @param [#network_interfaces] inventory
|
65
|
+
# Get list of available network interfaces
|
66
|
+
def show_me_network_interfaces(inventory)
|
67
|
+
@network_interfaces_inventory = inventory
|
68
|
+
end
|
69
|
+
|
70
|
+
# Default is to get all network interfaces
|
71
|
+
def local_network_interfaces
|
72
|
+
network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:all)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# This only is used if no other parser is available
|
77
|
+
#
|
78
|
+
# The "default" behaviour is to fail because of "Checks::DenyAnyAny"
|
79
|
+
class DefaultInformation < BasicInformation
|
80
|
+
def initialize(*args)
|
81
|
+
super
|
82
|
+
|
83
|
+
# Make this fail
|
84
|
+
@checks << Checks::DenyAnyAny.new
|
85
|
+
end
|
86
|
+
|
87
|
+
def resolve_me(*); end
|
88
|
+
|
89
|
+
# Always true
|
90
|
+
def self.matches?(*)
|
91
|
+
true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# This one is used if no bind address and no server name is given
|
96
|
+
class AllInterfaces < BasicInformation
|
97
|
+
def initialize(*args)
|
98
|
+
super
|
99
|
+
|
100
|
+
after_init
|
101
|
+
end
|
102
|
+
|
103
|
+
def self.matches?(opts={})
|
104
|
+
opts[:bind_address].blank? && opts[:server_name].blank?
|
105
|
+
end
|
106
|
+
|
107
|
+
# Resolve ips
|
108
|
+
def resolve_me(resolver)
|
109
|
+
hostname = ServerHostname.new(Socket.gethostname)
|
110
|
+
hostname_ips = resolver.ips_for(hostname)
|
111
|
+
network_interface = ServerIpAddress.new(Array(local_network_interfaces).first)
|
112
|
+
resolved_name = ServerHostname.new(resolver.names_for(network_interface).first)
|
113
|
+
|
114
|
+
if includes_array? local_network_interfaces, hostname_ips
|
115
|
+
@server_name = hostname
|
116
|
+
@site_addresses << hostname
|
117
|
+
|
118
|
+
network_interface = ServerIpAddress.new((local_network_interfaces & hostname_ips).first)
|
119
|
+
elsif RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
|
120
|
+
@server_name = hostname
|
121
|
+
@site_addresses << hostname
|
122
|
+
elsif !resolved_name.blank?
|
123
|
+
@server_name = resolved_name
|
124
|
+
@site_addresses << resolved_name
|
125
|
+
else
|
126
|
+
@server_name = network_interface
|
127
|
+
end
|
128
|
+
|
129
|
+
@site_addresses << network_interface
|
130
|
+
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
def includes_array?(a, b)
|
137
|
+
!(a & b).empty?
|
138
|
+
end
|
139
|
+
|
140
|
+
def after_init
|
141
|
+
@listeners << ServerIpAddress.new('::')
|
142
|
+
@listeners << ServerIpAddress.new('0.0.0.0')
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# This is used if bind address is 0.0.0.0, the server name needs to be
|
147
|
+
# blank
|
148
|
+
class AllIpv4Interfaces < AllInterfaces
|
149
|
+
def self.matches?(opts={})
|
150
|
+
opts[:bind_address] == '0.0.0.0' && opts[:server_name].blank?
|
151
|
+
end
|
152
|
+
|
153
|
+
# Use only ipv4 interfaces
|
154
|
+
def local_network_interfaces
|
155
|
+
network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:ipv4)
|
156
|
+
end
|
157
|
+
|
158
|
+
private
|
159
|
+
|
160
|
+
def after_init
|
161
|
+
@listeners << ServerIpAddress.new('0.0.0.0')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# This is used if bind address is ::, the server name needs to be blank
|
166
|
+
class AllIpv6Interfaces < AllInterfaces
|
167
|
+
def self.matches?(opts={})
|
168
|
+
opts[:bind_address] == '::' && opts[:server_name].blank?
|
169
|
+
end
|
170
|
+
|
171
|
+
# Use only ipv6 interfaces
|
172
|
+
def local_network_interfaces
|
173
|
+
network_interfaces_inventory.nil? ? [] : network_interfaces_inventory.network_interfaces(:ipv6)
|
174
|
+
end
|
175
|
+
|
176
|
+
private
|
177
|
+
|
178
|
+
def after_init
|
179
|
+
@listeners << ServerIpAddress.new('::')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Used if a bind address is given and the server name is blank
|
184
|
+
class BindAddressInformation < BasicInformation
|
185
|
+
def initialize(*args)
|
186
|
+
super
|
187
|
+
|
188
|
+
@listeners << bind_address
|
189
|
+
@site_addresses << bind_address
|
190
|
+
end
|
191
|
+
|
192
|
+
def self.matches?(opts={})
|
193
|
+
!opts[:bind_address].blank? && opts[:server_name].blank?
|
194
|
+
end
|
195
|
+
|
196
|
+
# Resolv
|
197
|
+
def resolve_me(resolver)
|
198
|
+
@server_name = ServerHostname.new(resolver.names_for(bind_address).first)
|
199
|
+
@site_addresses << @server_name unless @server_name.blank?
|
200
|
+
|
201
|
+
self
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# Use if server name is given and bind address is blank
|
206
|
+
class ServerNameInformation < BasicInformation
|
207
|
+
def initialize(*args)
|
208
|
+
super
|
209
|
+
|
210
|
+
@checks << Checks::RequiresBindAddressIfServerNameIsGiven.new
|
211
|
+
@site_addresses << server_name
|
212
|
+
end
|
213
|
+
|
214
|
+
def resolve_me(resolver)
|
215
|
+
@bind_address = ServerIpAddress.new(resolver.ips_for(server_name).first)
|
216
|
+
|
217
|
+
unless bind_address.blank?
|
218
|
+
@listeners << bind_address
|
219
|
+
@site_addresses << bind_address
|
220
|
+
end
|
221
|
+
|
222
|
+
self
|
223
|
+
end
|
224
|
+
|
225
|
+
def self.matches?(opts={})
|
226
|
+
opts[:bind_address].blank? && !opts[:server_name].blank?
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
# Only used if bind address and server name are given and bind address is
|
231
|
+
# not :: or 0.0.0.0
|
232
|
+
class BindAddressAndServerNameInformation < BasicInformation
|
233
|
+
def initialize(*args)
|
234
|
+
super
|
235
|
+
|
236
|
+
@listeners << bind_address
|
237
|
+
@site_addresses << server_name
|
238
|
+
@site_addresses << bind_address
|
239
|
+
|
240
|
+
@checks << Checks::ServerNameResolvesToBindAddress.new
|
241
|
+
end
|
242
|
+
|
243
|
+
def self.matches?(opts={})
|
244
|
+
!opts[:bind_address].blank? && !opts[:server_name].blank? && !%w(:: 0.0.0.0).include?(opts[:bind_address])
|
245
|
+
end
|
246
|
+
|
247
|
+
def resolve_me(*); end
|
248
|
+
end
|
249
|
+
|
250
|
+
# If the server name is either an ipv4 or ipv6 address, e.g. 127.0.0.1 or
|
251
|
+
# ::1, use this one
|
252
|
+
class ServerNameIsIpInformation < BasicInformation
|
253
|
+
def initialize(opts={})
|
254
|
+
super
|
255
|
+
|
256
|
+
ip = ServerIpAddress.new(server_name.to_s)
|
257
|
+
|
258
|
+
@listeners << ip
|
259
|
+
@site_addresses << ip
|
260
|
+
end
|
261
|
+
|
262
|
+
def resolve_me(*); end
|
263
|
+
|
264
|
+
def self.matches?(opts={})
|
265
|
+
ip = IPAddr.new(opts[:server_name])
|
266
|
+
|
267
|
+
ip.ipv4? || ip.ipv6?
|
268
|
+
rescue
|
269
|
+
false
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'middleman-core/preview_server/server_ip_address'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class PreviewServer
|
5
|
+
# This holds information about local network interfaces on the user systemd
|
6
|
+
class NetworkInterfaceInventory
|
7
|
+
# Return all ip interfaces
|
8
|
+
class All
|
9
|
+
def network_interfaces
|
10
|
+
ipv4_addresses = Socket.ip_address_list.select(&:ipv4?).map { |ai| ServerIpv4Address.new(ai.ip_address) }
|
11
|
+
ipv6_addresses = Socket.ip_address_list.select(&:ipv6?).map { |ai| ServerIpv6Address.new(ai.ip_address) }
|
12
|
+
|
13
|
+
ipv4_addresses + ipv6_addresses
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.match?(*)
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return all ipv4 interfaces
|
22
|
+
class Ipv4
|
23
|
+
def network_interfaces
|
24
|
+
Socket.ip_address_list.select { |ai| ai.ipv4? && !ai.ipv4_loopback? }.map { |ai| ServerIpv4Address.new(ai.ip_address) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.match?(type)
|
28
|
+
:ipv4 == type
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return all ipv6 interfaces
|
33
|
+
class Ipv6
|
34
|
+
def network_interfaces
|
35
|
+
Socket.ip_address_list.select { |ai| ai.ipv6? && !ai.ipv6_loopback? }.map { |ai| ServerIpv6Address.new(ai.ip_address) }
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.match?(type)
|
39
|
+
:ipv6 == type
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
attr_reader :types
|
46
|
+
|
47
|
+
public
|
48
|
+
|
49
|
+
def initialize
|
50
|
+
@types = []
|
51
|
+
@types << Ipv4
|
52
|
+
@types << Ipv6
|
53
|
+
@types << All
|
54
|
+
end
|
55
|
+
|
56
|
+
# Return ip interfaces
|
57
|
+
#
|
58
|
+
# @param [Symbol] type
|
59
|
+
# The type of interface which should be returned
|
60
|
+
def network_interfaces(type=:all)
|
61
|
+
types.find { |t| t.match? type.to_sym }.new.network_interfaces
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PreviewServer
|
3
|
+
class ServerHostname
|
4
|
+
class ServerFullHostname < SimpleDelegator
|
5
|
+
def to_s
|
6
|
+
__getobj__.gsub(/\s/, '+')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.match?(*)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method :to_browser, :to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
class ServerPlainHostname < SimpleDelegator
|
17
|
+
def to_s
|
18
|
+
__getobj__.gsub(/\s/, '+') + '.local'
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.match?(name)
|
22
|
+
# rubocop:disable Style/CaseEquality
|
23
|
+
name != 'localhost' && /^(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?\.?$/ === name
|
24
|
+
# rubocop:enable Style/CaseEquality
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :to_browser, :to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.new(string)
|
31
|
+
@names = []
|
32
|
+
@names << ServerPlainHostname
|
33
|
+
@names << ServerFullHostname
|
34
|
+
|
35
|
+
@names.find { |n| n.match? string }.new(string)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|