What's New
nanoc 2.1
Improved CLI
nanoc compile --verbosenow shows profiling informationwrite your own nanoc commands:
require 'nanoc/cli' class HelloWorldCommand < Nanoc::CLI::Command def name 'hello_world' end def aliases %w( hw ) end def short_desc 'print a simple greeting' end def long_desc 'Print the "hello world" greeting on the screen, in either ' + 'lowercase or uppercase. Can also print a custom text.' end def usage "nanoc hello_world [options] [custom_text]" end def option_definitions [ # --uppercase { :long => 'uppercase', :short => 'u', :argument => :forbidden, :desc => 'print the text in uppercase instead of lowercase' } ] end def run(options, arguments) # Get text text = (arguments[0] || 'hello world') # Print it puts (options.has_key?(:uppercase) ? text.upcase : text.downcase) end end
An open framework
- nanoc has a public API
- source code is now heavily documented: http://nanoc.stoneship.org/help/rdoc/
- expanded test suite
Improved data sources
- new data source:
filesystem_combined, to store page metadata in a single file (like Webby).- To use it, create a site with
nanoc create_site -d filesystem_combined my_new_site - You can switch an existing site to the new data source using
nanoc switch -d filesystem_combined
- To use it, create a site with
- If your site is stored in a VCS repository such as Subversion, git, Mercurial or Bazaar, you can tell nanoc to use this VCS’ commands using the -c switch. At the moment, nanoc supports svn, git, hg and bzr:
nanoc switch -d filesystem_combined -c git- TODO: check source
- Nanoc::Extra::VCS is a very simple representation of a version control system that abstracts the add, remove and move operations. It does not commit. This class is primarily used by data sources that store data as flat files on the disk.
- layouts are stored as directories
- new
updatecommand, to change site options:nanoc update -c hg
Routers
Not really clear from the post, specially because Danis doesn't show real working code...
Assets
- The new asset compilation feature allows a site to have assets, which can be run through filters. Assets can be anything—Sass stylesheets, images, MP3s, videos, and so on.
- Two kinds of assets: textual (processed by any text filter that nanoc supports, i.e: SASS, ERB, etc) and binary (processed by the new binary filters)
Assets are stored in the
assetsfolder, exactly like pages (each asset has a content part and a metadata part).The built in metadata for assets is:
binary: false filters: []
- Binary filters inherit from Nanoc::BinaryFilter instead of Nanoc::Filter. Their run method takes a File object and not a string containing the asset content. Additionally, binary filters should return a File object representing the processed file. The original File argument should not be modified (otherwise you’d lose the original asset).
- The default router saves compiled assets in an
assetsdirectory inside the output directory. It’s possible to set assets_prefix in the config file to something else such as “/media”, or even “” to save assets directly in the output directory. Multiple representations:
reps: default: filters: [] thumbnail: filters: [ 'image_science_thumbnail' ] thumbnail_size: 100
Misc
- Autocompiler now uses Rack
- Layout processors are gone. Instead, use filters.
- Layouts can be stored hierarchically (our patch got in!)
- New bundled filters:
- rdiscount
- maruku
- erubis
- A lot of helpers have been bundled with nanoc. There’s helpers for blogging, tagging, capturing, HTML-escaping *, rendering *, building XML sitemaps and linking. (*: included by default)
- To include then, use
include Nanoc::Helpers::LinkTo
- To include then, use
nanoc 2.0
New features in 2.0
- custom filters and custom layout processors.
- custom data sources (example?)
- parent and children links for page objects:
- @page.parent and @page.children
- autocompiler
Changes from nanoc 1.x
custom filters:
class MarkdownFilter < Nanoc::Filter identifiers :markdown, :bluecloth def run(content) nanoc_require 'bluecloth' ::BlueCloth.new(content).to_html end end- filters → filters_pre
- dropped Liquid support
- erubis is removed
- templates are NOT run through ERB when creating a page.
- Ruby 1.9 support
changed September 5, 2008