middleman 0.5.2 → 0.5.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -26,15 +26,22 @@ module Generators
26
26
  end
27
27
 
28
28
  if (args[0] === args[1])
29
- newext = case File.extname(args.first)
30
- when '.haml', '.erb', '.mab', '.maruku'
31
- '.html'
32
- when '.sass'
33
- '.css'
29
+ file_name_parts = File.basename(args.first).split('.')
30
+
31
+ if file_name_parts.length > 2
32
+ # static ext embedded in filename
33
+ newext = ""
34
34
  else
35
- File.extname(args.first)
35
+ # use defaults
36
+ newext = case file_name_parts.last
37
+ when 'haml', 'erb', 'mab', 'maruku'
38
+ '.html'
39
+ when 'sass'
40
+ '.css'
41
+ end
36
42
  end
37
- args[1] = args[0].gsub(File.extname(args.first), newext).gsub('views/', '')
43
+
44
+ args[1] = args[0].gsub(".#{file_name_parts.last}", newext).gsub('views/', '')
38
45
  end
39
46
 
40
47
  super(name, *args, &block)
@@ -14,7 +14,7 @@ class Middleman < Sinatra::Base
14
14
  set :static, true
15
15
  set :root, Dir.pwd
16
16
  set :environment, defined?(MIDDLEMAN_BUILDER) ? :build : :development
17
-
17
+ set :default_ext, 'html'
18
18
  set :supported_formats, %w(haml erb builder)
19
19
 
20
20
  helpers Sinatra::ContentFor
@@ -82,15 +82,20 @@ class Middleman < Sinatra::Base
82
82
 
83
83
  # All other files
84
84
  get /(.*)/ do |path|
85
- path << "index.html" if path.match(%r{/$})
85
+ path << "index.#{options.default_ext}" if path.match(%r{/$})
86
86
  path.gsub!(%r{^/}, '')
87
- path.gsub!(File.extname(path), '')
87
+ path_without_ext = path.gsub(File.extname(path), '')
88
88
 
89
89
  result = nil
90
90
  begin
91
91
  options.supported_formats.detect do |renderer|
92
- next false if !File.exists?(File.join(options.views, "#{path}.#{renderer}"))
93
- result = send(renderer.to_sym, path.to_sym)
92
+ if File.exists?(File.join(options.views, "#{path}.#{renderer}"))
93
+ result = send(renderer.to_sym, path.to_sym)
94
+ elsif File.exists?(File.join(options.views, "#{path_without_ext}.#{renderer}"))
95
+ result = send(renderer.to_sym, path_without_ext.to_sym)
96
+ else
97
+ false
98
+ end
94
99
  end
95
100
  rescue Haml::Error => e
96
101
  result = "Haml Error: #{e}"
@@ -99,4 +104,10 @@ class Middleman < Sinatra::Base
99
104
 
100
105
  result || pass
101
106
  end
107
+
108
+
109
+ get %r{/(.*\.xml)} do |path|
110
+ content_type 'text/xml', :charset => 'utf-8'
111
+ haml(path.to_sym, :layout => false)
112
+ end
102
113
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{middleman}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Thomas Reynolds"]
12
- s.date = %q{2009-09-17}
12
+ s.date = %q{2009-09-18}
13
13
  s.email = %q{tdreyno@gmail.com}
14
14
  s.executables = ["mm-init", "mm-build", "mm-server"]
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-17 00:00:00 -07:00
12
+ date: 2009-09-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency