diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/.gitignore b/.gitignore index 591c32b0..aabe272b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.byebug_history +npm-debug.log +manifest.yaml /.bundle .DS_Store coverage diff --git a/.rubocop.yml b/.rubocop.yml index 8346729e..c92b709f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,11 +10,13 @@ AllCops: - '**/tmp/**/*' - '**/bin/**/*' - 'middleman-core/lib/middleman-core/step_definitions/**/*' - - 'middleman-core/lib/vendored-middleman-deps/**/*' - - 'middleman-cli/lib/middleman-templates/**/*' - 'middleman-core/fixtures/**/*' - 'middleman-core/features/**/*' - 'middleman-core/spec/**/*' + - 'middleman-cli/lib/middleman-cli/templates/**/*' + - 'middleman-cli/fixtures/**/*' + - 'middleman-cli/features/**/*' + - 'middleman-cli/spec/**/*' DoubleNegation: Enabled: false LineLength: @@ -37,8 +39,6 @@ AssignmentInCondition: Enabled: false CyclomaticComplexity: Enabled: false -AbcSize: - Enabled: false HandleExceptions: Enabled: false EndAlignment: @@ -52,7 +52,9 @@ FormatString: CaseIndentation: IndentWhenRelativeTo: end TrivialAccessors: - ExactNameMatch: true + Enabled: false +SingleLineBlockParams: + Enabled: false Metrics/AbcSize: Enabled: false Metrics/PerceivedComplexity: @@ -63,3 +65,7 @@ Style/BlockDelimiters: Enabled: false Style/MultilineBlockChain: Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.travis.yml b/.travis.yml index f3150364..ac5a7f06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,8 @@ before_script: - bundle update rvm: - ruby-head - - 2.2.2 - - 2.1 - - 2.0 + - 2.3.1 + - 2.2.4 os: - linux # - osx diff --git a/CHANGELOG.md b/CHANGELOG.md index 486acada..148aa2e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,103 @@ master === +# 4.1.13 + +* Change how config options are passed to Thor. Removes new Thor warnings from #2017 + +# 4.1.12 + +* Fix broken `ignore { |p| true }` form. + +# 4.1.11 + +* Upgrade to Rack 2. + +# 4.1.10 + +* Fix unicode issues in URL deeplinks. +* Add prefix option to asset_hash (#1949) + +# 4.1.9 + +* Fix `--watcher-*` CLI flags. +* Allow spaces in paths to work with `link_to`. Fixes #1914 +* Add support for dotenv +* Fix asset_url with asset_hash (#1919) +* Allow partial lookups without a current_resource (#1912) + +# 4.1.8 + +* Expose `development?` and `production?` helpers to template context. +* require the `try` core extension (#1911) +* Fix contract for Sitemap::Store.register_resource_list_manipulator (#1907) +* Loosen contract on Resource#source_file to Maybe[String] (#1906) +* Let collection loops access ConfigContext for helpers. #1879 +* Use https:// to clone templates (#1901) +* Allow numbers to be unique page_ids (#1886) +* Prevent infinite loop when encountering files where base filename is a possible templating engine + +# 4.1.7 + +* Upgrade fastimage to 2.0 +* Fix shutdown of external_pipeline commands when config.rb is changed. #1877 +* Allow calls to `app.` to work as collections after initial config parse. #1876 + + +# 4.1.5-4.1.6 + +* Fix file recursion when looking for possible asset dependencies. Major preview server performance improvement. + +# 4.1.4 + +* Unify default extensions for all URL processing extensions. #1855 +* Fix URL regex for `content: ` context of CSS. #1853 +* Make sure CLI config over-rides `config.rb` order. +* Fix relative assets in some contexts. #1842 + +# 4.1.3 + +* Expose all top-level config options to CLI (flags now match config. latency -> watcher_latency, etc). +* Fix directory indexes with `.htm` and `.xhtml` files. #1821 + +# 4.1.2 + +* Add `page_id` concept. Using the `id` key in frontmatter, proxy or page will set an ID on a resource which can be referenced by `url_for` and `link_to`. +* Allow looking for `Gemfile` when setting up a project to fail gracefully. +* Send correct exit code when external_pipeline fails during build. +* Fix error when customizing `layouts_dir`. #1028 +* Fix collections (commands in loops) not being processed by `page` command. #1226 +* Correctly asset_hash sourcemap references. + +# 4.1.1 + +* Fix bad code that made `/__middleman/` break. + +# 4.1.0 + +* Add rewrite_ignore option to asset_hash, asset_host, cache_buster & relative_assets. This proc let's you opt-out of the extension behavior on a per-path basis. +* gzip extension now compresses svgs by default +* Fix the `encoding` option. +* Fix relative paths on `image_tag` helper. +* Correctly exit with error code on failed `init` +* Fixed `asset_hash` when path has query string or #hashes +* Fix new extension template +* Don't parse frontmatter on ignored files. +* Fix displaying frontmatter on `/__middleman/sitemap` +* Add `skip_build_clean` config which when set to a block, will avoid removing non-generated paths from build, like .git #1716 +* Minor performance improvements +* DRY-up config.rb-specific commands like `ignore` or `path`. +* Fix automatic images with absolute (or images dir missing) paths in markdown. Fixes #1755 +* Fix asset_host in combination with Google Analytics snippet. #1751 +* Show an error message when git CLI is not available. #1765 +* Correctly show file names of GZIP'ed assets. #1364 +* Build file output is now parallel-ized! Use `middleman build --no-parallel` to disable. +* Make template file extensions that get layouts by default configurable via `config[:extensions_with_layout]` +* Remove `=` from inline url matcher. This means paths in HTML attributes MUST be quoted. Fixes #1780 + +# 4.0.0 + +* Add `:locales` and `:data` source types to the list of files which trigger a live-reload. * Rename i18n `lang` and `langs` to `locale` and `locales`. * Avoid matching URLs across new lines. #1689 * Load Middleman Directory when doing `init` over SSL @@ -32,7 +129,7 @@ master * Add `resources` class method to extensions to allow simple string-based resource generation. * rename `app.add_to_instance` to `Extension.expose_to_application` for adding extension-local methods to the shared app instance. * rename `app.add_to_config_context` to `Extension.expose_to_config` for adding extension-local methods to the sandboxed scope of `config.rb` -* Add `Extension.expose_to_templates`, which auto binds copies of extension-local methods into a Template context. +* Add `Extension.expose_to_template`, which auto binds copies of extension-local methods into a Template context. * Remove side-loading of CLI tasks from `tasks/` * Add the option of naming `config.rb` as `middleman.rb`. * Builder extracted from Thor. `after_build` hook now passes an instance of a Builder instead of the Thor CLI. diff --git a/Gemfile b/Gemfile index 18832cec..db4043a0 100644 --- a/Gemfile +++ b/Gemfile @@ -5,12 +5,16 @@ gem 'rake', '~> 10.3', require: false gem 'yard', '~> 0.8', require: false # Test tools -gem 'pry', '~> 0.10', group: :development, require: false -gem 'pry-byebug' -gem 'pry-stack_explorer' +gem 'byebug' gem 'aruba', '~> 0.7.4', require: false gem 'rspec', '~> 3.0', require: false gem 'cucumber', '~> 2.0', require: false +gem 'addressable', '~> 2.4.0', require: false + +# Pry tools +gem 'pry' +gem 'pry-stack_explorer' +gem 'pry-rescue' # Optional middleman dependencies, included for tests gem 'haml', '>= 4.0.5', require: false @@ -20,7 +24,7 @@ gem 'kramdown', '~> 1.2', require: false gem 'slim', '>= 2.0', require: false gem 'liquid', '>= 2.6', require: false gem 'stylus', '>= 1.0', require: false -gem 'sinatra', '>= 1.4', require: false +gem 'sinatra', '>= 2.0.0.beta2', require: false gem 'redcarpet', '>= 3.1', require: false # Dns server to test preview server @@ -28,6 +32,7 @@ gem 'rubydns', '~> 1.0.1', require: false # To test javascript gem 'poltergeist', '~> 1.8', require: false +gem 'phantomjs', '~> 2.1.1.0', require: false # For less, note there is no compatible JS runtime for windows gem 'therubyrhino', '>= 2.0', platforms: :jruby diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md new file mode 100644 index 00000000..6d2dc0e0 --- /dev/null +++ b/ISSUE_TEMPLATE.md @@ -0,0 +1,9 @@ +## Expected behavior and actual behavior + +## Steps to reproduce the problem (from a clean middleman installation) + +## Additional information + +- Ruby version: +- Middleman version: +- OS version: diff --git a/README.md b/README.md index b7203403..df4497f7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The last few years have seen an explosion in the amount and variety of tools dev * [Sass](http://sass-lang.com/) for DRY stylesheets * [CoffeeScript](http://coffeescript.org/) for safer and less verbose javascript -* Multiple asset management solutions, including [Sprockets](https://github.com/sstephenson/sprockets) +* Multiple asset management solutions, including [Sprockets](https://github.com/rails/sprockets) * [ERb](http://ruby-doc.org/stdlib-2.0.0/libdoc/erb/rdoc/ERB.html) & [Haml](http://haml.info/) for dynamic pages and simplified HTML syntax **Middleman** gives the stand-alone developer access to all these tools and many, many more. Why would you use a stand-alone framework instead of Ruby on Rails? @@ -91,7 +91,7 @@ The best way to get quick responses to your issues and swift fixes to your bugs ## Donate -[Click here to lend your support to Middleman](https://spacebox.io/s/4dXbHBorC3) +[Click here to lend your support to Middleman](https://plasso.co/s/4dXbHBorC3) ## Versioning @@ -121,6 +121,6 @@ Copyright (c) 2010-2015 Thomas Reynolds. MIT Licensed, see [LICENSE] for details [codeclimate]: https://codeclimate.com/github/middleman/middleman [gittip]: https://www.gittip.com/middleman/ [rubyinstaller]: http://rubyinstaller.org/ -[RubyInstaller-Devkit]: http:rubyinstaller.org/add-ons/devkit/ +[RubyInstaller-Devkit]: http://rubyinstaller.org/add-ons/devkit/ [rubydoc]: http://rubydoc.info/github/middleman/middleman [LICENSE]: https://github.com/middleman/middleman/blob/master/LICENSE.md diff --git a/Rakefile b/Rakefile index 236a2d83..508c3a1d 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'rake' require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__) ROOT = File.expand_path(File.dirname(__FILE__)) -GEM_NAME = 'middleman' +GEM_NAME = 'middleman'.freeze middleman_gems = %w(middleman-core middleman-cli middleman) GEM_PATHS = middleman_gems.freeze @@ -36,7 +36,7 @@ end desc 'Generate documentation for all middleman gems' task :doc do GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" } + Dir.chdir(File.join(ROOT, g).to_s) { sh "#{Gem.ruby} -S rake yard" } end end @@ -45,14 +45,14 @@ task :test do Rake::Task['rubocop'].invoke GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" } + Dir.chdir(File.join(ROOT, g).to_s) { sh "#{Gem.ruby} -S rake test" } end end desc 'Run specs for all middleman gems' task :spec do GEM_PATHS.each do |g| - Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake spec" } + Dir.chdir(File.join(ROOT, g).to_s) { sh "#{Gem.ruby} -S rake spec" } end end diff --git a/middleman-cli/Rakefile b/middleman-cli/Rakefile index a7cd6621..db0d1cb8 100644 --- a/middleman-cli/Rakefile +++ b/middleman-cli/Rakefile @@ -1,4 +1,4 @@ # coding:utf-8 -RAKE_ROOT = __FILE__ -GEM_NAME = 'middleman-cli' +RAKE_ROOT = __FILE__.freeze +GEM_NAME = 'middleman-cli'.freeze require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman-cli/bin/middleman b/middleman-cli/bin/middleman index 165b7bc9..8b381a08 100755 --- a/middleman-cli/bin/middleman +++ b/middleman-cli/bin/middleman @@ -4,11 +4,37 @@ require 'middleman-core/profiling' if ARGV.include? '--profile' Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new end -Middleman::Profiling.start +# Middleman::Profiling.start require "middleman-core/load_paths" Middleman.setup_load_paths +require 'dotenv' +::Dotenv.load + +require 'middleman-core' +require 'middleman-core/logger' + +module Middleman::Cli + class << self + attr_accessor :config + end + + def self.import_config(base) + ::Middleman::Cli.config.all_settings.each do |setting| + if setting.default.is_a?(String) || setting.default.is_a?(NilClass) + base.class_option setting.key, + type: :string, + desc: setting.description + elsif setting.default.is_a?(TrueClass) || setting.default.is_a?(FalseClass) + base.class_option setting.key, + type: :boolean, + desc: setting.description + end + end + end +end + require "middleman-cli" # Change directory to the root @@ -19,5 +45,26 @@ if ARGV[0] != 'help' && (ARGV.length < 1 || ARGV.first.include?('-')) ARGV.unshift('server') end +::Middleman::Logger.singleton(3) +::Middleman::Cli.config = ::Middleman::Application.new do + # + config[:environment] = (ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development').to_sym + config[:mode] = :config + config[:exit_before_ready] = true + config[:watcher_disable] = true + config[:disable_sitemap] = true +end.config + +# Require the Middleman version +require 'middleman-core/version' + +# Include the core CLI items +require 'middleman-cli/init' +require 'middleman-cli/extension' +require 'middleman-cli/server' +require 'middleman-cli/build' +require 'middleman-cli/console' +require 'middleman-cli/config' + # Start the CLI Middleman::Cli::Base.start(ARGV) diff --git a/middleman-core/features/cli_extension.feature b/middleman-cli/features/cli_extension.feature similarity index 91% rename from middleman-core/features/cli_extension.feature rename to middleman-cli/features/cli_extension.feature index b762664c..5385a622 100644 --- a/middleman-core/features/cli_extension.feature +++ b/middleman-cli/features/cli_extension.feature @@ -9,6 +9,6 @@ Feature: Middleman New Extension CLI | Rakefile | | my-extension-library.gemspec | | features/support/env.rb | - | lib/middleman_extension.rb | + | lib/my-extension-library/extension.rb | | lib/my-extension-library.rb | | .gitignore | diff --git a/middleman-core/features/cli_init.feature b/middleman-cli/features/cli_init.feature similarity index 94% rename from middleman-core/features/cli_init.feature rename to middleman-cli/features/cli_init.feature index 52aa8f7b..96595422 100644 --- a/middleman-core/features/cli_init.feature +++ b/middleman-cli/features/cli_init.feature @@ -63,6 +63,10 @@ Feature: Middleman CLI And the file "Gemfile" should contain "middleman-blog" And the file ".gitignore" should exist + Scenario: Create an invalid project using Middleman directory + When I run `middleman init MY_PROJECT -T does-not-exist-for-reals` + Then the exit status should be 1 + Scenario: Create a new project using github(user/repository) When I run `middleman init MY_PROJECT -T middleman/middleman-templates-default` interactively And I type "y" diff --git a/middleman-core/features/cli/preview_server-hook.feature b/middleman-cli/features/preview_server-hook.feature similarity index 100% rename from middleman-core/features/cli/preview_server-hook.feature rename to middleman-cli/features/preview_server-hook.feature diff --git a/middleman-core/features/cli/preview_server.feature b/middleman-cli/features/preview_server.feature similarity index 99% rename from middleman-core/features/cli/preview_server.feature rename to middleman-cli/features/preview_server.feature index ab65683e..94ecc5b2 100644 --- a/middleman-core/features/cli/preview_server.feature +++ b/middleman-cli/features/preview_server.feature @@ -42,7 +42,7 @@ Feature: Run the preview server Inspect your site configuration at "http:// """ - @ruby-2.1 + @wip Scenario: Start the server with defaults in verbose mode, when a local mdns server resolves the local hostname Given I start a mdns server for the local hostname When I run `middleman server --verbose` interactively @@ -115,6 +115,7 @@ Feature: Run the preview server Inspect your site configuration at "http://127.0.0.1:4567/__middleman" """ + @wip Scenario: Start the server with bind address 127.0.0.5 This will have no hostname attached because the hosts file, the DNS server @@ -359,7 +360,6 @@ Feature: Run the preview server The Middleman preview server is bound to ":::65432", "0.0.0.0:65432" """ - @ruby-2.1 @wip Scenario: Start the server when port is blocked by other middleman instance Given `middleman server` is running in background @@ -469,7 +469,8 @@ Feature: Run the preview server Inspect your site configuration at "http://www.example.com:4567/__middleman", "http://127.0.0.1:4567/__middleman" """ - @ruby-2.1 + @ruby-2.1 + @wip Scenario: Start the server with server name "host.local" and the link local name server is used to resolve the server name To make the mdns resolver resolve a name, it needs to end with ".local". @@ -501,7 +502,8 @@ Feature: Run the preview server Inspect your site configuration at "http://host.local:4567/__middleman", "http://127.0.0.1:4567/__middleman" """ - @ruby-2.1 + @ruby-2.1 + @wip Scenario: Start the server with server name "host" and the link local name server is used to resolve the server name To make the mdns resolver resolve a name, it needs to end with ".local". If diff --git a/middleman-cli/features/support/env.rb b/middleman-cli/features/support/env.rb new file mode 100644 index 00000000..8044deab --- /dev/null +++ b/middleman-cli/features/support/env.rb @@ -0,0 +1,19 @@ +ENV["TEST"] = "true" + +require 'sassc' + +require 'simplecov' +SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/../..')) + +require 'phantomjs/poltergeist' +Capybara.javascript_driver = :poltergeist + +require 'coveralls' +Coveralls.wear! + +require 'codeclimate-test-reporter' +CodeClimate::TestReporter.start + +PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__))) +require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-cli') +require File.join(File.dirname(PROJECT_ROOT_PATH), 'middleman-core', 'lib', 'middleman-core', 'step_definitions') diff --git a/middleman-core/fixtures/preview-server-app/bin/dns_server.rb b/middleman-cli/fixtures/preview-server-app/bin/dns_server.rb similarity index 100% rename from middleman-core/fixtures/preview-server-app/bin/dns_server.rb rename to middleman-cli/fixtures/preview-server-app/bin/dns_server.rb diff --git a/middleman-core/fixtures/preview-server-app/config.rb b/middleman-cli/fixtures/preview-server-app/config.rb similarity index 100% rename from middleman-core/fixtures/preview-server-app/config.rb rename to middleman-cli/fixtures/preview-server-app/config.rb diff --git a/middleman-core/fixtures/preview-server-app/source/index.html.erb b/middleman-cli/fixtures/preview-server-app/source/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/index.html.erb rename to middleman-cli/fixtures/preview-server-app/source/index.html.erb diff --git a/middleman-core/fixtures/preview-server-app/source/layout.erb b/middleman-cli/fixtures/preview-server-app/source/layout.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/layout.erb rename to middleman-cli/fixtures/preview-server-app/source/layout.erb diff --git a/middleman-core/fixtures/preview-server-app/source/layouts/custom.erb b/middleman-cli/fixtures/preview-server-app/source/layouts/custom.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/layouts/custom.erb rename to middleman-cli/fixtures/preview-server-app/source/layouts/custom.erb diff --git a/middleman-core/fixtures/preview-server-app/source/real.html b/middleman-cli/fixtures/preview-server-app/source/real.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/real.html rename to middleman-cli/fixtures/preview-server-app/source/real.html diff --git a/middleman-core/fixtures/preview-server-app/source/real/index.html.erb b/middleman-cli/fixtures/preview-server-app/source/real/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/real/index.html.erb rename to middleman-cli/fixtures/preview-server-app/source/real/index.html.erb diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored.html diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored2.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored2.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored2.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored2.html diff --git a/middleman-core/fixtures/preview-server-app/source/should_be_ignored3.html b/middleman-cli/fixtures/preview-server-app/source/should_be_ignored3.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/should_be_ignored3.html rename to middleman-cli/fixtures/preview-server-app/source/should_be_ignored3.html diff --git a/middleman-core/fixtures/preview-server-app/source/static.html b/middleman-cli/fixtures/preview-server-app/source/static.html similarity index 100% rename from middleman-core/fixtures/preview-server-app/source/static.html rename to middleman-cli/fixtures/preview-server-app/source/static.html diff --git a/middleman-core/fixtures/preview-server-hook-app/config.rb b/middleman-cli/fixtures/preview-server-hook-app/config.rb similarity index 100% rename from middleman-core/fixtures/preview-server-hook-app/config.rb rename to middleman-cli/fixtures/preview-server-hook-app/config.rb diff --git a/middleman-core/fixtures/preview-server-hook-app/source/index.html.erb b/middleman-cli/fixtures/preview-server-hook-app/source/index.html.erb similarity index 100% rename from middleman-core/fixtures/preview-server-hook-app/source/index.html.erb rename to middleman-cli/fixtures/preview-server-hook-app/source/index.html.erb diff --git a/middleman-cli/lib/middleman-cli.rb b/middleman-cli/lib/middleman-cli.rb index 83b95d30..e17137e7 100644 --- a/middleman-cli/lib/middleman-cli.rb +++ b/middleman-cli/lib/middleman-cli.rb @@ -21,14 +21,3 @@ module Middleman::Cli end end end - -# Require the Middleman version -require 'middleman-core/version' - -# Include the core CLI items -require 'middleman-cli/init' -require 'middleman-cli/extension' -require 'middleman-cli/server' -require 'middleman-cli/build' -require 'middleman-cli/console' -require 'middleman-cli/config' diff --git a/middleman-cli/lib/middleman-cli/build.rb b/middleman-cli/lib/middleman-cli/build.rb index cf2d58a8..9e521dde 100644 --- a/middleman-cli/lib/middleman-cli/build.rb +++ b/middleman-cli/lib/middleman-cli/build.rb @@ -1,3 +1,5 @@ +require 'middleman-core/application' + # CLI Module module Middleman::Cli # The CLI Build class @@ -8,12 +10,15 @@ module Middleman::Cli class_option :environment, aliases: '-e', - default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'production', - desc: 'The environment Middleman will run under' + default: ENV['MM_ENV'] || ENV['RACK_ENV'] || :production class_option :clean, type: :boolean, default: true, desc: 'Remove orphaned files from build (--no-clean to disable)' + class_option :parallel, + type: :boolean, + default: true, + desc: 'Output files in parallel (--no-parallel to disable)' class_option :glob, type: :string, aliases: '-g', @@ -24,7 +29,7 @@ module Middleman::Cli default: false, desc: 'Print debug messages' class_option :instrument, - type: :string, + type: :boolean, default: false, desc: 'Print instrument messages' class_option :profile, @@ -32,6 +37,8 @@ module Middleman::Cli default: false, desc: 'Generate profiling report for the build' + Middleman::Cli.import_config(self) + # Core build Thor command # @return [void] def build @@ -44,35 +51,44 @@ module Middleman::Cli require 'middleman-core/builder' require 'fileutils' - env = options['environment'].to_sym verbose = options['verbose'] ? 0 : 1 instrument = options['instrument'] - @app = ::Middleman::Application.new do - config[:mode] = :build - config[:environment] = env - config[:show_exceptions] = false - ::Middleman::Logger.singleton(verbose, instrument) + builder = nil + cli_options = options + + ::Middleman::Logger.singleton(verbose, instrument) + + ::Middleman::Util.instrument 'builder.setup' do + @app = ::Middleman::Application.new do + config[:mode] = :build + config[:show_exceptions] = false + config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum| + sum[k] = v + end + end + + builder = Middleman::Builder.new(@app, + glob: options['glob'], + clean: options['clean'], + parallel: options['parallel']) + builder.thor = self + builder.on_build_event(&method(:on_event)) end - builder = Middleman::Builder.new(@app, - glob: options['glob'], - clean: options['clean'], - parallel: options['parallel']) - builder.thor = self - builder.on_build_event(&method(:on_event)) + ::Middleman::Util.instrument 'builder.run' do + if builder.run! + clean_directories! if options['clean'] + shell.say 'Project built successfully.' + else + msg = 'There were errors during this build' + unless options['verbose'] + msg << ', re-run with `middleman build --verbose` to see the full exception.' + end + shell.say msg, :red - if builder.run! - clean_directories! if options['clean'] - shell.say "Project built successfully." - else - msg = 'There were errors during this build' - unless options['verbose'] - msg << ', re-run with `middleman build --verbose` to see the full exception.' + exit(1) end - shell.say msg, :red - - exit(1) end end diff --git a/middleman-cli/lib/middleman-cli/config.rb b/middleman-cli/lib/middleman-cli/config.rb index 902ea216..add8730a 100644 --- a/middleman-cli/lib/middleman-cli/config.rb +++ b/middleman-cli/lib/middleman-cli/config.rb @@ -23,6 +23,9 @@ module Middleman::Cli ::Middleman::Logger.singleton(2, false) app = ::Middleman::Application.new do + config[:mode] = :config + config[:disable_sitemap] = true + config[:watcher_disable] = true config[:exit_before_ready] = true config[:environment] = opts[:environment].to_sym if opts[:environment] end diff --git a/middleman-cli/lib/middleman-cli/extension.rb b/middleman-cli/lib/middleman-cli/extension.rb index 1b079f4d..69e073fb 100644 --- a/middleman-cli/lib/middleman-cli/extension.rb +++ b/middleman-cli/lib/middleman-cli/extension.rb @@ -30,8 +30,8 @@ module Middleman::Cli template 'extension/Rakefile', File.join(name, 'Rakefile') template 'extension/gemspec', File.join(name, "#{name}.gemspec") template 'extension/Gemfile', File.join(name, 'Gemfile') - template 'extension/lib/middleman_extension.rb', File.join(name, 'lib', 'middleman_extension.rb') template 'extension/lib/lib.rb', File.join(name, 'lib', "#{name}.rb") + template 'extension/lib/lib/extension.rb', File.join(name, 'lib', name, 'extension.rb') template 'extension/features/support/env.rb', File.join(name, 'features', 'support', 'env.rb') empty_directory File.join(name, 'fixtures') end diff --git a/middleman-cli/lib/middleman-cli/init.rb b/middleman-cli/lib/middleman-cli/init.rb index 5bdfb6e3..e8e5770c 100644 --- a/middleman-cli/lib/middleman-cli/init.rb +++ b/middleman-cli/lib/middleman-cli/init.rb @@ -4,6 +4,8 @@ module Middleman::Cli class Init < Thor::Group include Thor::Actions + GIT_CMD = 'git'.freeze + check_unknown_options! argument :target, type: :string, default: '.' @@ -25,6 +27,13 @@ module Middleman::Cli require 'fileutils' require 'tmpdir' + unless git_present? + msg = 'You need to install the git command line tool to initialize a new project. ' + msg << "For help installing git, please refer to GitHub's tutorial at https://help.github.com/articles/set-up-git" + say msg, :red + exit 1 + end + repo_path, repo_branch = if shortname?(options[:template]) require 'open-uri' require 'json' @@ -39,7 +48,7 @@ module Middleman::Cli rescue ::OpenURI::HTTPError say "Template `#{options[:template]}` not found in Middleman Directory." say 'Did you mean to use a full `user/repo` path?' - exit + exit 1 end else repo_name, repo_branch = options[:template].split('#') @@ -51,11 +60,12 @@ module Middleman::Cli begin branch_cmd = repo_branch ? "-b #{repo_branch} " : '' - run("git clone --depth 1 #{branch_cmd}#{repo_path} #{dir}") + git_path = "#{branch_cmd}#{repo_path}" + run("#{GIT_CMD} clone --depth 1 #{branch_cmd}#{repo_path} #{dir}") - unless File.directory?(dir) - say 'Git clone failed, maybe the url is invalid or you don\'t have the permissions?', :red - exit + unless $?.success? + say "Git clone command failed. Make sure git repository exists: #{git_path}", :red + exit 1 end inside(target) do @@ -79,12 +89,31 @@ module Middleman::Cli protected + # Copied from Bundler + def git_present? + return @git_present if defined?(@git_present) + @git_present = which(GIT_CMD) || which('git.exe') + end + + # Copied from Bundler + def which(executable) + if File.file?(executable) && File.executable?(executable) + executable + elsif ENV['PATH'] + path = ENV['PATH'].split(File::PATH_SEPARATOR).find do |p| + abs_path = File.join(p, executable) + File.file?(abs_path) && File.executable?(abs_path) + end + path && File.expand_path(executable, path) + end + end + def shortname?(repo) repo.split('/').length == 1 end def repository_path(repo) - repo.include?('://') || repo.include?('git@') ? repo : "git://github.com/#{repo}.git" + repo.include?('://') || repo.include?('git@') ? repo : "https://github.com/#{repo}.git" end # Add to CLI diff --git a/middleman-cli/lib/middleman-cli/server.rb b/middleman-cli/lib/middleman-cli/server.rb index ab387ee6..85e75a9f 100644 --- a/middleman-cli/lib/middleman-cli/server.rb +++ b/middleman-cli/lib/middleman-cli/server.rb @@ -5,56 +5,33 @@ module Middleman::Cli check_unknown_options! class_option :environment, - aliases: '-e', - default: ENV['MM_ENV'] || ENV['RACK_ENV'] || 'development', - desc: 'The environment Middleman will run under' + aliases: '-e' class_option :port, - aliases: '-p', - desc: 'The port Middleman will listen on' + aliases: '-p' class_option :server_name, - aliases: '-s', - desc: 'The server name Middleman will use' + aliases: '-s' class_option :bind_address, - aliases: '-b', - desc: 'The bind address Middleman will listen on' - class_option :https, - type: :boolean, - desc: 'Serve the preview server over SSL/TLS' - class_option :ssl_certificate, - desc: 'Path to an X.509 certificate to use for the preview server' - class_option :ssl_private_key, - desc: "Path to an RSA private key for the preview server's certificate" + aliases: '-b' class_option :verbose, type: :boolean, default: false, desc: 'Print debug messages' class_option :instrument, - type: :string, - default: false, - desc: 'Print instrument messages' - class_option :disable_watcher, type: :boolean, default: false, - desc: 'Disable the file change and delete watcher process' + desc: 'Print instrument messages' class_option :profile, type: :boolean, default: false, desc: 'Generate profiling report for server startup' - class_option :force_polling, - type: :boolean, - default: false, - desc: 'Force file watcher into polling mode' - class_option :latency, - type: :numeric, - aliases: '-l', - default: 0.5, - desc: 'Set file watcher latency, in seconds' class_option :daemon, type: :boolean, aliases: '-d', default: false, desc: 'Daemonize preview server' + Middleman::Cli.import_config(self) + # Start the server def server require 'middleman-core' @@ -66,24 +43,14 @@ module Middleman::Cli end params = { - port: options['port'], - bind_address: options['bind_address'], - https: options['https'], - server_name: options['server_name'], - ssl_certificate: options['ssl_certificate'], - ssl_private_key: options['ssl_private_key'], - environment: options['environment'], debug: options['verbose'], instrumenting: options['instrument'], - disable_watcher: options['disable_watcher'], reload_paths: options['reload_paths'], - force_polling: options['force_polling'], - latency: options['latency'], daemon: options['daemon'] } puts '== The Middleman is loading' - ::Middleman::PreviewServer.start(params) + ::Middleman::PreviewServer.start(params, options) end # Add to CLI diff --git a/middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb b/middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb index 8a3c5dc6..48038a71 100644 --- a/middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb +++ b/middleman-cli/lib/middleman-cli/templates/extension/lib/lib.rb @@ -1,38 +1,6 @@ -# Require core library -require 'middleman-core' +require "middleman-core" -# Extension namespace -class MyExtension < ::Middleman::Extension - option :my_option, 'default', 'An example option' - - def initialize(app, options_hash={}, &block) - # Call super to build options from the options_hash - super - - # Require libraries only when activated - # require 'necessary/library' - - # set up your extension - # puts options.my_option - end - - def after_configuration - # Do something - end - - # A Sitemap Manipulator - # def manipulate_resource_list(resources) - # end - - # helpers do - # def a_helper - # end - # end +Middleman::Extensions.register :<%= name %> do + require "my-extension/extension" + MyExtension end - -# Register extensions which can be activated -# Make sure we have the version of Middleman we expect -# Name param may be omited, it will default to underscored -# version of class name - -# MyExtension.register(:my_extension) diff --git a/middleman-cli/lib/middleman-cli/templates/extension/lib/lib/extension.rb b/middleman-cli/lib/middleman-cli/templates/extension/lib/lib/extension.rb new file mode 100644 index 00000000..f831386f --- /dev/null +++ b/middleman-cli/lib/middleman-cli/templates/extension/lib/lib/extension.rb @@ -0,0 +1,31 @@ +# Require core library +require 'middleman-core' + +# Extension namespace +class MyExtension < ::Middleman::Extension + option :my_option, 'default', 'An example option' + + def initialize(app, options_hash={}, &block) + # Call super to build options from the options_hash + super + + # Require libraries only when activated + # require 'necessary/library' + + # set up your extension + # puts options.my_option + end + + def after_configuration + # Do something + end + + # A Sitemap Manipulator + # def manipulate_resource_list(resources) + # end + + # helpers do + # def a_helper + # end + # end +end diff --git a/middleman-cli/lib/middleman-cli/templates/extension/lib/middleman_extension.rb b/middleman-cli/lib/middleman-cli/templates/extension/lib/middleman_extension.rb deleted file mode 100644 index 6fba3c06..00000000 --- a/middleman-cli/lib/middleman-cli/templates/extension/lib/middleman_extension.rb +++ /dev/null @@ -1 +0,0 @@ -require '<%= name %>' diff --git a/middleman-cli/middleman-cli.gemspec b/middleman-cli/middleman-cli.gemspec index 05f5c456..e9447a9c 100644 --- a/middleman-cli/middleman-cli.gemspec +++ b/middleman-cli/middleman-cli.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0") s.executable = 'middleman' s.require_path = 'lib' - s.required_ruby_version = '>= 1.9.3' + s.required_ruby_version = '>= 2.2.0' # CLI s.add_dependency('thor', ['>= 0.17.0', '< 2.0']) diff --git a/middleman-core/Rakefile b/middleman-core/Rakefile index 3efd63ea..198f09ee 100644 --- a/middleman-core/Rakefile +++ b/middleman-core/Rakefile @@ -1,4 +1,4 @@ # coding:utf-8 -RAKE_ROOT = __FILE__ +RAKE_ROOT = __FILE__.freeze GEM_NAME = ENV['NAME'] || 'middleman-core' require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper') diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index 4e9b293d..7c173800 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -63,22 +63,29 @@ Feature: Assets get file hashes appended to them and references to them are upda Given the Server is running at "asset-hash-app" When I go to "/" Then I should see 'href="apple-touch-icon.png"' - And I should see 'href="stylesheets/site-d2959d87.css"' + And I should see 'href="stylesheets/site-d1a750ca.css"' + And I should see 'href="stylesheets/fragment-99b76247.css"' And I should see 'src="javascripts/application-1d8d5276.js"' And I should see 'src="images/100px-5fd6fb90.jpg"' And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"' + And I should see 'src="images/100px-5fd6fb90.jpg?test"' + And I should see 'src="images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="images/100px-5fd6fb90.jpg#test"' When I go to "/subdir/" - Then I should see 'href="../stylesheets/site-d2959d87.css"' + Then I should see 'href="../stylesheets/site-d1a750ca.css"' And I should see 'src="../javascripts/application-1d8d5276.js"' And I should see 'src="../images/100px-5fd6fb90.jpg"' When I go to "/other/" - Then I should see 'href="../stylesheets/site-d2959d87.css"' + Then I should see 'href="../stylesheets/site-d1a750ca.css"' And I should see 'src="../javascripts/application-1d8d5276.js"' And I should see 'src="../images/100px-5fd6fb90.jpg"' + And I should see 'src="../images/100px-5fd6fb90.jpg?test"' + And I should see 'src="../images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="../images/100px-5fd6fb90.jpg#test"' When I go to "/javascripts/application-1d8d5276.js" Then I should see "img.src = '/images/100px-5fd6fb90.jpg'" - When I go to "/stylesheets/site-d2959d87.css" - Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")' + When I go to "/stylesheets/site-d1a750ca.css" + Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg");' When I go to "/api.json" Then I should see 'images/100px-5fd6fb90.gif' And I should see 'images/100px-5fd6fb90.jpg' @@ -87,6 +94,11 @@ Feature: Assets get file hashes appended to them and references to them are upda Then I should see 'images/100px-5fd6fb90.gif' And I should see 'images/100px-5fd6fb90.jpg' And I should see 'images/100px-1242c368.png' + When I go to "/stylesheets/fragment-99b76247.css" + And I should see 'url("../images/100px-5fd6fb90.jpg");' + And I should see 'url("../images/100px-5fd6fb90.jpg?test");' + And I should see 'url("../images/100px-5fd6fb90.jpg?#test");' + And I should see 'url("../images/100px-5fd6fb90.jpg#test");' Scenario: Hashed assets work with Slim Given the Server is running at "asset-hash-app" @@ -95,17 +107,69 @@ Feature: Assets get file hashes appended to them and references to them are upda And I should see 'src="images/100px-5fd6fb90.jpg"' And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"' - Scenario: Enabling an asset host still produces hashed files and references + Scenario: Enabling an asset host still produces hashed files and references (hash first) + Given a fixture app "asset-hash-host-app" + And a file named "config.rb" with: + """ + set :sass_source_maps, false + activate :asset_hash + activate :directory_indexes + activate :asset_host, host: 'http://middlemanapp.com' + """ Given the Server is running at "asset-hash-host-app" When I go to "/" - Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"' + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' + Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-2902933e.css"' And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"' When I go to "/subdir/" - Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"' + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' When I go to "/other/" - Then I should see 'href="http://middlemanapp.com/stylesheets/site-e587b659.css"' + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"' + When I go to "/stylesheets/fragment-2902933e.css" + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg");' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test");' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test");' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg#test");' + + Scenario: Enabling an asset host still produces hashed files and references (host first) + Given a fixture app "asset-hash-host-app" + And a file named "config.rb" with: + """ + set :sass_source_maps, false + activate :asset_host, host: 'http://middlemanapp.com' + activate :directory_indexes + activate :asset_hash + """ + Given the Server is running at "asset-hash-host-app" + When I go to "/" + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' + Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-2902933e.css"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"' + When I go to "/subdir/" + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' + When I go to "/other/" + Then I should see 'href="http://middlemanapp.com/stylesheets/site-7474cadd.css"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"' + And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"' + When I go to "/stylesheets/fragment-2902933e.css" + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test")' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test")' + And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg#test")' Scenario: The asset hash should change when a SASS partial changes Given the Server is running at "asset-hash-app" @@ -115,14 +179,14 @@ Feature: Assets get file hashes appended to them and references to them are upda font-size: 14px """ When I go to "/partials/" - Then I should see 'href="../stylesheets/uses_partials-44fb2764.css' + Then I should see 'href="../stylesheets/uses_partials-4d4e34e6.css' And the file "source/stylesheets/_partial.sass" has the contents """ body font-size: 18px !important """ When I go to "/partials/" - Then I should see 'href="../stylesheets/uses_partials-10d8ae33.css' + Then I should see 'href="../stylesheets/uses_partials-ec347271.css' Scenario: The asset hash should change when a Rack-based filter changes Given a fixture app "asset-hash-app" @@ -136,12 +200,10 @@ Feature: Assets get file hashes appended to them and references to them are upda """ Given the Server is running at "asset-hash-app" When I go to "/" - Then I should see 'href="stylesheets/site-30784643.css' - When I go to "stylesheets/site-30784643.css" - Then I should see 'background-image' + Then I should see 'href="stylesheets/site-5ad7def0.css' + When I go to "stylesheets/site-5ad7def0.css" + Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")' Then I should see 'Added by Rack filter' - When I go to "stylesheets/site-7474cadd.css" - Then I should see 'Not Found' Scenario: Hashed-asset files are not produced for ignored paths Given a fixture app "asset-hash-app" @@ -179,10 +241,84 @@ Feature: Assets get file hashes appended to them and references to them are upda | javascripts/application-1d8d5276.js | | stylesheets/site-7474cadd.css | + Scenario: Hashed-asset files are not replaced for rewrite ignored paths + Given a fixture app "asset-hash-app" + And a file named "config.rb" with: + """ + is_stylesheet = proc { |path| path.start_with? '/stylesheets' } + activate :asset_hash, rewrite_ignore: [ + %r(javascripts/*), + '/subdir/*', + is_stylesheet + ] + activate :relative_assets + activate :directory_indexes + """ + And a successfully built app at "asset-hash-app" + When I cd to "build" + Then the following files should exist: + | index.html | + | subdir/index.html | + | images/100px-5fd6fb90.jpg | + | javascripts/application-1d8d5276.js | + | stylesheets/site-8bc55985.css | + And the following files should not exist: + | images/100px.jpg | + | javascripts/application.js | + | stylesheets/site.css | + And the file "javascripts/application-1d8d5276.js" should contain "img.src = '/images/100px.jpg'" + And the file "stylesheets/site-8bc55985.css" should contain: + """ + background-image: url("../images/100px.jpg") + """ + And the file "index.html" should contain 'href="stylesheets/site-8bc55985.css"' + And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"' + And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"' + And the file "subdir/index.html" should contain: + """ +
paragraph
" + + + Scenario: Markdown filter in Slim uses our link_to and image_tag helpers + Given a fixture app "markdown-in-slim-app" + And a file named "config.rb" with: + """ + set :markdown_engine, :redcarpet + activate :directory_indexes + """ + And a file named "source/link_and_image.html.slim" with: + """ + markdown: + [A link](/link_target.html) + +  + """ + Given the Server is running at "markdown-in-slim-app" + When I go to "/link_and_image/" + Then I should see "/link_target/" + Then I should see 'src="/images/blank.gif"' diff --git a/middleman-core/features/nested_layouts.feature b/middleman-core/features/nested_layouts.feature index d70a7e23..f51831fb 100644 --- a/middleman-core/features/nested_layouts.feature +++ b/middleman-core/features/nested_layouts.feature @@ -5,37 +5,37 @@ Feature: Allow nesting of layouts When I go to "/index.html" Then I should see: """ - Master + Master ErbThe Article Content
""" - + Scenario: A page uses an inner layout when uses an outer layout (slim) Given the Server is running at "nested-layout-app" When I go to "/slim-test.html" - Then I should see "New Article Title
The Article Content
" - + Then I should see "New Article Title
The Article Content
" + Scenario: A page uses an inner layout when uses an outer layout (haml) Given the Server is running at "nested-layout-app" When I go to "/haml-test.html" Then I should see: """ - Master + Master HamlThe Article Content
""" @@ -43,13 +43,16 @@ Feature: Allow nesting of layouts Given the Server is running at "nested-layout-app" When I go to "/data-one.html" Then I should see "Page Number One" - And I should see "Inner" + And I should see "Page #1" + And I should see "I am Inner" + And I should see "I am Outer" + And I should see "Master Erb" When I go to "/data-two.html" Then I should see "Page Number Two" - And I should not see "Inner" + And I should not see "I am Inner" When I go to "/data-one.html" Then I should see "Page Number One" - And I should see "Inner" + And I should see "I am Inner" When I go to "/data-two.html" Then I should see "Page Number Two" - And I should not see "Inner" + And I should not see "I am Inner" diff --git a/middleman-core/features/page-id.feature b/middleman-core/features/page-id.feature new file mode 100644 index 00000000..74d08cb5 --- /dev/null +++ b/middleman-core/features/page-id.feature @@ -0,0 +1,72 @@ +Feature: Page IDs + + Scenario: link_to works with blocks (erb) + Given the Server is running at "page-id-app" + When I go to "/index.html" + Then I should see "I am: index" + And I should see "URL1: /fm.html" + And I should see "URL2: /2.html" + And I should see 'URL3: Hi' + And I should see 'URL4: Sym' + And I should see 'URL5: Imp' + And I should see 'URL6: Foldern' + And I should see 'URL7: Feed' + + When I go to "/fm.html" + Then I should see "I am: frontmatter" + When I go to "/implicit.html" + Then I should see "I am: implicit" + When I go to "/feed.xml" + Then I should see "I am: feed.xml" + When I go to "/folder/foldern.html" + Then I should see "I am: folder/foldern" + + When I go to "/1.html" + Then I should see "I am: page1" + When I go to "/2.html" + Then I should see "I am: page2" + When I go to "/3.html" + Then I should see "I am: page3" + + When I go to "/overwrites/from-default.html" + Then I should see "I am: something-else" + + When I go to "/overwrites/from-frontmatter.html" + Then I should see "I am: from_frontmatter" + + Scenario: Override page ID derivation with a proc + Given a fixture app "page-id-app" + And app "page-id-app" is using config "proc" + And the Server is running at "page-id-app" + + When I go to "/index.html" + Then I should see "I am: index.html-foo" + And I should see "URL1: /fm.html" + And I should see "URL2: /2.html" + And I should see 'URL3: Hi' + And I should see 'URL4: Sym' + And I should see 'URL8: Imp' + And I should see 'URL9: Foldern' + And I should see 'URL10: Feed' + + When I go to "/fm.html" + Then I should see "I am: frontmatter" + When I go to "/implicit.html" + Then I should see "I am: implicit.html-foo" + When I go to "/feed.xml" + Then I should see "I am: feed.xml-foo" + When I go to "/folder/foldern.html" + Then I should see "I am: folder/foldern.html-foo" + + When I go to "/1.html" + Then I should see "I am: page1" + When I go to "/2.html" + Then I should see "I am: page2" + When I go to "/3.html" + Then I should see "I am: page3" + + When I go to "/overwrites/from-default.html" + Then I should see "I am: something-else" + + When I go to "/overwrites/from-frontmatter.html" + Then I should see "I am: from_frontmatter" diff --git a/middleman-core/features/partials.feature b/middleman-core/features/partials.feature index 86509027..8a0154c2 100644 --- a/middleman-core/features/partials.feature +++ b/middleman-core/features/partials.feature @@ -5,25 +5,30 @@ Feature: Provide Sane Defaults for Partial Behavior When I go to "/index.html" Then I should see "Header" And I should see "Footer" - + Scenario: Finds shared partials relative to the root (sub) Given the Server is running at "partials-app" When I go to "/sub/index.html" Then I should see "Header" And I should see "Footer" - + + Scenario: Flags error when partial is not found + Given the Server is running at "partials-app" + When I go to "/index_missing.html" + Then I should see "Error: Could not locate partial" + Scenario: Prefers partials of the same engine type Given the Server is running at "partials-app" When I go to "/index.html" Then I should see "ERb Main" - + Scenario: Prefers partials of the same engine type Given the Server is running at "partials-app" When I go to "/second.html" Then I should see "Str Main" And I should see "Header" And I should see "Footer" - + Scenario: Finds partial relative to template Given the Server is running at "partials-app" When I go to "/sub/index.html" @@ -33,7 +38,7 @@ Feature: Provide Sane Defaults for Partial Behavior Given the Server is running at "partials-app" When I go to "/locals.html" Then I should see "Local var is bar" - + Scenario: Partial and Layout use different engines Given the Server is running at "different-engine-partial" When I go to "/index.html" @@ -50,3 +55,10 @@ Feature: Provide Sane Defaults for Partial Behavior Then I should see "File Not Found" When I go to "/_code_snippet.html" Then I should see "File Not Found" + +Scenario: Works with blocks + Given the Server is running at "partials-app" + When I go to "/block.html" + Then I should see "Start" + And I should see "Contents" + And I should see "End" diff --git a/middleman-core/features/relative_assets.feature b/middleman-core/features/relative_assets.feature index 0f782761..ba131396 100644 --- a/middleman-core/features/relative_assets.feature +++ b/middleman-core/features/relative_assets.feature @@ -41,6 +41,11 @@ Feature: Relative Assets And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff' And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf' And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg' + When I go to "/stylesheets/fonts2.css" + Then I should see 'url(../fonts/roboto/roboto-regular-webfont.eot' + And I should see 'url(../fonts/roboto/roboto-regular-webfont.woff' + And I should see 'url(../fonts/roboto/roboto-regular-webfont.ttf' + And I should see 'url(../fonts/roboto/roboto-regular-webfont.svg' Scenario: Building css with the feature enabled Given a fixture app "relative-assets-app" @@ -115,7 +120,7 @@ Feature: Relative Assets """ And the Server is running at "relative-assets-app" When I go to "/sub/image_tag.html" - Then I should see '