nanoc3 3.0.9 → 3.1.0a1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/NEWS.md +360 -0
- data/README.md +85 -0
- data/Rakefile +2 -2
- data/bin/nanoc3 +0 -4
- data/lib/nanoc3/base/code_snippet.rb +14 -6
- data/lib/nanoc3/base/compiler.rb +68 -49
- data/lib/nanoc3/base/compiler_dsl.rb +70 -29
- data/lib/nanoc3/base/context.rb +47 -0
- data/lib/nanoc3/base/core_ext/array.rb +4 -0
- data/lib/nanoc3/base/core_ext/hash.rb +5 -1
- data/lib/nanoc3/base/core_ext/string.rb +2 -0
- data/lib/nanoc3/base/data_source.rb +132 -96
- data/lib/nanoc3/base/dependency_tracker.rb +160 -185
- data/lib/nanoc3/base/directed_graph.rb +252 -0
- data/lib/nanoc3/base/errors.rb +52 -4
- data/lib/nanoc3/base/filter.rb +43 -28
- data/lib/nanoc3/base/item.rb +93 -25
- data/lib/nanoc3/base/item_rep.rb +166 -55
- data/lib/nanoc3/base/layout.rb +16 -13
- data/lib/nanoc3/base/notification_center.rb +28 -12
- data/lib/nanoc3/base/plugin_registry.rb +158 -0
- data/lib/nanoc3/base/rule.rb +27 -8
- data/lib/nanoc3/base/rule_context.rb +59 -46
- data/lib/nanoc3/base/site.rb +124 -77
- data/lib/nanoc3/base.rb +7 -2
- data/lib/nanoc3/cli/base.rb +4 -1
- data/lib/nanoc3/cli/commands/autocompile.rb +5 -4
- data/lib/nanoc3/cli/commands/compile.rb +28 -7
- data/lib/nanoc3/cli/commands/create_item.rb +1 -1
- data/lib/nanoc3/cli/commands/create_layout.rb +1 -1
- data/lib/nanoc3/cli/commands/create_site.rb +46 -22
- data/lib/nanoc3/cli/commands/debug.rb +100 -0
- data/lib/nanoc3/cli/commands/help.rb +1 -1
- data/lib/nanoc3/cli/commands/info.rb +1 -1
- data/lib/nanoc3/cli/commands/view.rb +85 -0
- data/lib/nanoc3/cli/commands.rb +2 -0
- data/lib/nanoc3/cli/logger.rb +7 -0
- data/lib/nanoc3/cli.rb +0 -3
- data/lib/nanoc3/data_sources/{delicious.rb → deprecated/delicious.rb} +1 -24
- data/lib/nanoc3/data_sources/{last_fm.rb → deprecated/last_fm.rb} +1 -27
- data/lib/nanoc3/data_sources/{twitter.rb → deprecated/twitter.rb} +1 -14
- data/lib/nanoc3/data_sources/filesystem.rb +188 -176
- data/lib/nanoc3/data_sources/filesystem_unified.rb +107 -0
- data/lib/nanoc3/data_sources/filesystem_verbose.rb +80 -0
- data/lib/nanoc3/data_sources.rb +18 -9
- data/lib/nanoc3/extra/core_ext/enumerable.rb +39 -0
- data/lib/nanoc3/extra/core_ext/time.rb +2 -2
- data/lib/nanoc3/extra/core_ext.rb +1 -0
- data/lib/nanoc3/extra/deployers/rsync.rb +49 -3
- data/lib/nanoc3/extra/file_proxy.rb +7 -0
- data/lib/nanoc3/extra/vcs.rb +25 -24
- data/lib/nanoc3/extra/vcses/bazaar.rb +4 -0
- data/lib/nanoc3/extra/vcses/dummy.rb +4 -0
- data/lib/nanoc3/extra/vcses/git.rb +4 -0
- data/lib/nanoc3/extra/vcses/mercurial.rb +4 -0
- data/lib/nanoc3/extra/vcses/subversion.rb +4 -0
- data/lib/nanoc3/extra.rb +4 -1
- data/lib/nanoc3/filters/erb.rb +1 -1
- data/lib/nanoc3/filters/erubis.rb +1 -1
- data/lib/nanoc3/filters/haml.rb +1 -1
- data/lib/nanoc3/filters/kramdown.rb +14 -0
- data/lib/nanoc3/filters/maruku.rb +1 -1
- data/lib/nanoc3/filters/rainpress.rb +1 -1
- data/lib/nanoc3/filters/rdiscount.rb +3 -1
- data/lib/nanoc3/filters.rb +2 -0
- data/lib/nanoc3/helpers/blogging.rb +91 -75
- data/lib/nanoc3/helpers/breadcrumbs.rb +18 -10
- data/lib/nanoc3/helpers/capturing.rb +24 -29
- data/lib/nanoc3/helpers/filtering.rb +20 -17
- data/lib/nanoc3/helpers/html_escape.rb +7 -4
- data/lib/nanoc3/helpers/link_to.rb +51 -41
- data/lib/nanoc3/helpers/rendering.rb +15 -8
- data/lib/nanoc3/helpers/tagging.rb +27 -21
- data/lib/nanoc3/helpers/text.rb +12 -8
- data/lib/nanoc3/helpers/xml_sitemap.rb +13 -15
- data/lib/nanoc3/tasks/deploy/rsync.rake +4 -1
- data/lib/nanoc3/tasks.rb +2 -1
- data/lib/nanoc3.rb +24 -1
- metadata +43 -87
- data/NEWS.rdoc +0 -328
- data/README.rdoc +0 -83
- data/lib/nanoc3/base/plugin.rb +0 -88
- data/lib/nanoc3/base/preprocessor_context.rb +0 -37
- data/lib/nanoc3/data_sources/filesystem_combined.rb +0 -214
- data/lib/nanoc3/data_sources/filesystem_common.rb +0 -22
- data/lib/nanoc3/data_sources/filesystem_compact.rb +0 -256
- data/lib/nanoc3/extra/context.rb +0 -24
- data/lib/nanoc3/package.rb +0 -107
- data/vendor/cri/ChangeLog +0 -0
- data/vendor/cri/LICENSE +0 -19
- data/vendor/cri/NEWS +0 -0
- data/vendor/cri/README +0 -4
- data/vendor/cri/Rakefile +0 -25
- data/vendor/cri/lib/cri/base.rb +0 -153
- data/vendor/cri/lib/cri/command.rb +0 -105
- data/vendor/cri/lib/cri/core_ext/string.rb +0 -41
- data/vendor/cri/lib/cri/core_ext.rb +0 -8
- data/vendor/cri/lib/cri/option_parser.rb +0 -186
- data/vendor/cri/lib/cri.rb +0 -12
- data/vendor/cri/test/test_base.rb +0 -6
- data/vendor/cri/test/test_command.rb +0 -6
- data/vendor/cri/test/test_core_ext.rb +0 -21
- data/vendor/cri/test/test_option_parser.rb +0 -279
@@ -4,6 +4,39 @@ module Nanoc3::CLI::Commands
|
|
4
4
|
|
5
5
|
class CreateSite < Cri::Command
|
6
6
|
|
7
|
+
DEFAULT_RULES = <<EOS
|
8
|
+
#!/usr/bin/env ruby
|
9
|
+
|
10
|
+
# A few helpful tips about the Rules file:
|
11
|
+
#
|
12
|
+
# * The order of rules is important: for each item, only the first matching
|
13
|
+
# rule is applied.
|
14
|
+
#
|
15
|
+
# * Item identifiers start and end with a slash (e.g. “/about/” for the file
|
16
|
+
# “content/about.html”). To select all children, grandchildren, … of an
|
17
|
+
# item, use the pattern “/about/*/”; “/about/*” will also select the parent,
|
18
|
+
# because “*” matches zero or more characters.
|
19
|
+
|
20
|
+
compile '/stylesheet/' do
|
21
|
+
# don’t filter or layout
|
22
|
+
end
|
23
|
+
|
24
|
+
compile '*' do
|
25
|
+
filter :erb
|
26
|
+
layout 'default'
|
27
|
+
end
|
28
|
+
|
29
|
+
route '/stylesheet/' do
|
30
|
+
'/style.css'
|
31
|
+
end
|
32
|
+
|
33
|
+
route '*' do
|
34
|
+
item.identifier + 'index.html'
|
35
|
+
end
|
36
|
+
|
37
|
+
layout '*', :erb
|
38
|
+
EOS
|
39
|
+
|
7
40
|
DEFAULT_ITEM = <<EOS
|
8
41
|
<h1>A Brand New nanoc Site</h1>
|
9
42
|
|
@@ -128,6 +161,7 @@ EOS
|
|
128
161
|
<title>A Brand New nanoc Site - <%= @item[:title] %></title>
|
129
162
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
130
163
|
<link rel="stylesheet" type="text/css" href="/style.css" media="screen">
|
164
|
+
<meta name="generator" content="nanoc #{Nanoc3::VERSION}">
|
131
165
|
</head>
|
132
166
|
<body>
|
133
167
|
<div id="main">
|
@@ -169,7 +203,7 @@ EOS
|
|
169
203
|
end
|
170
204
|
|
171
205
|
def usage
|
172
|
-
"nanoc3 create_site [path
|
206
|
+
"nanoc3 create_site [options] path"
|
173
207
|
end
|
174
208
|
|
175
209
|
def option_definitions
|
@@ -252,18 +286,7 @@ EOS
|
|
252
286
|
|
253
287
|
# Create rules
|
254
288
|
File.open('Rules', 'w') do |io|
|
255
|
-
io.write
|
256
|
-
io.write "\n"
|
257
|
-
io.write "compile '*' do\n"
|
258
|
-
io.write " filter :erb\n"
|
259
|
-
io.write " layout 'default'\n"
|
260
|
-
io.write "end\n"
|
261
|
-
io.write "\n"
|
262
|
-
io.write "route '*' do\n"
|
263
|
-
io.write " item.identifier + 'index.html'\n"
|
264
|
-
io.write "end\n"
|
265
|
-
io.write "\n"
|
266
|
-
io.write "layout '*', :erb\n"
|
289
|
+
io.write DEFAULT_RULES
|
267
290
|
end
|
268
291
|
Nanoc3::NotificationCenter.post(:file_created, 'Rules')
|
269
292
|
end
|
@@ -285,29 +308,30 @@ EOS
|
|
285
308
|
def site_populate
|
286
309
|
# Get site
|
287
310
|
site = Nanoc3::Site.new('.')
|
288
|
-
|
289
|
-
# Create item
|
290
311
|
data_source = site.data_sources[0]
|
312
|
+
|
313
|
+
# Create home page
|
291
314
|
data_source.create_item(
|
292
315
|
DEFAULT_ITEM,
|
293
316
|
{ :title => "Home" },
|
294
317
|
'/'
|
295
318
|
)
|
296
319
|
|
320
|
+
# Create stylesheet
|
321
|
+
data_source.create_item(
|
322
|
+
DEFAULT_STYLESHEET,
|
323
|
+
{},
|
324
|
+
'/stylesheet/',
|
325
|
+
:extension => '.css'
|
326
|
+
)
|
327
|
+
|
297
328
|
# Create layout
|
298
|
-
data_source = site.data_sources[0]
|
299
329
|
data_source.create_layout(
|
300
330
|
DEFAULT_LAYOUT,
|
301
331
|
{},
|
302
332
|
'/default/'
|
303
333
|
)
|
304
334
|
|
305
|
-
# Create stylesheet
|
306
|
-
FileUtils.mkdir_p('output')
|
307
|
-
File.open('output/style.css', 'w') do |io|
|
308
|
-
io.write DEFAULT_STYLESHEET
|
309
|
-
end
|
310
|
-
|
311
335
|
# Create code
|
312
336
|
FileUtils.mkdir_p('lib')
|
313
337
|
File.open('lib/default.rb', 'w') do |io|
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc3::CLI::Commands
|
4
|
+
|
5
|
+
class Debug < Cri::Command
|
6
|
+
|
7
|
+
def name
|
8
|
+
'debug'
|
9
|
+
end
|
10
|
+
|
11
|
+
def aliases
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def short_desc
|
16
|
+
'show debug information for this site'
|
17
|
+
end
|
18
|
+
|
19
|
+
def long_desc
|
20
|
+
'Show information about all items, item representations and layouts ' \
|
21
|
+
'in the current site.'
|
22
|
+
end
|
23
|
+
|
24
|
+
def usage
|
25
|
+
"nanoc3 debug"
|
26
|
+
end
|
27
|
+
|
28
|
+
def option_definitions
|
29
|
+
[]
|
30
|
+
end
|
31
|
+
|
32
|
+
def run(options, arguments)
|
33
|
+
# Make sure we are in a nanoc site directory
|
34
|
+
print "Loading site data... "
|
35
|
+
@base.require_site
|
36
|
+
@base.site.load_data
|
37
|
+
puts "done"
|
38
|
+
puts
|
39
|
+
|
40
|
+
# Get data
|
41
|
+
items = @base.site.items
|
42
|
+
reps = items.map { |i| i.reps }.flatten
|
43
|
+
layouts = @base.site.layouts
|
44
|
+
|
45
|
+
# Calculate prettification data
|
46
|
+
identifier_length = items.map { |i| i.identifier.size }.max
|
47
|
+
rep_name_length = reps.map { |r| r.name.size }.max
|
48
|
+
|
49
|
+
# Print items
|
50
|
+
puts '=== Items'
|
51
|
+
puts
|
52
|
+
row = 0
|
53
|
+
items.sort_by { |i| i.identifier }.each do |item|
|
54
|
+
item.reps.sort_by { |r| r.name.to_s }.each do |rep|
|
55
|
+
# Determine filler
|
56
|
+
filler = (row % 3 == 0 ? '· ' : ' ')
|
57
|
+
row += 1
|
58
|
+
|
59
|
+
# Print rep
|
60
|
+
puts "* %s %s -> %s" % [
|
61
|
+
fill(item.identifier, identifier_length, filler),
|
62
|
+
fill(rep.name.to_s, rep_name_length, ' '),
|
63
|
+
rep.raw_path || '-'
|
64
|
+
]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
puts
|
68
|
+
|
69
|
+
# Print layouts
|
70
|
+
puts '=== Layouts'
|
71
|
+
puts
|
72
|
+
layouts.each do |layout|
|
73
|
+
puts "* #{layout.identifier}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
# Returns a string that is exactly `length` long, starting with `text` and
|
80
|
+
# filling up any unused space by repeating the string `filler`.
|
81
|
+
def fill(text, length, filler)
|
82
|
+
res = text.dup
|
83
|
+
|
84
|
+
filler_length = (length - 1 - text.length)
|
85
|
+
if filler_length >= 0
|
86
|
+
# Append spacer to ensure alignment
|
87
|
+
spacer_length = text.size % filler.length
|
88
|
+
filler_length -= spacer_length
|
89
|
+
res << ' ' * (spacer_length + 1)
|
90
|
+
|
91
|
+
# Append leader
|
92
|
+
res << filler*(filler_length/filler.length)
|
93
|
+
end
|
94
|
+
|
95
|
+
res
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Nanoc3::CLI::Commands
|
4
|
+
|
5
|
+
class View < Cri::Command
|
6
|
+
|
7
|
+
def name
|
8
|
+
'view'
|
9
|
+
end
|
10
|
+
|
11
|
+
def aliases
|
12
|
+
[]
|
13
|
+
end
|
14
|
+
|
15
|
+
def short_desc
|
16
|
+
'start the web server that serves static files'
|
17
|
+
end
|
18
|
+
|
19
|
+
def long_desc
|
20
|
+
'Start the static web server. Unless specified, the web server will run on port 3000 and listen on all IP addresses. Running the autocompiler requires \'adsf\' and \'rack\'.'
|
21
|
+
end
|
22
|
+
|
23
|
+
def usage
|
24
|
+
"nanoc3 view [options]"
|
25
|
+
end
|
26
|
+
|
27
|
+
def option_definitions
|
28
|
+
[
|
29
|
+
# --handler
|
30
|
+
{
|
31
|
+
:long => 'handler', :short => 'H', :argument => :required,
|
32
|
+
:desc => 'specify the handler to use (webrick/mongrel/...)'
|
33
|
+
},
|
34
|
+
# --host
|
35
|
+
{
|
36
|
+
:long => 'host', :short => 'o', :argument => :required,
|
37
|
+
:desc => 'specify the host to listen on (default: 0.0.0.0)'
|
38
|
+
},
|
39
|
+
# --port
|
40
|
+
{
|
41
|
+
:long => 'port', :short => 'p', :argument => :required,
|
42
|
+
:desc => 'specify the port to listen on (default: 3000)'
|
43
|
+
}
|
44
|
+
]
|
45
|
+
end
|
46
|
+
|
47
|
+
def run(options, arguments)
|
48
|
+
require 'rack'
|
49
|
+
require 'adsf'
|
50
|
+
|
51
|
+
# Make sure we are in a nanoc site directory
|
52
|
+
@base.require_site
|
53
|
+
|
54
|
+
# Set options
|
55
|
+
options_for_rack = {
|
56
|
+
:Port => (options[:port] || 3000).to_i,
|
57
|
+
:Host => (options[:host] || '0.0.0.0')
|
58
|
+
}
|
59
|
+
|
60
|
+
# Guess which handler we should use
|
61
|
+
unless handler = Rack::Handler.get(options[:handler])
|
62
|
+
begin
|
63
|
+
handler = Rack::Handler::Mongrel
|
64
|
+
rescue LoadError => e
|
65
|
+
handler = Rack::Handler::WEBrick
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# Build app
|
70
|
+
site = @base.site
|
71
|
+
app = Rack::Builder.new do
|
72
|
+
use Rack::CommonLogger
|
73
|
+
use Rack::ShowExceptions
|
74
|
+
use Rack::Lint
|
75
|
+
use Adsf::Rack::IndexFileFinder, :root => site.config[:output_dir]
|
76
|
+
run Rack::File.new(site.config[:output_dir])
|
77
|
+
end.to_app
|
78
|
+
|
79
|
+
# Run autocompiler
|
80
|
+
handler.run(app, options_for_rack)
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
data/lib/nanoc3/cli/commands.rb
CHANGED
@@ -8,6 +8,8 @@ require 'nanoc3/cli/commands/compile'
|
|
8
8
|
require 'nanoc3/cli/commands/create_layout'
|
9
9
|
require 'nanoc3/cli/commands/create_item'
|
10
10
|
require 'nanoc3/cli/commands/create_site'
|
11
|
+
require 'nanoc3/cli/commands/debug'
|
11
12
|
require 'nanoc3/cli/commands/help'
|
12
13
|
require 'nanoc3/cli/commands/info'
|
13
14
|
require 'nanoc3/cli/commands/update'
|
15
|
+
require 'nanoc3/cli/commands/view'
|
data/lib/nanoc3/cli/logger.rb
CHANGED
@@ -29,6 +29,13 @@ module Nanoc3::CLI
|
|
29
29
|
def initialize
|
30
30
|
@level = :high
|
31
31
|
@color = true
|
32
|
+
|
33
|
+
# Try enabling color support on Windows
|
34
|
+
begin
|
35
|
+
require 'Win32/Console/ANSI' if RUBY_PLATFORM =~/mswin|mingw/
|
36
|
+
rescue LoadError
|
37
|
+
warn 'The win32console gem is not available. Install it to enable color support on Windows.'
|
38
|
+
end
|
32
39
|
end
|
33
40
|
|
34
41
|
# Logs a file-related action.
|
data/lib/nanoc3/cli.rb
CHANGED
@@ -2,30 +2,7 @@
|
|
2
2
|
|
3
3
|
module Nanoc3::DataSources
|
4
4
|
|
5
|
-
#
|
6
|
-
# a single user as items (Nanoc3::Item instances).
|
7
|
-
#
|
8
|
-
# The configuration must have a "username" attribute containing the username
|
9
|
-
# of the account from which to fetch the bookmarks.
|
10
|
-
#
|
11
|
-
# The items returned by this data source will be mounted at {root}/{id},
|
12
|
-
# where +id+ is a sequence number that is not necessarily unique for this
|
13
|
-
# bookmark (because delicious.com unfortunately does not provide unique IDs
|
14
|
-
# for each bookmark).
|
15
|
-
#
|
16
|
-
# The items returned by this data source will have the following attributes:
|
17
|
-
#
|
18
|
-
# +:url+:: The URL the bookmark leads to.
|
19
|
-
#
|
20
|
-
# +:description+:: The description (title, usually) of the bookmark.
|
21
|
-
#
|
22
|
-
# +:tags+:: An array of tags (strings) for this bookmark.
|
23
|
-
#
|
24
|
-
# +:date+:: The timestamp when this bookmark was created (a Time object).
|
25
|
-
#
|
26
|
-
# +:note+:: The personal note for this bookmark (can be nil).
|
27
|
-
#
|
28
|
-
# +:author+:: The username of the person storing the bookmark.
|
5
|
+
# @deprecated Fetch data from online data sources manually instead
|
29
6
|
class Delicious < Nanoc3::DataSource
|
30
7
|
|
31
8
|
def items
|
@@ -2,33 +2,7 @@
|
|
2
2
|
|
3
3
|
module Nanoc3::DataSources
|
4
4
|
|
5
|
-
#
|
6
|
-
# from from a single Last.fm user as items (Nanoc3::Item instances).
|
7
|
-
#
|
8
|
-
# The configuration must have a "username" attribute containing the username
|
9
|
-
# of the account from which to fetch the data, and an "api_key" attribute
|
10
|
-
# containing the API key (which can be obtained from the Last.fm site).
|
11
|
-
#
|
12
|
-
# The items returned by this data source will be mounted at {root}/{id},
|
13
|
-
# where +id+ is a sequence number that is not necessarily unique for this
|
14
|
-
# bookmark (because delicious.com unfortunately does not provide unique IDs
|
15
|
-
# for each track).
|
16
|
-
#
|
17
|
-
# The items returned by this data source will have the following attributes:
|
18
|
-
#
|
19
|
-
# +:name+:: The name of the track.
|
20
|
-
#
|
21
|
-
# +played_at+:: The timestamp when the track was played (a Time instance).
|
22
|
-
#
|
23
|
-
# +url+:: The Last.fm URL corresponding to the track (a String instance).
|
24
|
-
#
|
25
|
-
# +artist+:: A hash containing information about the track's artist.
|
26
|
-
#
|
27
|
-
# The +artist+ hash consists of the following keys:
|
28
|
-
#
|
29
|
-
# +name+:: The name of the artist.
|
30
|
-
#
|
31
|
-
# +url+:: The Last.fm URL corresponding to the artist (a String instance).
|
5
|
+
# @deprecated Fetch data from online data sources manually instead
|
32
6
|
class LastFM < Nanoc3::DataSource
|
33
7
|
|
34
8
|
def items
|
@@ -2,20 +2,7 @@
|
|
2
2
|
|
3
3
|
module Nanoc3::DataSources
|
4
4
|
|
5
|
-
#
|
6
|
-
# (Nanoc3::Item instances).
|
7
|
-
#
|
8
|
-
# The configuration must have a "username" attribute containing the username
|
9
|
-
# of the account from which to fetch the tweets.
|
10
|
-
#
|
11
|
-
# The items returned by this data source will be mounted at {root}/{id},
|
12
|
-
# where +id+ is the unique identifier of the tweet.
|
13
|
-
#
|
14
|
-
# The items returned by this data source will have the following attributes:
|
15
|
-
#
|
16
|
-
# +:created_at+:: The timestamp when this tweet was posted (a string).
|
17
|
-
#
|
18
|
-
# +source+:: The client used to tweet this message (HTML-encoded).
|
5
|
+
# @deprecated Fetch data from online data sources manually instead
|
19
6
|
class Twitter < Nanoc3::DataSource
|
20
7
|
|
21
8
|
def items
|