nanoc 2.0 → 2.1

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.
Files changed (99) hide show
  1. data/ChangeLog +54 -0
  2. data/LICENSE +1 -1
  3. data/README +63 -3
  4. data/Rakefile +61 -14
  5. data/bin/nanoc +7 -199
  6. data/lib/nanoc/base/asset.rb +113 -0
  7. data/lib/nanoc/base/asset_defaults.rb +21 -0
  8. data/lib/nanoc/base/asset_rep.rb +277 -0
  9. data/lib/nanoc/base/binary_filter.rb +44 -0
  10. data/lib/nanoc/base/code.rb +41 -0
  11. data/lib/nanoc/base/compiler.rb +46 -34
  12. data/lib/nanoc/base/core_ext/hash.rb +51 -7
  13. data/lib/nanoc/base/core_ext/string.rb +8 -0
  14. data/lib/nanoc/base/data_source.rb +253 -20
  15. data/lib/nanoc/base/defaults.rb +30 -0
  16. data/lib/nanoc/base/enhancements.rb +9 -84
  17. data/lib/nanoc/base/filter.rb +109 -6
  18. data/lib/nanoc/base/layout.rb +91 -0
  19. data/lib/nanoc/base/notification_center.rb +66 -0
  20. data/lib/nanoc/base/page.rb +94 -121
  21. data/lib/nanoc/base/page_defaults.rb +20 -0
  22. data/lib/nanoc/base/page_rep.rb +318 -0
  23. data/lib/nanoc/base/plugin.rb +57 -9
  24. data/lib/nanoc/base/proxies/asset_proxy.rb +29 -0
  25. data/lib/nanoc/base/proxies/asset_rep_proxy.rb +26 -0
  26. data/lib/nanoc/base/proxies/layout_proxy.rb +25 -0
  27. data/lib/nanoc/base/proxies/page_proxy.rb +35 -0
  28. data/lib/nanoc/base/proxies/page_rep_proxy.rb +28 -0
  29. data/lib/nanoc/base/proxy.rb +37 -0
  30. data/lib/nanoc/base/router.rb +72 -0
  31. data/lib/nanoc/base/site.rb +220 -91
  32. data/lib/nanoc/base/template.rb +64 -0
  33. data/lib/nanoc/binary_filters/image_science_thumbnail.rb +28 -0
  34. data/lib/nanoc/cli/base.rb +219 -0
  35. data/lib/nanoc/cli/cli.rb +16 -0
  36. data/lib/nanoc/cli/command.rb +105 -0
  37. data/lib/nanoc/cli/commands/autocompile.rb +80 -0
  38. data/lib/nanoc/cli/commands/compile.rb +273 -0
  39. data/lib/nanoc/cli/commands/create_layout.rb +85 -0
  40. data/lib/nanoc/cli/commands/create_page.rb +85 -0
  41. data/lib/nanoc/cli/commands/create_site.rb +327 -0
  42. data/lib/nanoc/cli/commands/create_template.rb +76 -0
  43. data/lib/nanoc/cli/commands/help.rb +69 -0
  44. data/lib/nanoc/cli/commands/info.rb +114 -0
  45. data/lib/nanoc/cli/commands/switch.rb +141 -0
  46. data/lib/nanoc/cli/commands/update.rb +91 -0
  47. data/lib/nanoc/cli/ext.rb +37 -0
  48. data/lib/nanoc/cli/logger.rb +66 -0
  49. data/lib/nanoc/cli/option_parser.rb +168 -0
  50. data/lib/nanoc/cli.rb +1 -0
  51. data/lib/nanoc/data_sources/filesystem.rb +650 -215
  52. data/lib/nanoc/data_sources/filesystem_combined.rb +495 -0
  53. data/lib/nanoc/extra/auto_compiler.rb +265 -0
  54. data/lib/nanoc/extra/context.rb +22 -0
  55. data/lib/nanoc/extra/core_ext/hash.rb +54 -0
  56. data/lib/nanoc/extra/core_ext/time.rb +13 -0
  57. data/lib/nanoc/extra/file_proxy.rb +29 -0
  58. data/lib/nanoc/extra/vcs.rb +48 -0
  59. data/lib/nanoc/extra/vcses/bazaar.rb +21 -0
  60. data/lib/nanoc/extra/vcses/dummy.rb +20 -0
  61. data/lib/nanoc/extra/vcses/git.rb +21 -0
  62. data/lib/nanoc/extra/vcses/mercurial.rb +21 -0
  63. data/lib/nanoc/extra/vcses/subversion.rb +21 -0
  64. data/lib/nanoc/filters/bluecloth.rb +13 -0
  65. data/lib/nanoc/filters/erb.rb +6 -22
  66. data/lib/nanoc/filters/erubis.rb +14 -0
  67. data/lib/nanoc/filters/haml.rb +11 -6
  68. data/lib/nanoc/filters/markaby.rb +5 -5
  69. data/lib/nanoc/filters/maruku.rb +14 -0
  70. data/lib/nanoc/filters/old.rb +19 -0
  71. data/lib/nanoc/filters/rdiscount.rb +13 -0
  72. data/lib/nanoc/filters/rdoc.rb +5 -4
  73. data/lib/nanoc/filters/redcloth.rb +14 -0
  74. data/lib/nanoc/filters/rubypants.rb +14 -0
  75. data/lib/nanoc/filters/sass.rb +13 -0
  76. data/lib/nanoc/helpers/blogging.rb +170 -0
  77. data/lib/nanoc/helpers/capturing.rb +59 -0
  78. data/lib/nanoc/helpers/html_escape.rb +23 -0
  79. data/lib/nanoc/helpers/link_to.rb +69 -0
  80. data/lib/nanoc/helpers/render.rb +47 -0
  81. data/lib/nanoc/helpers/tagging.rb +52 -0
  82. data/lib/nanoc/helpers/xml_sitemap.rb +58 -0
  83. data/lib/nanoc/routers/default.rb +54 -0
  84. data/lib/nanoc/routers/no_dirs.rb +66 -0
  85. data/lib/nanoc/routers/versioned.rb +79 -0
  86. data/lib/nanoc.rb +83 -12
  87. metadata +144 -47
  88. data/lib/nanoc/base/auto_compiler.rb +0 -124
  89. data/lib/nanoc/base/layout_processor.rb +0 -33
  90. data/lib/nanoc/base/page_proxy.rb +0 -31
  91. data/lib/nanoc/base/plugin_manager.rb +0 -33
  92. data/lib/nanoc/data_sources/database.rb +0 -259
  93. data/lib/nanoc/data_sources/trivial.rb +0 -145
  94. data/lib/nanoc/filters/markdown.rb +0 -13
  95. data/lib/nanoc/filters/smartypants.rb +0 -13
  96. data/lib/nanoc/filters/textile.rb +0 -13
  97. data/lib/nanoc/layout_processors/erb.rb +0 -35
  98. data/lib/nanoc/layout_processors/haml.rb +0 -18
  99. data/lib/nanoc/layout_processors/markaby.rb +0 -16
@@ -0,0 +1,66 @@
1
+ module Nanoc::Routers
2
+
3
+ # The no-directories router organises pages very similarly to the default
4
+ # router, but does not create directories unless necessary. This router will
5
+ # therefore generate pages with less pretty URLs.
6
+ #
7
+ # For example, a page with path /about/ will be written to /about.html
8
+ # instead of /about/index.html.
9
+ class NoDirs < Nanoc::Router
10
+
11
+ identifier :no_dirs
12
+
13
+ def path_for_page_rep(page_rep)
14
+ # Get data we need
15
+ filename = page_rep.attribute_named(:filename)
16
+ extension = page_rep.attribute_named(:extension)
17
+
18
+ # Initialize path
19
+ if page_rep.page.path == '/'
20
+ path = '/' + filename
21
+ else
22
+ path = page_rep.page.path[0..-2]
23
+ end
24
+
25
+ # Add rep name if necessary
26
+ unless page_rep.name == :default
27
+ path += '-' + page_rep.name.to_s
28
+ end
29
+
30
+ # Add extension
31
+ path += '.' + extension
32
+
33
+ # Done
34
+ path
35
+ end
36
+
37
+ def path_for_asset_rep(asset_rep)
38
+ # Get data we need
39
+ extension = asset_rep.attribute_named(:extension)
40
+ modified_path = asset_rep.asset.path[0..-2]
41
+ version = asset_rep.attribute_named(:version)
42
+
43
+ # Initialize path
44
+ assets_prefix = @site.config[:assets_prefix] || '/assets'
45
+ path = assets_prefix + modified_path
46
+
47
+ # Add version if necessary
48
+ unless version.nil?
49
+ path += '-v' + version.to_s
50
+ end
51
+
52
+ # Add rep name
53
+ unless asset_rep.name == :default
54
+ path += '-' + asset_rep.name.to_s
55
+ end
56
+
57
+ # Add extension
58
+ path += '.' + extension
59
+
60
+ # Done
61
+ path
62
+ end
63
+
64
+ end
65
+
66
+ end
@@ -0,0 +1,79 @@
1
+ module Nanoc::Routers
2
+
3
+ # The versioned router behaves pretty much like the default router, with the
4
+ # exception that asset representations (but not page representations) can
5
+ # have versions which will be added to generated URLs.
6
+ #
7
+ # This is very useful if you want to cache assets aggressively by sending an
8
+ # +Expires+ header to clients. An +Expires+ header usually has the issue
9
+ # that clients will not request the asset even if it has changed; giving the
10
+ # asset a different version will cause the URL to be changed, which in turn
11
+ # will cause the client to request the new asset.
12
+ #
13
+ # = Example
14
+ #
15
+ # For example, the URL of a textual asset containing the CSS stylesheet with
16
+ # its 'version' attribute set to 28 will become /assets/style-v28.css.
17
+ #
18
+ # To link to the stylesheet in a DRY way,
19
+ # give the asset a unique name (such as 'style') and then do something along
20
+ # this way:
21
+ #
22
+ # <link rel="stylesheet"
23
+ # type="text/css"
24
+ # media="screen"
25
+ # href="<%= @assets.find { |a| a.asset_id == 'style' }.path %>">
26
+ class Versioned < Nanoc::Router
27
+
28
+ identifier :versioned
29
+
30
+ def path_for_page_rep(page_rep)
31
+ # Get data we need
32
+ filename = page_rep.attribute_named(:filename)
33
+ extension = page_rep.attribute_named(:extension)
34
+
35
+ # Initialize path
36
+ path = page_rep.page.path + filename
37
+
38
+ # Add rep name if necessary
39
+ unless page_rep.name == :default
40
+ path += '-' + page_rep.name.to_s
41
+ end
42
+
43
+ # Add extension
44
+ path += '.' + extension
45
+
46
+ # Done
47
+ path
48
+ end
49
+
50
+ def path_for_asset_rep(asset_rep)
51
+ # Get data we need
52
+ extension = asset_rep.attribute_named(:extension)
53
+ modified_path = asset_rep.asset.path[0..-2]
54
+ version = asset_rep.attribute_named(:version)
55
+
56
+ # Initialize path
57
+ assets_prefix = @site.config[:assets_prefix] || '/assets'
58
+ path = assets_prefix + modified_path
59
+
60
+ # Add version if necessary
61
+ unless version.nil?
62
+ path += '-v' + version.to_s
63
+ end
64
+
65
+ # Add rep name
66
+ unless asset_rep.name == :default
67
+ path += '-' + asset_rep.name.to_s
68
+ end
69
+
70
+ # Add extension
71
+ path += '.' + extension
72
+
73
+ # Done
74
+ path
75
+ end
76
+
77
+ end
78
+
79
+ end
data/lib/nanoc.rb CHANGED
@@ -1,24 +1,95 @@
1
1
  module Nanoc
2
2
 
3
- VERSION = '2.0'
3
+ # The current nanoc version.
4
+ VERSION = '2.1'
4
5
 
5
- def self.load_file(*path)
6
+ # Generic error. Superclass for all nanoc-specific errors.
7
+ class Error < RuntimeError ; end
8
+
9
+ module Errors # :nodoc:
10
+
11
+ # Error that is raised when a site is loaded that uses a data source with
12
+ # an unknown identifier.
13
+ class UnknownDataSourceError < Error ; end
14
+
15
+ # Error that is raised when a site is loaded that uses a data source with
16
+ # an unknown identifier.
17
+ class UnknownRouterError < Error ; end
18
+
19
+ # Error that is raised during site compilation when a page uses a layout
20
+ # that is not present in the site.
21
+ class UnknownLayoutError < Error ; end
22
+
23
+ # Error that is raised during site compilation when a page uses a filter
24
+ # that is not known.
25
+ class UnknownFilterError < Error ; end
26
+
27
+ # Error that is raised during site compilation when a layout is compiled
28
+ # for which the filter cannot be determined. This is similar to the
29
+ # UnknownFilterError, but specific for filters for layouts.
30
+ class CannotDetermineFilterError < Error ; end
31
+
32
+ # Error that is raised during site compilation when a page (directly or
33
+ # indirectly) includes its own page content, leading to endless recursion.
34
+ class RecursiveCompilationError < Error ; end
35
+
36
+ # Error that is raised when a certain function or feature is used that is
37
+ # no longer supported by nanoc.
38
+ class NoLongerSupportedError < Error ; end
39
+
40
+ end
41
+
42
+ module BinaryFilters # :nodoc:
43
+ end
44
+
45
+ module DataSources # :nodoc:
46
+ end
47
+
48
+ module Helpers # :nodoc:
49
+ end
50
+
51
+ module Extra # :nodoc:
52
+ end
53
+
54
+ module Filters # :nodoc:
55
+ end
56
+
57
+ module Routers # :nodoc:
58
+ end
59
+
60
+ # Requires the given Ruby files at the specified path.
61
+ #
62
+ # +path+:: An array containing path segments. This path is relative to the
63
+ # directory this file (nanoc.rb) is in. Can contain wildcards.
64
+ def self.load(*path)
6
65
  full_path = [ File.dirname(__FILE__), 'nanoc' ] + path
7
66
  Dir[File.join(full_path)].each { |f| require f }
8
67
  end
9
68
 
10
69
  end
11
70
 
71
+ # Load requirements
72
+ begin ; require 'rubygems' ; rescue LoadError ; end
73
+ require 'yaml'
74
+ require 'fileutils'
75
+
12
76
  # Load base
13
- Nanoc.load_file('base', 'enhancements.rb')
14
- Nanoc.load_file('base', 'core_ext', '*.rb')
15
- Nanoc.load_file('base', 'plugin.rb')
16
- Nanoc.load_file('base', '*.rb')
77
+ Nanoc.load('base', 'enhancements.rb')
78
+ Nanoc.load('base', 'defaults.rb')
79
+ Nanoc.load('base', 'proxy.rb')
80
+ Nanoc.load('base', 'proxies', '*.rb')
81
+ Nanoc.load('base', 'core_ext', '*.rb')
82
+ Nanoc.load('base', 'plugin.rb')
83
+ Nanoc.load('base', '*.rb')
17
84
 
18
- # Load plugins
19
- Nanoc.load_file('data_sources', '*.rb')
20
- Nanoc.load_file('filters', '*.rb')
21
- Nanoc.load_file('layout_processors', '*.rb')
85
+ # Load extra's
86
+ Nanoc.load('extra', 'core_ext', '*.rb')
87
+ Nanoc.load('extra', '*.rb')
88
+ Nanoc.load('extra', 'vcses', '*.rb')
22
89
 
