allow extensionless files to be previewed and built. fixes #270, but requires alternative layouts be placed in a layouts/ directory now.

i18n_v4
Thomas Reynolds 2012-02-12 11:45:42 -08:00
parent baaa3fd148
commit 5842bf8e5b
15 changed files with 85 additions and 16 deletions

View File

@ -6,7 +6,7 @@ group :development do
gem "rake", "~> 0.9.2"
gem "rspec", "~> 2.7"
gem "rdoc", "~> 3.9"
gem "yard"
# gem "yard"
end
group :test do
@ -15,8 +15,9 @@ group :test do
gem "slim"
gem "coffee-filter", "~> 0.1.1"
gem "liquid", "~> 2.2"
gem "jquery-rails"
gem "bootstrap-rails", "0.0.5"
gem "jquery-rails", "~> 2.0.0"
# gem "bootstrap-rails", "0.0.5"
# gem "zurb-foundation"
end
gem "middleman-core", :path => "middleman-core"

View File

@ -1,7 +1,7 @@
require 'rubygems' unless defined?(Gem)
# require 'fileutils' unless defined?(FileUtils)
require 'rake'
require 'yard'
# require 'yard'
require File.expand_path("../middleman-core/lib/middleman-core/version.rb", __FILE__)
@ -84,7 +84,7 @@ end
desc "Run tests for all middleman gems"
task :default => :test
desc "Generate documentation"
task :doc do
YARD::CLI::Yardoc.new.run
end
# desc "Generate documentation"
# task :doc do
# YARD::CLI::Yardoc.new.run
# end

View File

@ -1,7 +1,7 @@
require 'rubygems' unless defined?(Gem)
require 'rake'
require 'cucumber/rake/task'
require 'yard'
# require 'yard'
require 'bundler'
Bundler::GemHelper.install_tasks :name => GEM_NAME
@ -20,6 +20,6 @@ Cucumber::Rake::Task.new(:test, 'Run features that should pass') do |t|
t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
end
YARD::Rake::YardocTask.new
# YARD::Rake::YardocTask.new
task :default => :test

View File

@ -17,7 +17,6 @@ Feature: Builder
Then the following files should not exist:
| _partial |
| layout |
| other_layout |
| layouts/custom |
| layouts/content_for |

View File

@ -0,0 +1,58 @@
Feature: Text Files Without Extensions Should Build and Preview
Scenario: Building Text Files without directory indexes
Given a fixture app "extensionless-text-files-app"
And a file named "config.rb" with:
"""
"""
And a successfully built app at "extensionless-text-files-app"
When I cd to "build"
Then the following files should exist:
| CNAME |
| LICENSE |
| README |
Scenario: Building Text Files with directory indexes
Given a fixture app "extensionless-text-files-app"
And a file named "config.rb" with:
"""
activate :directory_indexes
"""
And a successfully built app at "extensionless-text-files-app"
When I cd to "build"
Then the following files should exist:
| CNAME |
| LICENSE |
| README |
Then the following files should not exist:
| CNAME/index.html |
| LICENSE/index.html |
| README/index.html |
Scenario: Previewing Text Files without directory indexes
Given "directory_indexes" feature is "disabled"
Given the Server is running at "extensionless-text-files-app"
When I go to "/CNAME"
Then I should see "test.github.com"
When I go to "/LICENSE"
Then I should see "You have the right to remain classy."
When I go to "/README"
Then I should see "Bork bork bork"
Scenario: Previewing Text Files with directory indexes
Given "directory_indexes" feature is "enabled"
Given the Server is running at "extensionless-text-files-app"
When I go to "/CNAME"
Then I should see "test.github.com"
When I go to "/LICENSE"
Then I should see "You have the right to remain classy."
When I go to "/README"
Then I should see "Bork bork bork"
# When I go to "/CNAME/index.html"
# Then I should see "File Not Found"
# When I go to "/LICENSE/index.html"
# Then I should see "File Not Found"
# When I go to "/README/index.html"
# Then I should see "File Not Found"

View File

@ -0,0 +1 @@
test.github.com

View File

@ -0,0 +1 @@
You have the right to remain classy.

View File

@ -0,0 +1 @@
Bork bork bork

View File

@ -19,8 +19,12 @@ module Middleman::CoreExtensions::Sitemap
# Files starting with an underscore, but not a double-underscore
:partials => proc { |file, path| (file.match(/\/_/) && !file.match(/\/__/)) },
:layout => proc { |file, path|
file.match(/^source\/layout\./) || file.match(/^source\/layouts\//)
},
# Files without any output extension (layouts, partials)
:extensionless => proc { |file, path| !path.match(/\./) },
# :extensionless => proc { |file, path| !path.match(/\./) },
}
# Include instance methods

View File

@ -88,7 +88,10 @@ module Middleman::Sitemap
def page_by_destination(destination_path)
# TODO: memoize this
destination_path = normalize_path(destination_path)
pages.find {|p| p.destination_path == destination_path }
pages.find do |p|
p.destination_path == destination_path ||
p.destination_path == destination_path.sub("/#{@app.index_file}", "")
end
end
# Whether a path is ignored

View File

@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.require_path = "lib"
# Core
s.add_dependency("rack", ["~> 1.3.5"])
s.add_dependency("rack", ["~> 1.4.0"])
s.add_dependency("tilt", ["~> 1.3.1"])
# Builder
@ -29,7 +29,7 @@ Gem::Specification.new do |s|
s.add_dependency("thor", ["~> 0.14.0"])
# Helpers
s.add_dependency("activesupport", ["~> 3.1.0"])
s.add_dependency("activesupport", ["~> 3.2.0"])
# Watcher
s.add_dependency("fssm", ["~> 0.2.8"])

View File

@ -24,7 +24,7 @@ Gem::Specification.new do |s|
s.add_dependency("sass", ["~> 3.1.7"])
s.add_dependency("compass", ["0.12.rc.1"])
s.add_dependency("coffee-script", ["~> 2.2.0"])
s.add_dependency("execjs", ["~> 1.2.7"])
s.add_dependency("execjs", ["~> 1.2"])
s.add_dependency("sprockets", ["~> 2.1.0"])
s.add_dependency("sprockets-sass", ["~> 0.6.0"])
s.add_dependency("redcarpet", ["~> 2.0.0"])