nanoc 2.2.2 → 3.0.0a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/bin/nanoc +29 -11
  2. data/bin/nanoc-select +85 -0
  3. metadata +27 -161
  4. data/ChangeLog +0 -3
  5. data/LICENSE +0 -19
  6. data/README +0 -75
  7. data/Rakefile +0 -76
  8. data/lib/nanoc.rb +0 -73
  9. data/lib/nanoc/base.rb +0 -26
  10. data/lib/nanoc/base/asset.rb +0 -117
  11. data/lib/nanoc/base/asset_defaults.rb +0 -21
  12. data/lib/nanoc/base/asset_rep.rb +0 -282
  13. data/lib/nanoc/base/binary_filter.rb +0 -44
  14. data/lib/nanoc/base/code.rb +0 -41
  15. data/lib/nanoc/base/compiler.rb +0 -67
  16. data/lib/nanoc/base/core_ext.rb +0 -2
  17. data/lib/nanoc/base/core_ext/hash.rb +0 -78
  18. data/lib/nanoc/base/core_ext/string.rb +0 -8
  19. data/lib/nanoc/base/data_source.rb +0 -286
  20. data/lib/nanoc/base/defaults.rb +0 -30
  21. data/lib/nanoc/base/filter.rb +0 -93
  22. data/lib/nanoc/base/layout.rb +0 -91
  23. data/lib/nanoc/base/notification_center.rb +0 -66
  24. data/lib/nanoc/base/page.rb +0 -132
  25. data/lib/nanoc/base/page_defaults.rb +0 -20
  26. data/lib/nanoc/base/page_rep.rb +0 -324
  27. data/lib/nanoc/base/plugin.rb +0 -71
  28. data/lib/nanoc/base/proxies.rb +0 -5
  29. data/lib/nanoc/base/proxies/asset_proxy.rb +0 -29
  30. data/lib/nanoc/base/proxies/asset_rep_proxy.rb +0 -26
  31. data/lib/nanoc/base/proxies/layout_proxy.rb +0 -25
  32. data/lib/nanoc/base/proxies/page_proxy.rb +0 -35
  33. data/lib/nanoc/base/proxies/page_rep_proxy.rb +0 -28
  34. data/lib/nanoc/base/proxy.rb +0 -37
  35. data/lib/nanoc/base/router.rb +0 -72
  36. data/lib/nanoc/base/site.rb +0 -274
  37. data/lib/nanoc/base/template.rb +0 -64
  38. data/lib/nanoc/binary_filters.rb +0 -1
  39. data/lib/nanoc/binary_filters/image_science_thumbnail.rb +0 -28
  40. data/lib/nanoc/cli.rb +0 -9
  41. data/lib/nanoc/cli/base.rb +0 -132
  42. data/lib/nanoc/cli/commands.rb +0 -10
  43. data/lib/nanoc/cli/commands/autocompile.rb +0 -80
  44. data/lib/nanoc/cli/commands/compile.rb +0 -311
  45. data/lib/nanoc/cli/commands/create_layout.rb +0 -85
  46. data/lib/nanoc/cli/commands/create_page.rb +0 -85
  47. data/lib/nanoc/cli/commands/create_site.rb +0 -323
  48. data/lib/nanoc/cli/commands/create_template.rb +0 -76
  49. data/lib/nanoc/cli/commands/help.rb +0 -69
  50. data/lib/nanoc/cli/commands/info.rb +0 -125
  51. data/lib/nanoc/cli/commands/switch.rb +0 -141
  52. data/lib/nanoc/cli/commands/update.rb +0 -91
  53. data/lib/nanoc/cli/logger.rb +0 -72
  54. data/lib/nanoc/data_sources.rb +0 -2
  55. data/lib/nanoc/data_sources/filesystem.rb +0 -707
  56. data/lib/nanoc/data_sources/filesystem_combined.rb +0 -495
  57. data/lib/nanoc/extra.rb +0 -6
  58. data/lib/nanoc/extra/auto_compiler.rb +0 -285
  59. data/lib/nanoc/extra/context.rb +0 -22
  60. data/lib/nanoc/extra/core_ext.rb +0 -2
  61. data/lib/nanoc/extra/core_ext/hash.rb +0 -54
  62. data/lib/nanoc/extra/core_ext/time.rb +0 -13
  63. data/lib/nanoc/extra/file_proxy.rb +0 -29
  64. data/lib/nanoc/extra/vcs.rb +0 -48
  65. data/lib/nanoc/extra/vcses.rb +0 -5
  66. data/lib/nanoc/extra/vcses/bazaar.rb +0 -21
  67. data/lib/nanoc/extra/vcses/dummy.rb +0 -20
  68. data/lib/nanoc/extra/vcses/git.rb +0 -21
  69. data/lib/nanoc/extra/vcses/mercurial.rb +0 -21
  70. data/lib/nanoc/extra/vcses/subversion.rb +0 -21
  71. data/lib/nanoc/filters.rb +0 -16
  72. data/lib/nanoc/filters/bluecloth.rb +0 -13
  73. data/lib/nanoc/filters/erb.rb +0 -19
  74. data/lib/nanoc/filters/erubis.rb +0 -14
  75. data/lib/nanoc/filters/haml.rb +0 -21
  76. data/lib/nanoc/filters/markaby.rb +0 -14
  77. data/lib/nanoc/filters/maruku.rb +0 -14
  78. data/lib/nanoc/filters/old.rb +0 -19
  79. data/lib/nanoc/filters/rainpress.rb +0 -13
  80. data/lib/nanoc/filters/rdiscount.rb +0 -13
  81. data/lib/nanoc/filters/rdoc.rb +0 -23
  82. data/lib/nanoc/filters/redcloth.rb +0 -14
  83. data/lib/nanoc/filters/relativize_paths.rb +0 -16
  84. data/lib/nanoc/filters/relativize_paths_in_css.rb +0 -16
  85. data/lib/nanoc/filters/relativize_paths_in_html.rb +0 -16
  86. data/lib/nanoc/filters/rubypants.rb +0 -14
  87. data/lib/nanoc/filters/sass.rb +0 -18
  88. data/lib/nanoc/helpers.rb +0 -9
  89. data/lib/nanoc/helpers/blogging.rb +0 -217
  90. data/lib/nanoc/helpers/capturing.rb +0 -63
  91. data/lib/nanoc/helpers/filtering.rb +0 -54
  92. data/lib/nanoc/helpers/html_escape.rb +0 -25
  93. data/lib/nanoc/helpers/link_to.rb +0 -113
  94. data/lib/nanoc/helpers/render.rb +0 -49
  95. data/lib/nanoc/helpers/tagging.rb +0 -56
  96. data/lib/nanoc/helpers/text.rb +0 -38
  97. data/lib/nanoc/helpers/xml_sitemap.rb +0 -63
  98. data/lib/nanoc/routers.rb +0 -3
  99. data/lib/nanoc/routers/default.rb +0 -54
  100. data/lib/nanoc/routers/no_dirs.rb +0 -66
  101. data/lib/nanoc/routers/versioned.rb +0 -79
  102. data/vendor/cri/ChangeLog +0 -0
  103. data/vendor/cri/LICENSE +0 -19
  104. data/vendor/cri/NEWS +0 -0
  105. data/vendor/cri/README +0 -4
  106. data/vendor/cri/Rakefile +0 -25
  107. data/vendor/cri/lib/cri.rb +0 -12
  108. data/vendor/cri/lib/cri/base.rb +0 -153
  109. data/vendor/cri/lib/cri/command.rb +0 -104
  110. data/vendor/cri/lib/cri/core_ext.rb +0 -8
  111. data/vendor/cri/lib/cri/core_ext/string.rb +0 -41
  112. data/vendor/cri/lib/cri/option_parser.rb +0 -186
  113. data/vendor/cri/test/test_base.rb +0 -6
  114. data/vendor/cri/test/test_command.rb +0 -6
  115. data/vendor/cri/test/test_core_ext.rb +0 -21
  116. data/vendor/cri/test/test_option_parser.rb +0 -279