23
- # Get global binding
24
- $nanoc_binding = binding
90
+ # Load plugins
91
+ Nanoc.load('data_sources', '*.rb')
92
+ Nanoc.load('filters', '*.rb')
93
+ Nanoc.load('binary_filters', '*.rb')
94
+ Nanoc.load('routers', '*.rb')
95
+ Nanoc.load('helpers', '*.rb')
metadata CHANGED
@@ -1,33 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: nanoc
5
3
  version: !ruby/object:Gem::Version
6
- version: "2.0"
7
- date: 2007-12-25 00:00:00 +01:00
8
- summary: a tool that runs on your local computer and compiles Markdown, Textile, Haml, ... documents into static web pages
9
- require_paths:
10
- - lib
11
- email: denis.defreyne@stoneship.org
12
- homepage: http://nanoc.stoneship.org/
13
- rubyforge_project: nanoc
14
- description: a tool that runs on your local computer and compiles Markdown, Textile, Haml, ... documents into static web pages
15
- autorequire:
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: false
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 1.8.2
24
- version:
4
+ version: "2.1"
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Denis Defreyne
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-17 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: a tool that runs on your local computer and compiles Markdown, Textile, Haml, ... documents into static web pages
17
+ email: denis.defreyne@stoneship.org
18
+ executables:
19
+ - nanoc
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README
31
24
  files:
32
25
  - README
33
26
  - LICENSE
@@ -36,47 +29,151 @@ files:
36
29
  - bin/nanoc
37
30
  - lib/nanoc
38
31
  - lib/nanoc/base
39
- - lib/nanoc/base/auto_compiler.rb
32
+ - lib/nanoc/base/asset.rb
33
+ - lib/nanoc/base/asset_defaults.rb
34
+ - lib/nanoc/base/asset_rep.rb
35
+ - lib/nanoc/base/binary_filter.rb
36
+ - lib/nanoc/base/code.rb
40
37
  - lib/nanoc/base/compiler.rb
41
38
  - lib/nanoc/base/core_ext
42
39
  - lib/nanoc/base/core_ext/hash.rb
40
+ - lib/nanoc/base/core_ext/string.rb
43
41
  - lib/nanoc/base/data_source.rb
42
+ - lib/nanoc/base/defaults.rb
44
43
  - lib/nanoc/base/enhancements.rb
45
44
  - lib/nanoc/base/filter.rb
46
- - lib/nanoc/base/layout_processor.rb
45
+ - lib/nanoc/base/layout.rb
46
+ - lib/nanoc/base/notification_center.rb
47
47
  - lib/nanoc/base/page.rb
48
- - lib/nanoc/base/page_proxy.rb
48
+ - lib/nanoc/base/page_defaults.rb
49
+ - lib/nanoc/base/page_rep.rb
49
50
  - lib/nanoc/base/plugin.rb
50
- - lib/nanoc/base/plugin_manager.rb
51
+ - lib/nanoc/base/proxies
52
+ - lib/nanoc/base/proxies/asset_proxy.rb
53
+ - lib/nanoc/base/proxies/asset_rep_proxy.rb
54
+ - lib/nanoc/base/proxies/layout_proxy.rb
55
+ - lib/nanoc/base/proxies/page_proxy.rb
56
+ - lib/nanoc/base/proxies/page_rep_proxy.rb
57
+ - lib/nanoc/base/proxy.rb
58
+ - lib/nanoc/base/router.rb
51
59
  - lib/nanoc/base/site.rb
