Compare commits
50 commits
Author | SHA1 | Date | |
---|---|---|---|
|
37845e89c0 | ||
|
9dc144e9f7 | ||
|
67f612a082 | ||
|
18b12eedcf | ||
|
fe74824651 | ||
|
30335091c8 | ||
|
fe4d3a4bb3 | ||
|
78fb92d497 | ||
|
e86110f506 | ||
|
2ee07bdcb6 | ||
|
02d25ee883 | ||
|
4e9ae8cc42 | ||
|
1d2126b9f7 | ||
|
741caab546 | ||
|
90d386079d | ||
|
77dad2a400 | ||
|
d67e5f512b | ||
|
575423628d | ||
|
c9bb4540b3 | ||
|
1c94fe989c | ||
|
097d19eaca | ||
|
807bb3264c | ||
|
8dbd35938d | ||
|
ec30622dc3 | ||
|
601653b766 | ||
|
c2f0db0951 | ||
|
3d88530925 | ||
|
5f69431a74 | ||
|
a4807496ed | ||
|
546cadf4fd | ||
|
db1e8b8611 | ||
|
58e794645b | ||
|
492281f9e8 | ||
|
4d46b84aae | ||
|
b9cdc2bba4 | ||
|
3a7848da9e | ||
|
8292bc9899 | ||
|
9a529cd294 | ||
|
529bcca927 | ||
|
5a4d7352f1 | ||
|
99c2362ee8 | ||
|
65a65b9677 | ||
|
a064ba93b3 | ||
|
2aac804e92 | ||
|
2870647097 | ||
|
41255e6727 | ||
|
c09b15a895 | ||
|
10feaad451 | ||
|
fa3a95fa23 | ||
|
2b449bc398 |
61 changed files with 557 additions and 234 deletions
|
@ -1,6 +1,14 @@
|
||||||
master
|
master
|
||||||
===
|
===
|
||||||
|
|
||||||
|
3.4.1
|
||||||
|
===
|
||||||
|
|
||||||
|
* Adapt to upstream hooks API change, fixing `after_render` hook bugs. (#1658)
|
||||||
|
* Add a bunch of requires to help Windows users.
|
||||||
|
* Refator Data Loader to prevent middleman from crashing due to invalid data file. (#1633)
|
||||||
|
* Add `before_server` hook.
|
||||||
|
|
||||||
3.4.0
|
3.4.0
|
||||||
===
|
===
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ Ideally, a bug report should include a pull request with failing specs.
|
||||||
[gist]: https://gist.github.com/
|
[gist]: https://gist.github.com/
|
||||||
|
|
||||||
## Submitting a Pull Request
|
## Submitting a Pull Request
|
||||||
|
|
||||||
|
**WE DO NOT ACCEPT NEW FEATURES FOR THE V3 BRANCH ANYMORE**
|
||||||
|
|
||||||
1. [Fork the repository.][fork]
|
1. [Fork the repository.][fork]
|
||||||
2. Create a topic [branch]. `git checkout -b local_topic_branch`
|
2. Create a topic [branch]. `git checkout -b local_topic_branch`
|
||||||
3. Add specs for your unimplemented feature or bug fix.
|
3. Add specs for your unimplemented feature or bug fix.
|
||||||
|
|
6
Gemfile
6
Gemfile
|
@ -6,7 +6,7 @@ gem 'yard', '~> 0.8', require: false
|
||||||
|
|
||||||
# Test tools
|
# Test tools
|
||||||
gem 'pry', '~> 0.10', group: :development
|
gem 'pry', '~> 0.10', group: :development
|
||||||
gem 'aruba', '~> 0.7.4'
|
gem 'aruba', '~> 0.10.0'
|
||||||
gem 'rspec', '~> 3.0'
|
gem 'rspec', '~> 3.0'
|
||||||
gem 'cucumber', '~> 2.0'
|
gem 'cucumber', '~> 2.0'
|
||||||
|
|
||||||
|
@ -35,6 +35,6 @@ gem 'simplecov', '~> 0.10', require: false
|
||||||
gem 'coveralls', '~> 0.8', require: false
|
gem 'coveralls', '~> 0.8', require: false
|
||||||
|
|
||||||
# Middleman itself
|
# Middleman itself
|
||||||
gem 'middleman', path: 'middleman'
|
|
||||||
gem 'middleman-core', path: 'middleman-core'
|
gem 'middleman-core', path: 'middleman-core'
|
||||||
gem 'middleman-sprockets', github: 'middleman/middleman-sprockets', branch: 'v3-stable-real'
|
gem 'middleman', path: 'middleman'
|
||||||
|
gem 'middleman-sprockets', git: 'https://github.com/middleman/middleman-sprockets', branch: 'v3-stable-real'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2010-2014 Thomas Reynolds
|
Copyright (c) 2010-2015 Thomas Reynolds
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/middleman/middleman?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/middleman/middleman?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
**Middleman** is a static site generator using all the shortcuts and tools in modern web development. Check out [middlemanapp.com](http://middlemanapp.com/) for detailed tutorials, including a [getting started guide](http://middlemanapp.com/basics/getting-started/). You can also follow [@middlemanapp](https://twitter.com/middlemanapp) for updates.
|
**Middleman** is a static site generator using all the shortcuts and tools in modern web development. Check out [middlemanapp.com](http://middlemanapp.com/) for detailed tutorials, including a [getting started guide](https://middlemanapp.com/basics/install/). You can also follow [@middlemanapp](https://twitter.com/middlemanapp) for updates.
|
||||||
|
|
||||||
## Why Middleman?
|
## Why Middleman?
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ These days, many websites are built with an API in mind. Rather than package the
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Middleman is built on Ruby and uses the RubyGems package manager for installation. These are usually pre-installed on Mac OS X and Linux. Windows users can install both using [RubyInstaller].
|
Middleman is built on Ruby and uses the [RubyGems package manager] (https://rubygems.org/pages/download) for installation. These are usually pre-installed on Mac OS X and Linux. Windows users can install both using [RubyInstaller].
|
||||||
|
|
||||||
```
|
```
|
||||||
gem install middleman
|
gem install middleman
|
||||||
|
@ -91,7 +91,7 @@ The best way to get quick responses to your issues and swift fixes to your bugs
|
||||||
|
|
||||||
## Donate
|
## Donate
|
||||||
|
|
||||||
[Click here to lend your support to Middleman](https://spacebox.io/s/4dXbHBorC3)
|
Help support the Middleman team [with a donation](https://plasso.co/s/4dXbHBorC3).
|
||||||
|
|
||||||
## Versioning
|
## Versioning
|
||||||
|
|
||||||
|
|
32
Rakefile
32
Rakefile
|
@ -1,18 +1,17 @@
|
||||||
require 'rubygems' unless defined?(Gem)
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
|
|
||||||
require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__)
|
require 'middleman-core/version'
|
||||||
|
|
||||||
ROOT = File.expand_path(File.dirname(__FILE__))
|
|
||||||
GEM_NAME = 'middleman'
|
|
||||||
|
|
||||||
middleman_gems = %w(middleman-core middleman)
|
|
||||||
GEM_PATHS = middleman_gems.freeze
|
|
||||||
|
|
||||||
def sh_rake(command)
|
def sh_rake(command)
|
||||||
sh "#{Gem.ruby} -S rake #{command}", verbose: true
|
sh "#{Gem.ruby} -S rake #{command}", verbose: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def within_each_gem(&block)
|
||||||
|
%w(middleman-core middleman).each do |dir|
|
||||||
|
Dir.chdir(dir) { block.call }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
desc 'Displays the current version'
|
desc 'Displays the current version'
|
||||||
task :version do
|
task :version do
|
||||||
puts "Current version: #{Middleman::VERSION}"
|
puts "Current version: #{Middleman::VERSION}"
|
||||||
|
@ -29,32 +28,23 @@ end
|
||||||
desc 'Release all middleman gems'
|
desc 'Release all middleman gems'
|
||||||
task publish: :push do
|
task publish: :push do
|
||||||
puts 'Pushing to rubygems...'
|
puts 'Pushing to rubygems...'
|
||||||
GEM_PATHS.each do |dir|
|
within_each_gem { sh_rake('release') }
|
||||||
Dir.chdir(dir) { sh_rake('release') }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Generate documentation for all middleman gems'
|
desc 'Generate documentation for all middleman gems'
|
||||||
task :doc do
|
task :doc do
|
||||||
GEM_PATHS.each do |g|
|
within_each_gem { sh_rake('yard') }
|
||||||
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake yard" }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Run tests for all middleman gems'
|
desc 'Run tests for all middleman gems'
|
||||||
task :test do
|
task :test do
|
||||||
Rake::Task['rubocop'].invoke
|
Rake::Task['rubocop'].invoke
|
||||||
|
within_each_gem { sh_rake('test') }
|
||||||
GEM_PATHS.each do |g|
|
|
||||||
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Run specs for all middleman gems'
|
desc 'Run specs for all middleman gems'
|
||||||
task :spec do
|
task :spec do
|
||||||
GEM_PATHS.each do |g|
|
within_each_gem { sh_rake('spec') }
|
||||||
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake spec" }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
require 'rubocop/rake_task'
|
require 'rubocop/rake_task'
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'rubygems' unless defined?(Gem)
|
|
||||||
require 'rake'
|
require 'rake'
|
||||||
require 'yard'
|
require 'yard'
|
||||||
|
|
||||||
|
@ -24,14 +23,6 @@ Cucumber::Rake::Task.new do |t|
|
||||||
t.cucumber_opts = "--require features --color #{exempt_tags.join(' ')} --strict"# --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
t.cucumber_opts = "--require features --color #{exempt_tags.join(' ')} --strict"# --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
||||||
end
|
end
|
||||||
|
|
||||||
Cucumber::Rake::Task.new(:cucumber_wip) do |t|
|
|
||||||
exempt_tags = ['--tags @wip']
|
|
||||||
exempt_tags << '--tags ~@nojava' if RUBY_PLATFORM == 'java'
|
|
||||||
exempt_tags << '--tags ~@encoding' unless Object.const_defined?(:Encoding)
|
|
||||||
exempt_tags << '--tags ~@nowindows' if Gem.win_platform?
|
|
||||||
t.cucumber_opts = "--color #{exempt_tags.join(' ')} --strict"# --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'rspec/core/rake_task'
|
require 'rspec/core/rake_task'
|
||||||
desc 'Run RSpec'
|
desc 'Run RSpec'
|
||||||
RSpec::Core::RakeTask.new do |spec|
|
RSpec::Core::RakeTask.new do |spec|
|
||||||
|
@ -39,8 +30,12 @@ RSpec::Core::RakeTask.new do |spec|
|
||||||
spec.rspec_opts = ['--color', '--format documentation']
|
spec.rspec_opts = ['--color', '--format documentation']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test_tasks = []
|
||||||
|
test_tasks << :spec if Dir.exists? 'spec'
|
||||||
|
test_tasks << :cucumber if Dir.exists? 'features'
|
||||||
|
|
||||||
desc 'Run tests, both RSpec and Cucumber'
|
desc 'Run tests, both RSpec and Cucumber'
|
||||||
task test: [:spec, :cucumber]
|
task test: test_tasks
|
||||||
|
|
||||||
YARD::Rake::YardocTask.new
|
YARD::Rake::YardocTask.new
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
--color
|
|
|
@ -1,7 +1 @@
|
||||||
# coding:utf-8
|
require_relative '../gem_rake_helper'
|
||||||
RAKE_ROOT = __FILE__
|
|
||||||
|
|
||||||
GEM_NAME = ENV['NAME'] || 'middleman-core'
|
|
||||||
|
|
||||||
require 'rubygems'
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
|
|
||||||
|
|
|
@ -42,3 +42,21 @@ Feature: Build Clean
|
||||||
Then the following files should not exist:
|
Then the following files should not exist:
|
||||||
| sub/dir/about.html |
|
| sub/dir/about.html |
|
||||||
| sub/dir/nested/nested.html |
|
| sub/dir/nested/nested.html |
|
||||||
|
|
||||||
|
Scenario: Build and clean an app under a hidden directory
|
||||||
|
Given a fixture app "clean-app"
|
||||||
|
And app "clean-app" is using config "hidden-dir-before"
|
||||||
|
And a built app at "clean-app"
|
||||||
|
Then the following files should exist:
|
||||||
|
| .build/index.html |
|
||||||
|
| .build/should_be_ignored.html |
|
||||||
|
| .build/should_be_ignored2.html |
|
||||||
|
| .build/should_be_ignored3.html |
|
||||||
|
Given app "clean-app" is using config "hidden-dir-after"
|
||||||
|
And a built app at "clean-app"
|
||||||
|
Then the following files should exist:
|
||||||
|
| .build/index.html |
|
||||||
|
And the following files should not exist:
|
||||||
|
| .build/should_be_ignored.html |
|
||||||
|
| .build/should_be_ignored2.html |
|
||||||
|
| .build/should_be_ignored3.html |
|
||||||
|
|
17
middleman-core/features/cli/preview_server-hook.feature
Normal file
17
middleman-core/features/cli/preview_server-hook.feature
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Feature: Run preview server before hook
|
||||||
|
|
||||||
|
Scenario: When run
|
||||||
|
Given a fixture app "preview-server-hook-app"
|
||||||
|
And the default aruba timeout is 30 seconds
|
||||||
|
When I run `middleman server --server-name localhost --bind-address 127.0.0.1` interactively
|
||||||
|
And I stop middleman if the output contains:
|
||||||
|
"""
|
||||||
|
### END ###
|
||||||
|
"""
|
||||||
|
Then the output should contain:
|
||||||
|
"""
|
||||||
|
/// 127.0.0.1:4567 ///
|
||||||
|
/// 4567 ///
|
||||||
|
/// localhost ///
|
||||||
|
/// http://localhost:4567 ///
|
||||||
|
"""
|
|
@ -6,7 +6,7 @@ Feature: Run the preview server
|
||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given a fixture app "preview-server-app"
|
Given a fixture app "preview-server-app"
|
||||||
And the default aruba timeout is 30 seconds
|
And the default aruba exit timeout is 30 seconds
|
||||||
|
|
||||||
Scenario: Start the server with defaults
|
Scenario: Start the server with defaults
|
||||||
When I run `middleman server` interactively
|
When I run `middleman server` interactively
|
||||||
|
@ -31,7 +31,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::4567", "0.0.0.0:4567"
|
The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -52,7 +52,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::4567", "0.0.0.0:4567"
|
The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -76,7 +76,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -104,7 +104,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -127,7 +127,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.5:4567"
|
The Middleman preview server is bound to "127.0.0.5:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -151,7 +151,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "::1:4567"
|
The Middleman preview server is bound to "::1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -170,7 +170,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "0.0.0.0:4567"
|
The Middleman preview server is bound to "0.0.0.0:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -189,7 +189,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::4567"
|
The Middleman preview server is bound to ":::4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -213,7 +213,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -241,7 +241,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -265,7 +265,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -284,7 +284,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -303,7 +303,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "::1:4567"
|
The Middleman preview server is bound to "::1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -322,7 +322,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::4567", "0.0.0.0:4567"
|
The Middleman preview server is bound to ":::4567", "0.0.0.0:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -341,7 +341,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::65432", "0.0.0.0:65432"
|
The Middleman preview server is bound to ":::65432", "0.0.0.0:65432"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: Start the server with port 65432 configured via config.rb
|
Scenario: Start the server with port 65432 configured via config.rb
|
||||||
|
@ -356,7 +356,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to ":::65432", "0.0.0.0:65432"
|
The Middleman preview server is bound to ":::65432", "0.0.0.0:65432"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
Scenario: Start the server when port is blocked by other middleman instance
|
Scenario: Start the server when port is blocked by other middleman instance
|
||||||
|
@ -456,7 +456,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -488,7 +488,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
@ -520,7 +520,7 @@ Feature: Run the preview server
|
||||||
"""
|
"""
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
The Middleman preview server is bind to "127.0.0.1:4567"
|
The Middleman preview server is bound to "127.0.0.1:4567"
|
||||||
"""
|
"""
|
||||||
And the output should contain:
|
And the output should contain:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -51,3 +51,31 @@ Feature: Local Data API
|
||||||
Then I should see "title1:Hello"
|
Then I should see "title1:Hello"
|
||||||
Then I should see "title2:More"
|
Then I should see "title2:More"
|
||||||
Then I should see "title3:Stuff"
|
Then I should see "title3:Stuff"
|
||||||
|
|
||||||
|
Scenario: Invalid YAML
|
||||||
|
Given a fixture app "basic-data-app"
|
||||||
|
And the default aruba exit timeout is 30 seconds
|
||||||
|
And a file named "data/test.yml" with:
|
||||||
|
"""
|
||||||
|
'ASDSFDa:
|
||||||
|
-asdf asdf
|
||||||
|
"""
|
||||||
|
When I run `middleman build`
|
||||||
|
Then the output should contain:
|
||||||
|
"""
|
||||||
|
failed due to an error:
|
||||||
|
"""
|
||||||
|
|
||||||
|
Scenario: Invalid JSON
|
||||||
|
Given a fixture app "basic-data-app"
|
||||||
|
And the default aruba exit timeout is 30 seconds
|
||||||
|
And a file named "data/test.json" with:
|
||||||
|
"""
|
||||||
|
'ASDSFDa:
|
||||||
|
-asdf asdf
|
||||||
|
"""
|
||||||
|
When I run `middleman build`
|
||||||
|
Then the output should contain:
|
||||||
|
"""
|
||||||
|
failed due to an error:
|
||||||
|
"""
|
||||||
|
|
|
@ -18,118 +18,195 @@ end
|
||||||
|
|
||||||
Then /^should raise an exception if the operator is not supported$/ do
|
Then /^should raise an exception if the operator is not supported$/ do
|
||||||
expect {
|
expect {
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :author, :operator => 'zomg'
|
::Middleman::Sitemap::Queryable::Selector.new :attribute => :author, :operator => 'zomg'
|
||||||
}.to raise_error(::Middleman::Sitemap::Queryable::OperatorNotSupportedError)
|
}.to raise_error(::Middleman::Sitemap::Queryable::OperatorNotSupportedError)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should limit the documents to the number specified$/ do
|
Then /^should limit the documents to the number specified$/ do
|
||||||
@server_inst.sitemap.order_by(:id).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.sitemap.order_by(:id).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should offset the documents by the number specified$/ do
|
Then /^should offset the documents by the number specified$/ do
|
||||||
@server_inst.sitemap.order_by(:id).offset(2).all.map { |r| r.raw_data[:id] }.sort.should == [3,4,5].sort
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.sitemap.order_by(:id).offset(2).all.map { |r| r.raw_data[:id] }.sort.should == [3,4,5].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should support offset and limit at the same time$/ do
|
Then /^should support offset and limit at the same time$/ do
|
||||||
@server_inst.sitemap.order_by(:id).offset(1).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.sitemap.order_by(:id).offset(1).limit(2).all.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should not freak out about an offset higher than the document count$/ do
|
Then /^should not freak out about an offset higher than the document count$/ do
|
||||||
@server_inst.sitemap.order_by(:id).offset(5).all.should == []
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.sitemap.order_by(:id).offset(5).all.should == []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should return the right documents$/ do
|
Then /^should return the right documents$/ do
|
||||||
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
cd '.' do
|
||||||
document_1 = documents[0]
|
with_environment do
|
||||||
document_2 = documents[1]
|
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
||||||
|
document_1 = documents[0]
|
||||||
|
document_2 = documents[1]
|
||||||
|
|
||||||
found_document = @server_inst.sitemap.where(:title => document_1.raw_data[:title]).first
|
found_document = @server_inst.sitemap.where(:title => document_1.raw_data[:title]).first
|
||||||
document_1.should == found_document
|
document_1.should == found_document
|
||||||
|
|
||||||
found_document = @server_inst.sitemap.where(:title => document_2.raw_data[:title]).first
|
found_document = @server_inst.sitemap.where(:title => document_2.raw_data[:title]).first
|
||||||
document_2.should == found_document
|
document_2.should == found_document
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should be chainable$/ do
|
Then /^should be chainable$/ do
|
||||||
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
cd '.' do
|
||||||
document_1 = documents[0]
|
with_environment do
|
||||||
|
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
|
||||||
|
document_1 = documents[0]
|
||||||
|
|
||||||
document_proxy = @server_inst.sitemap.where(:title => document_1.raw_data[:title])
|
document_proxy = @server_inst.sitemap.where(:title => document_1.raw_data[:title])
|
||||||
document_proxy.where(:id => document_1.raw_data[:id])
|
document_proxy.where(:id => document_1.raw_data[:id])
|
||||||
document_1.should == document_proxy.first
|
document_1.should == document_proxy.first
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should not be confused by attributes not present in all documents$/ do
|
Then /^should not be confused by attributes not present in all documents$/ do
|
||||||
result = @server_inst.sitemap.where(:seldom_attribute => 'is seldom').all
|
cd '.' do
|
||||||
result.map { |r| r.raw_data[:id] }.should == [4]
|
with_environment do
|
||||||
|
result = @server_inst.sitemap.where(:seldom_attribute => 'is seldom').all
|
||||||
|
result.map { |r| r.raw_data[:id] }.should == [4]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with a gt operator should return the right documents$/ do
|
Then /^with a gt operator should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 2).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [5,3,4].sort
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 2).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [5,3,4].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with a gte operator should return the right documents$/ do
|
Then /^with a gte operator should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gte'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gte'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 2).all
|
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,5,3,4].sort
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 2).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,5,3,4].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with an in operator should return the right documents$/ do
|
Then /^with an in operator should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
||||||
found_documents = @server_inst.sitemap.where(selector => [2,3]).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => [2,3]).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with an lt operator should return the right documents$/ do
|
Then /^with an lt operator should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lt'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lt'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 2).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.should == [1]
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 2).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.should == [1]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with an lte operator should return the right documents$/ do
|
Then /^with an lte operator should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 2).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 2).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with an include operator include should return the right documents$/ do
|
Then /^with an include operator include should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :tags, :operator => 'include'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :tags, :operator => 'include'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 'ruby').all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 'ruby').all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^with mixed operators should return the right documents$/ do
|
Then /^with mixed operators should return the right documents$/ do
|
||||||
in_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
in_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
|
||||||
gt_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
gt_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
|
||||||
documents_proxy = @server_inst.sitemap.where(in_selector => [2,3])
|
cd '.' do
|
||||||
found_documents = documents_proxy.where(gt_selector => 2).all
|
with_environment do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.should == [3]
|
documents_proxy = @server_inst.sitemap.where(in_selector => [2,3])
|
||||||
|
found_documents = documents_proxy.where(gt_selector => 2).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.should == [3]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^using multiple constrains in one where should return the right documents$/ do
|
Then /^using multiple constrains in one where should return the right documents$/ do
|
||||||
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
|
||||||
found_documents = @server_inst.sitemap.where(selector => 2, :status => :published).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.where(selector => 2, :status => :published).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should support ordering by attribute ascending$/ do
|
Then /^should support ordering by attribute ascending$/ do
|
||||||
found_documents = @server_inst.sitemap.order_by(:title => :asc).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.order_by(:title => :asc).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should support ordering by attribute descending$/ do
|
Then /^should support ordering by attribute descending$/ do
|
||||||
found_documents = @server_inst.sitemap.order_by(:title => :desc).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.should == [4,5,1,3,2]
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.order_by(:title => :desc).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.should == [4,5,1,3,2]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should order by attribute ascending by default$/ do
|
Then /^should order by attribute ascending by default$/ do
|
||||||
found_documents = @server_inst.sitemap.order_by(:title).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.order_by(:title).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^should exclude documents that do not own the attribute$/ do
|
Then /^should exclude documents that do not own the attribute$/ do
|
||||||
found_documents = @server_inst.sitemap.order_by(:status).all
|
cd '.' do
|
||||||
found_documents.map { |r| r.raw_data[:id] }.to_set.should == [1,2].to_set
|
with_environment do
|
||||||
|
found_documents = @server_inst.sitemap.order_by(:status).all
|
||||||
|
found_documents.map { |r| r.raw_data[:id] }.to_set.should == [1,2].to_set
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
@nojava
|
@wip @nojava
|
||||||
Feature: Stylus Updates and Partials
|
Feature: Stylus Updates and Partials
|
||||||
Scenario: The preview server should update stylesheets when Stylus changes
|
Scenario: The preview server should update stylesheets when Stylus changes
|
||||||
Given the Server is running at "stylus-preview-app"
|
Given the Server is running at "stylus-preview-app"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
= Page Title
|
= Page Title
|
||||||
|
:showtitle:
|
||||||
:page-layout: default
|
:page-layout: default
|
||||||
|
|
||||||
Hello, AsciiDoc!
|
Hello, AsciiDoc!
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
set :build_dir, ".build"
|
||||||
|
|
||||||
|
ignore "/should_be_ignored.html"
|
||||||
|
page "/should_be_ignored2.html", :ignore => true
|
||||||
|
page "/target_ignore.html", :proxy => "/should_be_ignored3.html", :ignore => true
|
|
@ -0,0 +1 @@
|
||||||
|
set :build_dir, ".build"
|
19
middleman-core/fixtures/preview-server-hook-app/config.rb
Normal file
19
middleman-core/fixtures/preview-server-hook-app/config.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
set :layout, false
|
||||||
|
|
||||||
|
class MyFeature < Middleman::Extension
|
||||||
|
def initialize(app, options_hash = {}, &block)
|
||||||
|
super
|
||||||
|
|
||||||
|
app.before_server do |server_information|
|
||||||
|
puts "/// #{server_information.listeners.first} ///"
|
||||||
|
puts "/// #{server_information.port} ///"
|
||||||
|
puts "/// #{server_information.server_name} ///"
|
||||||
|
puts "/// #{server_information.site_addresses.first} ///"
|
||||||
|
puts "/// ### END ### ///"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
::Middleman::Extensions.register(:my_feature, MyFeature)
|
||||||
|
|
||||||
|
activate :my_feature
|
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>preview-server-hook-app</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>preview-server-hook-app</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,9 +1,5 @@
|
||||||
# rubocop:disable FileName
|
# rubocop:disable FileName
|
||||||
|
|
||||||
# Setup our load paths
|
|
||||||
libdir = File.expand_path(File.dirname(__FILE__))
|
|
||||||
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
|
||||||
|
|
||||||
# Top-level Middleman namespace
|
# Top-level Middleman namespace
|
||||||
module Middleman
|
module Middleman
|
||||||
# Backwards compatibility namespace
|
# Backwards compatibility namespace
|
||||||
|
|
|
@ -41,6 +41,9 @@ module Middleman
|
||||||
# Runs after the build is finished
|
# Runs after the build is finished
|
||||||
define_hook :after_build
|
define_hook :after_build
|
||||||
|
|
||||||
|
# Runs before the preview server is started
|
||||||
|
define_hook :before_server
|
||||||
|
|
||||||
# Mix-in helper methods. Accepts either a list of Modules
|
# Mix-in helper methods. Accepts either a list of Modules
|
||||||
# and/or a block to be evaluated
|
# and/or a block to be evaluated
|
||||||
# @return [void]
|
# @return [void]
|
||||||
|
|
|
@ -5,7 +5,7 @@ require 'thor/group'
|
||||||
# CLI Module
|
# CLI Module
|
||||||
module Middleman
|
module Middleman
|
||||||
module Cli
|
module Cli
|
||||||
# The base task from which everything else etends
|
# The base task from which everything else extends
|
||||||
class Base < Thor
|
class Base < Thor
|
||||||
class << self
|
class << self
|
||||||
def start(*args)
|
def start(*args)
|
||||||
|
|
|
@ -167,7 +167,7 @@ module Middleman::Cli
|
||||||
paths = ::Middleman::Util.all_files_under(@build_dir).map(&:realpath).select(&:file?)
|
paths = ::Middleman::Util.all_files_under(@build_dir).map(&:realpath).select(&:file?)
|
||||||
|
|
||||||
@to_clean += paths.select do |path|
|
@to_clean += paths.select do |path|
|
||||||
path.to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/
|
path.relative_path_from(@build_dir.realpath).to_s !~ /\/\./ || path.to_s =~ /\.(htaccess|htpasswd)/
|
||||||
end
|
end
|
||||||
|
|
||||||
return unless RUBY_PLATFORM =~ /darwin/
|
return unless RUBY_PLATFORM =~ /darwin/
|
||||||
|
|
|
@ -48,7 +48,7 @@ module Middleman
|
||||||
self.class.config
|
self.class.config
|
||||||
end
|
end
|
||||||
|
|
||||||
# Backwards compatibilty with old Sinatra template interface
|
# Backwards compatibility with old Sinatra template interface
|
||||||
#
|
#
|
||||||
# @deprecated Prefer accessing settings through "config".
|
# @deprecated Prefer accessing settings through "config".
|
||||||
#
|
#
|
||||||
|
|
|
@ -7,9 +7,7 @@ module Middleman
|
||||||
class << self
|
class << self
|
||||||
# @private
|
# @private
|
||||||
def registered(app)
|
def registered(app)
|
||||||
# Data formats
|
require 'middleman-core/core_extensions/data/file_loader'
|
||||||
require 'yaml'
|
|
||||||
require 'json'
|
|
||||||
|
|
||||||
app.config.define_setting :data_dir, 'data', 'The directory data files are stored in'
|
app.config.define_setting :data_dir, 'data', 'The directory data files are stored in'
|
||||||
app.send :include, InstanceMethods
|
app.send :include, InstanceMethods
|
||||||
|
@ -95,11 +93,9 @@ module Middleman
|
||||||
|
|
||||||
data_path = full_path.relative_path_from(root + @app.config[:data_dir])
|
data_path = full_path.relative_path_from(root + @app.config[:data_dir])
|
||||||
|
|
||||||
if %w(.yaml .yml).include?(extension)
|
begin
|
||||||
data = YAML.load_file(full_path)
|
data = FileLoader.new.load(full_path)
|
||||||
elsif extension == '.json'
|
rescue FileLoader::NoFileLoaderFoundError
|
||||||
data = JSON.parse(full_path.read)
|
|
||||||
else
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
require 'yaml'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
module Middleman
|
||||||
|
module CoreExtensions
|
||||||
|
module Data
|
||||||
|
# Load data files
|
||||||
|
class FileLoader
|
||||||
|
# No parser available
|
||||||
|
class NoFileLoaderFoundError < StandardError; end
|
||||||
|
|
||||||
|
# Load yaml files
|
||||||
|
class YamlFileLoader
|
||||||
|
def match?(file)
|
||||||
|
%w(.yaml .yml).include? File.extname(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
# @param [Pathname] file
|
||||||
|
def load(file)
|
||||||
|
YAML.load_file(file)
|
||||||
|
rescue Psych::SyntaxError, StandardError => e
|
||||||
|
$stderr.puts %(Loading data file "#{file}" failed due to an error: #{e.message})
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load json files
|
||||||
|
class JsonFileLoader
|
||||||
|
def match?(file)
|
||||||
|
'.json' == File.extname(file)
|
||||||
|
end
|
||||||
|
|
||||||
|
# @param [Pathname] file
|
||||||
|
def load(file)
|
||||||
|
JSON.parse(file.read)
|
||||||
|
rescue => e
|
||||||
|
$stderr.puts %(Loading data file "#{file}" failed due to an error: #{e.message})
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Default loader
|
||||||
|
#
|
||||||
|
# Always fails
|
||||||
|
class NilFileLoader
|
||||||
|
def match?(file)
|
||||||
|
raise NoFileLoaderFoundError
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
attr_reader :loaders
|
||||||
|
|
||||||
|
public
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@loaders = []
|
||||||
|
@loaders << YamlFileLoader.new
|
||||||
|
@loaders << JsonFileLoader.new
|
||||||
|
@loaders << NilFileLoader.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# Load file using loader
|
||||||
|
def load(file)
|
||||||
|
loaders.find { |l| l.match? file }.load(file)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -214,7 +214,7 @@ module Middleman
|
||||||
locals = options[:locals]
|
locals = options[:locals]
|
||||||
|
|
||||||
if ::Tilt[found_partial]
|
if ::Tilt[found_partial]
|
||||||
# Render the partial if found, otherwide throw exception
|
# Render the partial if found, otherwise throw exception
|
||||||
_render_with_all_renderers(found_partial, locals, self, options, &block)
|
_render_with_all_renderers(found_partial, locals, self, options, &block)
|
||||||
else
|
else
|
||||||
read_template_file(found_partial)
|
read_template_file(found_partial)
|
||||||
|
@ -265,7 +265,7 @@ module Middleman
|
||||||
# Try to work around: https://github.com/middleman/middleman/issues/501
|
# Try to work around: https://github.com/middleman/middleman/issues/501
|
||||||
locs = locs.dup
|
locs = locs.dup
|
||||||
|
|
||||||
# Detect the remdering engine from the extension
|
# Detect the rendering engine from the extension
|
||||||
extension = File.extname(path)
|
extension = File.extname(path)
|
||||||
engine = extension[1..-1].to_sym
|
engine = extension[1..-1].to_sym
|
||||||
|
|
||||||
|
@ -296,10 +296,10 @@ module Middleman
|
||||||
# Allow hooks to manipulate the template before render
|
# Allow hooks to manipulate the template before render
|
||||||
self.class.callbacks_for_hook(:before_render).each do |callback|
|
self.class.callbacks_for_hook(:before_render).each do |callback|
|
||||||
# Uber::Options::Value doesn't respond to call
|
# Uber::Options::Value doesn't respond to call
|
||||||
newbody = if callback.respond_to?(:call)
|
newbody = if callback.is_a? ::Uber::Options::Value
|
||||||
callback.call(body, path, locs, template_class)
|
callback.call(self, body, path, locs, template_class)
|
||||||
elsif callback.respond_to?(:evaluate)
|
elsif callback.respond_to?(:evaluate)
|
||||||
callback.evaluate(self, body, path, locs, template_class)
|
callback.call(body, path, locs, template_class)
|
||||||
end
|
end
|
||||||
body = newbody if newbody # Allow the callback to return nil to skip it
|
body = newbody if newbody # Allow the callback to return nil to skip it
|
||||||
end
|
end
|
||||||
|
@ -315,10 +315,10 @@ module Middleman
|
||||||
# Allow hooks to manipulate the result after render
|
# Allow hooks to manipulate the result after render
|
||||||
self.class.callbacks_for_hook(:after_render).each do |callback|
|
self.class.callbacks_for_hook(:after_render).each do |callback|
|
||||||
# Uber::Options::Value doesn't respond to call
|
# Uber::Options::Value doesn't respond to call
|
||||||
newcontent = if callback.respond_to?(:call)
|
newcontent = if callback.is_a? ::Uber::Options::Value
|
||||||
content = callback.call(content, path, locs, template_class)
|
callback.call(self, content, path, locs, template_class)
|
||||||
elsif callback.respond_to?(:evaluate)
|
elsif callback.respond_to?(:evaluate)
|
||||||
content = callback.evaluate(self, content, path, locs, template_class)
|
callback.call(content, path, locs, template_class)
|
||||||
end
|
end
|
||||||
content = newcontent if newcontent # Allow the callback to return nil to skip it
|
content = newcontent if newcontent # Allow the callback to return nil to skip it
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Middleman
|
||||||
|
|
||||||
# When in dev
|
# When in dev
|
||||||
app.configure :development do
|
app.configure :development do
|
||||||
# Include middlemare
|
# Include middleware
|
||||||
use ::Rack::ShowExceptions if config[:show_exceptions]
|
use ::Rack::ShowExceptions if config[:show_exceptions]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Middleman
|
||||||
# Array of Names
|
# Array of Names
|
||||||
def getnames(ip)
|
def getnames(ip)
|
||||||
resolver.getnames(ip.to_s).map(&:to_s)
|
resolver.getnames(ip.to_s).map(&:to_s)
|
||||||
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
|
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ module Middleman
|
||||||
# Array of ipaddresses
|
# Array of ipaddresses
|
||||||
def getaddresses(name)
|
def getaddresses(name)
|
||||||
resolver.getaddresses(name.to_s).map(&:to_s)
|
resolver.getaddresses(name.to_s).map(&:to_s)
|
||||||
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
|
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
|
||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,6 @@ module Middleman
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
def load_extensions_in_path
|
def load_extensions_in_path
|
||||||
require 'rubygems'
|
|
||||||
|
|
||||||
extensions = rubygems_latest_specs.select do |spec|
|
extensions = rubygems_latest_specs.select do |spec|
|
||||||
spec_has_file?(spec, EXTENSION_FILE)
|
spec_has_file?(spec, EXTENSION_FILE)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
require 'padrino-helpers'
|
require 'padrino-helpers'
|
||||||
|
require 'padrino-helpers/output_helpers'
|
||||||
|
require 'padrino-helpers/tag_helpers'
|
||||||
|
|
||||||
module Middleman
|
module Middleman
|
||||||
module MetaPages
|
module MetaPages
|
||||||
|
|
|
@ -59,7 +59,7 @@ module Middleman
|
||||||
|
|
||||||
if path_parts.size == 1
|
if path_parts.size == 1
|
||||||
sitemap_class = SitemapResource
|
sitemap_class = SitemapResource
|
||||||
# Allow special sitemap resources to use custom metadata view calsses
|
# Allow special sitemap resources to use custom metadata view classes
|
||||||
sitemap_class = resource.meta_pages_class if resource.respond_to? :meta_pages_class
|
sitemap_class = resource.meta_pages_class if resource.respond_to? :meta_pages_class
|
||||||
|
|
||||||
@children[first_part] = sitemap_class.new(resource)
|
@children[first_part] = sitemap_class.new(resource)
|
||||||
|
|
|
@ -5,6 +5,7 @@ require 'middleman-core/meta_pages'
|
||||||
require 'middleman-core/logger'
|
require 'middleman-core/logger'
|
||||||
require 'middleman-core/preview_server/server_information'
|
require 'middleman-core/preview_server/server_information'
|
||||||
require 'middleman-core/preview_server/server_url'
|
require 'middleman-core/preview_server/server_url'
|
||||||
|
require 'middleman-core/preview_server/server_information_callback_proxy'
|
||||||
|
|
||||||
# rubocop:disable GlobalVars
|
# rubocop:disable GlobalVars
|
||||||
module Middleman
|
module Middleman
|
||||||
|
@ -13,10 +14,6 @@ module Middleman
|
||||||
attr_reader :app, :ssl_certificate, :ssl_private_key, :environment, :server_information
|
attr_reader :app, :ssl_certificate, :ssl_private_key, :environment, :server_information
|
||||||
delegate :logger, to: :app
|
delegate :logger, to: :app
|
||||||
|
|
||||||
def https?
|
|
||||||
@https
|
|
||||||
end
|
|
||||||
|
|
||||||
# Start an instance of Middleman::Application
|
# Start an instance of Middleman::Application
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def start(opts={})
|
def start(opts={})
|
||||||
|
@ -26,6 +23,7 @@ module Middleman
|
||||||
|
|
||||||
@options = opts
|
@options = opts
|
||||||
@server_information = ServerInformation.new
|
@server_information = ServerInformation.new
|
||||||
|
@server_information.https = (@options[:https] == true)
|
||||||
|
|
||||||
# New app evaluates the middleman configuration. Since this can be
|
# New app evaluates the middleman configuration. Since this can be
|
||||||
# invalid as well, we need to evaluate the configuration BEFORE
|
# invalid as well, we need to evaluate the configuration BEFORE
|
||||||
|
@ -42,9 +40,9 @@ module Middleman
|
||||||
|
|
||||||
logger.debug %(== Server information is provided by #{server_information.handler})
|
logger.debug %(== Server information is provided by #{server_information.handler})
|
||||||
logger.debug %(== The Middleman is running in "#{environment}" environment)
|
logger.debug %(== The Middleman is running in "#{environment}" environment)
|
||||||
logger.debug format('== The Middleman preview server is bind to %s', ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: https?).to_bind_addresses.join(', '))
|
logger.debug format('== The Middleman preview server is bound to %s', ServerUrl.new(hosts: server_information.listeners, port: server_information.port, https: server_information.https?).to_bind_addresses.join(', '))
|
||||||
logger.info format('== View your site at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: https?).to_urls.join(', '))
|
logger.info format('== View your site at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_urls.join(', '))
|
||||||
logger.info format('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: https?).to_config_urls.join(', '))
|
logger.info format('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: server_information.https?).to_config_urls.join(', '))
|
||||||
|
|
||||||
@initialized ||= false
|
@initialized ||= false
|
||||||
return if @initialized
|
return if @initialized
|
||||||
|
@ -56,6 +54,8 @@ module Middleman
|
||||||
# reloading later on.
|
# reloading later on.
|
||||||
::Middleman::Profiling.report('server_start')
|
::Middleman::Profiling.report('server_start')
|
||||||
|
|
||||||
|
app.run_hook(:before_server, ServerInformationCallbackProxy.new(server_information))
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
@webrick.start
|
@webrick.start
|
||||||
|
|
||||||
|
@ -153,7 +153,6 @@ module Middleman
|
||||||
|
|
||||||
logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless @app.config[:port] == configured_port
|
logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless @app.config[:port] == configured_port
|
||||||
|
|
||||||
@https = @app.config[:https]
|
|
||||||
@environment = @app.config[:environment]
|
@environment = @app.config[:environment]
|
||||||
|
|
||||||
@ssl_certificate = @app.config[:ssl_certificate]
|
@ssl_certificate = @app.config[:ssl_certificate]
|
||||||
|
@ -199,7 +198,7 @@ module Middleman
|
||||||
@listener.start
|
@listener.start
|
||||||
end
|
end
|
||||||
|
|
||||||
# Trap some interupt signals and shut down smoothly
|
# Trap some interrupt signals and shut down smoothly
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def register_signal_handlers
|
def register_signal_handlers
|
||||||
%w(INT HUP TERM QUIT).each do |sig|
|
%w(INT HUP TERM QUIT).each do |sig|
|
||||||
|
@ -224,7 +223,7 @@ module Middleman
|
||||||
DoNotReverseLookup: true
|
DoNotReverseLookup: true
|
||||||
}
|
}
|
||||||
|
|
||||||
if https?
|
if server_information.https?
|
||||||
http_opts[:SSLEnable] = true
|
http_opts[:SSLEnable] = true
|
||||||
|
|
||||||
if ssl_certificate || ssl_private_key
|
if ssl_certificate || ssl_private_key
|
||||||
|
|
|
@ -20,6 +20,8 @@ module Middleman
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
|
attr_writer :https
|
||||||
|
|
||||||
def initialize(opts={})
|
def initialize(opts={})
|
||||||
@resolver = opts.fetch(:resolver, DnsResolver.new)
|
@resolver = opts.fetch(:resolver, DnsResolver.new)
|
||||||
@validator = opts.fetch(:validator, ServerInformationValidator.new)
|
@validator = opts.fetch(:validator, ServerInformationValidator.new)
|
||||||
|
@ -64,13 +66,15 @@ module Middleman
|
||||||
@bind_address = config[:bind_address]
|
@bind_address = config[:bind_address]
|
||||||
@port = config[:port]
|
@port = config[:port]
|
||||||
@server_name = config[:server_name]
|
@server_name = config[:server_name]
|
||||||
|
@https = config[:https]
|
||||||
|
|
||||||
config[:bind_address] = bind_address
|
config[:bind_address] = bind_address
|
||||||
config[:port] = port
|
config[:port] = port
|
||||||
config[:server_name] = server_name
|
config[:server_name] = server_name
|
||||||
|
config[:https] = https?
|
||||||
end
|
end
|
||||||
|
|
||||||
# Make information of internal server class avaible to make debugging
|
# Make information of internal server class available to make debugging
|
||||||
# easier. This can be used to log the class which was used to determine
|
# easier. This can be used to log the class which was used to determine
|
||||||
# the preview server settings
|
# the preview server settings
|
||||||
#
|
#
|
||||||
|
@ -139,6 +143,11 @@ module Middleman
|
||||||
def listeners
|
def listeners
|
||||||
information.listeners
|
information.listeners
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Is https enabled?
|
||||||
|
def https?
|
||||||
|
@https == true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
module Middleman
|
||||||
|
class PreviewServer
|
||||||
|
# This class wraps server information to be used in call back
|
||||||
|
#
|
||||||
|
# * listeners
|
||||||
|
# * port
|
||||||
|
# * server name
|
||||||
|
# * site_addresses
|
||||||
|
#
|
||||||
|
# All information is "dupped" and the callback is not meant to be used to
|
||||||
|
# modify these information.
|
||||||
|
class ServerInformationCallbackProxy
|
||||||
|
attr_reader :server_name, :port, :site_addresses, :listeners
|
||||||
|
|
||||||
|
def initialize(server_information)
|
||||||
|
@listeners = ServerUrl.new(
|
||||||
|
hosts: server_information.listeners,
|
||||||
|
port: server_information.port,
|
||||||
|
https: server_information.https?,
|
||||||
|
format_output: false
|
||||||
|
).to_bind_addresses
|
||||||
|
|
||||||
|
@port = server_information.port
|
||||||
|
@server_name = server_information.server_name.dup unless server_information.server_name == nil
|
||||||
|
|
||||||
|
@site_addresses = ServerUrl.new(
|
||||||
|
hosts: server_information.site_addresses,
|
||||||
|
port: server_information.port,
|
||||||
|
https: server_information.https?,
|
||||||
|
format_output: false
|
||||||
|
).to_urls
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -6,7 +6,7 @@ module Middleman
|
||||||
class ServerUrl
|
class ServerUrl
|
||||||
private
|
private
|
||||||
|
|
||||||
attr_reader :hosts, :port, :https
|
attr_reader :hosts, :port, :https, :format_output
|
||||||
|
|
||||||
public
|
public
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ module Middleman
|
||||||
@hosts = opts.fetch(:hosts)
|
@hosts = opts.fetch(:hosts)
|
||||||
@port = opts.fetch(:port)
|
@port = opts.fetch(:port)
|
||||||
@https = opts.fetch(:https, false)
|
@https = opts.fetch(:https, false)
|
||||||
|
@format_output = opts.fetch(:format_output, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return bind addresses
|
# Return bind addresses
|
||||||
|
@ -21,7 +22,11 @@ module Middleman
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
# List of bind addresses of format host:port
|
# List of bind addresses of format host:port
|
||||||
def to_bind_addresses
|
def to_bind_addresses
|
||||||
hosts.map { |l| format('"%s:%s"', l.to_s, port) }
|
if format_output
|
||||||
|
hosts.map { |l| format('"%s:%s"', l.to_s, port) }
|
||||||
|
else
|
||||||
|
hosts.map { |l| format('%s:%s', l.to_s, port) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return server urls
|
# Return server urls
|
||||||
|
@ -29,7 +34,11 @@ module Middleman
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
# List of urls of format http://host:port
|
# List of urls of format http://host:port
|
||||||
def to_urls
|
def to_urls
|
||||||
hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) }
|
if format_output
|
||||||
|
hosts.map { |l| format('"%s://%s:%s"', https? ? 'https' : 'http', l.to_browser, port) }
|
||||||
|
else
|
||||||
|
hosts.map { |l| format('%s://%s:%s', https? ? 'https' : 'http', l.to_browser, port) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return server config urls
|
# Return server config urls
|
||||||
|
@ -37,7 +46,11 @@ module Middleman
|
||||||
# @return [Array]
|
# @return [Array]
|
||||||
# List of urls of format http://host:port/__middleman
|
# List of urls of format http://host:port/__middleman
|
||||||
def to_config_urls
|
def to_config_urls
|
||||||
hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) }
|
if format_output
|
||||||
|
hosts.map { |l| format('"%s://%s:%s/__middleman"', https? ? 'https' : 'http', l.to_browser, port) }
|
||||||
|
else
|
||||||
|
hosts.map { |l| format('%s://%s:%s/__middleman', https? ? 'https' : 'http', l.to_browser, port) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Middleman
|
||||||
app.config.define_setting :asciidoc, {
|
app.config.define_setting :asciidoc, {
|
||||||
safe: :safe,
|
safe: :safe,
|
||||||
backend: :html5,
|
backend: :html5,
|
||||||
attributes: %W(showtitle env=middleman env-middleman middleman-version=#{::Middleman::VERSION})
|
attributes: %W(env=middleman env-middleman middleman-version=#{::Middleman::VERSION})
|
||||||
}, 'AsciiDoc engine options (Hash)'
|
}, 'AsciiDoc engine options (Hash)'
|
||||||
app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)'
|
app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)'
|
||||||
app.before_configuration do
|
app.before_configuration do
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Middleman
|
||||||
module Liquid
|
module Liquid
|
||||||
# Setup extension
|
# Setup extension
|
||||||
class << self
|
class << self
|
||||||
# Once registerd
|
# Once registered
|
||||||
def registered(app)
|
def registered(app)
|
||||||
app.before_configuration do
|
app.before_configuration do
|
||||||
template_extensions liquid: :html
|
template_extensions liquid: :html
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Middleman::Sitemap::Extensions
|
||||||
module ContentType
|
module ContentType
|
||||||
# The preferred MIME content type for this resource
|
# The preferred MIME content type for this resource
|
||||||
def content_type
|
def content_type
|
||||||
# Allow explcitly setting content type from page/proxy options
|
# Allow explicitly setting content type from page/proxy options
|
||||||
meta_type = metadata[:options][:content_type]
|
meta_type = metadata[:options][:content_type]
|
||||||
return meta_type if meta_type
|
return meta_type if meta_type
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ module Middleman
|
||||||
rebuild_resource_list!(:registered_new)
|
rebuild_resource_list!(:registered_new)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rebuild the list of resources from scratch, using registed manipulators
|
# Rebuild the list of resources from scratch, using registered manipulators
|
||||||
# rubocop:disable UnusedMethodArgument
|
# rubocop:disable UnusedMethodArgument
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def rebuild_resource_list!(reason=nil)
|
def rebuild_resource_list!(reason=nil)
|
||||||
|
@ -99,7 +99,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Invalidate our cached view of resource that are not ingnored. If your extension
|
# Invalidate our cached view of resource that are not ignored. If your extension
|
||||||
# adds ways to ignore files, you should call this to make sure #resources works right.
|
# adds ways to ignore files, you should call this to make sure #resources works right.
|
||||||
def invalidate_resources_not_ignored_cache!
|
def invalidate_resources_not_ignored_cache!
|
||||||
@resources_not_ignored = nil
|
@resources_not_ignored = nil
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
require 'aruba/cucumber'
|
require 'aruba/cucumber'
|
||||||
require 'aruba/jruby'
|
require 'aruba/config/jruby'
|
||||||
require 'middleman-core/step_definitions/middleman_steps'
|
require 'middleman-core/step_definitions/middleman_steps'
|
||||||
require 'middleman-core/step_definitions/builder_steps'
|
require 'middleman-core/step_definitions/builder_steps'
|
||||||
require 'middleman-core/step_definitions/server_steps'
|
require 'middleman-core/step_definitions/server_steps'
|
||||||
|
|
|
@ -5,29 +5,27 @@ Before do
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
|
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
|
||||||
target = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
copy("config-#{config_name}.rb", 'config.rb')
|
||||||
config_path = File.join(current_directory, "config-#{config_name}.rb")
|
|
||||||
config_dest = File.join(current_directory, 'config.rb')
|
|
||||||
FileUtils.cp(config_path, config_dest)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^an empty app$/ do
|
Given /^an empty app$/ do
|
||||||
step %Q{a directory named "empty_app"}
|
step %Q{a directory named "empty_app"}
|
||||||
step %Q{I cd to "empty_app"}
|
step %Q{I cd to "empty_app"}
|
||||||
ENV['MM_ROOT'] = nil
|
|
||||||
|
delete_environment_variable 'MM_ROOT'
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^a fixture app "([^\"]*)"$/ do |path|
|
Given /^a fixture app "([^\"]*)"$/ do |path|
|
||||||
ENV['MM_ROOT'] = nil
|
delete_environment_variable 'MM_ROOT'
|
||||||
|
|
||||||
# This step can be reentered from several places but we don't want
|
# This step can be reentered from several places but we don't want
|
||||||
# to keep re-copying and re-cd-ing into ever-deeper directories
|
# to keep re-copying and re-cd-ing into ever-deeper directories
|
||||||
next if File.basename(current_directory) == path
|
next if File.basename(expand_path('.')) == path
|
||||||
|
|
||||||
step %Q{a directory named "#{path}"}
|
step %Q{a directory named "#{path}"}
|
||||||
|
|
||||||
target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
target_path = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
|
||||||
FileUtils.cp_r(target_path, current_directory)
|
FileUtils.cp_r(target_path, expand_path('.'))
|
||||||
|
|
||||||
step %Q{I cd to "#{path}"}
|
step %Q{I cd to "#{path}"}
|
||||||
end
|
end
|
||||||
|
@ -58,20 +56,20 @@ Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path,
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^a modification time for a file named "([^\"]*)"$/ do |file|
|
Given /^a modification time for a file named "([^\"]*)"$/ do |file|
|
||||||
target = File.join(current_directory, file)
|
target = expand_path(file)
|
||||||
@modification_times[target] = File.mtime(target)
|
@modification_times[target] = File.mtime(target)
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the file "([^\"]*)" should not have been updated$/ do |file|
|
Then /^the file "([^\"]*)" should not have been updated$/ do |file|
|
||||||
target = File.join(current_directory, file)
|
target = expand_path(file)
|
||||||
File.mtime(target).should == @modification_times[target]
|
File.mtime(target).should == @modification_times[target]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Provide this Aruba overload in case we're matching something with quotes in it
|
# Provide this Aruba overload in case we're matching something with quotes in it
|
||||||
Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
|
Then /^the file "([^"]*)" should contain '([^']*)'$/ do |file, partial_content|
|
||||||
check_file_content(file, Regexp.new(Regexp.escape(partial_content)), true)
|
expect(file).to have_file_content Regexp.new(Regexp.escape(partial_content))
|
||||||
end
|
end
|
||||||
|
|
||||||
And /the file "(.*)" should be gzipped/ do |file|
|
And /the file "(.*)" should be gzipped/ do |file|
|
||||||
expect(File.binread(File.join(current_directory, file), 2)).to eq(['1F8B'].pack('H*'))
|
expect(File.binread(expand_path(file), 2)).to eq(['1F8B'].pack('H*'))
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
|
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
|
||||||
begin
|
begin
|
||||||
Timeout.timeout(exit_timeout) do
|
Timeout.timeout(aruba.config.exit_timeout) do
|
||||||
loop do
|
loop do
|
||||||
fail "You need to start middleman interactively first." unless @interactive
|
fail "You need to start middleman interactively first." if last_command_started.nil?
|
||||||
|
|
||||||
if unescape(@interactive.output) =~ Regexp.new(unescape(expected))
|
if sanitize_text(last_command_started.output) =~ Regexp.new(sanitize_text(expected))
|
||||||
only_processes.each { |p| p.terminate }
|
terminate_all_commands
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -13,10 +13,10 @@ When /^I stop (?:middleman|all commands) if the output( of the last command)? co
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue ChildProcess::TimeoutError, TimeoutError
|
rescue ChildProcess::TimeoutError, TimeoutError
|
||||||
@interactive.terminate
|
terminate_all_commands
|
||||||
ensure
|
ensure
|
||||||
announcer.stdout @interactive.stdout
|
announcer.announce :stdout, last_command_started.stdout
|
||||||
announcer.stderr @interactive.stderr
|
announcer.announce :stderr, last_command_started.stderr
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ Given /I start a mdns server with:/ do |string|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
set_env 'PATH', File.expand_path(File.join(current_dir, 'bin')) + ':' + ENV['PATH']
|
set_environment_variable 'PATH', File.expand_path(File.join(current_dir, 'bin')) + ':' + ENV['PATH']
|
||||||
write_file db_file, string
|
write_file db_file, string
|
||||||
|
|
||||||
@mdns_server = run("dns_server.rb #{db_file} #{port}", 120)
|
@mdns_server = run("dns_server.rb #{db_file} #{port}", 120)
|
||||||
|
@ -80,7 +80,7 @@ end
|
||||||
|
|
||||||
# Make sure each and every process is really dead
|
# Make sure each and every process is really dead
|
||||||
After do
|
After do
|
||||||
only_processes.each { |p| p.terminate }
|
terminate_all_commands
|
||||||
end
|
end
|
||||||
|
|
||||||
Before '@ruby-2.1' do
|
Before '@ruby-2.1' do
|
||||||
|
|
|
@ -9,9 +9,17 @@ Then /^the file "([^\"]*)" is removed$/ do |path|
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the file "([^\"]*)" did change$/ do |path|
|
Then /^the file "([^\"]*)" did change$/ do |path|
|
||||||
@server_inst.files.did_change(path)
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.files.did_change(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the file "([^\"]*)" did delete$/ do |path|
|
Then /^the file "([^\"]*)" did delete$/ do |path|
|
||||||
@server_inst.files.did_delete(path)
|
cd '.' do
|
||||||
|
with_environment do
|
||||||
|
@server_inst.files.did_delete(path)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,15 +31,13 @@ Given /^current environment is "([^\"]*)"$/ do |env|
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^the Server is running$/ do
|
Given /^the Server is running$/ do
|
||||||
root_dir = File.expand_path(current_directory)
|
if exist? 'source'
|
||||||
|
set_environment_variable 'MM_SOURCE', 'source'
|
||||||
if File.exists?(File.join(root_dir, 'source'))
|
|
||||||
ENV['MM_SOURCE'] = 'source'
|
|
||||||
else
|
else
|
||||||
ENV['MM_SOURCE'] = ''
|
set_environment_variable 'MM_SOURCE', ''
|
||||||
end
|
end
|
||||||
|
|
||||||
ENV['MM_ROOT'] = root_dir
|
set_environment_variable 'MM_ROOT', expand_path('.')
|
||||||
|
|
||||||
initialize_commands = @initialize_commands || []
|
initialize_commands = @initialize_commands || []
|
||||||
initialize_commands.unshift lambda {
|
initialize_commands.unshift lambda {
|
||||||
|
@ -47,10 +45,12 @@ Given /^the Server is running$/ do
|
||||||
set :show_exceptions, false
|
set :show_exceptions, false
|
||||||
}
|
}
|
||||||
|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
@server_inst = Middleman::Application.server.inst do
|
with_environment do
|
||||||
initialize_commands.each do |p|
|
@server_inst = Middleman::Application.server.inst do
|
||||||
instance_exec(&p)
|
initialize_commands.each do |p|
|
||||||
|
instance_exec(&p)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -68,61 +68,81 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I go to "([^\"]*)"$/ do |url|
|
When /^I go to "([^\"]*)"$/ do |url|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
visit(URI.encode(url).to_s)
|
with_environment do
|
||||||
|
visit(URI.encode(url).to_s)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
with_environment do
|
||||||
|
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
Then /^the content type should be "([^\"]*)"$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.response_headers['Content-Type']).to start_with expected
|
with_environment do
|
||||||
|
expect(page.response_headers['Content-Type']).to start_with expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)"$/ do |expected|
|
Then /^I should see "([^\"]*)"$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body).to include expected
|
with_environment do
|
||||||
|
expect(page.body).to include expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see '([^\']*)'$/ do |expected|
|
Then /^I should see '([^\']*)'$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body).to include expected
|
with_environment do
|
||||||
|
expect(page.body).to include expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see:$/ do |expected|
|
Then /^I should see:$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body).to include expected
|
with_environment do
|
||||||
|
expect(page.body).to include expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see "([^\"]*)"$/ do |expected|
|
Then /^I should not see "([^\"]*)"$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body).not_to include expected
|
with_environment do
|
||||||
|
expect(page.body).not_to include expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not see:$/ do |expected|
|
Then /^I should not see:$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body).not_to include expected
|
with_environment do
|
||||||
|
expect(page.body).not_to include expected
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
Then /^the status code should be "([^\"]*)"$/ do |expected|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.status_code).to eq expected.to_i
|
with_environment do
|
||||||
|
expect(page.status_code).to eq expected.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
Then /^I should see "([^\"]*)" lines$/ do |lines|
|
||||||
in_current_directory do
|
cd '.' do
|
||||||
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
with_environment do
|
||||||
|
expect(page.body.chomp.split($/).length).to eq lines.to_i
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
require 'rubygems'
|
|
||||||
require 'middleman/rack'
|
require 'middleman/rack'
|
||||||
|
|
||||||
run Middleman.server
|
run Middleman.server
|
||||||
|
|
|
@ -16,3 +16,6 @@
|
||||||
|
|
||||||
# Ignore .DS_store file
|
# Ignore .DS_store file
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
# Ignore gems installed in local directory
|
||||||
|
/vendor/bundle/
|
||||||
|
|
|
@ -112,7 +112,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get a recusive list of files inside a path.
|
# Get a recursive list of files inside a path.
|
||||||
# Works with symlinks.
|
# Works with symlinks.
|
||||||
#
|
#
|
||||||
# @param path Some path string or Pathname
|
# @param path Some path string or Pathname
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Middleman
|
module Middleman
|
||||||
# Current Version
|
# Current Version
|
||||||
# @return [String]
|
# @return [String]
|
||||||
VERSION = '3.4.0' unless const_defined?(:VERSION)
|
VERSION = '3.4.1' unless const_defined?(:VERSION)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
require 'padrino-helpers'
|
require 'padrino-helpers'
|
||||||
|
require 'padrino-helpers/asset_tag_helpers'
|
||||||
|
require 'padrino-helpers/form_helpers'
|
||||||
|
require 'padrino-helpers/format_helpers'
|
||||||
|
require 'padrino-helpers/number_helpers'
|
||||||
|
require 'padrino-helpers/output_helpers'
|
||||||
|
require 'padrino-helpers/render_helpers'
|
||||||
|
require 'padrino-helpers/tag_helpers'
|
||||||
|
|
||||||
# Don't fail on invalid locale, that's not what our current
|
# Don't fail on invalid locale, that's not what our current
|
||||||
# users expect.
|
# users expect.
|
||||||
::I18n.enforce_available_locales = false
|
::I18n.enforce_available_locales = false
|
||||||
|
|
||||||
class Padrino::Helpers::OutputHelpers::ErbHandler
|
class ::Padrino::Helpers::OutputHelpers::ErbHandler
|
||||||
# Force Erb capture not to use safebuffer
|
# Force Erb capture not to use safebuffer
|
||||||
# rubocop:disable UnderscorePrefixedVariableName
|
# rubocop:disable UnderscorePrefixedVariableName
|
||||||
def capture_from_template(*args, &block)
|
def capture_from_template(*args, &block)
|
||||||
|
@ -216,7 +223,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||||
# @return [String] The fully qualified asset url
|
# @return [String] The fully qualified asset url
|
||||||
def asset_url(path, prefix='', options={})
|
def asset_url(path, prefix='', options={})
|
||||||
# Don't touch assets which already have a full path
|
# Don't touch assets which already have a full path
|
||||||
if path.include?('//') || path.start_with?('data:') || !current_resource
|
if path.include?('//') || path.start_with?('data:')
|
||||||
path
|
path
|
||||||
else # rewrite paths to use their destination path
|
else # rewrite paths to use their destination path
|
||||||
result = if resource = sitemap.find_resource_by_destination_path(url_for(path))
|
result = if resource = sitemap.find_resource_by_destination_path(url_for(path))
|
||||||
|
@ -234,6 +241,10 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||||
if options[:relative] != true
|
if options[:relative] != true
|
||||||
result
|
result
|
||||||
else
|
else
|
||||||
|
unless current_resource
|
||||||
|
raise ArgumentError, "#asset_url must be run in a context with current_resource if relative: true"
|
||||||
|
end
|
||||||
|
|
||||||
current_dir = Pathname('/' + current_resource.destination_path)
|
current_dir = Pathname('/' + current_resource.destination_path)
|
||||||
Pathname(result).relative_path_from(current_dir.dirname).to_s
|
Pathname(result).relative_path_from(current_dir.dirname).to_s
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
||||||
else
|
else
|
||||||
# It's a template, possible with partials. We can't really
|
# It's a template, possible with partials. We can't really
|
||||||
# know when it's updated, so generate fresh cache buster every
|
# know when it's updated, so generate fresh cache buster every
|
||||||
# time during developement
|
# time during development
|
||||||
http_path << '?' + Time.now.strftime('%s')
|
http_path << '?' + Time.now.strftime('%s')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
# -*- encoding: utf-8 -*-
|
lib = File.expand_path("../lib", __FILE__)
|
||||||
require File.expand_path("../lib/middleman-core/version", __FILE__)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
|
||||||
|
require "middleman-core/version"
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = "middleman-core"
|
s.name = "middleman-core"
|
||||||
|
|
|
@ -1,5 +1 @@
|
||||||
# coding:utf-8
|
require_relative '../gem_rake_helper'
|
||||||
RAKE_ROOT = __FILE__
|
|
||||||
|
|
||||||
GEM_NAME = 'middleman'
|
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# -*- encoding: utf-8 -*-
|
lib = File.expand_path('../lib', __FILE__)
|
||||||
$:.push File.expand_path("../lib", __FILE__)
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||||
|
|
||||||
require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__)
|
require File.expand_path("../../middleman-core/lib/middleman-core/version.rb", __FILE__)
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
|
@ -14,7 +15,6 @@ Gem::Specification.new do |s|
|
||||||
s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle."
|
s.description = "A static site generator. Provides dozens of templating languages (Haml, Sass, Compass, Slim, CoffeeScript, and more). Makes minification, compression, cache busting, Yaml data (and more) an easy part of your development cycle."
|
||||||
|
|
||||||
s.files = `git ls-files -z`.split("\0")
|
s.files = `git ls-files -z`.split("\0")
|
||||||
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
|
||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
s.required_ruby_version = '>= 1.9.3'
|
s.required_ruby_version = '>= 1.9.3'
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue