nanoc 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,6 +1,13 @@
1
1
  nanoc Release Notes
2
2
  ===================
3
3
 
4
+ 2.0.3
5
+ -----
6
+
7
+ * autocompiler now honors custom paths
8
+ * autocompiler now attempts to serve pages with the most appropriate MIME
9
+ type, instead of always serving everything as "text/html"
10
+
4
11
  2.0.2
5
12
  -----
6
13
 
data/lib/nanoc.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Nanoc
2
2
 
3
- VERSION = '2.0.2'
3
+ VERSION = '2.0.3'
4
4
 
5
5
  def self.load_file(*path)
6
6
  full_path = [ File.dirname(__FILE__), 'nanoc' ] + path
@@ -72,7 +72,7 @@ END
72
72
 
73
73
  if page.nil?
74
74
  # Serve file
75
- if File.exist?(file_path)
75
+ if File.file?(file_path)
76
76
  serve_file(file_path, response)
77
77
  else
78
78
  serve_404(request.path, response)
@@ -114,8 +114,12 @@ END
114
114
  return
115
115
  end
116
116
 
117
+ # Determine most likely MIME type
118
+ mime_type = MIME::Types.of(page.path).first
119
+ mime_type = mime_type.nil? ? 'text/html' : mime_type.simplified
120
+
117
121
  response.status = 200
118
- response['Content-Type'] = 'text/html'
122
+ response['Content-Type'] = mime_type
119
123
  response.body = page.layouted_content
120
124
  end
121
125
 
@@ -59,8 +59,13 @@ module Nanoc
59
59
  @content[:post]
60
60
  end
61
61
 
62
- def skip_output? ; attribute_named(:skip_output) ; end
63
- def path ; attribute_named(:path) ; end
62
+ def skip_output?
63
+ attribute_named(:skip_output)
64
+ end
65
+
66
+ def path
67
+ attribute_named(:custom_path) || attribute_named(:path)
68
+ end
64
69
 
65
70
  def path_on_filesystem
66
71
  if attribute_named(:custom_path).nil?
@@ -152,10 +152,11 @@ module Nanoc::DataSource::Filesystem
152
152
  # processor; which extension maps to which layout processor is defined in
153
153
  # the layout processors.
154
154
  def layouts
155
- Dir["layouts/*"].reject { |f| f =~ /~$/ }.map do |filename|
155
+ Dir["layouts/**/*"].reject { |f| f =~ /~$/ }.map do |filename|
156
156
  # Get layout details
157
157
  extension = File.extname(filename)
158
- name = File.basename(filename, extension)
158
+ #name = File.basename(filename, extension)
159
+ name = filename.gsub(/layouts\//,"").gsub(extension,"")
159
160
  content = File.read(filename)
160
161
 
161
162
  # Build hash for layout
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-26 00:00:00 +01:00
12
+ date: 2008-03-25 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15