60
+ - lib/nanoc/base/template.rb
61
+ - lib/nanoc/binary_filters
62
+ - lib/nanoc/binary_filters/image_science_thumbnail.rb
63
+ - lib/nanoc/cli
64
+ - lib/nanoc/cli/base.rb
65
+ - lib/nanoc/cli/cli.rb
66
+ - lib/nanoc/cli/command.rb
67
+ - lib/nanoc/cli/commands
68
+ - lib/nanoc/cli/commands/autocompile.rb
69
+ - lib/nanoc/cli/commands/compile.rb
70
+ - lib/nanoc/cli/commands/create_layout.rb
71
+ - lib/nanoc/cli/commands/create_page.rb
72
+ - lib/nanoc/cli/commands/create_site.rb
73
+ - lib/nanoc/cli/commands/create_template.rb
74
+ - lib/nanoc/cli/commands/help.rb
75
+ - lib/nanoc/cli/commands/info.rb
76
+ - lib/nanoc/cli/commands/switch.rb
77
+ - lib/nanoc/cli/commands/update.rb
78
+ - lib/nanoc/cli/ext.rb
79
+ - lib/nanoc/cli/logger.rb
80
+ - lib/nanoc/cli/option_parser.rb
81
+ - lib/nanoc/cli.rb
52
82
  - lib/nanoc/data_sources
53
- - lib/nanoc/data_sources/database.rb
54
83
  - lib/nanoc/data_sources/filesystem.rb
55
- - lib/nanoc/data_sources/trivial.rb
84
+ - lib/nanoc/data_sources/filesystem_combined.rb
85
+ - lib/nanoc/extra
86
+ - lib/nanoc/extra/auto_compiler.rb
87
+ - lib/nanoc/extra/context.rb
88
+ - lib/nanoc/extra/core_ext
89
+ - lib/nanoc/extra/core_ext/hash.rb
90
+ - lib/nanoc/extra/core_ext/time.rb
91
+ - lib/nanoc/extra/file_proxy.rb
92
+ - lib/nanoc/extra/vcs.rb
93
+ - lib/nanoc/extra/vcses
94
+ - lib/nanoc/extra/vcses/bazaar.rb
95
+ - lib/nanoc/extra/vcses/dummy.rb
96
+ - lib/nanoc/extra/vcses/git.rb
97
+ - lib/nanoc/extra/vcses/mercurial.rb
98
+ - lib/nanoc/extra/vcses/subversion.rb
56
99
  - lib/nanoc/filters
100
+ - lib/nanoc/filters/bluecloth.rb
57
101
  - lib/nanoc/filters/erb.rb
102
+ - lib/nanoc/filters/erubis.rb
58
103
  - lib/nanoc/filters/haml.rb
59
104
  - lib/nanoc/filters/markaby.rb
60
- - lib/nanoc/filters/markdown.rb
105
+ - lib/nanoc/filters/maruku.rb
106
+ - lib/nanoc/filters/old.rb
107
+ - lib/nanoc/filters/rdiscount.rb
61
108
  - lib/nanoc/filters/rdoc.rb
62
- - lib/nanoc/filters/smartypants.rb
63
- - lib/nanoc/filters/textile.rb
64
- - lib/nanoc/layout_processors
65
- - lib/nanoc/layout_processors/erb.rb
66
- - lib/nanoc/layout_processors/haml.rb
67
- - lib/nanoc/layout_processors/markaby.rb
109
+ - lib/nanoc/filters/redcloth.rb
110
+ - lib/nanoc/filters/rubypants.rb
111
+ - lib/nanoc/filters/sass.rb
112
+ - lib/nanoc/helpers
113
+ - lib/nanoc/helpers/blogging.rb
114
+ - lib/nanoc/helpers/capturing.rb
115
+ - lib/nanoc/helpers/html_escape.rb
116
+ - lib/nanoc/helpers/link_to.rb
117
+ - lib/nanoc/helpers/render.rb
118
+ - lib/nanoc/helpers/tagging.rb
119
+ - lib/nanoc/helpers/xml_sitemap.rb
120
+ - lib/nanoc/routers
121
+ - lib/nanoc/routers/default.rb
122
+ - lib/nanoc/routers/no_dirs.rb
123
+ - lib/nanoc/routers/versioned.rb
68
124
  - lib/nanoc.rb
