nanoc 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,11 +1,18 @@
1
1
  nanoc Release Notes
2
2
  ===================
3
3
 
4
+ 2.0.4
5
+ -----
6
+
7
+ * Fixed default.rb's `html_escape`
8
+ * Updated Haml filter and layout processor so that @page, @pages and @config
9
+ are now available as instance variables instead of local variables
10
+
4
11
  2.0.3
5
12
  -----
6
13
 
7
- * autocompiler now honors custom paths
8
- * autocompiler now attempts to serve pages with the most appropriate MIME
14
+ * The utocompiler now honors custom paths
15
+ * The autocompiler now attempts to serve pages with the most appropriate MIME
9
16
  type, instead of always serving everything as "text/html"
10
17
 
11
18
  2.0.2
data/bin/nanoc CHANGED
File without changes
@@ -51,8 +51,12 @@ END
51
51
  end
52
52
 
53
53
  def start(port)
54
- nanoc_require('mime/types', "'mime/types' is required to autocompile sites.")
55
-
54
+ nanoc_require(
55
+ 'mime/types',
56
+ "'mime/types' is required to autocompile sites. You may want to " +
57
+ "install the mime-types gem by running 'gem install mime-types'."
58
+ )
59
+
56
60
  # Create server
57
61
  @server = WEBrick::HTTPServer.new(:Port => port || 3000)
58
62
  @server.mount_proc("/") { |request, response| handle_request(request, response) }
@@ -87,7 +87,7 @@ module Nanoc::DataSource::Filesystem
87
87
  "\# before nanoc starts compiling.\n" +
88
88
  "\n" +
89
89
  "def html_escape(str)\n" +
90
- " str.gsub('&', '&amp;').str('<', '&lt;').str('>', '&gt;').str('\"', '&quot;')\n" +
90
+ " str.gsub('&', '&amp;').gsub('<', '&lt;').gsub('>', '&gt;').gsub('\"', '&quot;')\n" +
91
91
  "end\n" +
92
92
  "alias h html_escape\n"
93
93
  end
@@ -152,11 +152,10 @@ 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)
159
- name = filename.gsub(/layouts\//,"").gsub(extension,"")
158
+ name = File.basename(filename, extension)
160
159
  content = File.read(filename)
161
160
 
162
161
  # Build hash for layout
@@ -1,6 +1,6 @@
1
1
  module Nanoc::Filter::ERB
2
2
 
3
- class ERBContext
3
+ class Context
4
4
 
5
5
  def initialize(hash)
6
6
  hash.each_pair do |key, value|
@@ -23,7 +23,7 @@ module Nanoc::Filter::ERB
23
23
 
24
24
  # Create context
25
25
  assigns = { :page => @page, :pages => @pages, :config => @config, :site => @site }
26
- context = ERBContext.new(assigns)
26
+ context = Context.new(assigns)
27
27
 
28
28
  # Get result
29
29
  ::ERB.new(content).result(context.get_binding)
@@ -1,4 +1,19 @@
1
1
  module Nanoc::Filter::Haml
2
+
3
+ class Context
4
+
5
+ def initialize(hash)
6
+ hash.each_pair do |key, value|
7
+ instance_variable_set('@' + key.to_s, value)
8
+ end
9
+ end
10
+
11
+ def get_binding
12
+ binding
13
+ end
14
+
15
+ end
16
+
2
17
  class HamlFilter < Nanoc::Filter
3
18
 
4
19
  identifiers :haml
@@ -6,11 +21,17 @@ module Nanoc::Filter::Haml
6
21
  def run(content)
7
22
  nanoc_require 'haml'
8
23
 
24
+ # Get options
9
25
  options = @page.haml_options || {}
10
- options[:locals] = { :page => @page, :pages => @pages, :config => @config, :site => @site }
11
26
 
12
- ::Haml::Engine.new(content, options).to_html
27
+ # Get assigns/locals
28
+ assigns = { :page => @page, :pages => @pages, :config => @config, :site => @site }
29
+ context = Context.new(assigns)
30
+
31
+ # Get result
32
+ ::Haml::Engine.new(content, options).render(context, assigns)
13
33
  end
14
34
 
15
35
  end
36
+
16
37
  end
@@ -1,18 +1,38 @@
1
1
  module Nanoc::LayoutProcessor::Haml
2
+
3
+ class Context
4
+
5
+ def initialize(hash)
6
+ hash.each_pair do |key, value|
7
+ instance_variable_set('@' + key.to_s, value)
8
+ end
9
+ end
10
+
11
+ def get_binding
12
+ binding
13
+ end
14
+
15
+ end
16
+
2
17
  class HamlLayoutProcessor < Nanoc::LayoutProcessor
3
18
 
4
19
  identifiers :haml
5
20
  extensions '.haml'
6
21
 
7
- def run(layout)
22
+ def run(content)
8
23
  nanoc_require 'haml'
9
24
 
10
- options = @page[:haml_options] || {}
11
- assigns = @other_assigns.merge({ :page => @page, :pages => @pages, :config => @config, :site => @site })
12
- options[:locals] = assigns
25
+ # Get options
26
+ options = @page.haml_options || {}
13
27
 
14
- ::Haml::Engine.new(layout, options).to_html
28
+ # Get assigns/locals
29
+ assigns = { :page => @page, :pages => @pages, :config => @config, :site => @site }
30
+ context = Context.new(assigns)
31
+
32
+ # Get result
33
+ ::Haml::Engine.new(content, options).render(context, assigns)
15
34
  end
16
35
 
17
36
  end
37
+
18
38
  end
data/lib/nanoc.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  module Nanoc
2
2
 
3
- VERSION = '2.0.3'
3
+ VERSION = '2.0.4'
4
4
 
5
5
  def self.load_file(*path)
6
6
  full_path = [ File.dirname(__FILE__), 'nanoc' ] + path
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.3
4
+ version: 2.0.4
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-03-25 00:00:00 +01:00
12
+ date: 2008-05-04 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  requirements: []
82
82
 
83
83
  rubyforge_project: nanoc
84
- rubygems_version: 1.0.1
84
+ rubygems_version: 1.1.1
85
85
  signing_key:
86
86
  specification_version: 2
87
87
  summary: a tool that runs on your local computer and compiles Markdown, Textile, Haml, ... documents into static web pages