middleman 1.1.5 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,4 +9,31 @@ Feature: Custom layouts
|
|
9
9
|
Scenario: Using with_layout block
|
10
10
|
Given "/custom-layout.html" with_layout block has layout "custom"
|
11
11
|
When I go to "/custom-layout.html"
|
12
|
+
Then I should see "Custom Layout"
|
13
|
+
|
14
|
+
Scenario: Using custom :layout attribute with folders
|
15
|
+
Given page "/custom-layout-dir/" has layout "custom"
|
16
|
+
When I go to "/custom-layout-dir"
|
17
|
+
Then I should see "Custom Layout"
|
18
|
+
When I go to "/custom-layout-dir/"
|
19
|
+
Then I should see "Custom Layout"
|
20
|
+
When I go to "/custom-layout-dir/index.html"
|
21
|
+
Then I should see "Custom Layout"
|
22
|
+
|
23
|
+
Scenario: Using custom :layout attribute with folders
|
24
|
+
Given page "/custom-layout-dir" has layout "custom"
|
25
|
+
When I go to "/custom-layout-dir"
|
26
|
+
Then I should see "Custom Layout"
|
27
|
+
When I go to "/custom-layout-dir/"
|
28
|
+
Then I should see "Custom Layout"
|
29
|
+
When I go to "/custom-layout-dir/index.html"
|
30
|
+
Then I should see "Custom Layout"
|
31
|
+
|
32
|
+
Scenario: Using custom :layout attribute with folders
|
33
|
+
Given page "/custom-layout-dir/index.html" has layout "custom"
|
34
|
+
When I go to "/custom-layout-dir"
|
35
|
+
Then I should see "Custom Layout"
|
36
|
+
When I go to "/custom-layout-dir/"
|
37
|
+
Then I should see "Custom Layout"
|
38
|
+
When I go to "/custom-layout-dir/index.html"
|
12
39
|
Then I should see "Custom Layout"
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 Welcome
|
data/lib/middleman/server.rb
CHANGED
@@ -101,12 +101,20 @@ module Middleman
|
|
101
101
|
# page "/about.html", :layout => false
|
102
102
|
# page "/", :layout => :homepage_layout
|
103
103
|
def self.page(url, options={}, &block)
|
104
|
-
url
|
104
|
+
url = url.gsub(%r{#{settings.index_file}$}, "")
|
105
|
+
url = url.gsub(%r{(\/)$}, "") if url.length > 1
|
106
|
+
|
107
|
+
paths = [url]
|
108
|
+
paths << "#{url}/" if url.length > 1 && url.split("/").last.split('.').length <= 1
|
109
|
+
paths << "/#{path_to_index(url)}"
|
105
110
|
|
106
111
|
options[:layout] = current_layout if options[:layout].nil?
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
|
113
|
+
paths.each do |p|
|
114
|
+
get(p) do
|
115
|
+
return yield if block_given?
|
116
|
+
process_request(options)
|
117
|
+
end
|
110
118
|
end
|
111
119
|
end
|
112
120
|
|
@@ -116,15 +124,18 @@ module Middleman
|
|
116
124
|
end
|
117
125
|
|
118
126
|
private
|
119
|
-
|
120
|
-
def process_request(options={})
|
121
|
-
# Normalize the path and add index if we're looking at a directory
|
122
|
-
path = request.path
|
127
|
+
def self.path_to_index(path)
|
123
128
|
parts = path ? path.split('/') : []
|
124
129
|
if parts.last.nil? || parts.last.split('.').length == 1
|
125
130
|
path = File.join(path, settings.index_file)
|
126
131
|
end
|
127
|
-
path.gsub
|
132
|
+
path.gsub(%r{^/}, '')
|
133
|
+
end
|
134
|
+
|
135
|
+
# Internal method to look for templates and evaluate them if found
|
136
|
+
def process_request(options={})
|
137
|
+
# Normalize the path and add index if we're looking at a directory
|
138
|
+
path = self.class.path_to_index(request.path)
|
128
139
|
|
129
140
|
static_path = File.join(Middleman::Server.public, path)
|
130
141
|
# if File.exists? static_path
|
data/lib/middleman/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 6
|
10
|
+
version: 1.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Thomas Reynolds
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-22 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -393,6 +393,7 @@ files:
|
|
393
393
|
- fixtures/test-app/views/auto-css.html.haml
|
394
394
|
- fixtures/test-app/views/auto-image-sizes.html.haml
|
395
395
|
- fixtures/test-app/views/cache-buster.html.haml
|
396
|
+
- fixtures/test-app/views/custom-layout-dir/index.html.haml
|
396
397
|
- fixtures/test-app/views/custom-layout.html.haml
|
397
398
|
- fixtures/test-app/views/index.html.haml
|
398
399
|
- fixtures/test-app/views/inline-css.html.haml
|
@@ -528,6 +529,7 @@ test_files:
|
|
528
529
|
- fixtures/test-app/views/auto-css.html.haml
|
529
530
|
- fixtures/test-app/views/auto-image-sizes.html.haml
|
530
531
|
- fixtures/test-app/views/cache-buster.html.haml
|
532
|
+
- fixtures/test-app/views/custom-layout-dir/index.html.haml
|
531
533
|
- fixtures/test-app/views/custom-layout.html.haml
|
532
534
|
- fixtures/test-app/views/index.html.haml
|
533
535
|
- fixtures/test-app/views/inline-css.html.haml
|