Compare commits

...

50 Commits

Author SHA1 Message Date
Thomas Reynolds 37845e89c0 Changelog [ci skip] 2015-12-10 13:24:35 -08:00
Thomas Reynolds 9dc144e9f7 Disable stylus test 2015-12-10 13:22:46 -08:00
Thomas Reynolds 67f612a082 Merge pull request #1555 from skybon/patch-1
Remove showtitle attribute from asciidoc renderer
2015-11-27 15:31:35 -08:00
Thomas Reynolds 18b12eedcf Merge pull request #1679 from dg-ratiodata/feature/upgrade_aruba
Upgrade to aruba 0.10.x [WIP]
2015-11-27 14:12:16 -08:00
Thomas Reynolds fe74824651 Merge pull request #1686 from stevenosloan/allow_asset_url_to_work_outside_of_a_resource
Allow asset_url to work outside of a resource context when relative: !true
2015-11-13 10:35:06 -08:00
Steven Sloan 30335091c8 fix(default_helpers): allow asset_url to work outside of a resource context
This way calls from extensions/etc can call app.asset_url() and get the correct
path back.

Additionally, an exception will be raised if also using relative assets as the current resource
will be needed in that case.
2015-11-12 15:27:26 -05:00
Thomas Reynolds fe4d3a4bb3 Merge pull request #1681 from maxmeyer/feature/server_hook_v3
Add "before_server"-hook to preview server in v3
2015-11-11 13:49:57 -08:00
Thomas Reynolds 78fb92d497 Adapt to upstream hooks API change. Fixes #1658 2015-11-11 13:25:17 -08:00
Thomas Reynolds e86110f506 Merge pull request #1680 from maxmeyer/patch-1
Add warning to contributing.md
2015-11-11 13:18:46 -08:00
Dennis Günnewig 2ee07bdcb6 Update CONTRIBUTING.md 2015-11-11 21:52:28 +01:00
Dennis Günnewig 02d25ee883 Add warning to contributing.md 2015-11-11 21:51:35 +01:00
Dennis Günnewig 4e9ae8cc42 Before server hook 2015-11-11 21:49:37 +01:00
Dennis Günnewig 1d2126b9f7 Move HTTPS to server information 2015-11-11 21:39:54 +01:00
Dennis Günnewig 741caab546 Make middleman compatible with aruba 0.10.x 2015-11-09 14:46:48 +01:00
Dennis Günnewig 90d386079d Make it easier for users behind http proxies to install gems from github with bundler 1.x 2015-11-09 14:46:28 +01:00
Thomas Reynolds 77dad2a400 Merge pull request #1674 from LandonSchropp/v3-stable
Add missing require to default_helpers.rb
2015-11-02 23:15:34 -08:00
Landon Schropp d67e5f512b Add missing require to default_helpers.rb
Helps resolve #1673
2015-11-02 20:56:39 -08:00
Thomas Reynolds 575423628d Add back full version path, fixes #1671 2015-11-01 09:23:33 -08:00
Thomas Reynolds c9bb4540b3 Merge pull request #1668 from djpowers/patch-1
Update link to getting started guide
2015-10-28 20:34:23 -07:00
Dave Powers 1c94fe989c Update link to getting started guide
[ci skip]
2015-10-28 20:50:10 -04:00
Thomas Reynolds 097d19eaca Merge pull request #1661 from tysongach/tg-donation-link
Update donation link
2015-10-28 09:15:10 -07:00
Tyson Gach 807bb3264c Update donation link 2015-10-28 09:50:02 -04:00
Thomas Reynolds 8dbd35938d Merge pull request #1659 from glamouracademy/v3-stable
Add link for RubyGem package manager download
2015-10-27 10:54:50 -07:00
glamouracademy ec30622dc3 Merge pull request #1 from glamouracademy/glamouracademy-patch-1
Add link for RubyGem package manager download
2015-10-27 12:42:27 -04:00
glamouracademy 601653b766 Add link for RubyGem package manager download 2015-10-27 12:38:16 -04:00
Thomas Reynolds c2f0db0951 Merge pull request #1650 from jenniferyien/v3-stable
Update LICENSE.md
2015-10-24 13:54:33 -07:00
Jenn 3d88530925 Update LICENSE.md
updated copyright year from 2014 to 2015
2015-10-23 23:33:39 -04:00
Thomas Reynolds 5f69431a74 Merge pull request #1614 from poporul/v3-stable
Little bit cleaned up. Dry in rake tasks. Fix $LOAD_PATH
2015-10-22 19:56:24 -07:00
Thomas Reynolds a4807496ed Merge pull request #1640 from tommysanterre/Fix_issue_1601_unitialized_constant_on_windows
Add some requires to help #1601
2015-10-19 15:32:30 -07:00
Tommy Santerre 546cadf4fd Add some requires to help #1601 2015-10-17 21:53:47 -04:00
Thomas Reynolds db1e8b8611 add a specific require. hopefully helping #1601 2015-10-17 14:06:50 -07:00
Thomas Reynolds 58e794645b Merge pull request #1633 from dg-ratiodata/feature/preven_crash_due_to_invalid_data_file
Refactor Data Loader to prevent middleman from crashing due to invalid…
2015-10-09 12:41:26 -07:00
Dennis Günnewig 492281f9e8 Refator Data Loader to prevent middleman from crashing due to invalid data file 2015-10-09 12:15:09 +02:00
Alexey Pokhozhaev 4d46b84aae Do not run specs if there is no spec directory 2015-10-07 15:59:12 +03:00
Alexey Pokhozhaev b9cdc2bba4 Run cucumber if features directory exists + removed unused task 2015-10-07 15:29:34 +03:00
Alexey Pokhozhaev 3a7848da9e Little bit cleaned up. Dry in rake tasks. Fix $LOAD_PATH 2015-10-07 14:33:56 +03:00
Thomas Reynolds 8292bc9899 Merge pull request #1625 from ajsharp/patch-1
Add Errno::ENETUNREACH to exception list in BasicNetworkResolver
2015-10-05 20:47:19 -07:00
Alex Sharp 9a529cd294 Add Errno::ENETUNREACH to exception list in BasicNetworkResolver
Fixes #1621
2015-10-05 11:08:52 -07:00
Thomas Reynolds 529bcca927 Merge pull request #1623 from boone/spellcheck
Fixed typos.
2015-10-05 08:21:06 -07:00
Mike Boone 5a4d7352f1 Fixed typos. 2015-10-04 20:59:53 -04:00
Thomas Reynolds 99c2362ee8 Merge pull request #1616 from y-yagi/reomve_unnecessary_require
remove unnecessary require
2015-10-04 11:50:46 -07:00
yuuji.yaginuma 65a65b9677 remove unnecessary require
`require 'rubygems'` is already required in Ruby 1.9 or later.
2015-10-03 10:06:52 +09:00
Thomas Reynolds a064ba93b3 Merge pull request #1613 from ne-sachirou/fix/clean_under_hidden_dir
Fix: Can't clean files when the project is under a hidden directory.
2015-09-30 23:57:05 -07:00
inoue_sachiro 2aac804e92 Fix: Can't clean files when the project is under a hidden directory. 2015-09-30 21:23:27 +09:00
Thomas Reynolds 2870647097 Merge pull request #1578 from ashfurrow/after_render-fix
Fixes problem with after_render hooks returning nil.
2015-09-17 09:35:37 -07:00
Thomas Reynolds 41255e6727 Merge pull request #1599 from nslocum/v3-stable
Ignore gems installed in local dir.
2015-09-17 09:03:51 -07:00
Nick Slocum c09b15a895 specify the root directory. 2015-09-13 11:05:11 -04:00
nslocum 10feaad451 Ignore gems installed in local dir. 2015-09-11 08:42:52 -04:00
Ash Furrow fa3a95fa23 Fixes problem with after_render hooks returning nil. 2015-08-01 18:09:14 -04:00
Artem Vorotnikov 2b449bc398 Remove showtitle attribute from asciidoc renderer 2015-07-05 09:19:10 +03:00
61 changed files with 557 additions and 234 deletions

View File

@ -1,6 +1,14 @@
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
===

View File

@ -29,6 +29,9 @@ Ideally, a bug report should include a pull request with failing specs.
[gist]: https://gist.github.com/
## Submitting a Pull Request
**WE DO NOT ACCEPT NEW FEATURES FOR THE V3 BRANCH ANYMORE**
1. [Fork the repository.][fork]
2. Create a topic [branch]. `git checkout -b local_topic_branch`
3. Add specs for your unimplemented feature or bug fix.

View File

@ -6,7 +6,7 @@ gem 'yard', '~> 0.8', require: false
# Test tools
gem 'pry', '~> 0.10', group: :development
gem 'aruba', '~> 0.7.4'
gem 'aruba', '~> 0.10.0'
gem 'rspec', '~> 3.0'
gem 'cucumber', '~> 2.0'
@ -35,6 +35,6 @@ gem 'simplecov', '~> 0.10', require: false
gem 'coveralls', '~> 0.8', require: false
# Middleman itself
gem 'middleman', path: 'middleman'
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'

View File

@ -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
a copy of this software and associated documentation files (the
@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -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)
**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?
@ -19,7 +19,7 @@ These days, many websites are built with an API in mind. Rather than package the
## 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
@ -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)
Help support the Middleman team [with a donation](https://plasso.co/s/4dXbHBorC3).
## Versioning

View File

@ -1,18 +1,17 @@
require 'rubygems' unless defined?(Gem)
require 'rake'
require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FILE__)
ROOT = File.expand_path(File.dirname(__FILE__))
GEM_NAME = 'middleman'
middleman_gems = %w(middleman-core middleman)
GEM_PATHS = middleman_gems.freeze
require 'middleman-core/version'
def sh_rake(command)
sh "#{Gem.ruby} -S rake #{command}", verbose: true
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'
task :version do
puts "Current version: #{Middleman::VERSION}"
@ -29,32 +28,23 @@ end
desc 'Release all middleman gems'
task publish: :push do
puts 'Pushing to rubygems...'
GEM_PATHS.each do |dir|
Dir.chdir(dir) { sh_rake('release') }
end
within_each_gem { sh_rake('release') }
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" }
end
within_each_gem { sh_rake('yard') }
end
desc 'Run tests for all middleman gems'
task :test do
Rake::Task['rubocop'].invoke
GEM_PATHS.each do |g|
Dir.chdir("#{File.join(ROOT, g)}") { sh "#{Gem.ruby} -S rake test" }
end
within_each_gem { sh_rake('test') }
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" }
end
within_each_gem { sh_rake('spec') }
end
require 'rubocop/rake_task'

