Created
December 1, 2008 18:42
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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