The error that you are getting means that your #route block returns something that does not start with a slash.
In this case, I believe you are returning the string ".html" while you should be returning "/index.html", because the item content/index.haml has the identifier "/" and "/".chop + '.' + 'html' == ".html". I think you’d need a special case for the item with identifier "/", but it’s a bit icky (no other clean way around it though).
There’s one thing I don’t understand about your Rules file… if the item extension is .haml, you write an item /foo/ to /foo.html, otherwise you write an item /foo/ to /foo/index.html. Is this intentional? It seems a bit weird to use “clean URLs” (in the non-Haml case) and URLs with extensions at the same time.
Personally, I’d just use clean URLs all the time (that’s what the default nanoc Rules file does).
Cheers,
Denis
> --
> You received this message because you are subscribed to the nanoc discusssion group.
>
> To post to this group, send email to na...@googlegroups.com
> To unsubscribe from this group, send email to
> nanoc+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nanoc?hl=en
Thanks Denis, that's indeed the way we went with it. :)
https://github.com/aeolusproject/aeolus-website/blob/nanoc/nanocsite/Rules
> There’s one thing I don’t understand about your Rules file… if the item extension is .haml, you write an item /foo/ to /foo.html, otherwise you write an item /foo/ to /foo/index.html. Is this intentional? It seems a bit weird to use “clean URLs” (in the non-Haml case) and URLs with extensions at the same time.
Sorry, I've read this bit through a few times, and it's not making sense to me what you're trying to point out. :(
We have an existing code base, that we've imported from Webby.
Webby is a pretty simple system, it doesn't do any URL translation at all, except change haml files to .html extension.
(the way we've been using it anyway)
It keeps the directory structure from the content directory, and copies anything it doesn't recognise to the output directory verbatim.
That's pretty much what I'm trying to replicate.
Does that make sense?
>> There’s one thing I don’t understand about your Rules file… if the item extension is .haml, you write an item /foo/ to /foo.html, otherwise you write an item /foo/ to /foo/index.html. Is this intentional? It seems a bit weird to use “clean URLs” (in the non-Haml case) and URLs with extensions at the same time.
>
> Sorry, I've read this bit through a few times, and it's not making sense to me what you're trying to point out. :(
Never mind. I was confused by the special case for the item with identifier “/”, where where you have to append index.html.
Doing what Webby does should be quite straightfoward as Webby was inspired by nanoc. The default nanoc configuration mostly works, but if you do not want pretty URLs (e.g. /foo.html instead of /foo/index.html) then you need to adjust the routing rules (as you already did).
Denis
Yeah, it wasn't working properly deeper than the base directory though. :(
Discovered the =~ operator (I'm not a Ruby coder), and this seems to work:
if item[:filename] =~ /index.haml$/
item.identifier + 'index.html'
else
# Write out haml files with a flat dir structure
item.identifier.chop + '.' + 'html'
end
Hopefully I never have to look at the Rules file ever again. :)
> Yeah, it wasn't working properly deeper than the base directory though. :(
>
> Discovered the =~ operator (I'm not a Ruby coder), and this seems to work:
>
> if item[:filename] =~ /index.haml$/
> item.identifier + 'index.html'
> else
> # Write out haml files with a flat dir structure
> item.identifier.chop + '.' + 'html'
> end
Hi Justin,
I think that will fail for content/foo/index.haml as well (corresponding with an item /foo/), so I think the better way would be to have
if item.identifier == '/'
instead of
if item[:filename] =~ /index.haml$/
> Hopefully I never have to look at the Rules file ever again. :)
Once you have a setup that works and you’re happy with, in *theory* you don’t need to touch it again. I keep on tweaking mine though. :)
Cheers,
Denis
Strangely enough, the =~ above approach works for index.haml files in subdirectories, whereas the == '/' approach only matches the root directory and nothing deeper. It's actually what I went "from".
Figured this out using the simple puts approach in the Rules file:
puts 'Item filename: ' + item[:filename] + ' Item identifier: ' + item.identifier
That showed me what was _actually_ happening for each file being processed, so I went from there. "_
>> Hopefully I never have to look at the Rules file ever again. :)
>
> Once you have a setup that works and you’re happy with, in *theory* you don’t need to touch it again. I keep on tweaking mine though. :)
Heh yeah. Just added direct kramdown support to ours. (fixes the Markdown issues also reported)