atom_feed not working in nanoc3

10 views
Skip to first unread message

Pradeep

unread,
Nov 13, 2009, 6:13:41 AM11/13/09
to nanoc
It throws an error
TypeError at /feed.xml can't convert nil into String

Stack trace at

z:/Ruby/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/helpers/
blogging.rb: in +
@site.config[:base_url] + (item[:custom_path_in_feed] || item.reps
[0].path)

I filed a ticket here
http://projects.stoneship.org/trac/nanoc/ticket/74

h3raLd

unread,
Nov 13, 2009, 11:17:59 AM11/13/09
to nanoc
I think I remembered stumbling against a similar problem when I
migrated my site. But, because I needed RSS feeds as well and slightly
different Atom feeds, I completely rewrote the helpers myself. If
you're interested, you can find them here (they seem to work fine on
h3rald.com):

http://github.com/h3rald/h3rald/blob/master/lib/helpers.rb

Denis Defreyne

unread,
Nov 13, 2009, 1:36:43 PM11/13/09
to na...@googlegroups.com
Op 13 Nov 2009, om 12:13 heeft Pradeep het volgende geschreven:

> It throws an error
> TypeError at /feed.xml can't convert nil into String
>
> Stack trace at
>
> z:/Ruby/lib/ruby/gems/1.8/gems/nanoc3-3.0.1/lib/nanoc3/helpers/
> blogging.rb: in +
> @site.config[:base_url] + (item[:custom_path_in_feed] || item.reps
> [0].path)

Hi,

This happens because #url_for(item) is being called with an item that
does not have an output file (route returns nil). This is a bug in
#url_for: instead of breaking, it should simply return nil as well.
#atom_feed is buggy too: items that aren't outputted shouldn't be
included in the feed.

I'll fix this issue ASAP. For the time being, you can override
#url_for and make it return nil for items that are not outputted.

Regards,

Denis

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

Denis Defreyne

unread,
Nov 14, 2009, 7:48:49 AM11/14/09
to na...@googlegroups.com
On 13 Nov 2009, at 12:13, Pradeep wrote:

> It throws an error
> TypeError at /feed.xml can't convert nil into String

Hi,

I've fixed this bug in revision 1453. You can see the diff at <http://projects.stoneship.org/hg/nanoc/rev/0482155ed3d7
>. If you want, you can take the most recent lib/nanoc3/helpers/
blogging.rb file from the repository and put it in your site's lib/
directory; the code in there will override the existing code.

Denis Defreyne

unread,
Nov 14, 2009, 7:54:41 AM11/14/09
to na...@googlegroups.com
On 13 Nov 2009, at 17:17, h3raLd wrote:

> I think I remembered stumbling against a similar problem when I
> migrated my site. But, because I needed RSS feeds as well and slightly
> different Atom feeds, I completely rewrote the helpers myself. If
> you're interested, you can find them here (they seem to work fine on
> h3rald.com):
>
> http://github.com/h3rald/h3rald/blob/master/lib/helpers.rb

Hi,

Your rewritten helpers are interesting. I might take a few ideas from
them, if you don't mind.

I'd recommend against overriding the existing helpers, though. I
believe that it is better to create a separate module for each helper.
For example, H3rald::Nanoc3::Helpers instead of Nanoc3::Helpers.

Pradeep

unread,
Nov 16, 2009, 2:00:12 AM11/16/09
to nanoc
@h3rald.
Thanks for the pointer to your custom helper.
Your helper raised "Cannot build feed: no articles" for my site. And I
think its got to do something incorrect with my Rules file.

My rules had an index building approach taken from
http://starrhorne.com/posts/howto_build_a_blog_with_nanoc/.

It made the routes for posts as nill for a new rep for summary
purposes alone. So it appears once you write a route for a particular
rep the default representation is not available. (which might be
expected)

This ended up triggering an issue with url_for while building feeds
that Denis identified.

After applying Denis's patch to blogging.rb it shows an empty feed (no
more error).

Then correcting the Rules by adding a route for the default
representation started populating the feed.

So all's fine now.

Thanks Denis for the quick diagnosis and fix.

Regards,
Pradeep


On Nov 14, 5:54 pm, Denis Defreyne <denis.defre...@stoneship.org>
wrote:
> denis.defre...@stoneship.org
Reply all
Reply to author
Forward
0 new messages