middleman-core 3.4.1 → 4.0.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{fixtures/asciidoc-app/config.rb → .gemtest} +0 -0
- data/.yardopts +2 -6
- data/Rakefile +5 -1
- data/features/asset_hash.feature +32 -61
- data/features/asset_host.feature +11 -23
- data/features/builder.feature +2 -0
- data/features/cache_buster.feature +1 -1
- data/features/chained_templates.feature +2 -92
- data/features/clean_build.feature +0 -18
- data/features/cli_init.feature +17 -111
- data/features/content_type.feature +2 -5
- data/features/custom_layouts.feature +24 -20
- data/features/data.feature +0 -28
- data/features/directory_index.feature +9 -9
- data/features/front-matter-neighbor.feature +0 -32
- data/features/front-matter.feature +0 -17
- data/features/helpers_content_tag.feature +2 -2
- data/features/helpers_form_tag.feature +4 -4
- data/features/helpers_link_to.feature +11 -29
- data/features/helpers_url_for.feature +11 -11
- data/features/i18n_builder.feature +5 -5
- data/features/i18n_preview.feature +8 -8
- data/features/markdown_kramdown.feature +1 -1
- data/features/markdown_kramdown_in_haml.feature +1 -2
- data/features/markdown_redcarpet.feature +23 -23
- data/features/minify_css.feature +9 -75
- data/features/minify_javascript.feature +12 -65
- data/features/mount_rack.feature +2 -4
- data/features/multiple-sources.feature +27 -0
- data/features/proxy_pages.feature +0 -10
- data/features/redirects.feature +6 -7
- data/features/relative_assets.feature +21 -66
- data/features/slim.feature +11 -7
- data/features/stylus.feature +1 -1
- data/features/support/env.rb +4 -4
- data/fixtures/asset-hash-app/config.rb +0 -2
- data/fixtures/asset-hash-app/source/index.html.erb +1 -1
- data/fixtures/asset-hash-host-app/config.rb +1 -3
- data/fixtures/asset-host-app/source/asset_host.html.erb +20 -1
- data/fixtures/asset-host-app/source/stylesheets/asset_host.css.sass +47 -2
- data/fixtures/auto-css-app/config.rb +8 -10
- data/fixtures/auto-js-app/config.rb +8 -10
- data/fixtures/basic-data-app/config.rb +2 -4
- data/fixtures/cache-buster-app/source/stylesheets/relative_assets.css.sass +0 -1
- data/fixtures/cache-buster-app/source/stylesheets/site.css.sass +3 -1
- data/fixtures/capture-html-app/config.rb +3 -5
- data/fixtures/clean-app/config-complications.rb +4 -6
- data/fixtures/clean-app/config.rb +4 -6
- data/fixtures/content-for-app/config.rb +3 -5
- data/fixtures/custom-layout-app/config.rb +1 -1
- data/fixtures/data-app/config.rb +1 -1
- data/fixtures/dynamic-pages-app/config.rb +20 -42
- data/fixtures/dynamic-pages-app/source/real/index.html.erb +3 -3
- data/fixtures/ember-cli-app/config.rb +5 -0
- data/fixtures/{compass-sprites-app/config.rb → ember-cli-app/source/javascripts/file.js} +0 -0
- data/fixtures/ember-cli-app/test-app/.bowerrc +3 -0
- data/fixtures/ember-cli-app/test-app/.gitignore +17 -0
- data/fixtures/ember-cli-app/test-app/.jshintrc +32 -0
- data/fixtures/ember-cli-app/test-app/Brocfile.js +20 -0
- data/fixtures/ember-cli-app/test-app/README.md +25 -0
- data/fixtures/ember-cli-app/test-app/app/app.js +14 -0
- data/fixtures/{implied-extensions-app/config.rb → ember-cli-app/test-app/app/components/.gitkeep} +0 -0
- data/fixtures/{javascript-app/config.rb → ember-cli-app/test-app/app/controllers/.gitkeep} +0 -0
- data/fixtures/{more-implied-extensions-app/config.rb → ember-cli-app/test-app/app/helpers/.gitkeep} +0 -0
- data/fixtures/ember-cli-app/test-app/app/index.html +26 -0
- data/fixtures/{partial-chained_templates-app/config.rb → ember-cli-app/test-app/app/models/.gitkeep} +0 -0
- data/fixtures/ember-cli-app/test-app/app/router.js +10 -0
- data/fixtures/{preview-server-app/config-empty.rb → ember-cli-app/test-app/app/routes/.gitkeep} +0 -0
- data/fixtures/{request-app/config.rb → ember-cli-app/test-app/app/styles/.gitkeep} +0 -0
- data/fixtures/ember-cli-app/test-app/app/styles/app.css +3 -0
- data/fixtures/{traversal-app/source/.htaccess → ember-cli-app/test-app/app/templates/.gitkeep} +0 -0
- data/fixtures/ember-cli-app/test-app/app/templates/application.hbs +3 -0
- data/{lib/middleman-core/templates/html5/source/img/.gitignore → fixtures/ember-cli-app/test-app/app/templates/components/.gitkeep} +0 -0
- data/{lib/middleman-core/templates/mobile/source/js/script.js → fixtures/ember-cli-app/test-app/app/views/.gitkeep} +0 -0
- data/fixtures/ember-cli-app/test-app/bower.json +16 -0
- data/fixtures/ember-cli-app/test-app/config/environment.js +38 -0
- data/fixtures/ember-cli-app/test-app/package.json +31 -0
- data/fixtures/ember-cli-app/test-app/public/.gitkeep +0 -0
- data/fixtures/ember-cli-app/test-app/testem.json +6 -0
- data/fixtures/ember-cli-app/test-app/tests/.jshintrc +73 -0
- data/fixtures/ember-cli-app/test-app/tests/helpers/resolver.js +9 -0
- data/fixtures/ember-cli-app/test-app/tests/helpers/start-app.js +30 -0
- data/fixtures/ember-cli-app/test-app/tests/index.html +50 -0
- data/fixtures/ember-cli-app/test-app/tests/test-helper.js +6 -0
- data/fixtures/ember-cli-app/test-app/tests/unit/.gitkeep +0 -0
- data/fixtures/env-app/config.rb +0 -0
- data/fixtures/env-app/environments/development.rb +1 -0
- data/fixtures/env-app/environments/production.rb +2 -0
- data/fixtures/env-app/source/index.html.erb +3 -0
- data/fixtures/env-app/source/stylesheets/site.css.scss +3 -0
- data/fixtures/external-helpers/config.rb +1 -1
- data/fixtures/feature-params-app/config.rb +10 -6
- data/fixtures/feature-params-app/source/index.html.erb +2 -3
- data/fixtures/fonts-app/source/stylesheets/fonts.css.scss +6 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +30 -0
- data/fixtures/frontmatter-settings-app/config.rb +2 -2
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +33 -3
- data/fixtures/generator-test/config.rb +5 -10
- data/fixtures/glob-app/config.rb +1 -1
- data/fixtures/i18n-force-locale/config.rb +2 -4
- data/fixtures/i18n-force-locale/source/{index.haml → index.html.haml} +0 -0
- data/fixtures/i18n-test-app/source/localizable/{one.en.md → one.en.html.md} +0 -0
- data/fixtures/i18n-test-app/source/localizable/{one.es.md → one.es.html.md} +0 -0
- data/fixtures/indexable-app/config.rb +2 -2
- data/fixtures/indexable-app/source/evil spaces.html +1 -1
- data/fixtures/large-build-app/config.rb +1 -5
- data/fixtures/large-build-app/source/spaces in file.html.erb +1 -1
- data/fixtures/manual-layout-override/config.rb +1 -1
- data/fixtures/markdown-app/config.rb +1 -1
- data/fixtures/markdown-frontmatter-options-app/config.rb +1 -1
- data/fixtures/minify-css-app/source/stylesheets/site.css.sass +3 -1
- data/fixtures/more-frontmatter-settings-app/config.rb +1 -1
- data/fixtures/more-markdown-app/source/{with_layout.markdown → with_layout.html.markdown} +0 -0
- data/fixtures/more-markdown-app/source/{with_layout_erb.markdown.erb → with_layout_erb.html.markdown.erb} +0 -0
- data/fixtures/more-traversal-app/config.rb +4 -4
- data/fixtures/more-traversal-app/source/layout.erb +1 -1
- data/fixtures/multiple-data-sources-app/config.rb +3 -0
- data/fixtures/multiple-data-sources-app/data/data.yml +1 -0
- data/fixtures/multiple-data-sources-app/data/two.yml +1 -0
- data/fixtures/multiple-data-sources-app/data0/one.yml +1 -0
- data/fixtures/multiple-data-sources-app/data1/data1.yml +1 -0
- data/fixtures/multiple-data-sources-app/data1/one.yml +1 -0
- data/fixtures/multiple-data-sources-app/data2/data2.yml +1 -0
- data/fixtures/multiple-data-sources-app/data2/two.yml +1 -0
- data/fixtures/multiple-data-sources-app/source/index.html.erb +10 -0
- data/fixtures/multiple-sources-app/config.rb +3 -0
- data/fixtures/multiple-sources-app/source/index.html.erb +1 -0
- data/fixtures/multiple-sources-app/source/override-in-two.html.erb +1 -0
- data/fixtures/multiple-sources-app/source0/override-in-one.html.erb +1 -0
- data/fixtures/multiple-sources-app/source1/index1.html.erb +1 -0
- data/fixtures/multiple-sources-app/source1/override-in-one.html.erb +1 -0
- data/fixtures/multiple-sources-app/source2/index2.html.erb +1 -0
- data/fixtures/multiple-sources-app/source2/override-in-two.html.erb +1 -0
- data/fixtures/padrino-helpers-app/source/former_padrino_test.html.erb +3 -3
- data/fixtures/page-classes-app/config.rb +2 -4
- data/fixtures/page-classes-app/source/2-starts-with-numeric-custom.html.erb +1 -1
- data/fixtures/page-helper-layout-block-app/config.rb +1 -1
- data/fixtures/partials-app/source/locals.html.erb +1 -1
- data/fixtures/partials-app/source/shared/{snippet.erb → _snippet.html.erb} +0 -0
- data/fixtures/partials-app/source/sub/index.html.erb +1 -1
- data/fixtures/passthrough-app/source/stylesheets/site.css.sass +5 -1
- data/fixtures/proxy-pages-app/config.rb +12 -15
- data/fixtures/relative-app/source/stylesheets/relative_assets.css.sass +1 -2
- data/fixtures/relative-assets-app/source/javascripts/application.js +8 -0
- data/fixtures/relative-assets-app/source/relative_image.html.erb +0 -1
- data/fixtures/relative-assets-app/source/stylesheets/relative_assets.css.sass +1 -2
- data/fixtures/scss-app/source/stylesheets/site_scss.css.scss +3 -1
- data/fixtures/stylus-preview-app/source/content.html.erb +4 -0
- data/fixtures/traversal-app/config.rb +4 -4
- data/fixtures/traversal-app/source/layout.erb +1 -1
- data/fixtures/v4-extension-callbacks/config.rb +21 -5
- data/fixtures/wildcard-app/config.rb +1 -1
- data/fixtures/wildcard-directory-index-app/config.rb +1 -1
- data/lib/middleman-core.rb +5 -2
- data/lib/middleman-core/application.rb +212 -131
- data/lib/middleman-core/builder.rb +255 -0
- data/lib/middleman-core/config_context.rb +103 -0
- data/lib/middleman-core/configuration.rb +15 -92
- data/lib/middleman-core/contracts.rb +149 -0
- data/lib/middleman-core/core_extensions.rb +86 -45
- data/lib/middleman-core/core_extensions/data.rb +82 -72
- data/lib/{middleman-more → middleman-core}/core_extensions/default_helpers.rb +34 -140
- data/lib/middleman-core/core_extensions/external_helpers.rb +23 -27
- data/lib/middleman-core/core_extensions/file_watcher.rb +59 -169
- data/lib/middleman-core/core_extensions/front_matter.rb +72 -131
- data/lib/middleman-core/core_extensions/i18n.rb +186 -0
- data/lib/middleman-core/core_extensions/rendering.rb +45 -533
- data/lib/middleman-core/core_extensions/routing.rb +53 -51
- data/lib/middleman-core/core_extensions/show_exceptions.rb +11 -18
- data/lib/middleman-core/extension.rb +183 -56
- data/lib/middleman-core/extension_manager.rb +80 -0
- data/lib/middleman-core/extensions.rb +96 -67
- data/lib/middleman-core/extensions/asset_hash.rb +92 -0
- data/lib/middleman-core/extensions/asset_host.rb +37 -0
- data/lib/{middleman-more → middleman-core}/extensions/automatic_alt_tags.rb +6 -5
- data/lib/{middleman-more → middleman-core}/extensions/automatic_image_sizes.rb +9 -13
- data/lib/middleman-core/extensions/cache_buster.rb +27 -0
- data/lib/{middleman-more → middleman-core}/extensions/directory_indexes.rb +9 -7
- data/lib/middleman-core/extensions/external_pipeline.rb +37 -0
- data/lib/{middleman-more → middleman-core}/extensions/gzip.rb +10 -3
- data/lib/{middleman-more → middleman-core}/extensions/lorem.rb +2 -2
- data/lib/middleman-core/extensions/minify_css.rb +86 -0
- data/lib/middleman-core/extensions/minify_javascript.rb +93 -0
- data/lib/middleman-core/extensions/relative_assets.rb +38 -0
- data/lib/middleman-core/file_renderer.rb +139 -0
- data/lib/middleman-core/load_paths.rb +21 -28
- data/lib/middleman-core/meta_pages.rb +9 -9
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +3 -6
- data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
- data/lib/middleman-core/middleware/inline_url_rewriter.rb +96 -0
- data/lib/middleman-core/preview_server.rb +65 -196
- data/lib/middleman-core/profiling.rb +14 -15
- data/lib/middleman-core/rack.rb +138 -0
- data/lib/middleman-core/renderers/coffee_script.rb +10 -13
- data/lib/middleman-core/renderers/erb.rb +3 -15
- data/lib/middleman-core/renderers/haml.rb +33 -18
- data/lib/middleman-core/renderers/kramdown.rb +6 -4
- data/lib/middleman-core/renderers/less.rb +12 -18
- data/lib/middleman-core/renderers/liquid.rb +22 -18
- data/lib/middleman-core/renderers/markdown.rb +36 -49
- data/lib/middleman-core/renderers/redcarpet.rb +11 -4
- data/lib/middleman-core/renderers/sass.rb +36 -27
- data/lib/middleman-core/renderers/sass_functions.rb +116 -0
- data/lib/middleman-core/renderers/slim.rb +19 -26
- data/lib/middleman-core/renderers/stylus.rb +4 -14
- data/lib/middleman-core/sitemap/extensions/ignores.rb +35 -73
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +29 -48
- data/lib/middleman-core/sitemap/extensions/proxies.rb +111 -133
- data/lib/middleman-core/sitemap/extensions/redirects.rb +68 -102
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +59 -83
- data/lib/middleman-core/sitemap/extensions/traversal.rb +14 -15
- data/lib/middleman-core/sitemap/resource.rb +99 -71
- data/lib/middleman-core/sitemap/store.rb +79 -132
- data/lib/middleman-core/sources.rb +310 -0
- data/lib/middleman-core/sources/source_watcher.rb +268 -0
- data/lib/middleman-core/step_definitions.rb +2 -3
- data/lib/middleman-core/step_definitions/builder_steps.rb +15 -13
- data/lib/middleman-core/step_definitions/middleman_steps.rb +2 -18
- data/lib/middleman-core/step_definitions/server_steps.rb +43 -77
- data/lib/middleman-core/template_context.rb +181 -0
- data/lib/middleman-core/template_renderer.rb +213 -0
- data/lib/middleman-core/util.rb +319 -241
- data/lib/middleman-core/util/hash_with_indifferent_access.rb +103 -0
- data/lib/middleman-core/version.rb +1 -1
- data/lib/middleman/rack.rb +0 -1
- data/middleman-core.gemspec +36 -28
- data/spec/middleman-core/path_match_spec.rb +37 -0
- data/spec/spec_helper.rb +2 -25
- metadata +237 -454
- data/bin/middleman +0 -18
- data/cucumber.yml +0 -2
- data/features/asciidoc.feature +0 -155
- data/features/cli/preview_server-hook.feature +0 -17
- data/features/cli/preview_server.feature +0 -532
- data/features/compass-sprites.feature +0 -6
- data/features/console.feature +0 -10
- data/features/current_page_request_path_backwards.feature +0 -6
- data/features/fonts.feature +0 -15
- data/features/i18n_link_to.feature +0 -209
- data/features/image_srcset_paths.feature +0 -7
- data/features/implied_extensions.feature +0 -69
- data/features/instance_vars.feature +0 -9
- data/features/javascript-testing.feature +0 -18
- data/features/more-implied_extensions.feature +0 -44
- data/features/partials_dir.feature +0 -30
- data/features/queryable.feature +0 -35
- data/features/request_params.feature +0 -6
- data/features/static_server.feature +0 -6
- data/features/step_definitions/page_layout_steps.rb +0 -15
- data/features/step_definitions/queryable_steps.rb +0 -212
- data/features/support/preserve_mime_types.rb +0 -7
- data/features/v3_extensions.feature +0 -20
- data/features/working_directory.feature +0 -33
- data/fixtures/asciidoc-app/source/_include.adoc +0 -1
- data/fixtures/asciidoc-app/source/code.adoc +0 -3
- data/fixtures/asciidoc-app/source/custom-attribute.adoc +0 -3
- data/fixtures/asciidoc-app/source/gallery.adoc +0 -1
- data/fixtures/asciidoc-app/source/hello-no-layout.adoc +0 -2
- data/fixtures/asciidoc-app/source/hello-with-front-matter.adoc +0 -5
- data/fixtures/asciidoc-app/source/hello-with-layout.adoc +0 -2
- data/fixtures/asciidoc-app/source/hello-with-title.adoc +0 -5
- data/fixtures/asciidoc-app/source/hello.adoc +0 -4
- data/fixtures/asciidoc-app/source/images/tiger.gif +0 -0
- data/fixtures/asciidoc-app/source/layouts/default.erb +0 -9
- data/fixtures/asciidoc-app/source/master.adoc +0 -3
- data/fixtures/asset-hash-app/source/api.json.erb +0 -1
- 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/images/200px.jpg +0 -0
- data/fixtures/asset-hash-app/source/images/300px.jpg +0 -0
- data/fixtures/asset-hash-app/source/slim.html.slim +0 -8
- data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +0 -4
- data/fixtures/asset-hash-app/source/subdir/api.json.erb +0 -1
- data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +0 -8
- data/fixtures/clean-app/config-hidden-dir-after.rb +0 -5
- data/fixtures/clean-app/config-hidden-dir-before.rb +0 -1
- data/fixtures/compass-sprites-app/source/images/icon/arrow_down.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_left.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_right.png +0 -0
- data/fixtures/compass-sprites-app/source/images/icon/arrow_up.png +0 -0
- data/fixtures/compass-sprites-app/source/stylesheets/site.css.scss +0 -3
- data/fixtures/content-type-app/source/index.php +0 -1
- data/fixtures/current-page-app/config.rb +0 -3
- data/fixtures/current-page-app/source/request-path.html.erb +0 -1
- data/fixtures/default-partials-dir-app/source/_partial.html.erb +0 -1
- data/fixtures/default-partials-dir-app/source/index.html.erb +0 -2
- data/fixtures/fonts-app/source/stylesheets/fonts.css.sass +0 -5
- data/fixtures/frontmatter-app/source/front-matter-auto.erb +0 -6
- data/fixtures/frontmatter-app/source/front-matter-pandoc.html.md.erb +0 -13
- data/fixtures/frontmatter-app/source/json-front-matter-auto.erb +0 -6
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb +0 -1
- data/fixtures/frontmatter-neighbor-app/source/front-matter-auto.erb.frontmatter +0 -4
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb +0 -1
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-auto.erb.frontmatter +0 -4
- data/fixtures/image-srcset-paths-app/image-srcset-paths.html.erb +0 -1
- data/fixtures/image-srcset-paths-app/images/blank.gif +0 -0
- data/fixtures/implied-extensions-app/source/index.erb +0 -1
- data/fixtures/instance-vars-app/config.rb +0 -7
- data/fixtures/instance-vars-app/source/content.html.erb +0 -2
- data/fixtures/instance-vars-app/source/layout.erb +0 -1
- data/fixtures/javascript-app/source/index.html +0 -17
- data/fixtures/minify-css-app/source/inline-css.php +0 -8
- data/fixtures/minify-css-app/source/stylesheets/site.xcss.sass +0 -5
- data/fixtures/minify-js-app/source/inline-js.php +0 -22
- data/fixtures/minify-js-app/source/javascripts/js_test.xjs +0 -8
- data/fixtures/more-implied-extensions-app/source/javascripts/app.coffee +0 -1
- data/fixtures/more-implied-extensions-app/source/layouts/layout.erb +0 -3
- data/fixtures/more-implied-extensions-app/source/stylesheets/style.scss +0 -3
- data/fixtures/more-implied-extensions-app/source/stylesheets/style2.sass +0 -3
- data/fixtures/more-implied-extensions-app/source/test.haml +0 -4
- data/fixtures/more-implied-extensions-app/source/test2.markdown +0 -3
- data/fixtures/more-implied-extensions-app/source/test3.slim +0 -3
- data/fixtures/more-implied-extensions-app/source/test4.liquid +0 -1
- data/fixtures/partials-dir-app/source/index.html.erb +0 -2
- data/fixtures/partials-dir-app/source/nested/partials/_partial.html.erb +0 -1
- data/fixtures/partials-dir-app/source/partials/_partial.html.erb +0 -1
- data/fixtures/plain-app/index.html +0 -1
- data/fixtures/preview-server-app/bin/dns_server.rb +0 -33
- data/fixtures/preview-server-app/config-complications.rb +0 -11
- data/fixtures/preview-server-app/config.rb +0 -11
- data/fixtures/preview-server-app/source/index.html.erb +0 -1
- data/fixtures/preview-server-app/source/layout.erb +0 -9
- data/fixtures/preview-server-app/source/layouts/custom.erb +0 -8
- data/fixtures/preview-server-app/source/real.html +0 -1
- data/fixtures/preview-server-app/source/real/index.html.erb +0 -5
- data/fixtures/preview-server-app/source/should_be_ignored.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored2.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored3.html +0 -1
- data/fixtures/preview-server-app/source/static.html +0 -1
- data/fixtures/preview-server-hook-app/config.rb +0 -19
- data/fixtures/preview-server-hook-app/source/index.html.erb +0 -9
- data/fixtures/proxy-pages-app/source/real/index-ivars.html.erb +0 -6
- data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +0 -9
- data/fixtures/relative-assets-app/source/javascripts/app.js +0 -3
- data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +0 -9
- data/fixtures/request-app/source/index.html.erb +0 -3
- data/fixtures/stylus-preview-app/source/layout.erb +0 -1
- data/lib/middleman-core/cli.rb +0 -88
- data/lib/middleman-core/cli/build.rb +0 -300
- data/lib/middleman-core/cli/bundler.rb +0 -39
- data/lib/middleman-core/cli/console.rb +0 -52
- data/lib/middleman-core/cli/extension.rb +0 -47
- data/lib/middleman-core/cli/init.rb +0 -71
- data/lib/middleman-core/cli/server.rb +0 -99
- data/lib/middleman-core/core_extensions/data/file_loader.rb +0 -71
- data/lib/middleman-core/core_extensions/extensions.rb +0 -197
- data/lib/middleman-core/core_extensions/request.rb +0 -312
- data/lib/middleman-core/dns_resolver.rb +0 -73
- data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +0 -52
- data/lib/middleman-core/dns_resolver/hosts_resolver.rb +0 -63
- data/lib/middleman-core/dns_resolver/local_link_resolver.rb +0 -44
- data/lib/middleman-core/dns_resolver/network_resolver.rb +0 -42
- data/lib/middleman-core/preview_server/checks.rb +0 -81
- data/lib/middleman-core/preview_server/information.rb +0 -273
- data/lib/middleman-core/preview_server/network_interface_inventory.rb +0 -65
- data/lib/middleman-core/preview_server/server_hostname.rb +0 -39
- data/lib/middleman-core/preview_server/server_information.rb +0 -153
- data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +0 -35
- data/lib/middleman-core/preview_server/server_information_validator.rb +0 -18
- data/lib/middleman-core/preview_server/server_ip_address.rb +0 -55
- data/lib/middleman-core/preview_server/server_url.rb +0 -63
- data/lib/middleman-core/preview_server/tcp_port_prober.rb +0 -29
- data/lib/middleman-core/renderers/asciidoc.rb +0 -58
- data/lib/middleman-core/sitemap.rb +0 -76
- data/lib/middleman-core/sitemap/extensions/content_type.rb +0 -16
- data/lib/middleman-core/sitemap/queryable.rb +0 -151
- data/lib/middleman-core/step_definitions/commandline_steps.rb +0 -88
- data/lib/middleman-core/templates.rb +0 -101
- data/lib/middleman-core/templates/default.rb +0 -37
- data/lib/middleman-core/templates/default/source/images/background.png +0 -0
- data/lib/middleman-core/templates/default/source/images/middleman.png +0 -0
- data/lib/middleman-core/templates/default/source/index.html.erb +0 -10
- data/lib/middleman-core/templates/default/source/javascripts/all.js +0 -1
- data/lib/middleman-core/templates/default/source/layouts/layout.erb +0 -19
- data/lib/middleman-core/templates/default/source/stylesheets/all.css +0 -55
- data/lib/middleman-core/templates/default/source/stylesheets/normalize.css +0 -375
- data/lib/middleman-core/templates/empty.rb +0 -22
- data/lib/middleman-core/templates/empty/Gemfile.tt +0 -6
- data/lib/middleman-core/templates/extension/Gemfile +0 -18
- data/lib/middleman-core/templates/extension/Rakefile +0 -14
- data/lib/middleman-core/templates/extension/features/support/env.rb +0 -4
- data/lib/middleman-core/templates/extension/gemspec +0 -24
- data/lib/middleman-core/templates/extension/gitignore +0 -5
- data/lib/middleman-core/templates/extension/lib/lib.rb +0 -38
- data/lib/middleman-core/templates/extension/lib/middleman_extension.rb +0 -1
- data/lib/middleman-core/templates/html5.rb +0 -29
- data/lib/middleman-core/templates/html5/source/.htaccess +0 -542
- data/lib/middleman-core/templates/html5/source/404.html +0 -157
- data/lib/middleman-core/templates/html5/source/LICENSE.md +0 -19
- data/lib/middleman-core/templates/html5/source/README.md +0 -63
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-114x114-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-144x144-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-57x57-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-72x72-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon-precomposed.png +0 -0
- data/lib/middleman-core/templates/html5/source/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/html5/source/crossdomain.xml +0 -15
- data/lib/middleman-core/templates/html5/source/css/main.css +0 -298
- data/lib/middleman-core/templates/html5/source/css/normalize.css +0 -504
- data/lib/middleman-core/templates/html5/source/favicon.ico +0 -0
- data/lib/middleman-core/templates/html5/source/humans.txt +0 -15
- data/lib/middleman-core/templates/html5/source/index.html.erb +0 -6
- data/lib/middleman-core/templates/html5/source/js/main.js +0 -1
- data/lib/middleman-core/templates/html5/source/js/plugins.js +0 -14
- data/lib/middleman-core/templates/html5/source/js/vendor/jquery-1.8.0.min.js +0 -2
- data/lib/middleman-core/templates/html5/source/js/vendor/modernizr-2.6.1.min.js +0 -4
- data/lib/middleman-core/templates/html5/source/layouts/layout.erb +0 -40
- data/lib/middleman-core/templates/html5/source/robots.txt +0 -3
- data/lib/middleman-core/templates/local.rb +0 -27
- data/lib/middleman-core/templates/mobile.rb +0 -24
- data/lib/middleman-core/templates/mobile/source/404.html +0 -37
- data/lib/middleman-core/templates/mobile/source/README.markdown +0 -21
- data/lib/middleman-core/templates/mobile/source/crossdomain.xml +0 -25
- data/lib/middleman-core/templates/mobile/source/css/style.css +0 -315
- data/lib/middleman-core/templates/mobile/source/humans.txt +0 -43
- data/lib/middleman-core/templates/mobile/source/img/h/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/h/splash.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon-precomposed.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/l/splash.png +0 -0
- data/lib/middleman-core/templates/mobile/source/img/m/apple-touch-icon.png +0 -0
- data/lib/middleman-core/templates/mobile/source/index.html +0 -92
- data/lib/middleman-core/templates/mobile/source/js/libs/modernizr-custom.js +0 -14
- data/lib/middleman-core/templates/mobile/source/js/libs/respond.min.js +0 -7
- data/lib/middleman-core/templates/mobile/source/js/mylibs/helper.js +0 -171
- data/lib/middleman-core/templates/mobile/source/js/plugins.js +0 -20
- data/lib/middleman-core/templates/mobile/source/robots.txt +0 -4
- data/lib/middleman-core/templates/mobile/source/sitemap.xml +0 -9
- data/lib/middleman-core/templates/mobile/source/test/index.html +0 -31
- data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.css +0 -148
- data/lib/middleman-core/templates/mobile/source/test/qunit/qunit.js +0 -1265
- data/lib/middleman-core/templates/mobile/source/test/tests.js +0 -21
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/Readme.PDF +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx1.snippet +0 -31
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/aspx2.snippet +0 -2
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/ga.aspx +0 -195
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/aspx/sample.aspx +0 -44
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/ga.jsp +0 -225
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp1.snippet +0 -35
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/jsp2.snippet +0 -2
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/jsp/sample.jsp +0 -51
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/ga.php +0 -176
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php1.snippet +0 -30
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/php2.snippet +0 -4
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/php/sample.php +0 -44
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/ga.pl +0 -195
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl1.snippet +0 -27
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/perl2.snippet +0 -1
- data/lib/middleman-core/templates/mobile/source/tools/googleanalyticsformobile/pl/sample.pl +0 -38
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/COPYING +0 -202
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/bookmark_bubble.js +0 -559
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.html +0 -43
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/example/example.js +0 -57
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/arrow.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/close.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/generate_base64_images +0 -33
- data/lib/middleman-core/templates/mobile/source/tools/mobile-bookmark-bubble/images/icon_calendar.png +0 -0
- data/lib/middleman-core/templates/mobile/source/tools/wspl/README +0 -27
- data/lib/middleman-core/templates/mobile/source/tools/wspl/databasefactory.js +0 -45
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker.js +0 -324
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworker_test.html +0 -393
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbworkerstarter.js +0 -32
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears.js +0 -595
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_gears_test.html +0 -404
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5.js +0 -203
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapper_html5_test.html +0 -468
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi.js +0 -202
- data/lib/middleman-core/templates/mobile/source/tools/wspl/dbwrapperapi_test.html +0 -51
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset.js +0 -71
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_resultset_test.html +0 -86
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction.js +0 -196
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gears_transaction_test.html +0 -221
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils.js +0 -94
- data/lib/middleman-core/templates/mobile/source/tools/wspl/gearsutils_test.html +0 -84
- data/lib/middleman-core/templates/mobile/source/tools/wspl/global_functions.js +0 -72
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/index.html +0 -347
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/simplenotes.js +0 -503
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/styles.css +0 -66
- data/lib/middleman-core/templates/mobile/source/tools/wspl/simplenotes/template.js +0 -75
- data/lib/middleman-core/templates/shared/Gemfile.tt +0 -14
- data/lib/middleman-core/templates/shared/config.ru +0 -3
- data/lib/middleman-core/templates/shared/config.tt +0 -87
- data/lib/middleman-core/templates/shared/gitignore +0 -21
- data/lib/middleman-more/core_extensions/compass.rb +0 -75
- data/lib/middleman-more/core_extensions/i18n.rb +0 -312
- data/lib/middleman-more/extensions/asset_hash.rb +0 -128
- data/lib/middleman-more/extensions/asset_host.rb +0 -50
- data/lib/middleman-more/extensions/cache_buster.rb +0 -55
- data/lib/middleman-more/extensions/minify_css.rb +0 -112
- data/lib/middleman-more/extensions/minify_javascript.rb +0 -120
- data/lib/middleman-more/extensions/relative_assets.rb +0 -24
- data/lib/middleman-more/templates/smacss.rb +0 -29
- data/lib/middleman-more/templates/smacss/source/_footer.haml +0 -1
- data/lib/middleman-more/templates/smacss/source/index.html.haml +0 -1
- data/lib/middleman-more/templates/smacss/source/layouts/layout.haml +0 -13
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/README.markdown +0 -11
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/base.scss +0 -1
- data/lib/middleman-more/templates/smacss/source/stylesheets/base/normalize.scss +0 -375
- data/lib/middleman-more/templates/smacss/source/stylesheets/layout/README.markdown +0 -9
- data/lib/middleman-more/templates/smacss/source/stylesheets/modules/README.markdown +0 -9
- data/lib/middleman-more/templates/smacss/source/stylesheets/states/README.markdown +0 -12
- data/lib/middleman-more/templates/smacss/source/stylesheets/style.css.scss +0 -12
- data/lib/vendored-middleman-deps/fastimage.rb +0 -287
- data/spec/middleman-core/dns_resolver_spec.rb +0 -118
- data/spec/middleman-core/preview_server/server_hostname_spec.rb +0 -39
- data/spec/middleman-core/preview_server/server_ip_address_spec.rb +0 -43
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'resolv'
|
2
|
-
require 'middleman-core/dns_resolver/network_resolver'
|
3
|
-
require 'middleman-core/dns_resolver/hosts_resolver'
|
4
|
-
|
5
|
-
module Middleman
|
6
|
-
# This resolves IP address to names and vice versa
|
7
|
-
class DnsResolver
|
8
|
-
private
|
9
|
-
|
10
|
-
attr_reader :resolvers
|
11
|
-
|
12
|
-
public
|
13
|
-
|
14
|
-
# Create resolver
|
15
|
-
#
|
16
|
-
# First the local resolver is used. If environment variable HOSTSRC is
|
17
|
-
# given this file is used for local name lookup.
|
18
|
-
#
|
19
|
-
# @param [#getnames, #getaddresses] network_resolver
|
20
|
-
# The resolver which uses a network name server to resolve ip addresses
|
21
|
-
# and names.
|
22
|
-
#
|
23
|
-
# @param [#getnames, #getaddresses] local_resolver
|
24
|
-
# The resolver uses /etc/hosts on POSIX-systems and
|
25
|
-
# C:\Windows\System32\drivers\etc\hosts on Windows-operating systems to
|
26
|
-
# resolve ip addresses and names.
|
27
|
-
#
|
28
|
-
# First the local resolver is queried. If this raises an error or returns
|
29
|
-
# nil or [] the network resolver is queried.
|
30
|
-
def initialize(opts={})
|
31
|
-
@resolvers = []
|
32
|
-
@resolvers << opts.fetch(:hosts_resolver, HostsResolver.new)
|
33
|
-
|
34
|
-
if RUBY_VERSION >= '2.1'
|
35
|
-
require 'middleman-core/dns_resolver/local_link_resolver'
|
36
|
-
@resolvers << opts.fetch(:local_link_resolver, LocalLinkResolver.new)
|
37
|
-
end
|
38
|
-
|
39
|
-
@resolvers << opts.fetch(:network_resolver, NetworkResolver.new)
|
40
|
-
end
|
41
|
-
|
42
|
-
# Get names for given ip
|
43
|
-
#
|
44
|
-
# @param [String] ip
|
45
|
-
# The ip which should be resolved.
|
46
|
-
def names_for(ip)
|
47
|
-
resolvers.each do |r|
|
48
|
-
names = r.getnames(ip)
|
49
|
-
|
50
|
-
return names unless names.nil? || names.empty?
|
51
|
-
end
|
52
|
-
|
53
|
-
[]
|
54
|
-
end
|
55
|
-
|
56
|
-
# Get ips for given name
|
57
|
-
#
|
58
|
-
# First the local resolver is used. On POSIX-systems /etc/hosts is used. On
|
59
|
-
# Windows C:\Windows\System32\drivers\etc\hosts is used.
|
60
|
-
#
|
61
|
-
# @param [String] name
|
62
|
-
# The name which should be resolved.
|
63
|
-
def ips_for(name)
|
64
|
-
resolvers.each do |r|
|
65
|
-
ips = r.getaddresses(name)
|
66
|
-
|
67
|
-
return ips unless ips.nil? || ips.empty?
|
68
|
-
end
|
69
|
-
|
70
|
-
[]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
module Middleman
|
2
|
-
class DnsResolver
|
3
|
-
# Use network name server to resolve ips and names
|
4
|
-
class BasicNetworkResolver
|
5
|
-
private
|
6
|
-
|
7
|
-
attr_reader :resolver, :timeouts
|
8
|
-
|
9
|
-
public
|
10
|
-
|
11
|
-
def initialize(opts={})
|
12
|
-
@timeouts = opts.fetch(:timeouts, 2)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Get names for ip
|
16
|
-
#
|
17
|
-
# @param [#to_s] ip
|
18
|
-
# The ip to resolve into names
|
19
|
-
#
|
20
|
-
# @return [Array]
|
21
|
-
# Array of Names
|
22
|
-
def getnames(ip)
|
23
|
-
resolver.getnames(ip.to_s).map(&:to_s)
|
24
|
-
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
|
25
|
-
[]
|
26
|
-
end
|
27
|
-
|
28
|
-
# Get ips for name
|
29
|
-
#
|
30
|
-
# @param [#to_s] name
|
31
|
-
# The name to resolve into ips
|
32
|
-
#
|
33
|
-
# @return [Array]
|
34
|
-
# Array of ipaddresses
|
35
|
-
def getaddresses(name)
|
36
|
-
resolver.getaddresses(name.to_s).map(&:to_s)
|
37
|
-
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
|
38
|
-
[]
|
39
|
-
end
|
40
|
-
|
41
|
-
# Set timeout for lookup
|
42
|
-
#
|
43
|
-
# @param [Integer] value
|
44
|
-
# The timeout value
|
45
|
-
def timeouts=(timeouts)
|
46
|
-
return if RUBY_VERSION < '2'
|
47
|
-
|
48
|
-
resolver.timeouts = timeouts
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Middleman
|
2
|
-
class DnsResolver
|
3
|
-
# Use network name server to resolve ips and names
|
4
|
-
class HostsResolver
|
5
|
-
private
|
6
|
-
|
7
|
-
attr_reader :resolver
|
8
|
-
|
9
|
-
public
|
10
|
-
|
11
|
-
def initialize(opts={})
|
12
|
-
# using the splat operator works around a non-existing HOSTSRC variable
|
13
|
-
# using nil as input does not work, but `*[]` does and then Resolv::Hosts
|
14
|
-
# uses its defaults
|
15
|
-
@resolver = opts.fetch(:resolver, Resolv::Hosts.new(*hosts_file))
|
16
|
-
end
|
17
|
-
|
18
|
-
# Get names for ip
|
19
|
-
#
|
20
|
-
# @param [#to_s] ip
|
21
|
-
# The ip to resolve into names
|
22
|
-
#
|
23
|
-
# @return [Array]
|
24
|
-
# Array of Names
|
25
|
-
def getnames(ip)
|
26
|
-
resolver.getnames(ip.to_s).map(&:to_s)
|
27
|
-
rescue Resolv::ResolvError
|
28
|
-
[]
|
29
|
-
end
|
30
|
-
|
31
|
-
# Get ips for name
|
32
|
-
#
|
33
|
-
# @param [#to_s] name
|
34
|
-
# The name to resolve into ips
|
35
|
-
#
|
36
|
-
# @return [Array]
|
37
|
-
# Array of ipaddresses
|
38
|
-
def getaddresses(name)
|
39
|
-
resolver.getaddresses(name.to_s).map(&:to_s)
|
40
|
-
rescue Resolv::ResolvError
|
41
|
-
[]
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
# Path to hosts file
|
47
|
-
#
|
48
|
-
# This looks for MM_HOSTSRC in your environment
|
49
|
-
#
|
50
|
-
# @return [Array]
|
51
|
-
# This needs to be an array, to make the splat operator work
|
52
|
-
#
|
53
|
-
# @example
|
54
|
-
# # <ip> <hostname>
|
55
|
-
# 127.0.0.1 localhost.localhost localhost
|
56
|
-
def hosts_file
|
57
|
-
return [ENV['MM_HOSTSRC']] if ENV.key?('MM_HOSTSRC') && File.file?(ENV['MM_HOSTSRC'])
|
58
|
-
|
59
|
-
[]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'middleman-core/dns_resolver/basic_network_resolver'
|
2
|
-
|
3
|
-
module Middleman
|
4
|
-
class DnsResolver
|
5
|
-
# Use network name server to resolve ips and names
|
6
|
-
class LocalLinkResolver < BasicNetworkResolver
|
7
|
-
def initialize(opts={})
|
8
|
-
super
|
9
|
-
|
10
|
-
@timeouts = opts.fetch(:timeouts, 1)
|
11
|
-
@resolver = opts.fetch(:resolver, Resolv::MDNS.new(nameserver_config))
|
12
|
-
|
13
|
-
self.timeouts = timeouts
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
# Hosts + Ports for MDNS resolver
|
19
|
-
#
|
20
|
-
# This looks for MM_MDNSRC in your environment. If you are going to use
|
21
|
-
# IPv6-addresses: Make sure you do not forget to add the port at the end.
|
22
|
-
#
|
23
|
-
# MM_MDNSRC=ip:port ip:port
|
24
|
-
#
|
25
|
-
# @return [Hash]
|
26
|
-
# Returns the configuration for the nameserver
|
27
|
-
#
|
28
|
-
# @example
|
29
|
-
# export MM_MDNSRC="224.0.0.251:5353 ff02::fb:5353"
|
30
|
-
#
|
31
|
-
def nameserver_config
|
32
|
-
return unless ENV.key?('MM_MDNSRC') && ENV['MM_MDNSRC']
|
33
|
-
|
34
|
-
address, port = ENV['MM_MDNSRC'].split(/:/)
|
35
|
-
|
36
|
-
{
|
37
|
-
nameserver_port: [[address, port.to_i]]
|
38
|
-
}
|
39
|
-
rescue StandardError
|
40
|
-
{}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'middleman-core/dns_resolver/basic_network_resolver'
|
2
|
-
|
3
|
-
module Middleman
|
4
|
-
class DnsResolver
|
5
|
-
# Use network name server to resolve ips and names
|
6
|
-
class NetworkResolver < BasicNetworkResolver
|
7
|
-
def initialize(opts={})
|
8
|
-
super
|
9
|
-
|
10
|
-
@resolver = opts.fetch(:resolver, Resolv::DNS.new(nameserver_config))
|
11
|
-
self.timeouts = timeouts
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
# Hosts + Ports for MDNS resolver
|
17
|
-
#
|
18
|
-
# This looks for MM_MDNSRC in your environment. If you are going to use
|
19
|
-
# IPv6-addresses: Make sure you do not forget to add the port at the end.
|
20
|
-
#
|
21
|
-
# MM_MDNSRC=ip:port ip:port
|
22
|
-
#
|
23
|
-
# @return [Hash]
|
24
|
-
# Returns the configuration for the nameserver
|
25
|
-
#
|
26
|
-
# @example
|
27
|
-
# export MM_MDNSRC="224.0.0.251:5353 ff02::fb:5353"
|
28
|
-
#
|
29
|
-
def nameserver_config
|
30
|
-
return unless ENV.key?('MM_DNSRC') && ENV['MM_DNSRC']
|
31
|
-
|
32
|
-
address, port = ENV['MM_DNSRC'].split(/:/)
|
33
|
-
|
34
|
-
{
|
35
|
-
nameserver_port: [[address, port.to_i]]
|
36
|
-
}
|
37
|
-
rescue StandardError
|
38
|
-
{}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,81 +0,0 @@
|
|
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
|
@@ -1,273 +0,0 @@
|
|
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
|