nanoc 3.0.0 beta 1

14 views
Skip to first unread message

Denis Defreyne

unread,
Aug 8, 2009, 12:15:42 PM8/8/09
to na...@googlegroups.com
Hi,

I've just published the first beta version of nanoc 3.0.0. To install
it, use rubygems the usual way but also pass a --prerelease flag, like
this:

sudo gem install nanoc3 --prerelease

This beta version differs from previous preview releases in that it
fixes a few bugs, and also gives the #render method the ability to
take a block. Take a look at <http://pastie.textmate.org/pastes/
575806> to see an example.

Note that the Render helper has been renamed to Rendering, for
consistency's sake. The migration guide on the web site doesn't
reflect this yet, but it will soon.

Do give this beta version a try and let me know what you think!

Regards,

Denis

--
Denis Defreyne
denis.d...@stoneship.org

JLF

unread,
Aug 9, 2009, 6:07:31 AM8/9/09
to nanoc
Hi Denis,

I have started testing nanoc3. I must say I like most of the changes
and new features after a first glance. So thank you for all the work.

Some small glitchs:

1. When using the 'filesystem_combined' datasource, the yaml preamble
of a newly generated page is ugly.

-----
---
title: A New Item

-----
Hi, I'm a new item!

I thing you should remove the 3 dashes.


2. The rake 'clean' task does not seem to work. Generated pages are
still in the output dir after execution.


3. The generated 'default.html' erb layout has a 'filter: erb'
attribute. Does it work ? Does this declaration overide the new
'layout' rules ?


If I discover new issues , is there a bug tracking site or you prefer
I post the problem in this group ?

Cheers,

jl

Denis Defreyne

unread,
Aug 9, 2009, 6:29:31 AM8/9/09
to na...@googlegroups.com
On 09 Aug 2009, at 12:07, JLF wrote:

> 1. When using the 'filesystem_combined' datasource, the yaml
> preamble of a newly generated page is ugly.

Yeah, it rather is. I've changed the format a little bit, so instead
of this:

> -----
> ---
> title: A New Item
>
> -----
> Hi, I'm a new item!

… you now have this:

> ---
> title: A New Item
>
> ---

> Hi, I'm a new item!

(The three dashes in the original format are actually generated by
YAML.dump.)

> 2. The rake 'clean' task does not seem to work. Generated pages are
> still in the output dir after execution.

Hm, that's odd. It seems to work fine here. If you want/can, send me
your site source and I'll check why it isn't working like it is
supposed to.

> 3. The generated 'default.html' erb layout has a 'filter: erb'
> attribute. Does it work ? Does this declaration overide the new
> 'layout' rules ?

Ahh, that's a bug. It's not supposed to be there. The 'filter'
attribute doesn't do anything special in nanoc3. Fixed!

> If I discover new issues , is there a bug tracking site or you
> prefer I post the problem in this group ?

You can use the issue tracker and create a new ticket there by going
to <http://projects.stoneship.org/trac/nanoc/newticket>. You may need
to log in; use username/password nanocuser/nospam. Feel free to leave
fields blank if you don't know what to put there.

JLF

unread,
Aug 9, 2009, 10:11:42 AM8/9/09
to nanoc
Thanks for you fast answers. I just opened a ticket for the 'rake
clean' issue in traq. I uploaded a minimal website subject to this
problem.

I have some questions about features:

1. Is there a way of storing site wide metadata in a central place and
accessing the values from items, helper and layouts ?

2. I would like to use the 'coderay filter' on code excerpts in some
items. However I do not want to filter the whole items with code ray.
Is there a built-in way to apply a filter to just a part of a page ?

Best,

jl

Denis Defreyne

unread,
Aug 9, 2009, 10:17:17 AM8/9/09
to na...@googlegroups.com
On 09 Aug 2009, at 16:11, JLF wrote:

> 1. Is there a way of storing site wide metadata in a central place
> and accessing the values from items, helper and layouts ?

I find the site configuration (config.yaml) to be a good location for
storing such stuff. You can access it using @config, which can be
addressed like a hash, e.g. <%= @config[:foo] %>.

> 2. I would like to use the 'coderay filter' on code excerpts in some
> items. However I do not want to filter the whole items with code
> ray. Is there a built-in way to apply a filter to just a part of a
> page ?

