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,105 +1,81 @@
|
|
1
|
+
require 'middleman-core/sitemap/resource'
|
2
|
+
|
1
3
|
module Middleman
|
2
4
|
module Sitemap
|
3
5
|
module Extensions
|
4
|
-
|
5
|
-
# Setup extension
|
6
|
-
class << self
|
7
|
-
# Once registered
|
8
|
-
def registered(app)
|
9
|
-
# Include methods
|
10
|
-
app.send :include, InstanceMethods
|
11
|
-
end
|
12
|
-
|
13
|
-
alias_method :included, :registered
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
def endpoint_manager
|
18
|
-
@_endpoint_manager ||= EndpointManager.new(self)
|
19
|
-
end
|
20
|
-
|
21
|
-
def endpoint(*args, &block)
|
22
|
-
endpoint_manager.create_endpoint(*args, &block)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
6
|
+
class RequestEndpoints < Extension
|
26
7
|
# Manages the list of proxy configurations and manipulates the sitemap
|
27
8
|
# to include new resources based on those configurations
|
28
|
-
|
29
|
-
|
30
|
-
@app = app
|
31
|
-
@endpoints = {}
|
32
|
-
end
|
33
|
-
|
34
|
-
# Setup a proxy from a path to a target
|
35
|
-
# @param [String] path
|
36
|
-
# @param [Hash] opts The :path value gives a request path if it
|
37
|
-
# differs from the output path
|
38
|
-
def create_endpoint(path, opts={}, &block)
|
39
|
-
endpoint = {
|
40
|
-
request_path: path
|
41
|
-
}
|
9
|
+
def initialize(app, config={}, &block)
|
10
|
+
super
|
42
11
|
|
43
|
-
|
44
|
-
endpoint[:output] = block
|
45
|
-
else
|
46
|
-
endpoint[:request_path] = opts[:path] if opts.key?(:path)
|
47
|
-
end
|
48
|
-
|
49
|
-
@endpoints[path] = endpoint
|
50
|
-
|
51
|
-
@app.sitemap.rebuild_resource_list!(:added_endpoint)
|
52
|
-
end
|
12
|
+
@app.add_to_config_context(:endpoint, &method(:create_endpoint))
|
53
13
|
|
54
|
-
|
55
|
-
# @return [void]
|
56
|
-
def manipulate_resource_list(resources)
|
57
|
-
resources + @endpoints.map do |path, config|
|
58
|
-
r = EndpointResource.new(
|
59
|
-
@app.sitemap,
|
60
|
-
path,
|
61
|
-
config[:request_path]
|
62
|
-
)
|
63
|
-
r.output = config[:output] if config.key?(:output)
|
64
|
-
r
|
65
|
-
end
|
66
|
-
end
|
14
|
+
@endpoints = {}
|
67
15
|
end
|
68
16
|
|
69
|
-
|
70
|
-
|
17
|
+
# Setup a proxy from a path to a target
|
18
|
+
# @param [String] path
|
19
|
+
# @param [Hash] opts The :path value gives a request path if it
|
20
|
+
# differs from the output path
|
21
|
+
Contract String, Or[({ path: String }), Proc] => Any
|
22
|
+
def create_endpoint(path, opts={}, &block)
|
23
|
+
endpoint = {
|
24
|
+
request_path: path
|
25
|
+
}
|
26
|
+
|
27
|
+
if block_given?
|
28
|
+
endpoint[:output] = block
|
29
|
+
else
|
30
|
+
endpoint[:request_path] = opts[:path] if opts.key?(:path)
|
31
|
+
end
|
71
32
|
|
72
|
-
|
73
|
-
@request_path = ::Middleman::Util.normalize_path(source_file)
|
33
|
+
@endpoints[path] = endpoint
|
74
34
|
|
75
|
-
|
76
|
-
|
35
|
+
@app.sitemap.rebuild_resource_list!(:added_endpoint)
|
36
|
+
end
|
77
37
|
|
78
|
-
|
79
|
-
|
38
|
+
# Update the main sitemap resource list
|
39
|
+
# @return Array<Middleman::Sitemap::Resource>
|
40
|
+
Contract ResourceList => ResourceList
|
41
|
+
def manipulate_resource_list(resources)
|
42
|
+
resources + @endpoints.map do |path, config|
|
43
|
+
r = EndpointResource.new(
|
44
|
+
@app.sitemap,
|
45
|
+
path,
|
46
|
+
config[:request_path]
|
47
|
+
)
|
48
|
+
r.output = config[:output] if config.key?(:output)
|
49
|
+
r
|
80
50
|
end
|
51
|
+
end
|
52
|
+
end
|
81
53
|
|
82
|
-
|
83
|
-
|
84
|
-
|
54
|
+
class EndpointResource < ::Middleman::Sitemap::Resource
|
55
|
+
Contract None => Maybe[Proc]
|
56
|
+
attr_accessor :output
|
85
57
|
|
86
|
-
|
58
|
+
def initialize(store, path, request_path)
|
59
|
+
super(store, path)
|
60
|
+
@request_path = ::Middleman::Util.normalize_path(request_path)
|
61
|
+
end
|
87
62
|
|
88
|
-
|
89
|
-
|
90
|
-
end
|
63
|
+
Contract None => String
|
64
|
+
attr_reader :request_path
|
91
65
|
|
92
|
-
|
93
|
-
|
94
|
-
|
66
|
+
Contract None => Bool
|
67
|
+
def template?
|
68
|
+
true
|
69
|
+
end
|
95
70
|
|
96
|
-
|
97
|
-
|
98
|
-
|
71
|
+
Contract Args[Any] => String
|
72
|
+
def render(*)
|
73
|
+
return output.call if output
|
74
|
+
end
|
99
75
|
|
100
|
-
|
101
|
-
|
102
|
-
|
76
|
+
Contract None => Bool
|
77
|
+
def ignored?
|
78
|
+
false
|
103
79
|
end
|
104
80
|
end
|
105
81
|
end
|
@@ -7,15 +7,13 @@ module Middleman
|
|
7
7
|
def parent
|
8
8
|
parts = path.split('/')
|
9
9
|
tail = parts.pop
|
10
|
-
is_index = (tail == app.index_file)
|
10
|
+
is_index = (tail == @app.config[:index_file])
|
11
11
|
|
12
|
-
if parts.
|
13
|
-
return is_index ? nil : store.find_resource_by_path(app.index_file)
|
14
|
-
end
|
12
|
+
return nil if is_index && parts.length < 1
|
15
13
|
|
16
14
|
test_expr = parts.join('\\/')
|
17
|
-
#
|
18
|
-
found = store.resources.find do |candidate|
|
15
|
+
# eponymous reverse-lookup
|
16
|
+
found = @store.resources.find do |candidate|
|
19
17
|
candidate.path =~ %r{^#{test_expr}(?:\.[a-zA-Z0-9]+|\/)$}
|
20
18
|
end
|
21
19
|
|
@@ -23,7 +21,7 @@ module Middleman
|
|
23
21
|
found
|
24
22
|
else
|
25
23
|
parts.pop if is_index
|
26
|
-
store.find_resource_by_destination_path("#{parts.join('/')}/#{app.index_file}")
|
24
|
+
@store.find_resource_by_destination_path("#{parts.join('/')}/#{@app.config[:index_file]}")
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -36,11 +34,11 @@ module Middleman
|
|
36
34
|
base_path = eponymous_directory_path
|
37
35
|
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
38
36
|
else
|
39
|
-
base_path = path.sub("#{app.index_file}", '')
|
37
|
+
base_path = path.sub("#{@app.config[:index_file]}", '')
|
40
38
|
prefix = %r{^#{base_path.sub("/", "\\/")}}
|
41
39
|
end
|
42
40
|
|
43
|
-
store.resources.select do |sub_resource|
|
41
|
+
@store.resources.select do |sub_resource|
|
44
42
|
if sub_resource.path == path || sub_resource.path !~ prefix
|
45
43
|
false
|
46
44
|
else
|
@@ -49,7 +47,7 @@ module Middleman
|
|
49
47
|
if parts.length == 1
|
50
48
|
true
|
51
49
|
elsif parts.length == 2
|
52
|
-
parts.last == app.index_file
|
50
|
+
parts.last == @app.config[:index_file]
|
53
51
|
else
|
54
52
|
false
|
55
53
|
end
|
@@ -64,22 +62,23 @@ module Middleman
|
|
64
62
|
parent.children.reject { |p| p == self }
|
65
63
|
end
|
66
64
|
|
67
|
-
# Whether this resource either a directory index, or has the same name as an existing directory in the source
|
65
|
+
# Whether this resource is either a directory index, or has the same name as an existing directory in the source
|
68
66
|
# @return [Boolean]
|
69
67
|
def directory_index?
|
70
|
-
path.include?(app.index_file) || path =~ /\/$/ || eponymous_directory?
|
68
|
+
path.include?(@app.config[:index_file]) || path =~ /\/$/ || eponymous_directory?
|
71
69
|
end
|
72
70
|
|
73
71
|
# Whether the resource has the same name as a directory in the source
|
74
72
|
# (e.g., if the resource is named 'gallery.html' and a path exists named 'gallery/', this would return true)
|
75
73
|
# @return [Boolean]
|
76
74
|
def eponymous_directory?
|
77
|
-
if !path.end_with?("/#{app.index_file}") && destination_path.end_with?("/#{app.index_file}")
|
75
|
+
if !path.end_with?("/#{@app.config[:index_file]}") && destination_path.end_with?("/#{@app.config[:index_file]}")
|
78
76
|
return true
|
79
77
|
end
|
80
78
|
|
81
|
-
|
82
|
-
|
79
|
+
@app.files.by_type(:source).watchers.any? do |source|
|
80
|
+
(source.directory + Pathname(eponymous_directory_path)).directory?
|
81
|
+
end
|
83
82
|
end
|
84
83
|
|
85
84
|
# The path for this resource if it were a directory, and not a file
|
@@ -1,150 +1,178 @@
|
|
1
|
+
require 'rack/mime'
|
1
2
|
require 'middleman-core/sitemap/extensions/traversal'
|
2
|
-
require 'middleman-core/
|
3
|
+
require 'middleman-core/file_renderer'
|
4
|
+
require 'middleman-core/template_renderer'
|
5
|
+
require 'middleman-core/contracts'
|
3
6
|
|
4
7
|
module Middleman
|
5
8
|
# Sitemap namespace
|
6
9
|
module Sitemap
|
7
10
|
# Sitemap Resource class
|
8
11
|
class Resource
|
12
|
+
include Contracts
|
9
13
|
include Middleman::Sitemap::Extensions::Traversal
|
10
|
-
include Middleman::Sitemap::Extensions::ContentType
|
11
|
-
|
12
|
-
# @return [Middleman::Application]
|
13
|
-
attr_reader :app
|
14
|
-
delegate :logger, :instrument, to: :app
|
15
|
-
|
16
|
-
# @return [Middleman::Sitemap::Store]
|
17
|
-
attr_reader :store
|
18
14
|
|
19
15
|
# The source path of this resource (relative to the source directory,
|
20
16
|
# without template extensions)
|
21
17
|
# @return [String]
|
22
18
|
attr_reader :path
|
23
19
|
|
24
|
-
# The output path for this resource
|
20
|
+
# The output path in the build directory for this resource
|
25
21
|
# @return [String]
|
26
22
|
attr_accessor :destination_path
|
27
23
|
|
28
|
-
#
|
24
|
+
# The on-disk source file for this resource, if there is one
|
29
25
|
# @return [String]
|
30
|
-
|
26
|
+
Contract None => Maybe[IsA['Middleman::SourceFile']]
|
27
|
+
attr_reader :source_file
|
31
28
|
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
# The path to use when requesting this resource. Normally it's
|
30
|
+
# the same as {#destination_path} but it can be overridden in subclasses.
|
31
|
+
# @return [String]
|
32
|
+
alias_method :request_path, :destination_path
|
33
|
+
|
34
|
+
METADATA_HASH = ({ options: Maybe[Hash], locals: Maybe[Hash], page: Maybe[Hash] })
|
35
|
+
|
36
|
+
# The metadata for this resource
|
37
|
+
# @return [Hash]
|
38
|
+
Contract None => METADATA_HASH
|
39
|
+
attr_reader :metadata
|
35
40
|
|
36
41
|
# Initialize resource with parent store and URL
|
37
42
|
# @param [Middleman::Sitemap::Store] store
|
38
43
|
# @param [String] path
|
39
44
|
# @param [String] source_file
|
45
|
+
Contract IsA['Middleman::Sitemap::Store'], String, Maybe[IsA['Middleman::SourceFile']] => Any
|
40
46
|
def initialize(store, path, source_file=nil)
|
41
47
|
@store = store
|
42
48
|
@app = @store.app
|
43
|
-
@path = path
|
49
|
+
@path = path.gsub(' ', '%20') # handle spaces in filenames
|
44
50
|
@source_file = source_file
|
45
51
|
@destination_path = @path
|
46
52
|
|
47
|
-
|
53
|
+
# Options are generally rendering/sitemap options
|
54
|
+
# Locals are local variables for rendering this resource's template
|
55
|
+
# Page are data that is exposed through this resource's data member.
|
56
|
+
# Note: It is named 'page' for backwards compatibility with older MM.
|
57
|
+
@metadata = { options: {}, locals: {}, page: {} }
|
48
58
|
end
|
49
59
|
|
50
60
|
# Whether this resource has a template file
|
51
61
|
# @return [Boolean]
|
62
|
+
Contract None => Bool
|
52
63
|
def template?
|
53
64
|
return false if source_file.nil?
|
54
|
-
!::Tilt[source_file].nil?
|
65
|
+
!::Tilt[source_file[:full_path].to_s].nil?
|
55
66
|
end
|
56
67
|
|
57
|
-
#
|
58
|
-
# @
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
68
|
+
# Merge in new metadata specific to this resource.
|
69
|
+
# @param [Hash] meta A metadata block with keys :options, :locals, :page.
|
70
|
+
# Options are generally rendering/sitemap options
|
71
|
+
# Locals are local variables for rendering this resource's template
|
72
|
+
# Page are data that is exposed through this resource's data member.
|
73
|
+
# Note: It is named 'page' for backwards compatibility with older MM.
|
74
|
+
Contract METADATA_HASH => METADATA_HASH
|
75
|
+
def add_metadata(meta={})
|
76
|
+
@metadata.deep_merge!(meta)
|
77
|
+
end
|
65
78
|
|
66
|
-
|
67
|
-
|
68
|
-
|
79
|
+
# Data about this resource, populated from frontmatter or extensions.
|
80
|
+
# @return [HashWithIndifferentAccess]
|
81
|
+
Contract None => IsA['Middleman::Util::HashWithIndifferentAccess']
|
82
|
+
def data
|
83
|
+
# TODO: Should this really be a HashWithIndifferentAccess?
|
84
|
+
::Middleman::Util.recursively_enhance(metadata[:page])
|
85
|
+
end
|
69
86
|
|
70
|
-
|
71
|
-
|
87
|
+
# Options about how this resource is rendered, such as its :layout,
|
88
|
+
# :renderer_options, and whether or not to use :directory_indexes.
|
89
|
+
# @return [Hash]
|
90
|
+
Contract None => Hash
|
91
|
+
def options
|
92
|
+
metadata[:options]
|
72
93
|
end
|
73
94
|
|
74
|
-
#
|
75
|
-
# @
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
@local_metadata.deep_merge!(metadata)
|
80
|
-
@local_metadata[:blocks] += [block] if block_given?
|
95
|
+
# Local variable mappings that are used when rendering the template for this resource.
|
96
|
+
# @return [Hash]
|
97
|
+
Contract None => Hash
|
98
|
+
def locals
|
99
|
+
metadata[:locals]
|
81
100
|
end
|
82
101
|
|
83
102
|
# Extension of the path (i.e. '.js')
|
84
103
|
# @return [String]
|
104
|
+
Contract None => String
|
85
105
|
def ext
|
86
106
|
File.extname(path)
|
87
107
|
end
|
88
108
|
|
89
|
-
def request_path
|
90
|
-
destination_path
|
91
|
-
end
|
92
|
-
|
93
109
|
# Render this resource
|
94
110
|
# @return [String]
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
relative_source = Pathname(source_file).relative_path_from(Pathname(app.root))
|
111
|
+
Contract Hash, Hash => String
|
112
|
+
def render(opts={}, locs={})
|
113
|
+
return ::Middleman::FileRenderer.new(@app, source_file[:full_path].to_s).template_data_for_file unless template?
|
99
114
|
|
100
|
-
instrument 'render.resource', path:
|
101
|
-
md = metadata
|
115
|
+
::Middleman::Util.instrument 'render.resource', path: source_file[:full_path].to_s, destination_path: destination_path do
|
116
|
+
md = metadata
|
102
117
|
opts = md[:options].deep_merge(opts)
|
103
|
-
|
104
|
-
# Pass "renderer_options" hash from frontmatter along to renderer
|
105
|
-
if md[:page]['renderer_options']
|
106
|
-
opts[:renderer_options] = {}
|
107
|
-
md[:page]['renderer_options'].each do |k, v|
|
108
|
-
opts[:renderer_options][k.to_sym] = v
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
118
|
locs = md[:locals].deep_merge(locs)
|
113
|
-
|
114
|
-
# Forward remaining data to helpers
|
115
|
-
app.data.store('page', md[:page]) if md.key?(:page)
|
116
|
-
|
117
|
-
blocks = Array(md[:blocks]).dup
|
118
|
-
blocks << block if block_given?
|
119
|
-
|
120
|
-
app.current_path ||= destination_path
|
119
|
+
locs[:current_path] ||= destination_path
|
121
120
|
|
122
121
|
# Certain output file types don't use layouts
|
123
122
|
unless opts.key?(:layout)
|
124
123
|
opts[:layout] = false if %w(.js .json .css .txt).include?(ext)
|
125
124
|
end
|
126
125
|
|
127
|
-
|
126
|
+
renderer = ::Middleman::TemplateRenderer.new(@app, source_file[:full_path].to_s)
|
127
|
+
renderer.render(locs, opts)
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
131
|
# A path without the directory index - so foo/index.html becomes
|
132
132
|
# just foo. Best for linking.
|
133
133
|
# @return [String]
|
134
|
+
Contract None => String
|
134
135
|
def url
|
135
136
|
url_path = destination_path
|
136
|
-
if app.strip_index_file
|
137
|
-
url_path = url_path.sub(/(^|\/)#{Regexp.escape(app.index_file)}$/,
|
138
|
-
app.trailing_slash ? '/' : '')
|
137
|
+
if @app.config[:strip_index_file]
|
138
|
+
url_path = url_path.sub(/(^|\/)#{Regexp.escape(@app.config[:index_file])}$/,
|
139
|
+
@app.config[:trailing_slash] ? '/' : '')
|
139
140
|
end
|
140
|
-
File.join(app.
|
141
|
+
File.join(@app.config[:http_prefix], url_path)
|
141
142
|
end
|
142
143
|
|
143
144
|
# Whether the source file is binary.
|
144
145
|
#
|
145
146
|
# @return [Boolean]
|
147
|
+
Contract None => Bool
|
146
148
|
def binary?
|
147
|
-
::Middleman::Util.binary?(source_file)
|
149
|
+
!source_file.nil? && ::Middleman::Util.binary?(source_file[:full_path].to_s)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Ignore a resource directly, without going through the whole
|
153
|
+
# ignore filter stuff.
|
154
|
+
# @return [void]
|
155
|
+
Contract None => Any
|
156
|
+
def ignore!
|
157
|
+
@ignored = true
|
158
|
+
end
|
159
|
+
|
160
|
+
# Whether the Resource is ignored
|
161
|
+
# @return [Boolean]
|
162
|
+
Contract None => Bool
|
163
|
+
def ignored?
|
164
|
+
return true if @ignored
|
165
|
+
# Ignore based on the source path (without template extensions)
|
166
|
+
return true if @app.sitemap.ignored?(path)
|
167
|
+
# This allows files to be ignored by their source file name (with template extensions)
|
168
|
+
!self.is_a?(ProxyResource) && @app.sitemap.ignored?(source_file[:relative_path].to_s)
|
169
|
+
end
|
170
|
+
|
171
|
+
# The preferred MIME content type for this resource based on extension or metadata
|
172
|
+
# @return [String] MIME type for this resource
|
173
|
+
Contract None => Maybe[String]
|
174
|
+
def content_type
|
175
|
+
options[:content_type] || ::Rack::Mime.mime_type(ext, nil)
|
148
176
|
end
|
149
177
|
end
|
150
178
|
end
|