View File

@ -1,4 +1,3 @@
require 'rubygems' unless defined?(Gem)
require 'rake'
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'}"
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'
desc 'Run RSpec'
RSpec::Core::RakeTask.new do |spec|
@ -39,8 +30,12 @@ RSpec::Core::RakeTask.new do |spec|
spec.rspec_opts = ['--color', '--format documentation']
end
test_tasks = []
test_tasks << :spec if Dir.exists? 'spec'
test_tasks << :cucumber if Dir.exists? 'features'
desc 'Run tests, both RSpec and Cucumber'
task test: [:spec, :cucumber]
task test: test_tasks
YARD::Rake::YardocTask.new

View File

@ -1 +0,0 @@
--color

View File

@ -1,7 +1 @@
# coding:utf-8
RAKE_ROOT = __FILE__
GEM_NAME = ENV['NAME'] || 'middleman-core'
require 'rubygems'
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
require_relative '../gem_rake_helper'

View File

@ -42,3 +42,21 @@ Feature: Build Clean
Then the following files should not exist:
| sub/dir/about.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 |

View 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 ///
"""

View File

@ -6,7 +6,7 @@ Feature: Run the preview server
Background:
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
When I run `middleman server` interactively
@ -31,7 +31,7 @@ Feature: Run the preview server
"""
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:
"""
@ -52,7 +52,7 @@ Feature: Run the preview server
"""
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:
"""
@ -76,7 +76,7 @@ Feature: Run the preview server
"""
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:
"""
@ -104,7 +104,7 @@ Feature: Run the preview server
"""
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:
"""
@ -127,7 +127,7 @@ Feature: Run the preview server
"""
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:
"""
@ -151,7 +151,7 @@ Feature: Run the preview server
"""
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:
"""
@ -170,7 +170,7 @@ Feature: Run the preview server
"""
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:
"""
@ -189,7 +189,7 @@ Feature: Run the preview server
"""
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:
"""
@ -213,7 +213,7 @@ Feature: Run the preview server
"""
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:
"""
@ -241,7 +241,7 @@ Feature: Run the preview server
"""
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:
"""
@ -265,7 +265,7 @@ Feature: Run the preview server
"""
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:
"""
@ -284,7 +284,7 @@ Feature: Run the preview server
"""
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:
"""
@ -303,7 +303,7 @@ Feature: Run the preview server
"""
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:
"""
@ -322,7 +322,7 @@ Feature: Run the preview server
"""
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:
"""
@ -341,7 +341,7 @@ Feature: Run the preview server
"""
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
@ -356,7 +356,7 @@ Feature: Run the preview server
"""
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
@ -456,7 +456,7 @@ Feature: Run the preview server
"""
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:
"""
@ -488,7 +488,7 @@ Feature: Run the preview server
"""
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:
"""
@ -520,7 +520,7 @@ Feature: Run the preview server
"""
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:
"""

View File

@ -51,3 +51,31 @@ Feature: Local Data API
Then I should see "title1:Hello"
Then I should see "title2:More"
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:
"""

View File

@ -18,118 +18,195 @@ end
Then /^should raise an exception if the operator is not supported$/ do
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)
end
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
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
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
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
Then /^should return the right documents$/ do
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
document_1 = documents[0]
document_2 = documents[1]
cd '.' do
with_environment do
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
document_1.should == found_document
found_document = @server_inst.sitemap.where(:title => document_2.raw_data[:title]).first
document_2.should == found_document
found_document = @server_inst.sitemap.where(:title => document_1.raw_data[:title]).first
document_1.should == found_document
found_document = @server_inst.sitemap.where(:title => document_2.raw_data[:title]).first
document_2.should == found_document
end
end
end
Then /^should be chainable$/ do
documents = @server_inst.sitemap.resources.select { |r| !r.raw_data.empty? }
document_1 = documents[0]
cd '.' do
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.where(:id => document_1.raw_data[:id])
document_1.should == document_proxy.first
document_proxy = @server_inst.sitemap.where(:title => document_1.raw_data[:title])
document_proxy.where(:id => document_1.raw_data[:id])
document_1.should == document_proxy.first
end
end
end
Then /^should not be confused by attributes not present in all documents$/ do
result = @server_inst.sitemap.where(:seldom_attribute => 'is seldom').all
result.map { |r| r.raw_data[:id] }.should == [4]
cd '.' do
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
Then /^with a gt operator should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
found_documents = @server_inst.sitemap.where(selector => 2).all
found_documents.map { |r| r.raw_data[:id] }.sort.should == [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 == [5,3,4].sort
end
end
end
Then /^with a gte operator should return the right documents$/ do
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
Then /^with an in operator should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
found_documents = @server_inst.sitemap.where(selector => [2,3]).all
found_documents.map { |r| r.raw_data[:id] }.sort.should == [2,3].sort
cd '.' do
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
Then /^with an lt operator should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lt'
found_documents = @server_inst.sitemap.where(selector => 2).all
found_documents.map { |r| r.raw_data[:id] }.should == [1]
cd '.' do
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
Then /^with an lte operator should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
found_documents = @server_inst.sitemap.where(selector => 2).all
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].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 == [1,2].sort
end
end
end
Then /^with an include operator include should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :tags, :operator => 'include'
found_documents = @server_inst.sitemap.where(selector => 'ruby').all
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
cd '.' do
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
Then /^with mixed operators should return the right documents$/ do
in_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'in'
gt_selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'gt'
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]
cd '.' do
with_environment do
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
Then /^using multiple constrains in one where should return the right documents$/ do
selector = ::Middleman::Sitemap::Queryable::Selector.new :attribute => :id, :operator => 'lte'
found_documents = @server_inst.sitemap.where(selector => 2, :status => :published).all
found_documents.map { |r| r.raw_data[:id] }.sort.should == [1,2].sort
cd '.' do
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
Then /^should support ordering by attribute ascending$/ 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]
cd '.' do
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
Then /^should support ordering by attribute descending$/ 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]
cd '.' do
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
Then /^should order by attribute ascending by default$/ do
found_documents = @server_inst.sitemap.order_by(:title).all
found_documents.map { |r| r.raw_data[:id] }.should == [2,3,1,5,4]
cd '.' do
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
Then /^should exclude documents that do not own the attribute$/ 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
cd '.' do
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

View File

@ -1,4 +1,4 @@
@nojava
@wip @nojava
Feature: Stylus Updates and Partials
Scenario: The preview server should update stylesheets when Stylus changes
Given the Server is running at "stylus-preview-app"

View File