69
- test_files: []
70
-
71
- rdoc_options: []
72
-
73
- extra_rdoc_files: []
74
-
75
- executables:
125
+ has_rdoc: true
126
+ homepage: http://nanoc.stoneship.org/
127
+ post_install_message: |-
128
+ ------------------------------------------------------------------------------
129
+ Thanks for installing nanoc 2.1! Here are some resources to help you get started:
130
+
131
+ * The tutorial at <http://nanoc.stoneship.org/help/tutorial/>
132
+ * The manual at <http://nanoc.stoneship.org/help/manual/>
133
+ * The discussion group at <http://groups.google.com/group/nanoc>
134
+
135
+ Because nanoc 2.1 has a lot of new features, be sure to check out the nanoc blog at <http://nanoc.stoneship.org/blog/> for details about this release.
136
+
137
+ Enjoy!
138
+ ------------------------------------------------------------------------------
139
+ rdoc_options:
140
+ - --title
76
141
  - nanoc
77
- extensions: []
78
-
142
+ - --main
143
+ - README
144
+ - --charset
145
+ - utf-8
146
+ - --exclude
147
+ - lib/nanoc/cli/commands
148
+ - --exclude
149
+ - lib/nanoc/binary_filters
150
+ - --exclude
151
+ - lib/nanoc/extra/vcses
152
+ - --exclude
153
+ - lib/nanoc/filters
154
+ - --exclude
155
+ - test
156
+ - --line-numbers
157
+ require_paths:
158
+ - lib
159
+ required_ruby_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: 1.8.5
164
+ version:
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: "0"
170
+ version:
79
171
  requirements: []
80
172
 
81
- dependencies: []
173
+ rubyforge_project: nanoc
174
+ rubygems_version: 1.2.0
175
+ signing_key:
176
+ specification_version: 2
177
+ summary: a tool that runs on your local computer and compiles Markdown, Textile, Haml, ... documents into static web pages
178
+ test_files: []
82
179
 