@@ -1,85 +0,0 @@
1
- module Nanoc::CLI
2
-
3
- class CreateLayoutCommand < Cri::Command # :nodoc:
4
-
5
- def name
6
- 'create_layout'
7
- end
8
-
9
- def aliases
10
- [ 'cl' ]
11
- end
12
-
13
- def short_desc
14
- 'create a layout'
15
- end
16
-
17
- def long_desc
18
- 'Create a new layout in the current site.'
19
- end
20
-
21
- def usage
22
- "nanoc create_layout [path]"
23
- end
24
-
25
- def option_definitions
26
- [
27
- # --vcs
28
- {
29
- :long => 'vcs', :short => 'c', :argument => :required,
30
- :desc => 'select the VCS to use'
31
- }
32
- ]
33
- end
34
-
35
- def run(options, arguments)
36
- # Check arguments
37
- if arguments.length != 1
38
- $stderr.puts "usage: #{usage}"
39
- exit 1
40
- end
41
-
42
- # Extract arguments
43
- path = arguments[0].cleaned_path
44
-
45
- # Make sure we are in a nanoc site directory
46
- @base.require_site
47
-
48
- # Set VCS if possible
49
- @base.set_vcs(options[:vcs])
50
-
51
- # Check whether layout is unique
52
- if !@base.site.layouts.find { |l| l.path == path }.nil?
53
- $stderr.puts "A layout already exists at #{path}. Please pick a unique name " +
54
- "for the layout you are creating."
55
- exit 1
56
- end
57
-
58
- # Setup notifications
59
- Nanoc::NotificationCenter.on(:file_created) do |file_path|
60
- Nanoc::CLI::Logger.instance.file(:high, :create, file_path)
61
- end
62
-
63
- # Create layout
64
- layout = Nanoc::Layout.new(
65
- "<html>\n" +
66
- " <head>\n" +
67
- " <title><%= @page.title %></title>\n" +
68
- " </head>\n" +
69
- " <body>\n" +
70
- " <p>Hi, I'm a new layout. Please customize me!</p>\n" +
71
- "<%= @page.content %>\n" +
72
- " </body>\n" +
73
- "</html>\n",
74
- { :filter => 'erb' },
75
- path
76
- )
77
- layout.site = @base.site
78
- layout.save
79
-
80
- puts "A layout has been created at #{path}."
81
- end
82
-
83
- end
84
-
85
- end
@@ -1,85 +0,0 @@
1
- module Nanoc::CLI
2
-
3
- class CreatePageCommand < Cri::Command # :nodoc:
4
-
5
- def name
6
- 'create_page'
7
- end
8
-
9
- def aliases
10
- [ 'cp' ]
11
- end
12
-
13
- def short_desc
14
- 'create a page'
15
- end
16
-
17
- def long_desc
18
- 'Create a new page in the current site. The template that will be ' +
19
- 'used for generating the page will be \'default\', unless otherwise ' +
20
- 'specified.'
21
- end
22
-
23
- def usage
24
- "nanoc create_page [options] [path]"
25
- end
26
-
27
- def option_definitions
28
- [
29
- # --vcs
30
- {
31
- :long => 'vcs', :short => 'c', :argument => :required,
32
- :desc => 'select the VCS to use'
33
- },
34
- # --template
35
- {
36
- :long => 'template', :short => 't', :argument => :required,
37
- :desc => 'specify the template for the new page'
38
- }
39
- ]
40
- end
41
-
42
- def run(options, arguments)
43
- # Check arguments
44
- if arguments.length != 1
45
- $stderr.puts "usage: #{usage}"
46
- exit 1
47
- end
48
-
49
- # Extract arguments and options
50
- path = arguments[0].cleaned_path
51
- template_name = options[:template] || 'default'
52
-
53
- # Make sure we are in a nanoc site directory
54
- @base.require_site
55
-
56
- # Set VCS if possible
57
- @base.set_vcs(options[:vcs])
58
-
59
- # Find template
60
- template = @base.site.templates.find { |t| t.name == template_name }
61
- if template.nil?
62
- $stderr.puts "A template named '#{template_name}' was not found; aborting."
63
- exit 1
64
- end
65
-
66
- # Setup notifications
67
- Nanoc::NotificationCenter.on(:file_created) do |file_path|
68
- Nanoc::CLI::Logger.instance.file(:high, :create, file_path)
69
- end
70
-
71
- # Create page
72
- page = Nanoc::Page.new(
73
- template.page_content,
74
- template.page_attributes,
75
- path
76
- )
77
- page.site = @base.site
78
- page.save
79
-
80
- puts "A page has been created at #{path}."
81
- end
82
-
83
- end
84
-
85
- end
@@ -1,323 +0,0 @@
1
- module Nanoc::CLI
2
-
3
- class CreateSiteCommand < Cri::Command # :nodoc:
4
-
5
- DEFAULT_PAGE = <<EOS
6
- <h1>A Brand New nanoc Site</h1>
7
- <p>You&#8217;ve just created a new nanoc site. The page you are looking at right now is the home page for your site (and it&#8217;s probably the only page).</p>
8
- <p>To get started, consider replacing this default homepage with your own customized homepage. Some pointers on how to do so:</p>
9
- <ul>
10
- <li><strong>Change this page&#8217;s content</strong> by editing &#8220;content.txt&#8221; file in the &#8220;content&#8221; directory. This is the actual page content, and therefore doesn&#8217;t include the header, sidebar or style information (those are part of the layout).</li>
11
- <li><strong>Change the layout</strong>, which is the &#8220;default.txt&#8221; file in the &#8220;layouts/default&#8221; directory, and create something unique (and hopefully less bland).</li>
12
- </ul>
13
- <p>If you need any help with customizing your nanoc web site, be sure to check out the documentation (see sidebar), and be sure to subscribe to the discussion group (also see sidebar). Enjoy!</p>
14
- EOS
15
-
16
- DEFAULT_LAYOUT = <<EOS
17
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
18
- <html>
19
- <head>
20
- <title>A Brand New nanoc Site - <%= @page.title %></title>
21
- <style type="text/css" media="screen">
22
- * {
23
- margin: 0;
24
- padding: 0;
25
-
26
- font-family: Georgia, Palatino, Times, 'Times New Roman', sans-serif;
27
- }
28
-
29
- body {
30
- background: #fff;
31
- }
32
-
33
- a {
34
- text-decoration: none;
35
- }
36
-
37
- a:link,
38
- a:visited {
39
- color: #f30;
40
- }
41
-
42
- a:hover {
43
- color: #f90;
44
- }
45
-
46
- #main {
47
- position: absolute;
48
-
49
- top: 20px;
50
- left: 280px;
51
-
52
- width: 500px;
53
- }
54
-
55
- #main h1 {
56
- font-size: 40px;
57
- font-weight: normal;
58
-
59
- line-height: 40px;
60
-
61
- padding: 20px 0 20px 0;
62
-
63
- letter-spacing: -1px;
64
- }
65
-
66
- #main p {
67
- margin: 0 0 20px 0;
68
-
69
- font-size: 15px;
70
-
71
- line-height: 20px;
72
- }
73
-
74
- #main ul {
75
- padding: 0 0 0 20px;
76
- }
77
-
78
- #main li {
79
- margin: 0 0 20px 0;
80
-
81
- list-style-type: square;
82
-
83
- font-size: 15px;
84
-
85
- line-height: 20px;
86
- }
87
-
88
- #sidebar {
89
- position: absolute;
90
-
91
- top: 40px;
92
- left: 20px;
93
- width: 200px;
94
-
95
- padding: 20px 20px 0 0;
96
-
97
- border-right: 1px solid #ccc;
98
-
99
- text-align: right;
100
- }
101
-
102
- #sidebar h2 {
103
- text-transform: uppercase;
104
-
105
- font-size: 13px;
106
-
107
- color: #333;
108
-
109
- letter-spacing: 1px;
110
-
111
- line-height: 20px;
112
- }
113
-
114
- #sidebar ul {
115
- list-style-type: none;
116
-
117
- margin: 20px 0;
118
- }
119
-
120
- #sidebar li {
121
- font-size: 14px;
122
-
123
- line-height: 20px;
124
- }
125
- </style>
126
- </head>
127
- <body>
128
- <div id="main">
129
- <%= @page_rep.content %>
130
- </div>
131
- <div id="sidebar">
132
- <h2>Documentation</h2>
133
- <ul>
134
- <li><a href="http://nanoc.stoneship.org/help/tutorial/">Tutorial</a></li>
135
- <li><a href="http://nanoc.stoneship.org/help/manual/">Manual</a></li>
136
- </ul>
137
- <h2>Community</h2>
138
- <ul>
139
- <li><a href="http://groups.google.com/group/nanoc/">Discussion Group</a></li>
140
- <li><a href="http://groups.google.com/group/nanoc-es/">Spanish Discussion Group</a></li>
141
- <li><a href="http://nanoc.stoneship.org/trac/">Wiki</a></li>
142
- </ul>
143
- </div>
144
- </body>
145
- </html>
146
- EOS
147
-
148
- def name
149
- 'create_site'
150
- end
151
-
152
- def aliases
153
- [ 'cs' ]
154
- end
155
-
156
- def short_desc
157
- 'create a site'
158
- end
159
-
160
- def long_desc
161
- 'Create a new site at the given path. The site will use the ' +
162
- 'filesystem data source (but this can be changed later on). It will ' +
163
- 'also include a few stub rakefiles to make adding new tasks easier.'
164
- end
165
-
166
- def usage
167
- "nanoc create_site [path]"
168
- end
169
-
170
- def option_definitions
171
- [
172
- # --datasource
173
- {
174
- :long => 'datasource', :short => 'd', :argument => :required,
175
- :desc => 'specify the data source for the new site'
176
- }
177
- ]
178
- end
179
-
180
- def run(options, arguments)
181
- # Check arguments
182
- if arguments.length != 1
183
- $stderr.puts "usage: #{usage}"
184
- exit 1
185
- end
186
-
187
- # Extract arguments and options
188
- path = arguments[0]
189
- data_source = options[:datasource] || 'filesystem'
190
-
191
- # Check whether site exists
192
- if File.exist?(path)
193
- $stderr.puts "A site at '#{path}' already exists."
194
- exit 1
195
- end
196
-
197
- # Check whether data source exists
198
- if Nanoc::DataSource.named(data_source).nil?
199
- $stderr.puts "Unrecognised data source: #{data_source}"
200
- exit 1
201
- end
202
-
203
- # Setup notifications
204
- Nanoc::NotificationCenter.on(:file_created) do |file_path|
205
- Nanoc::CLI::Logger.instance.file(:high, :create, file_path)
206
- end
207
-
208
- # Build entire site
209
- FileUtils.mkdir_p(path)
210
- FileUtils.cd(File.join(path)) do
211
- site_create_minimal(data_source)
212
- site_setup
213
- site_populate
214
- end
215
-
216
- puts "Created a blank nanoc site at '#{path}'. Enjoy!"
217
- end
218
-
219
- protected
220
-
221
- # Creates a configuration file and a output directory for this site, as
222
- # well as a rakefile and a 'tasks' directory because raking is fun.
223
- def site_create_minimal(data_source)
224
- # Create output
225
- FileUtils.mkdir_p('output')
226
-
227
- # Create config
228
- File.open('config.yaml', 'w') do |io|
229
- io.write "output_dir: \"output\"\n"
230
- io.write "data_source: \"#{data_source}\"\n"
231
- io.write "router: \"default\"\n"
232
- end
233
- Nanoc::NotificationCenter.post(:file_created, 'config.yaml')
234
-
235
- # Create rakefile
236
- File.open('Rakefile', 'w') do |io|
237
- io.write "Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile }\n"
238
- io.write "\n"
239
- io.write "task :default do\n"
240
- io.write " puts 'This is an example rake task.'\n"
241
- io.write "end\n"
242
- end
243
- Nanoc::NotificationCenter.post(:file_created, 'Rakefile')
244
-
245
- # Create tasks
246
- FileUtils.mkdir_p('tasks')
247
- File.open('tasks/default.rake', 'w') do |io|
248
- io.write "task :example do\n"
249
- io.write " puts 'This is an example rake task in tasks/default.rake.'\n"
250
- io.write "end\n"
251
- end
252
- Nanoc::NotificationCenter.post(:file_created, 'tasks/default.rake')
253
- end
254
-
255
- # Sets up the site's data source, i.e. creates the bare essentials for
256
- # this data source to work.
257
- def site_setup
258
- # Get site
259
- site = Nanoc::Site.new(YAML.load_file('config.yaml'))
260
-
261
- # Set up data source
262
- site.data_source.loading do
263
- site.data_source.setup
264
- end
265
- end
266
-
267
- # Populates the site with some initial data, such as a root page, a
268
- # default layout, a default template, and so on.
269
- def site_populate
270
- # Get site
271
- site = Nanoc::Site.new(YAML.load_file('config.yaml'))
272
-
273
- # Create page
274
- page = Nanoc::Page.new(
275
- DEFAULT_PAGE,
276
- { :title => 'Home' },
277
- '/'
278
- )
279
- page.site = site
280
- page.save
281
-
282
- # Fill asset defaults
283
- Nanoc::Asset::DEFAULTS.each_pair do |key, value|
284
- site.asset_defaults.attributes[key] = value
285
- end
286
- site.asset_defaults.save
287
-
288
- # Fill page defaults
289
- Nanoc::Page::DEFAULTS.each_pair do |key, value|
290
- site.page_defaults.attributes[key] = value
291
- end
292
- site.page_defaults.save
293
-
294
- # Create layout
295
- layout = Nanoc::Layout.new(
296
- DEFAULT_LAYOUT,
297
- { :filter => 'erb' },
298
- '/default/'
299
- )
300
- layout.site = site
301
- layout.save
302
-
303
- # Create template
304
- template = Nanoc::Template.new(
305
- "Hi, I'm a new page!\n",
306
- { :title => "A New Page" },
307
- 'default'
308
- )
309
- template.site = site
310
- template.save
311
-
312
- # Fill code
313
- code = Nanoc::Code.new(
314
- "\# All files in the 'lib' directory will be loaded\n" +
315
- "\# before nanoc starts compiling.\n"
316
- )
317
- code.site = site
318
- code.save
319
- end
320
-
321
- end
322
-
323
- end