@ -1,4 +1,5 @@
= Page Title
:showtitle:
:page-layout: default
Hello, AsciiDoc!

View File

@ -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

View File

@ -0,0 +1 @@
set :build_dir, ".build"

View 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

View File

@ -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>

View File

@ -1,9 +1,5 @@
# 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
module Middleman
# Backwards compatibility namespace

View File

@ -41,6 +41,9 @@ module Middleman
# Runs after the build is finished
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
# and/or a block to be evaluated
# @return [void]

View File

@ -5,7 +5,7 @@ require 'thor/group'
# CLI Module
module Middleman
module Cli
# The base task from which everything else etends
# The base task from which everything else extends
class Base < Thor
class << self
def start(*args)

View File

@ -167,7 +167,7 @@ module Middleman::Cli
paths = ::Middleman::Util.all_files_under(@build_dir).map(&:realpath).select(&:file?)
@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
return unless RUBY_PLATFORM =~ /darwin/

View File

@ -48,7 +48,7 @@ module Middleman
self.class.config
end
# Backwards compatibilty with old Sinatra template interface
# Backwards compatibility with old Sinatra template interface
#
# @deprecated Prefer accessing settings through "config".
#

View File

@ -7,9 +7,7 @@ module Middleman
class << self
# @private
def registered(app)
# Data formats
require 'yaml'
require 'json'
require 'middleman-core/core_extensions/data/file_loader'
app.config.define_setting :data_dir, 'data', 'The directory data files are stored in'
app.send :include, InstanceMethods
@ -95,11 +93,9 @@ module Middleman
data_path = full_path.relative_path_from(root + @app.config[:data_dir])
if %w(.yaml .yml).include?(extension)
data = YAML.load_file(full_path)
elsif extension == '.json'
data = JSON.parse(full_path.read)
else
begin
data = FileLoader.new.load(full_path)
rescue FileLoader::NoFileLoaderFoundError
return
end

View File

@ -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

View File

@ -214,7 +214,7 @@ module Middleman
locals = options[:locals]
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)
else
read_template_file(found_partial)
@ -265,7 +265,7 @@ module Middleman
# Try to work around: https://github.com/middleman/middleman/issues/501
locs = locs.dup
# Detect the remdering engine from the extension
# Detect the rendering engine from the extension
extension = File.extname(path)
engine = extension[1..-1].to_sym
@ -296,10 +296,10 @@ module Middleman
# Allow hooks to manipulate the template before render
self.class.callbacks_for_hook(:before_render).each do |callback|
# Uber::Options::Value doesn't respond to call
newbody = if callback.respond_to?(:call)
callback.call(body, path, locs, template_class)
newbody = if callback.is_a? ::Uber::Options::Value
callback.call(self, body, path, locs, template_class)
elsif callback.respond_to?(:evaluate)
callback.evaluate(self, body, path, locs, template_class)
callback.call(body, path, locs, template_class)
end
body = newbody if newbody # Allow the callback to return nil to skip it
end
@ -315,10 +315,10 @@ module Middleman
# Allow hooks to manipulate the result after render
self.class.callbacks_for_hook(:after_render).each do |callback|
# Uber::Options::Value doesn't respond to call
newcontent = if callback.respond_to?(:call)
content = callback.call(content, path, locs, template_class)
newcontent = if callback.is_a? ::Uber::Options::Value
callback.call(self, content, path, locs, template_class)
elsif callback.respond_to?(:evaluate)
content = callback.evaluate(self, content, path, locs, template_class)
callback.call(content, path, locs, template_class)
end
content = newcontent if newcontent # Allow the callback to return nil to skip it
end

View File

@ -15,7 +15,7 @@ module Middleman
# When in dev
app.configure :development do
# Include middlemare
# Include middleware
use ::Rack::ShowExceptions if config[:show_exceptions]
end
end

View File

@ -21,7 +21,7 @@ module Middleman
# Array of Names
def getnames(ip)
resolver.getnames(ip.to_s).map(&:to_s)
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
[]
end
@ -34,7 +34,7 @@ module Middleman
# Array of ipaddresses
def getaddresses(name)
resolver.getaddresses(name.to_s).map(&:to_s)
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
[]
end

View File

@ -56,8 +56,6 @@ module Middleman
#
# @private
def load_extensions_in_path
require 'rubygems'
extensions = rubygems_latest_specs.select do |spec|
spec_has_file?(spec, EXTENSION_FILE)
end