@@ -1,124 +0,0 @@
1
- require 'webrick'
2
-
3
- module Nanoc
4
-
5
- class AutoCompiler
6
-
7
- ERROR_404 = <<END
8
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
9
- <html>
10
- <head>
11
- <title>404 File Not Found</title>
12
- <style type="text/css">
13
- body { padding: 10px; border: 10px solid #f00; margin: 10px; font-family: Helvetica, Arial, sans-serif; }
14
- </style>
15
- </head>
16
- <body>
17
- <h1>404 File Not Found</h1>
18
- <p>The file you requested, <i><%=h path %></i>, was not found on this server.</p>
19
- </body>
20
- </html>
21
- END
22
-
23
- ERROR_500 = <<END
24
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
25
- <html>
26
- <head>
27
- <title>500 Server Error</title>
28
- <style type="text/css">
29
- body { padding: 10px; border: 10px solid #f00; margin: 10px; font-family: Helvetica, Arial, sans-serif; }
30
- </style>
31
- </head>
32
- <body>
33
- <h1>500 Server Error</h1>
34
- <p>An error occurred while compiling the page you requested, <i><%=h path %></i>.</p>
35
- <p>If you think this is a bug in nanoc, please do <a href="http://nanoc.stoneship.org/trac/newticket">report it</a>&mdash;thanks!</p>
36
- <p>Message:</p>
37
- <blockquote><p><%=h exception.message %></p></blockquote>
38
- <p>Backtrace:</p>
39
- <ol>
40
- <% exception.backtrace.each do |line| %>
41
- <li><%= line %></li>
42
- <% end %>
43
- </ol>
44
- </body>
45
- </html>
46
- END
47
-
48
- def initialize(site)
49
- # Set site
50
- @site = site
51
- end
52
-
53
- def start(port)
54
- nanoc_require('mime/types', "'mime/types' is required to autocompile sites.")
55
-
56
- # Create server
57
- @server = WEBrick::HTTPServer.new(:Port => port || 3000)
58
- @server.mount_proc("/") { |request, response| handle_request(request, response) }
59
-
60
- # Start server
61
- trap('INT') { @server.shutdown }
62
- @server.start
63
- end
64
-
65
- def handle_request(request, response)
66
- # Reload site data
67
- @site.load_data(true)
68
-
69
- # Get page or file
70
- page = @site.pages.find { |page| page.path == request.path }
71
- file_path = @site.config[:output_dir] + request.path
72
-
73
- if page.nil?
74
- # Serve file
75
- if File.exist?(file_path)
76
- serve_file(file_path, response)
77
- else
78
- serve_404(request.path, response)
79
- end
80
- else
81
- # Serve page
82
- serve_page(page, response)
83
- end
84
- end
85
-
86
- def h(s)
87
- ERB::Util.html_escape(s)
88
- end
89
-
90
- def serve_404(path, response)
91
- response.status = 404
92
- response['Content-Type'] = 'text/html'
93
- response.body = ERB.new(ERROR_404).result(binding)
94
- end
95
-
96
- def serve_500(path, exception, response)
97
- response.status = 500
98
- response['Content-Type'] = 'text/html'
99
- response.body = ERB.new(ERROR_500).result(binding)
100
- end
101
-
102
- def serve_file(path, response)
103
- response.status = 200
104
- response['Content-Type'] = MIME::Types.of(path).first || 'application/octet-stream'
105
- response.body = File.read(path)
106
- end
107
-
108
- def serve_page(page, response)
109
- # Recompile page
110
- begin
111
- @site.compiler.run(page)
112
- rescue => exception
113
- serve_500(page.path, exception, response)
114
- return
115
- end
116
-
117
- response.status = 200
118
- response['Content-Type'] = 'text/html'
119
- response.body = page.layouted_content
120
- end
121
-
122
- end
123
-
124
- end
@@ -1,33 +0,0 @@
1
- module Nanoc
2
- class LayoutProcessor < Plugin
3
-
4
- def initialize(page, pages, config, site, other_assigns={})
5
- @page = page
6
- @pages = pages
7
- @config = config
8
- @site = site
9
- @other_assigns = other_assigns
10
- end
11
-
12
- def run(layout)
13
- error 'LayoutProcessor#run must be overridden'
14
- end
15
-
16
- # Extensions
17
-
18
- class << self
19
- attr_accessor :_extensions
20
- end
21
-
22
- def self.extensions(*extensions)
23
- self._extensions = [] unless instance_variable_defined?(:@_extensions)
24
- extensions.empty? ? self._extensions || [] : self._extensions = (self._extensions || []) + extensions
25
- end
26
-
27
- def self.extension(extension=nil)
28
- self._extensions = [] unless instance_variable_defined?(:@_extensions)
29
- extension.nil? ? self.extensions.first : self.extensions(extension)
30
- end
31
-
32
- end
33
- end
@@ -1,31 +0,0 @@
1
- module Nanoc
2
- class PageProxy
3
-
4
- def initialize(page)
5
- @page = page
6
- end
7
-
8
- def [](key)
9
- real_key = key.to_s.sub(/\?$/, '').to_sym
10
-
11
- if real_key == :content
12
- @page.content
13
- elsif real_key == :parent
14
- @page.parent.nil? ? nil : @page.parent.to_proxy
15
- elsif real_key == :children
16
- @page.children.map { |page| page.to_proxy }
17
- else
18
- @page.attribute_named(real_key)
19
- end
20
- end
21
-
22
- def []=(key, value)
23
- @page.attributes[key.to_sym] = value
24
- end
25
-
26
- def method_missing(method, *args)
27
- self[method]
28
- end
29
-
30
- end
31
- end