nanoc 2.0.4 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +31 -1
- data/LICENSE +1 -1
- data/README +63 -3
- data/Rakefile +59 -12
- data/bin/nanoc +7 -199
- data/lib/nanoc.rb +83 -12
- data/lib/nanoc/base/asset.rb +113 -0
- data/lib/nanoc/base/asset_defaults.rb +21 -0
- data/lib/nanoc/base/asset_rep.rb +277 -0
- data/lib/nanoc/base/binary_filter.rb +44 -0
- data/lib/nanoc/base/code.rb +41 -0
- data/lib/nanoc/base/compiler.rb +46 -34
- data/lib/nanoc/base/core_ext/hash.rb +51 -7
- data/lib/nanoc/base/core_ext/string.rb +8 -0
- data/lib/nanoc/base/data_source.rb +253 -20
- data/lib/nanoc/base/defaults.rb +30 -0
- data/lib/nanoc/base/enhancements.rb +9 -84
- data/lib/nanoc/base/filter.rb +109 -6
- data/lib/nanoc/base/layout.rb +91 -0
- data/lib/nanoc/base/notification_center.rb +66 -0
- data/lib/nanoc/base/page.rb +94 -126
- data/lib/nanoc/base/page_defaults.rb +20 -0
- data/lib/nanoc/base/page_rep.rb +318 -0
- data/lib/nanoc/base/plugin.rb +57 -9
- data/lib/nanoc/base/proxies/asset_proxy.rb +29 -0
- data/lib/nanoc/base/proxies/asset_rep_proxy.rb +26 -0
- data/lib/nanoc/base/proxies/layout_proxy.rb +25 -0
- data/lib/nanoc/base/proxies/page_proxy.rb +35 -0
- data/lib/nanoc/base/proxies/page_rep_proxy.rb +28 -0
- data/lib/nanoc/base/proxy.rb +37 -0
- data/lib/nanoc/base/router.rb +72 -0
- data/lib/nanoc/base/site.rb +219 -88
- data/lib/nanoc/base/template.rb +64 -0
- data/lib/nanoc/binary_filters/image_science_thumbnail.rb +28 -0
- data/lib/nanoc/cli.rb +1 -0
- data/lib/nanoc/cli/base.rb +219 -0
- data/lib/nanoc/cli/cli.rb +16 -0
- data/lib/nanoc/cli/command.rb +105 -0
- data/lib/nanoc/cli/commands/autocompile.rb +80 -0
- data/lib/nanoc/cli/commands/compile.rb +273 -0
- data/lib/nanoc/cli/commands/create_layout.rb +85 -0
- data/lib/nanoc/cli/commands/create_page.rb +85 -0
- data/lib/nanoc/cli/commands/create_site.rb +327 -0
- data/lib/nanoc/cli/commands/create_template.rb +76 -0
- data/lib/nanoc/cli/commands/help.rb +69 -0
- data/lib/nanoc/cli/commands/info.rb +114 -0
- data/lib/nanoc/cli/commands/switch.rb +141 -0
- data/lib/nanoc/cli/commands/update.rb +91 -0
- data/lib/nanoc/cli/ext.rb +37 -0
- data/lib/nanoc/cli/logger.rb +66 -0
- data/lib/nanoc/cli/option_parser.rb +168 -0
- data/lib/nanoc/data_sources/filesystem.rb +645 -224
- data/lib/nanoc/data_sources/filesystem_combined.rb +495 -0
- data/lib/nanoc/extra/auto_compiler.rb +265 -0
- data/lib/nanoc/extra/context.rb +22 -0
- data/lib/nanoc/extra/core_ext/hash.rb +54 -0
- data/lib/nanoc/extra/core_ext/time.rb +13 -0
- data/lib/nanoc/extra/file_proxy.rb +29 -0
- data/lib/nanoc/extra/vcs.rb +48 -0
- data/lib/nanoc/extra/vcses/bazaar.rb +21 -0
- data/lib/nanoc/extra/vcses/dummy.rb +20 -0
- data/lib/nanoc/extra/vcses/git.rb +21 -0
- data/lib/nanoc/extra/vcses/mercurial.rb +21 -0
- data/lib/nanoc/extra/vcses/subversion.rb +21 -0
- data/lib/nanoc/filters/bluecloth.rb +13 -0
- data/lib/nanoc/filters/erb.rb +6 -22
- data/lib/nanoc/filters/erubis.rb +14 -0
- data/lib/nanoc/filters/haml.rb +7 -23
- data/lib/nanoc/filters/markaby.rb +5 -5
- data/lib/nanoc/filters/maruku.rb +14 -0
- data/lib/nanoc/filters/old.rb +19 -0
- data/lib/nanoc/filters/rdiscount.rb +13 -0
- data/lib/nanoc/filters/rdoc.rb +5 -4
- data/lib/nanoc/filters/redcloth.rb +14 -0
- data/lib/nanoc/filters/rubypants.rb +14 -0
- data/lib/nanoc/filters/sass.rb +13 -0
- data/lib/nanoc/helpers/blogging.rb +170 -0
- data/lib/nanoc/helpers/capturing.rb +59 -0
- data/lib/nanoc/helpers/html_escape.rb +23 -0
- data/lib/nanoc/helpers/link_to.rb +69 -0
- data/lib/nanoc/helpers/render.rb +47 -0
- data/lib/nanoc/helpers/tagging.rb +52 -0
- data/lib/nanoc/helpers/xml_sitemap.rb +58 -0
- data/lib/nanoc/routers/default.rb +54 -0
- data/lib/nanoc/routers/no_dirs.rb +66 -0
- data/lib/nanoc/routers/versioned.rb +79 -0
- metadata +112 -22
- data/lib/nanoc/base/auto_compiler.rb +0 -132
- data/lib/nanoc/base/layout_processor.rb +0 -33
- data/lib/nanoc/base/page_proxy.rb +0 -31
- data/lib/nanoc/base/plugin_manager.rb +0 -33
- data/lib/nanoc/data_sources/database.rb +0 -259
- data/lib/nanoc/data_sources/trivial.rb +0 -145
- data/lib/nanoc/filters/markdown.rb +0 -13
- data/lib/nanoc/filters/smartypants.rb +0 -13
- data/lib/nanoc/filters/textile.rb +0 -13
- data/lib/nanoc/layout_processors/erb.rb +0 -35
- data/lib/nanoc/layout_processors/haml.rb +0 -38
- data/lib/nanoc/layout_processors/markaby.rb +0 -16
data/ChangeLog
CHANGED
@@ -1,6 +1,36 @@
|
|
1
1
|
nanoc Release Notes
|
2
2
|
===================
|
3
3
|
|
4
|
+
2.1
|
5
|
+
---
|
6
|
+
|
7
|
+
This is only a short summary of all changes in 2.1. For details, see the nanoc
|
8
|
+
web site at <http://nanoc.stoneship.org/> -- especially the blog and the
|
9
|
+
updated manual will be useful.
|
10
|
+
|
11
|
+
New:
|
12
|
+
|
13
|
+
* New filters: RDiscount, Maruku, Erubis
|
14
|
+
* A better commandline frontend
|
15
|
+
* A new filesystem data source named "filesystem_combined"
|
16
|
+
* Routers, which decide where compiled pages should be written to
|
17
|
+
* Page/layout mtimes can now be retrieved through page.mtime/layout.mtime
|
18
|
+
|
19
|
+
Changed:
|
20
|
+
|
21
|
+
* Already compiled pages will no longer be re-compiled unless outdated
|
22
|
+
* Layout processors and filters have been merged
|
23
|
+
* Layouts no longer rely on file extensions to determine the layout processor
|
24
|
+
* Greatly improved source code documentation
|
25
|
+
* Greatly improved unit test suite
|
26
|
+
|
27
|
+
Removed:
|
28
|
+
|
29
|
+
* Several filters have been removed and replaced by newer filters:
|
30
|
+
* `eruby`: use `erb` or `erubis` instead
|
31
|
+
* `markdown`: use `bluecloth`, `rdiscount` or `maruku` instead
|
32
|
+
* `textile`: use `redcloth` instead
|
33
|
+
|
4
34
|
2.0.4
|
5
35
|
-----
|
6
36
|
|
@@ -11,7 +41,7 @@ nanoc Release Notes
|
|
11
41
|
2.0.3
|
12
42
|
-----
|
13
43
|
|
14
|
-
* The
|
44
|
+
* The autocompiler now honors custom paths
|
15
45
|
* The autocompiler now attempts to serve pages with the most appropriate MIME
|
16
46
|
type, instead of always serving everything as "text/html"
|
17
47
|
|
data/LICENSE
CHANGED
data/README
CHANGED
@@ -1,14 +1,74 @@
|
|
1
1
|
== Overview
|
2
2
|
|
3
|
-
nanoc is a simple but very flexible
|
3
|
+
nanoc is a simple but very flexible static site generator written in Ruby.
|
4
4
|
It operates on local files, and therefore does not run on the server. nanoc
|
5
5
|
"compiles" the local source files into HTML (usually), by evaluating eRuby,
|
6
6
|
Markdown, etc.
|
7
7
|
|
8
8
|
== Documentation
|
9
9
|
|
10
|
-
nanoc
|
11
|
-
|
10
|
+
nanoc's web site, which can be found at http://nanoc.stoneship.org, contains a
|
11
|
+
few useful resources to help you get started with nanoc:
|
12
|
+
|
13
|
+
* The tutorial at http://nanoc.stoneship.org/help/tutorial
|
14
|
+
* The manual at http://nanoc.stoneship.org/help/manual
|
15
|
+
|
16
|
+
It is probably also worth checking out and perhaps subscribing to the
|
17
|
+
discussion groups:
|
18
|
+
|
19
|
+
* The discussion group in English at http://groups.google.com/group/nanoc
|
20
|
+
* The discussion group in Spanish at http://groups.google.com/group/nanoc-es
|
21
|
+
|
22
|
+
=== Source Code Documentation
|
23
|
+
|
24
|
+
The source code is structured in a few directories:
|
25
|
+
|
26
|
+
* *bin* contains the commandline tool aptly named +nanoc+
|
27
|
+
* *lib*
|
28
|
+
* *nanoc*
|
29
|
+
* *base* contains the bare essentials necessary for nanoc to function
|
30
|
+
* *binary_filters* contains the standard binary filters
|
31
|
+
(Nanoc::BinaryFilter subclasses) such as the thumbnail filter
|
32
|
+
* *cli* contains the commandline interface
|
33
|
+
* *data_sources* contains the standard data sources (Nanoc::DataSource
|
34
|
+
subclasses), such as the filesystem data source
|
35
|
+
* *helpers* contains helpers, which provide functionality some sites
|
36
|
+
may find useful, such as the blogging and tagging helpers
|
37
|
+
* *extra* contains stuff that is not needed by nanoc itself, but which may
|
38
|
+
be used by helpers, data sources, filters or routers.
|
39
|
+
* *filters* contains the standard filters (Nanoc::Filter subclasses) such
|
40
|
+
as ERB, Markdown, Haml, ...
|
41
|
+
* *routers* contains the standard routers (Nanoc::Router subclasses)
|
42
|
+
* *test* contains test fixtures as well as testing code, structured in the
|
43
|
+
same way as lib/nanoc
|
44
|
+
|
45
|
+
The namespaces (modules) are organised like this:
|
46
|
+
|
47
|
+
* *Nanoc* is the namespace for everything nanoc-related (obviously). The
|
48
|
+
classes in 'lib/nanoc/base' are part of this module (not Nanoc::Base which
|
49
|
+
does not exist)
|
50
|
+
* *BinaryFilters* contains the binary filters
|
51
|
+
* *CLI* containing everything related to the commandline tool.
|
52
|
+
* *DataSources* contains the data sources
|
53
|
+
* *Helpers* contains the helpers
|
54
|
+
* *Extra* contains useful stuff not needed by nanoc itself
|
55
|
+
* *Filters* contains the (textual) filters
|
56
|
+
* *Routers* contains the routers
|
57
|
+
|
58
|
+
The central class in nanoc is Nanoc::Site, so you should start there if you
|
59
|
+
want to explore nanoc from a technical perspective.
|
60
|
+
|
61
|
+
== Contributors
|
62
|
+
|
63
|
+
(In alphabetical order)
|
64
|
+
|
65
|
+
* Colin Barrett
|
66
|
+
* Dmitry Bilunov
|
67
|
+
* Šime Ramov
|
68
|
+
* "Soryu"
|
69
|
+
* Dennis Sutch
|
70
|
+
|
71
|
+
Special thanks to Ale Muñoz.
|
12
72
|
|
13
73
|
== Contact
|
14
74
|
|
data/Rakefile
CHANGED
@@ -4,25 +4,44 @@ require 'rake'
|
|
4
4
|
|
5
5
|
require 'rake/clean'
|
6
6
|
require 'rake/gempackagetask'
|
7
|
+
require 'rake/rdoctask'
|
7
8
|
require 'rake/testtask'
|
8
9
|
|
9
10
|
require File.dirname(__FILE__) + '/lib/nanoc.rb'
|
10
11
|
|
11
12
|
##### General details
|
12
13
|
|
13
|
-
NAME
|
14
|
-
VERS
|
15
|
-
SUMMARY
|
16
|
-
|
14
|
+
NAME = 'nanoc'
|
15
|
+
VERS = Nanoc::VERSION
|
16
|
+
SUMMARY = 'a tool that runs on your local computer and compiles ' +
|
17
|
+
'Markdown, Textile, Haml, ... documents into static web pages'
|
17
18
|
HOMEPAGE = 'http://nanoc.stoneship.org/'
|
18
19
|
|
19
20
|
AUTHOR = 'Denis Defreyne'
|
20
21
|
EMAIL = 'denis.defreyne@stoneship.org'
|
21
22
|
|
23
|
+
MESSAGE = <<EOS
|
24
|
+
Thanks for installing nanoc 2.1! Here are some resources to help you get started:
|
25
|
+
|
26
|
+
* The tutorial at <http://nanoc.stoneship.org/help/tutorial/>
|
27
|
+
* The manual at <http://nanoc.stoneship.org/help/manual/>
|
28
|
+
* The discussion group at <http://groups.google.com/group/nanoc>
|
29
|
+
|
30
|
+
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.
|
31
|
+
|
32
|
+
Enjoy!
|
33
|
+
EOS
|
34
|
+
|
22
35
|
##### Cleaning
|
23
36
|
|
24
|
-
CLEAN.include
|
25
|
-
|
37
|
+
CLEAN.include([
|
38
|
+
'coverage',
|
39
|
+
'rdoc',
|
40
|
+
'tmp',
|
41
|
+
File.join('test', 'fixtures', '*', 'output', '*'),
|
42
|
+
File.join('test', 'fixtures', '*', 'tmp')
|
43
|
+
])
|
44
|
+
CLOBBER.include([ 'pkg' ])
|
26
45
|
|
27
46
|
##### Packaging
|
28
47
|
|
@@ -37,12 +56,25 @@ spec = Gem::Specification.new do |s|
|
|
37
56
|
s.author = AUTHOR
|
38
57
|
s.email = EMAIL
|
39
58
|
|
59
|
+
s.post_install_message = '-' * 78 + "\n" + MESSAGE + '-' * 78
|
60
|
+
|
40
61
|
s.rubyforge_project = 'nanoc'
|
41
62
|
|
42
63
|
s.required_ruby_version = '>= 1.8.5'
|
43
64
|
|
44
|
-
s.has_rdoc =
|
45
|
-
s.
|
65
|
+
s.has_rdoc = true
|
66
|
+
s.extra_rdoc_files = [ 'README' ]
|
67
|
+
s.rdoc_options << '--title' << 'nanoc' <<
|
68
|
+
'--main' << 'README' <<
|
69
|
+
'--charset' << 'utf-8' <<
|
70
|
+
'--exclude' << 'lib/nanoc/cli/commands' <<
|
71
|
+
'--exclude' << 'lib/nanoc/binary_filters' <<
|
72
|
+
'--exclude' << 'lib/nanoc/extra/vcses' <<
|
73
|
+
'--exclude' << 'lib/nanoc/filters' <<
|
74
|
+
'--exclude' << 'test' <<
|
75
|
+
'--line-numbers'
|
76
|
+
|
77
|
+
s.files = %w( README LICENSE ChangeLog Rakefile ) + Dir[File.join('{bin,lib}', '**', '*')]
|
46
78
|
s.executables = [ 'nanoc' ]
|
47
79
|
s.require_path = 'lib'
|
48
80
|
s.bindir = 'bin'
|
@@ -52,17 +84,32 @@ Rake::GemPackageTask.new(spec) { |task| }
|
|
52
84
|
|
53
85
|
task :install_gem do
|
54
86
|
sh %{rake package}
|
55
|
-
sh %{
|
87
|
+
sh %{gem install pkg/#{NAME}-#{VERS}}
|
56
88
|
end
|
57
89
|
|
58
90
|
task :uninstall_gem do
|
59
|
-
sh %{
|
91
|
+
sh %{gem uninstall #{NAME}}
|
92
|
+
end
|
93
|
+
|
94
|
+
### Documentation
|
95
|
+
|
96
|
+
Rake::RDocTask.new do |task|
|
97
|
+
task.rdoc_files.include(spec.extra_rdoc_files + [ 'lib' ])
|
98
|
+
task.rdoc_dir = 'rdoc'
|
99
|
+
task.options = spec.rdoc_options
|
60
100
|
end
|
61
101
|
|
62
102
|
### Testing
|
63
103
|
|
64
|
-
|
65
|
-
|
104
|
+
task :rcov do
|
105
|
+
sh %{rcov test/**/test_*.rb -I test -x /Library}
|
106
|
+
end
|
107
|
+
|
108
|
+
Rake::TestTask.new(:test) do |task|
|
109
|
+
ENV['QUIET'] = 'true'
|
110
|
+
|
111
|
+
task.libs = [ 'lib', 'test' ]
|
112
|
+
task.test_files = Dir[ 'test/**/test_*.rb' ]
|
66
113
|
end
|
67
114
|
|
68
115
|
task :default => [ :test ]
|
data/bin/nanoc
CHANGED
@@ -1,204 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
#
|
4
|
-
|
3
|
+
# Load nanoc
|
5
4
|
require File.dirname(__FILE__) + '/../lib/nanoc.rb'
|
6
|
-
require '
|
7
|
-
|
8
|
-
# Helper functions
|
9
|
-
|
10
|
-
def usage(s)
|
11
|
-
error(s, 'Usage')
|
12
|
-
end
|
13
|
-
|
14
|
-
# Define some texts
|
15
|
-
|
16
|
-
version_text = "nanoc #{Nanoc::VERSION} (c) 2007-2008 Denis Defreyne."
|
17
|
-
help_text = <<EOT
|
18
|
-
Usage: nanoc [-chvV]
|
19
|
-
nanoc compile
|
20
|
-
nanoc autocompile
|
21
|
-
nanoc create_layout [layout_name]
|
22
|
-
nanoc create_page [page_name] [-t template]
|
23
|
-
nanoc create_site [site_name]
|
24
|
-
nanoc create_template [template_name]
|
25
|
-
|
26
|
-
Options:
|
27
|
-
-h, --help Show this help message and quit.
|
28
|
-
-p, --port Port the autocompiler should be run on.
|
29
|
-
-t, --template Template that should be used when creating a page.
|
30
|
-
(can only be used with create_page)
|
31
|
-
-V, --verbose Display more verbose log messages.
|
32
|
-
-v, --version Show the nanoc version number and quit.
|
33
|
-
|
34
|
-
Description:
|
35
|
-
The 'nanoc' command is used for creating nanoc-powered sites, as well as
|
36
|
-
managing them: creating pages and templates and compiling the site.
|
37
|
-
|
38
|
-
Read more about nanoc on the site: <http://nanoc.stoneship.org/>
|
39
|
-
EOT
|
40
|
-
|
41
|
-
# Create site
|
42
|
-
|
43
|
-
$nanoc_site = Nanoc::Site.from_cwd
|
44
|
-
|
45
|
-
# Parse options
|
46
|
-
|
47
|
-
opts = GetoptLong.new(
|
48
|
-
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
49
|
-
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
50
|
-
[ '--template', '-t', GetoptLong::REQUIRED_ARGUMENT ],
|
51
|
-
[ '--verbose', '-V', GetoptLong::NO_ARGUMENT ],
|
52
|
-
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
53
|
-
[ '--yes', '-y', GetoptLong::NO_ARGUMENT ]
|
54
|
-
)
|
55
|
-
$unprocessed_opts = {}
|
56
|
-
begin
|
57
|
-
opts.each do |opt, arg|
|
58
|
-
case opt
|
59
|
-
when '--help'
|
60
|
-
$stderr.puts help_text
|
61
|
-
exit
|
62
|
-
when '--verbose'
|
63
|
-
$log_level = :low
|
64
|
-
when '--version'
|
65
|
-
puts version_text
|
66
|
-
exit
|
67
|
-
else
|
68
|
-
$unprocessed_opts[opt] = arg
|
69
|
-
end
|
70
|
-
end
|
71
|
-
rescue GetoptLong::InvalidOption
|
72
|
-
$stderr.puts usage_text
|
73
|
-
exit(1)
|
74
|
-
end
|
75
|
-
|
76
|
-
# Make sure we have at least one argument
|
77
|
-
|
78
|
-
usage 'nanoc [options] [command] [parameters]' if ARGV.size == 0
|
79
|
-
|
80
|
-
# Functions for handing commands
|
81
|
-
|
82
|
-
def setup
|
83
|
-
# Check syntax
|
84
|
-
usage 'Usage: nanoc setup' if ARGV.size != 1
|
85
|
-
|
86
|
-
# Make sure we are in a nanoc site directory
|
87
|
-
unless $nanoc_site
|
88
|
-
error 'The current working directory does not seem to ' +
|
89
|
-
'be a valid/complete nanoc site directory; aborting.'
|
90
|
-
end
|
91
|
-
|
92
|
-
# Check for -y switch
|
93
|
-
unless $unprocessed_opts.has_key?('--yes')
|
94
|
-
error 'Are you absolutely sure you want to set up the data source for ' +
|
95
|
-
'this site? Setting up the data source will remove existing ' +
|
96
|
-
'data. To continue, use the -y switch, like "nanoc setup -y".'
|
97
|
-
end
|
98
|
-
|
99
|
-
# Setup
|
100
|
-
$nanoc_site.setup
|
101
|
-
end
|
102
|
-
|
103
|
-
def create_site
|
104
|
-
# Check syntax
|
105
|
-
usage 'Usage: nanoc create_site [site_name] [options]' if ARGV.size != 2
|
106
|
-
|
107
|
-
# Create site
|
108
|
-
Nanoc::Site.create(ARGV[1])
|
109
|
-
end
|
110
|
-
|
111
|
-
def create_page
|
112
|
-
# Check syntax
|
113
|
-
usage 'Usage: nanoc create_page [page_name] [options]' if ARGV.size != 2
|
114
|
-
|
115
|
-
# Make sure we are in a nanoc site directory
|
116
|
-
unless $nanoc_site
|
117
|
-
error 'The current working directory does not seem to ' +
|
118
|
-
'be a valid/complete nanoc site directory; aborting.'
|
119
|
-
end
|
120
|
-
|
121
|
-
# Create page
|
122
|
-
if $unprocessed_opts['--template'].nil?
|
123
|
-
$nanoc_site.create_page(ARGV[1])
|
124
|
-
else
|
125
|
-
$nanoc_site.create_page(ARGV[1], $unprocessed_opts['--template'])
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def create_layout
|
130
|
-
# Check syntax
|
131
|
-
usage 'nanoc create_layout [layout_name]' if ARGV.size != 2
|
132
|
-
|
133
|
-
# Make sure we are in a nanoc site directory
|
134
|
-
unless $nanoc_site
|
135
|
-
error 'The current working directory does not seem to ' +
|
136
|
-
'be a valid/complete nanoc site directory; aborting.'
|
137
|
-
end
|
138
|
-
|
139
|
-
# Create template
|
140
|
-
$nanoc_site.create_layout(ARGV[1])
|
141
|
-
end
|
142
|
-
|
143
|
-
def create_template
|
144
|
-
# Check syntax
|
145
|
-
usage 'nanoc create_template [template_name]' if ARGV.size != 2
|
146
|
-
|
147
|
-
# Make sure we are in a nanoc site directory
|
148
|
-
unless $nanoc_site
|
149
|
-
error 'The current working directory does not seem to ' +
|
150
|
-
'be a valid/complete nanoc site directory; aborting.'
|
151
|
-
end
|
152
|
-
|
153
|
-
# Create template
|
154
|
-
$nanoc_site.create_template(ARGV[1])
|
155
|
-
end
|
156
|
-
|
157
|
-
def compile_site
|
158
|
-
# Check syntax
|
159
|
-
usage 'nanoc compile' if ARGV.size != 1
|
160
|
-
|
161
|
-
# Make sure we are in a nanoc site directory
|
162
|
-
unless $nanoc_site
|
163
|
-
error 'The current working directory does not seem to ' +
|
164
|
-
'be a valid/complete nanoc site directory; aborting.'
|
165
|
-
end
|
166
|
-
|
167
|
-
# Compile site
|
168
|
-
$nanoc_site.compile
|
169
|
-
end
|
170
|
-
|
171
|
-
def autocompile_site
|
172
|
-
# Check syntax
|
173
|
-
usage 'nanoc compile' if ARGV.size != 1
|
174
|
-
|
175
|
-
# Make sure we are in a nanoc site directory
|
176
|
-
unless $nanoc_site
|
177
|
-
error 'The current working directory does not seem to ' +
|
178
|
-
'be a valid/complete nanoc site directory; aborting.'
|
179
|
-
end
|
180
|
-
|
181
|
-
# Autocompile site
|
182
|
-
$nanoc_site.autocompile($unprocessed_opts['--port'])
|
183
|
-
end
|
5
|
+
require File.dirname(__FILE__) + '/../lib/nanoc/cli.rb'
|
184
6
|
|
185
|
-
#
|
7
|
+
# Load custom code that can't be load later
|
8
|
+
Dir['lib/commands/*.rb'].each { |f| require f }
|
9
|
+
Dir['lib/data_sources/*.rb'].each { |f| require f }
|
186
10
|
|
187
|
-
|
188
|
-
|
189
|
-
autocompile_site
|
190
|
-
when 'create_site', 'cs'
|
191
|
-
create_site
|
192
|
-
when 'create_page', 'cp'
|
193
|
-
create_page
|
194
|
-
when 'create_layout', 'cl'
|
195
|
-
create_layout
|
196
|
-
when 'create_template', 'ct'
|
197
|
-
create_template
|
198
|
-
when 'compile_site', 'compile', 'co'
|
199
|
-
compile_site
|
200
|
-
when 'setup', 's'
|
201
|
-
setup
|
202
|
-
else
|
203
|
-
error 'Unrecognised command \'' + ARGV[0] + '\''
|
204
|
-
end
|
11
|
+
# Run base
|
12
|
+
Nanoc::CLI::Base.new.run(ARGV)
|