View File

@ -1,4 +1,6 @@
require 'padrino-helpers'
require 'padrino-helpers/output_helpers'
require 'padrino-helpers/tag_helpers'
module Middleman
module MetaPages

View File

@ -59,7 +59,7 @@ module Middleman
if path_parts.size == 1
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
@children[first_part] = sitemap_class.new(resource)

View File

@ -5,6 +5,7 @@ require 'middleman-core/meta_pages'
require 'middleman-core/logger'
require 'middleman-core/preview_server/server_information'
require 'middleman-core/preview_server/server_url'
require 'middleman-core/preview_server/server_information_callback_proxy'
# rubocop:disable GlobalVars
module Middleman
@ -13,10 +14,6 @@ module Middleman
attr_reader :app, :ssl_certificate, :ssl_private_key, :environment, :server_information
delegate :logger, to: :app
def https?
@https
end
# Start an instance of Middleman::Application
# @return [void]
def start(opts={})
@ -26,6 +23,7 @@ module Middleman
@options = opts
@server_information = ServerInformation.new
@server_information.https = (@options[:https] == true)
# New app evaluates the middleman configuration. Since this can be
# 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 %(== 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.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('== Inspect your site configuration at %s', ServerUrl.new(hosts: server_information.site_addresses, port: server_information.port, https: https?).to_config_urls.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: 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: server_information.https?).to_config_urls.join(', '))
@initialized ||= false
return if @initialized
@ -56,6 +54,8 @@ module Middleman
# reloading later on.
::Middleman::Profiling.report('server_start')
app.run_hook(:before_server, ServerInformationCallbackProxy.new(server_information))
loop do
@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
@https = @app.config[:https]
@environment = @app.config[:environment]
@ssl_certificate = @app.config[:ssl_certificate]
@ -199,7 +198,7 @@ module Middleman
@listener.start
end
# Trap some interupt signals and shut down smoothly
# Trap some interrupt signals and shut down smoothly
# @return [void]
def register_signal_handlers
%w(INT HUP TERM QUIT).each do |sig|
@ -224,7 +223,7 @@ module Middleman
DoNotReverseLookup: true
}
if https?
if server_information.https?
http_opts[:SSLEnable] = true
if ssl_certificate || ssl_private_key

View File

@ -20,6 +20,8 @@ module Middleman
public
attr_writer :https
def initialize(opts={})
@resolver = opts.fetch(:resolver, DnsResolver.new)
@validator = opts.fetch(:validator, ServerInformationValidator.new)
@ -64,13 +66,15 @@ module Middleman
@bind_address = config[:bind_address]
@port = config[:port]
@server_name = config[:server_name]
@https = config[:https]
config[:bind_address] = bind_address
config[:port] = port
config[:server_name] = server_name
config[:port] = port
config[:server_name] = server_name
config[:https] = https?
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
# the preview server settings
#
@ -139,6 +143,11 @@ module Middleman
def listeners
information.listeners
end
# Is https enabled?
def https?
@https == true
end
end
end
end

View File

@ -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

View File

@ -6,7 +6,7 @@ module Middleman
class ServerUrl
private
attr_reader :hosts, :port, :https
attr_reader :hosts, :port, :https, :format_output
public
@ -14,6 +14,7 @@ module Middleman
@hosts = opts.fetch(:hosts)
@port = opts.fetch(:port)
@https = opts.fetch(:https, false)
@format_output = opts.fetch(:format_output, true)
end
# Return bind addresses
@ -21,7 +22,11 @@ module Middleman
# @return [Array]
# List of bind addresses of format host:port
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
# Return server urls
@ -29,7 +34,11 @@ module Middleman
# @return [Array]
# List of urls of format http://host:port
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
# Return server config urls
@ -37,7 +46,11 @@ module Middleman
# @return [Array]
# List of urls of format http://host:port/__middleman
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
private

View File

@ -8,7 +8,7 @@ module Middleman
app.config.define_setting :asciidoc, {
safe: :safe,
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)'
app.config.define_setting :asciidoc_attributes, [], 'AsciiDoc custom attributes (Array)'
app.before_configuration do

View File

@ -7,7 +7,7 @@ module Middleman
module Liquid
# Setup extension
class << self
# Once registerd
# Once registered
def registered(app)
app.before_configuration do
template_extensions liquid: :html

View File

@ -5,7 +5,7 @@ module Middleman::Sitemap::Extensions
module ContentType
# The preferred MIME content type for this resource
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]
return meta_type if meta_type

View File

@ -54,7 +54,7 @@ module Middleman
rebuild_resource_list!(:registered_new)
end
# Rebuild the list of resources from scratch, using registed manipulators
# Rebuild the list of resources from scratch, using registered manipulators
# rubocop:disable UnusedMethodArgument
# @return [void]
def rebuild_resource_list!(reason=nil)
@ -99,7 +99,7 @@ module Middleman
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.
def invalidate_resources_not_ignored_cache!
@resources_not_ignored = nil

View File

@ -1,5 +1,5 @@
require 'aruba/cucumber'
require 'aruba/jruby'
require 'aruba/config/jruby'
require 'middleman-core/step_definitions/middleman_steps'
require 'middleman-core/step_definitions/builder_steps'
require 'middleman-core/step_definitions/server_steps'

View File

@ -5,29 +5,27 @@ Before do
end
Given /^app "([^\"]*)" is using config "([^\"]*)"$/ do |path, config_name|
target = File.join(PROJECT_ROOT_PATH, 'fixtures', path)
config_path = File.join(current_directory, "config-#{config_name}.rb")
config_dest = File.join(current_directory, 'config.rb')
FileUtils.cp(config_path, config_dest)
copy("config-#{config_name}.rb", 'config.rb')
end
Given /^an empty app$/ do
step %Q{a directory named "empty_app"}
step %Q{I cd to "empty_app"}
ENV['MM_ROOT'] = nil
delete_environment_variable 'MM_ROOT'
end
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
# 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}"}
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}"}
end
@ -58,20 +56,20 @@ Given /^a successfully built app at "([^\"]*)" with flags "([^\"]*)"$/ do |path,
end
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)
end
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]
end
# Provide this Aruba overload in case we're matching something with quotes in it
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
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

View File

@ -1,11 +1,11 @@
When /^I stop (?:middleman|all commands) if the output( of the last command)? contains:$/ do |last_command, expected|
begin
Timeout.timeout(exit_timeout) do
Timeout.timeout(aruba.config.exit_timeout) 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))
only_processes.each { |p| p.terminate }
if sanitize_text(last_command_started.output) =~ Regexp.new(sanitize_text(expected))
terminate_all_commands
break
end
@ -13,10 +13,10 @@ When /^I stop (?:middleman|all commands) if the output( of the last command)? co
end
end
rescue ChildProcess::TimeoutError, TimeoutError
@interactive.terminate
terminate_all_commands
ensure
announcer.stdout @interactive.stdout
announcer.stderr @interactive.stderr
announcer.announce :stdout, last_command_started.stdout
announcer.announce :stderr, last_command_started.stderr
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
@mdns_server = run("dns_server.rb #{db_file} #{port}", 120)
@ -80,7 +80,7 @@ end
# Make sure each and every process is really dead
After do
only_processes.each { |p| p.terminate }
terminate_all_commands
end
Before '@ruby-2.1' do

View File

@ -9,9 +9,17 @@ Then /^the file "([^\"]*)" is removed$/ do |path|
end
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
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

View File

