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,153 @@
|
|
1
|
+
require 'middleman-core/dns_resolver'
|
2
|
+
require 'middleman-core/preview_server/information'
|
3
|
+
require 'middleman-core/preview_server/network_interface_inventory'
|
4
|
+
require 'middleman-core/preview_server/tcp_port_prober'
|
5
|
+
require 'middleman-core/preview_server/server_information_validator'
|
6
|
+
|
7
|
+
module Middleman
|
8
|
+
class PreviewServer
|
9
|
+
# This class holds all information which the preview server needs to setup a listener
|
10
|
+
#
|
11
|
+
# * server name
|
12
|
+
# * bind address
|
13
|
+
# * port
|
14
|
+
#
|
15
|
+
# Furthermore it probes for a free tcp port, if the default one 4567 is not available.
|
16
|
+
class ServerInformation
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :resolver, :validator, :network_interface_inventory, :informations, :tcp_port_prober
|
20
|
+
|
21
|
+
public
|
22
|
+
|
23
|
+
attr_writer :https
|
24
|
+
|
25
|
+
def initialize(opts={})
|
26
|
+
@resolver = opts.fetch(:resolver, DnsResolver.new)
|
27
|
+
@validator = opts.fetch(:validator, ServerInformationValidator.new)
|
28
|
+
@network_interface_inventory = opts.fetch(:network_interface_inventory, NetworkInterfaceInventory.new)
|
29
|
+
@tcp_port_prober = opts.fetch(:tcp_port_prober, TcpPortProber.new)
|
30
|
+
|
31
|
+
@informations = []
|
32
|
+
@informations << AllInterfaces
|
33
|
+
@informations << AllIpv4Interfaces
|
34
|
+
@informations << AllIpv6Interfaces
|
35
|
+
@informations << ServerNameIsIpInformation
|
36
|
+
@informations << ServerNameInformation
|
37
|
+
@informations << BindAddressInformation
|
38
|
+
@informations << BindAddressAndServerNameInformation
|
39
|
+
@informations << DefaultInformation
|
40
|
+
end
|
41
|
+
|
42
|
+
# The information
|
43
|
+
#
|
44
|
+
# Is cached
|
45
|
+
def information
|
46
|
+
return @information if @information
|
47
|
+
|
48
|
+
# The `DefaultInformation`-class always returns `true`, so there's
|
49
|
+
# always a klass available and find will never return nil
|
50
|
+
listener_klass = informations.find { |l| l.matches? bind_address: @bind_address, server_name: @server_name }
|
51
|
+
@information = listener_klass.new(bind_address: @bind_address, server_name: @server_name)
|
52
|
+
|
53
|
+
@information.show_me_network_interfaces(network_interface_inventory)
|
54
|
+
@information.resolve_me(resolver)
|
55
|
+
@information.port = tcp_port_prober.port(@port)
|
56
|
+
@information.validate_me(validator)
|
57
|
+
|
58
|
+
@information
|
59
|
+
end
|
60
|
+
|
61
|
+
# Use a middleman configuration to get information
|
62
|
+
#
|
63
|
+
# @param [#[]] config
|
64
|
+
# The middleman config
|
65
|
+
def use(config)
|
66
|
+
@bind_address = config[:bind_address]
|
67
|
+
@port = config[:port]
|
68
|
+
@server_name = config[:server_name]
|
69
|
+
@https = config[:https]
|
70
|
+
|
71
|
+
config[:bind_address] = bind_address
|
72
|
+
config[:port] = port
|
73
|
+
config[:server_name] = server_name
|
74
|
+
config[:https] = https?
|
75
|
+
end
|
76
|
+
|
77
|
+
# Make information of internal server class avaible to make debugging
|
78
|
+
# easier. This can be used to log the class which was used to determine
|
79
|
+
# the preview server settings
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
# The name of the class
|
83
|
+
def handler
|
84
|
+
information.class.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
# Is the server information valid?
|
88
|
+
#
|
89
|
+
# This is used to output a helpful error message, which can be stored in
|
90
|
+
# `#reason`.
|
91
|
+
#
|
92
|
+
# @return [TrueClass, FalseClass]
|
93
|
+
# The result
|
94
|
+
def valid?
|
95
|
+
information.valid?
|
96
|
+
end
|
97
|
+
|
98
|
+
# The reason why the information is NOT valid
|
99
|
+
#
|
100
|
+
# @return [String]
|
101
|
+
# The reason why the information is not valid
|
102
|
+
def reason
|
103
|
+
information.reason
|
104
|
+
end
|
105
|
+
|
106
|
+
# The server name
|
107
|
+
#
|
108
|
+
# @return [String]
|
109
|
+
# The name of the server
|
110
|
+
def server_name
|
111
|
+
information.server_name
|
112
|
+
end
|
113
|
+
|
114
|
+
# The bind address of server
|
115
|
+
#
|
116
|
+
# @return [String]
|
117
|
+
# The bind address of the server
|
118
|
+
def bind_address
|
119
|
+
information.bind_address
|
120
|
+
end
|
121
|
+
|
122
|
+
# The port on which the server should listen
|
123
|
+
#
|
124
|
+
# @return [Integer]
|
125
|
+
# The port number
|
126
|
+
def port
|
127
|
+
information.port
|
128
|
+
end
|
129
|
+
|
130
|
+
# A list of site addresses
|
131
|
+
#
|
132
|
+
# @return [Array]
|
133
|
+
# A list of addresses which can be used to access the middleman preview
|
134
|
+
# server
|
135
|
+
def site_addresses
|
136
|
+
information.site_addresses
|
137
|
+
end
|
138
|
+
|
139
|
+
# A list of listeners
|
140
|
+
#
|
141
|
+
# @return [Array]
|
142
|
+
# A list of bind address where the
|
143
|
+
def listeners
|
144
|
+
information.listeners
|
145
|
+
end
|
146
|
+
|
147
|
+
# Is https enabled?
|
148
|
+
def https?
|
149
|
+
@https == true
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PreviewServer
|
3
|
+
# This class wraps server information to be used in call back
|
4
|
+
#
|
5
|
+
# * listeners
|
6
|
+
# * port
|
7
|
+
# * server name
|
8
|
+
# * site_addresses
|
9
|
+
#
|
10
|
+
# All information is "dupped" and the callback is not meant to be used to
|
11
|
+
# modify these information.
|
12
|
+
class ServerInformationCallbackProxy
|
13
|
+
attr_reader :server_name, :port, :site_addresses, :listeners
|
14
|
+
|
15
|
+
def initialize(server_information)
|
16
|
+
@listeners = ServerUrl.new(
|
17
|
+
hosts: server_information.listeners,
|
18
|
+
port: server_information.port,
|
19
|
+
https: server_information.https?,
|
20
|
+
format_output: false
|
21
|
+
).to_bind_addresses
|
22
|
+
|
23
|
+
@port = server_information.port
|
24
|
+
@server_name = server_information.server_name.dup unless server_information.server_name.nil?
|
25
|
+
|
26
|
+
@site_addresses = ServerUrl.new(
|
27
|
+
hosts: server_information.site_addresses,
|
28
|
+
port: server_information.port,
|
29
|
+
https: server_information.https?,
|
30
|
+
format_output: false
|
31
|
+
).to_urls
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PreviewServer
|
3
|
+
# Validate user input
|
4
|
+
class ServerInformationValidator
|
5
|
+
# Validate the input
|
6
|
+
#
|
7
|
+
# @param [ServerInformation] information
|
8
|
+
# The information instance which holds information about the preview
|
9
|
+
# server settings
|
10
|
+
#
|
11
|
+
# @param [Array] checks
|
12
|
+
# A list of checks which should be evaluated
|
13
|
+
def validate(information, checks)
|
14
|
+
checks.each { |c| c.validate information }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
class PreviewServer
|
6
|
+
class ServerIpAddress
|
7
|
+
def self.new(ip_address)
|
8
|
+
@parser = []
|
9
|
+
@parser << ServerIpv6Address
|
10
|
+
@parser << ServerIpv4Address
|
11
|
+
|
12
|
+
@parser.find { |p| p.match? ip_address }.new(ip_address)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class BasicServerIpAddress < SimpleDelegator
|
17
|
+
end
|
18
|
+
|
19
|
+
class ServerIpv4Address < BasicServerIpAddress
|
20
|
+
def to_browser
|
21
|
+
__getobj__.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.match?(*)
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class ServerIpv6Address < BasicServerIpAddress
|
30
|
+
def to_s
|
31
|
+
__getobj__.sub(/%.*$/, '')
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_browser
|
35
|
+
format('[%s]', to_s)
|
36
|
+
end
|
37
|
+
|
38
|
+
if RUBY_VERSION < '2'
|
39
|
+
def self.match?(str)
|
40
|
+
str = str.to_s.sub(/%.*$/, '')
|
41
|
+
IPAddr.new(str).ipv6?
|
42
|
+
rescue StandardError
|
43
|
+
false
|
44
|
+
end
|
45
|
+
else
|
46
|
+
def self.match?(str)
|
47
|
+
str = str.to_s.sub(/%.*$/, '')
|
48
|
+
IPAddr.new(str).ipv6?
|
49
|
+
rescue IPAddr::InvalidAddressError, IPAddr::AddressFamilyError
|
50
|
+
false
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class PreviewServer
|
5
|
+
# This builds the server urls for the preview server
|
6
|
+
class ServerUrl
|
7
|
+
private
|
8
|
+
|
9
|
+
attr_reader :hosts, :port, :https, :format_output
|
10
|
+
|
11
|
+
public
|
12
|
+
|
13
|
+
def initialize(opts={})
|
14
|
+
@hosts = opts.fetch(:hosts)
|
15
|
+
@port = opts.fetch(:port)
|
16
|
+
@https = opts.fetch(:https, false)
|
17
|
+
@format_output = opts.fetch(:format_output, true)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Return bind addresses
|
21
|
+
#
|
22
|
+
# @return [Array]
|
23
|
+
# List of bind addresses of format host:port
|
24
|
+
def to_bind_addresses
|
25
|
+
if format_output
|
26
|
+
hosts.map { |l| format('"%s:%s"', l.to_s, port) }
|
27
|
+
else
|
28
|
+
hosts.map { |l| format('%s:%s', l.to_s, port) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Return server urls
|
33
|
+
#
|
34
|
+
# @return [Array]
|
35
|
+
# List of urls of format http://host:port
|
36
|
+
def to_urls
|
37
|
+
if format_output
|
38
|
+
hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) }
|
39
|
+
else
|
40
|
+
hosts.map { |l| format('%s://%s:%s', https? ? 'https' : 'http', l.to_browser, port) }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Return server config urls
|
45
|
+
#
|
46
|
+
# @return [Array]
|
47
|
+
# List of urls of format http://host:port/__middleman
|
48
|
+
def to_config_urls
|
49
|
+
if format_output
|
50
|
+
hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) }
|
51
|
+
else
|
52
|
+
hosts.map { |l| format('%s://%s:%s/__middleman', https? ? 'https' : 'http', l.to_browser, port) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def https?
|
59
|
+
https == true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Middleman
|
2
|
+
class PreviewServer
|
3
|
+
# Probe for tcp ports
|
4
|
+
#
|
5
|
+
# This one first tries `try_port` if this is not available use the free
|
6
|
+
# port returned by TCPServer.
|
7
|
+
class TcpPortProber
|
8
|
+
# Check for port
|
9
|
+
#
|
10
|
+
# @param [Integer] try_port
|
11
|
+
# The port to be checked
|
12
|
+
#
|
13
|
+
# @return [Integer]
|
14
|
+
# The port
|
15
|
+
def port(try_port)
|
16
|
+
server = TCPServer.open(try_port)
|
17
|
+
server.close
|
18
|
+
|
19
|
+
try_port
|
20
|
+
rescue
|
21
|
+
server = TCPServer.open(0)
|
22
|
+
port = server.addr[1]
|
23
|
+
server.close
|
24
|
+
|
25
|
+
port
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/middleman-core/rack.rb
CHANGED
@@ -14,6 +14,12 @@ require 'middleman-core/template_renderer'
|
|
14
14
|
::Rack::Mime::MIME_TYPES['.html'] = 'text/html; charset=utf-8'
|
15
15
|
::Rack::Mime::MIME_TYPES['.htm'] = 'text/html; charset=utf-8'
|
16
16
|
|
17
|
+
# Sourcemap format
|
18
|
+
::Rack::Mime::MIME_TYPES['.map'] = 'application/json; charset=utf-8'
|
19
|
+
|
20
|
+
# Create a MIME type for PHP files (for detection by extensions)
|
21
|
+
::Rack::Mime::MIME_TYPES['.php'] = 'text/php'
|
22
|
+
|
17
23
|
module Middleman
|
18
24
|
class Rack
|
19
25
|
extend Forwardable
|
@@ -102,7 +108,7 @@ module Middleman
|
|
102
108
|
|
103
109
|
begin
|
104
110
|
# Write out the contents of the page
|
105
|
-
res.write resource.render({},
|
111
|
+
res.write resource.render({}, rack: { request: req })
|
106
112
|
|
107
113
|
# Valid content is a 200 status
|
108
114
|
res.status = 200
|
@@ -40,7 +40,6 @@ module Middleman
|
|
40
40
|
|
41
41
|
# Haml Renderer
|
42
42
|
class Haml < ::Middleman::Extension
|
43
|
-
|
44
43
|
def initialize(app, options={}, &block)
|
45
44
|
super
|
46
45
|
|
@@ -53,7 +52,7 @@ module Middleman
|
|
53
52
|
modified_options = options.dup
|
54
53
|
modified_options[:context] = compiler_options[:context]
|
55
54
|
|
56
|
-
text = template_class.new(nil, 1, modified_options) {text}.render
|
55
|
+
text = template_class.new(nil, 1, modified_options) { text }.render
|
57
56
|
super(text, compiler_options)
|
58
57
|
end
|
59
58
|
end
|
@@ -24,7 +24,7 @@ module Middleman
|
|
24
24
|
|
25
25
|
resources.each do |resource|
|
26
26
|
next if resource.file_descriptor.nil?
|
27
|
-
next unless resource.file_descriptor[:
|
27
|
+
next unless resource.file_descriptor[:full_path].to_s =~ %r{\.liquid$}
|
28
28
|
|
29
29
|
# Convert data object into a hash for liquid
|
30
30
|
resource.add_metadata locals: {
|
@@ -1,34 +1,4 @@
|
|
1
1
|
require 'sass'
|
2
|
-
require 'compass/import-once'
|
3
|
-
|
4
|
-
GLOB = /\*|\[.+\]/
|
5
|
-
|
6
|
-
# Hack around broken sass globs when combined with import-once
|
7
|
-
# Targets compass-import-once 1.0.4
|
8
|
-
# Tracking issue: https://github.com/chriseppstein/compass/issues/1529
|
9
|
-
module Compass
|
10
|
-
module ImportOnce
|
11
|
-
module Importer
|
12
|
-
def find_relative(uri, base, options, *args)
|
13
|
-
if uri =~ GLOB
|
14
|
-
force_import = true
|
15
|
-
else
|
16
|
-
uri, force_import = handle_force_import(uri)
|
17
|
-
end
|
18
|
-
maybe_replace_with_dummy_engine(super(uri, base, options, *args), options, force_import)
|
19
|
-
end
|
20
|
-
|
21
|
-
def find(uri, options, *args)
|
22
|
-
if uri =~ GLOB
|
23
|
-
force_import = true
|
24
|
-
else
|
25
|
-
uri, force_import = handle_force_import(uri)
|
26
|
-
end
|
27
|
-
maybe_replace_with_dummy_engine(super(uri, options, *args), options, force_import)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
2
|
|
33
3
|
module Middleman
|
34
4
|
module Renderers
|
@@ -38,6 +8,8 @@ module Middleman
|
|
38
8
|
def initialize(app, options={}, &block)
|
39
9
|
super
|
40
10
|
|
11
|
+
logger.info "== Preferring use of LibSass" if defined?(::SassC)
|
12
|
+
|
41
13
|
app.files.ignore :sass_cache, :source, /(^|\/)\.sass-cache\//
|
42
14
|
|
43
15
|
opts = { output_style: :nested }
|
@@ -47,6 +19,7 @@ module Middleman
|
|
47
19
|
app.config.define_setting :sass, opts, 'Sass engine options'
|
48
20
|
|
49
21
|
app.config.define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files'
|
22
|
+
app.config.define_setting :sass_source_maps, app.development?, 'Whether to inline sourcemap into Sass'
|
50
23
|
|
51
24
|
# Tell Tilt to use it as well (for inline sass blocks)
|
52
25
|
::Tilt.register 'sass', SassPlusCSSFilenameTemplate
|
@@ -56,8 +29,6 @@ module Middleman
|
|
56
29
|
::Tilt.register 'scss', ScssPlusCSSFilenameTemplate
|
57
30
|
::Tilt.prefer(ScssPlusCSSFilenameTemplate)
|
58
31
|
|
59
|
-
::Compass::ImportOnce.activate!
|
60
|
-
|
61
32
|
require 'middleman-core/renderers/sass_functions'
|
62
33
|
end
|
63
34
|
|
@@ -82,11 +53,18 @@ module Middleman
|
|
82
53
|
# @return [String]
|
83
54
|
def evaluate(context, _)
|
84
55
|
@context ||= context
|
85
|
-
|
56
|
+
|
57
|
+
sass_module = if defined?(::SassC)
|
58
|
+
::SassC
|
59
|
+
else
|
60
|
+
::Sass
|
61
|
+
end
|
62
|
+
|
63
|
+
@engine = sass_module::Engine.new(data, sass_options)
|
86
64
|
|
87
65
|
begin
|
88
66
|
@engine.render
|
89
|
-
rescue ::
|
67
|
+
rescue sass_module::SyntaxError => e
|
90
68
|
::Sass::SyntaxError.exception_to_css(e)
|
91
69
|
end
|
92
70
|
end
|
@@ -97,13 +75,22 @@ module Middleman
|
|
97
75
|
ctx = @context
|
98
76
|
|
99
77
|
more_opts = {
|
100
|
-
load_paths: ctx.config[:sass_assets_paths],
|
78
|
+
load_paths: ::Sass.load_paths | ctx.config[:sass_assets_paths],
|
101
79
|
filename: eval_file,
|
102
80
|
line: line,
|
103
81
|
syntax: syntax,
|
104
|
-
custom: (options[:custom] || {}).merge(
|
82
|
+
custom: (options[:custom] || {}).merge(
|
83
|
+
middleman_context: ctx.app,
|
84
|
+
current_resource: ctx.current_resource
|
85
|
+
)
|
105
86
|
}
|
106
87
|
|
88
|
+
if ctx.config[:sass_source_maps]
|
89
|
+
more_opts[:source_map_file] = '.'
|
90
|
+
more_opts[:source_map_embed] = true
|
91
|
+
more_opts[:source_map_contents] = true
|
92
|
+
end
|
93
|
+
|
107
94
|
if ctx.is_a?(::Middleman::TemplateContext) && file
|
108
95
|
more_opts[:css_filename] = file.sub(/\.s[ac]ss$/, '')
|
109
96
|
end
|