If there’s any wider interest for such a feature, I could package it
as a Behavior.
Is there any way (or plan) to inject default ActionView helper method
(such as link_to, …) to Radiant behaviors? I doubt a simple mix-in
would do the trick but I admit I haven’t looked at it yet. Wouldn’t
that be terrific if behaviors had access to all Rails bells and
whistles? Especially when some custom Radius tags generate more
complex output…
If there’s any wider interest for such a feature, I could package it
as a Behavior.
Definitely. I just did something similar, already set up as a behavior,
but it’s hardcoded to my site at the moment, while I tried to figure out
how to get at the full URL…
–
class SiteMapBehavior < Behavior::Base
register "Sitemap"
description %{
Creates a Google sitemap.
}
define_tags do
tag "sitemap" do |tag|
root = Page.find_by_parent_id(nil)
sitemap_header
sitemap_for(root)
sitemap_footer
end
end
private
def sitemap_for(page)
sitemap_url(page.url, page.published_at)
page.children.each do |child|
if child.published? and not child.virtual?
sitemap_for(child)
end
end
end
def sitemap_header
@sitemap = '<?xml version="1.0" encoding="UTF-8"?>' + "\n" +
'<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' +
“\n”
@sitemap << DummyController.new(self).url_for("/testing")
end
def sitemap_footer
@sitemap << "</urlset>"
end
def sitemap_url(url, published_at)
@sitemap << "<url>\n"
full_url = "http://www.wellesleycarriagehouse.com#{url}"
@sitemap << " <loc>#{full_url}</loc>\n"
if published_at
pub_date = published_at.strftime("%Y-%m-%d")
@sitemap << " <lastmod>#{pub_date}</lastmod>\n"
end
@sitemap << "</url>\n"
end
Definitely. I just did something similar, already set up as a behavior,
but it’s hardcoded to my site at the moment, while I tried to figure out
how to get at the full URL…
That’s cool.
ActionView helpers provides all the tool you need to build your URL in
the cleanest fashion, that’s exactly why I asked about the
availability of helpers to Behaviors in the same message.
And that’s also why I did not implemented it as a Behavior in the first
place…
If there’s any wider interest for such a feature, I could package it
as a Behavior.
I was looking for adding support for google sitemap to a site and I
found
this thread. Once I’ll have implemented it, I’d like to add a recipe
(How
to) for a google sitemap behavior/code to the wiki. Is the code found in
this thread OK? Did someone develop anything better or updated it
recently?
Thank you.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.