Skip to content

Instantly share code, notes, and snippets.

@Oshuma
Created December 1, 2008 18:42
Show Gist options
  • Select an option

  • Save Oshuma/30800 to your computer and use it in GitHub Desktop.

Select an option

Save Oshuma/30800 to your computer and use it in GitHub Desktop.
View helper I use in my Merb blog's atom feed to create a TagURI.
# Create a Tag URI for the given +article+
# (See http://www.taguri.org/)
# Should return something along the lines of:
# tag:example.org,2008-12-01:/articles/1
def tag_uri(article)
tag = absolute_url(:article, :id => article)
tag.gsub!(/^http:\/\//, 'tag:')
tag.gsub!('#', '/')
pub_date = article.created_at.strftime("%Y-%m-%d")
tag.gsub!(/#{request.host}/, "#{request.host},#{pub_date}:")
tag
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment