sitemap code

4 views
Skip to first unread message

Tim Pease

unread,
Apr 4, 2008, 11:56:53 AM4/4/08
to Webby
A little challenge for anyone willing to take up the gauntlet ...

Create a snippet of code that will generate a sitemap. There is
currently code to generate breadcrumb links. You can find this in the
"lib" folder of any site created with Webby 0.8.2. The breadcrumb
code takes the current page, finds the parent page, generates a link
to the parent, and then iterates this process till there are no more
parents.

Sitemap code would work in a similar fashion except going in the other
direction. Start with the root of the website and work your way down
to all the child pages generating a tree of links as you go.

The pages DB object keeps track of all the pages in the site by
directory. You can find this class in the Webby source code at "lib/
webby/resources/db.rb". This class has the "parent_of" method used by
the breadcrumb code.

That's it. Have a great weekend everyone!

Blessings,
TwP

Mel

unread,
Apr 10, 2008, 2:13:45 PM4/10/08
to Webby
Did anyone make any progress on this?

I've checked out webby, but haven't had a free moment to dig into the
code.

One thing I know that does NOT work is recursion with @pages.find

For example say I have 'mypage.txt', in the meta-data headers I'll put
a key called 'children' with the path to a directory as a value.

If I do something along the lines of

all_pages = @pages.find(:all, :in_directory => "current")

all_pages.each {|page|

if page.children

all_children = @pages.find(:all, :in_directory =>
page.children)

end

}


I can't use any methods on members of the all_children
collection....ie I loop over all_children and attempt to do something
like child.url, I get nothing :(
Reply all
Reply to author
Forward
0 new messages