@ -31,15 +31,13 @@ Given /^current environment is "([^\"]*)"$/ do |env|
end
Given /^the Server is running$/ do
root_dir = File.expand_path(current_directory)
if File.exists?(File.join(root_dir, 'source'))
ENV['MM_SOURCE'] = 'source'
if exist? 'source'
set_environment_variable 'MM_SOURCE', 'source'
else
ENV['MM_SOURCE'] = ''
set_environment_variable 'MM_SOURCE', ''
end
ENV['MM_ROOT'] = root_dir
set_environment_variable 'MM_ROOT', expand_path('.')
initialize_commands = @initialize_commands || []
initialize_commands.unshift lambda {
@ -47,10 +45,12 @@ Given /^the Server is running$/ do
set :show_exceptions, false
}
in_current_directory do
@server_inst = Middleman::Application.server.inst do
initialize_commands.each do |p|
instance_exec(&p)
cd '.' do
with_environment do
@server_inst = Middleman::Application.server.inst do
initialize_commands.each do |p|
instance_exec(&p)
end
end
end
end
@ -68,61 +68,81 @@ Given /^a template named "([^\"]*)" with:$/ do |name, string|
end
When /^I go to "([^\"]*)"$/ do |url|
in_current_directory do
visit(URI.encode(url).to_s)
cd '.' do
with_environment do
visit(URI.encode(url).to_s)
end
end
end
Then /^going to "([^\"]*)" should not raise an exception$/ do |url|
in_current_directory do
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
cd '.' do
with_environment do
expect{ visit(URI.encode(url).to_s) }.to_not raise_exception
end
end
end
Then /^the content type should be "([^\"]*)"$/ do |expected|
in_current_directory do
expect(page.response_headers['Content-Type']).to start_with expected
cd '.' do
with_environment do
expect(page.response_headers['Content-Type']).to start_with expected
end
end
end
Then /^I should see "([^\"]*)"$/ do |expected|
in_current_directory do
expect(page.body).to include expected
cd '.' do
with_environment do
expect(page.body).to include expected
end
end
end
Then /^I should see '([^\']*)'$/ do |expected|
in_current_directory do
expect(page.body).to include expected
cd '.' do
with_environment do
expect(page.body).to include expected
end
end
end
Then /^I should see:$/ do |expected|
in_current_directory do
expect(page.body).to include expected
cd '.' do
with_environment do
expect(page.body).to include expected
end
end
end
Then /^I should not see "([^\"]*)"$/ do |expected|
in_current_directory do
expect(page.body).not_to include expected
cd '.' do
with_environment do
expect(page.body).not_to include expected
end
end
end
Then /^I should not see:$/ do |expected|
in_current_directory do
expect(page.body).not_to include expected
cd '.' do
with_environment do
expect(page.body).not_to include expected
end
end
end
Then /^the status code should be "([^\"]*)"$/ do |expected|
in_current_directory do
expect(page.status_code).to eq expected.to_i
cd '.' do
with_environment do
expect(page.status_code).to eq expected.to_i
end
end
end
Then /^I should see "([^\"]*)" lines$/ do |lines|
in_current_directory do
expect(page.body.chomp.split($/).length).to eq lines.to_i
cd '.' do
with_environment do
expect(page.body.chomp.split($/).length).to eq lines.to_i
end
end
end

View File

@ -1,4 +1,3 @@
require 'rubygems'
require 'middleman/rack'
run Middleman.server

View File

@ -16,3 +16,6 @@
# Ignore .DS_store file
.DS_Store
# Ignore gems installed in local directory
/vendor/bundle/

View File

@ -112,7 +112,7 @@ module Middleman
end
end
# Get a recusive list of files inside a path.
# Get a recursive list of files inside a path.
# Works with symlinks.
#
# @param path Some path string or Pathname

View File

@ -1,5 +1,5 @@
module Middleman
# Current Version
# @return [String]
VERSION = '3.4.0' unless const_defined?(:VERSION)
VERSION = '3.4.1' unless const_defined?(:VERSION)
end

View File

@ -1,10 +1,17 @@
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
# users expect.
::I18n.enforce_available_locales = false
class Padrino::Helpers::OutputHelpers::ErbHandler
class ::Padrino::Helpers::OutputHelpers::ErbHandler
# Force Erb capture not to use safebuffer
# rubocop:disable UnderscorePrefixedVariableName
def capture_from_template(*args, &block)
@ -216,7 +223,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
# @return [String] The fully qualified asset url
def asset_url(path, prefix='', options={})
# 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
else # rewrite paths to use their destination 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
result
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)
Pathname(result).relative_path_from(current_dir.dirname).to_s
end

View File

@ -43,7 +43,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
else
# It's a template, possible with partials. We can't really
# know when it's updated, so generate fresh cache buster every
# time during developement
# time during development
http_path << '?' + Time.now.strftime('%s')
end
end

View File

@ -1,5 +1,7 @@
# -*- encoding: utf-8 -*-
require File.expand_path("../lib/middleman-core/version", __FILE__)
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "middleman-core/version"
Gem::Specification.new do |s|
s.name = "middleman-core"

View File

View File

@ -1,5 +1 @@
# coding:utf-8
RAKE_ROOT = __FILE__
GEM_NAME = 'middleman'
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
require_relative '../gem_rake_helper'

View File

@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
lib = 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__)
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.files = `git ls-files -z`.split("\0")
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
s.require_paths = ["lib"]
s.required_ruby_version = '>= 1.9.3'