There is a "filtering" helper (Nanoc3::Helpers::Filtering), which,
once activated, will give you a #filter method that calls a filter and
outputs the filtered content. It works like this:

<% filter :coderay, :lang => 'ruby' do %>
@foo = bar.baz() - quux
<% end %>

I'll look into the 'rake clean' issue ASAP.

Denis Defreyne

unread,
Aug 9, 2009, 10:33:22 AM8/9/09
to na...@googlegroups.com
On 09 Aug 2009, at 16:11, JLF wrote:

> I just opened a ticket for the 'rake clean' issue in traq. I
> uploaded a minimal website subject to this problem.

Thanks! I've fixed the issue (the Nanoc3::Site object wasn't created
the proper way).

JLF

unread,
Aug 9, 2009, 11:55:56 AM8/9/09
to nanoc
Thanks for the bug. Another small issue concerning 'link_to':

The doc (http://nanoc.stoneship.org/v3.0/doc/3.0.0/Nanoc3/Helpers/
LinkTo.html) has this example:

item_rep = @items.find { |i| i.item_id == 'special' }.reps(:default)
link_to('Special Item', item_rep)

However #reps does not seem to take any arguments. How do I select the
"default" rep for an item. I tried 'reps[0]' which works because (if I
understand correctly) I have only one rep, but what will happen if I
have two ?

Denis Defreyne

unread,
Aug 9, 2009, 12:05:14 PM8/9/09
to na...@googlegroups.com

Yeah, #reps simply returns an array now. To get the default rep, you'd
do

reps.find { |r| r.name == :default }

If you only have one rep, reps[0] works and this is something I use a
lot too. In any case, I've updated the documentation. Thanks for
letting me know!

Alexander Mankuta

unread,
Aug 9, 2009, 12:33:59 PM8/9/09
to na...@googlegroups.com
I have this in my lib dir.
module Nanoc3
module Helpers
module ItemExtensions
def rep(name)
reps.find{|r| r.name == name}
end

def default_rep
rep(:default) || reps.first
end
end
end

class Nanoc3::Item
include Helpers::ItemExtensions
end
end

JLF

unread,
Aug 9, 2009, 3:41:12 PM8/9/09
to nanoc
I am experiencing a strange bug when trying to use the 'blogging'
extension. I use the 'preprocess' rule to generate the feed item:

Sun Aug 09 21:32:17 +0200 2009


preprocess do

items << Nanoc3::Item.new( "<%= atom_feed %>",
{:title=>"Articles
récents", :author_name=>"Paradigmatic", :author_uri => config
[:base_url]},
"/atom_feed/" )


end

I have to dummy articles whith this attribute: created_at: "Sun Aug
09 21:32:17 +0200 2009"

and I got the following error at compilation:

=== MESSAGE:

ArgumentError: argument out of range

=== COMPILATION STACK:

- [item] /atom_feed/ (rep default)

=== BACKTRACE:

0. /usr/lib/ruby/1.8/time.rb:184:in `local'
1. /usr/lib/ruby/1.8/time.rb:184:in `make_time'
2. /usr/lib/ruby/1.8/time.rb:243:in `parse'
3. /usr/lib/ruby/gems/1.8/gems/nanoc3-3.0b1/lib/nanoc3/helpers/
blogging.rb:145:in `atom_feed'
4. /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`sort_by'
5. /usr/lib/ruby/gems/1.8/gems/nanoc3-3.0b1/lib/nanoc3/helpers/
blogging.rb:145:in `each'
6. /usr/lib/ruby/gems/1.8/gems/nanoc3-3.0b1/lib/nanoc3/helpers/
blogging.rb:145:in `sort_by'
7. /usr/lib/ruby/gems/1.8/gems/nanoc3-3.0b1/lib/nanoc3/helpers/
blogging.rb:145:in `atom_feed'
[...]


Am I doing something wrong ?

cheers,

jl

Alexander Mankuta

unread,
Aug 9, 2009, 3:48:27 PM8/9/09
to na...@googlegroups.com
Try stating time in yaml format.

Like this: 2009-08-09 21:32:17 +02:00

JLF

unread,
Aug 9, 2009, 4:30:51 PM8/9/09
to nanoc
Thanks, it works !

JLF

unread,
Aug 10, 2009, 11:33:57 AM8/10/09
to nanoc
I am experiencing a weird behavior when playing with '@config[:foo]'
while in 'nanoc3 auto' mode. The changes I do in the 'config.yaml'
file are not reflected in the generated output.

I did the following experiment:

Starting with the default layout:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<title><%= @item[:title] %></title>
<link rel="stylesheet" type="text/css" href="/style.css"
media="screen">
</head>
<body>
<p><pre><%= @config[:foo] %></pre></p>
</body>
</html>

I added in 'config.yaml' the following line:

foo: bar

After 'nanoc3 co' and 'nanoc3 auto' everything worked as expected
('bar' appears on the rendered page).

I changed then config file to:

foo: baz

And despite manual compilation step, or clean/compilation, 'bar' was
still rendered in place of 'baz' in the output.

More troubling I changed the layout body line to:

<p><pre><%= puts @config.inspect; @config.inspect %></pre></p>

to output to the console the full @config object and to rendered it
verbatim. Here is the page output:

{:foo=>"bar", :output_dir=>"output", ... }

Here is the console output after 'nanoc3 co':

{:foo=>"baz", :output_dir=>"output", ...}

And finally here is the console output of the 'nanoc3 auto' process,
still running in background:

{:foo=>"bar", :output_dir=>"output", ...}

The problem is fixed by stoping and restarting 'nanoc3 auto', so I do
not know if it qualifies as a bug, but it is clearly an unexpected
behavior.

What do you think ?

PS: the 'Rules' stuff is great. Congratulations ! I will post a small
example later.

Denis Defreyne

unread,
Aug 10, 2009, 2:55:17 PM8/10/09
to na...@googlegroups.com
On 10 Aug 2009, at 17:33, JLF wrote:

> I am experiencing a weird behavior when playing with '@config[:foo]'
> while in 'nanoc3 auto' mode. The changes I do in the 'config.yaml'
> file are not reflected in the generated output.

Ahh, good catch!

This is actually a fundamental flaw in the Nanoc3::Extra::AutoCompiler
API: the initializer expects a Nanoc3::Site object, but a site cannot
reload its configuration file (because a Site does not necessarily
need an actual physical configuration file; it can use a hash as well).

Fortunately, it's only a tiny flaw that's easily corrected. I've
changed the AutoCompiler API a little: the initializer now expects the
path to a site directory. So, instead of doing
`Nanoc3::Extra::AutoCompiler.new(site)`, you'd do
`Nanoc3::Extra::AutoCompiler.new('.')`.

This is fixed in the repository, so you can either "hg pull -u" in
your existing repo, "hg clone" a new repo, or simply download a
compressed bz2/gz/zip archive at <http://projects.stoneship.org/hg/
nanoc>. To install, cd into the dir and "rake gem:install"--you need
the latest version of rubygems and rdoc, and possibly rake and yard
too. But I'm sure I've mentioned that somewhere else in another thread
already…

JLF

unread,
Aug 11, 2009, 4:31:46 AM8/11/09
to nanoc
I have trouble with #mtime on items created during preprocessing
directive (in 'Rules'). The modification date does not seem to be
defined. I can not set it myself because it is a read-only accessor.

I could add a "generated_at" attribute with 'Time.now' value, but I
think it would be a nice idea to set the mtime by default to
'Time.now' also.

Cheers,

jl

Denis Defreyne

unread,
Aug 11, 2009, 10:12:27 AM8/11/09
to na...@googlegroups.com

Hi,

mtime being nil means "the mtime isn't known" and setting it to
Time.now therefore doesn't seem like the right thing to do. It's true
that you can't change an Item/Layout's mtime once it is created, but
you can pass the mtime to the initializer. For example,
Item#initialize looks like this:

def initialize(raw_content, attributes, identifier, mtime=nil)
# ...
end

Does passing the mtime to the constructor solve your issue? I could
make a mtime setter, but I don't think it makes sense to allow
changing the mtime once the Item/Layout has been created already…

JLF

unread,
Aug 11, 2009, 1:06:14 PM8/11/09
to nanoc
That makes sense ! I will then use the constructor.

Thank you,

jl
Reply all
Reply to author
Forward
0 new messages