Installing Feedzirra RSS Parser on Ubuntu 8
I recently watched a RailsCasts episode (http://railscasts.com/episodes/168-feed-parsing) on parsing and persisting RSS feeds using Feedzirra. It took a little setting up on Ubuntu because it relies on some libraries that aren’t included with Ubuntu > 8.
The gem will fail right off the bat
gem sources -a http://gems.github.com # if you haven't already gem install pauldix-feedzirra
Here is what I needed before I could install the gem
apt-get install libcurl3 apt-get install libxml2 libxml2-dev apt-get install libxslt1-dev
Then go ahead and
gem install pauldix-feedzirra
Here are some other useful resources
http://github.com/pauldix/feedzirra/tree/master
http://ruby.zigzo.com/2009/02/15/feedzirra-installation-errors/
Ruby on Rails: email hyperlinking obfuscation parsing recipes regex regular expressions security
by bseanvt
1 comment
Email Obfuscation and Extraction from Text with Rails
There is a helper method for handling the obfuscation of email addresses in Rails.
mail_to "me@domain.com", "My email", :encode => "hex" # => <a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d">My email</a>
If you want to then extract an email address(or all email addresses) from a block of text here is the code. I created a helper function called “emailitize” and put it in the ApplicationHelper module inside helpers/application_helper.rb
module ApplicationHelper
#takes a string and will return the same string but with email addresses encoded and hyperlinked
def emailitize(text)
text.gsub(/([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})/i) {|m|
mail_to(m, m.gsub("@", "<small>[at]</small>"), :encode=>:hex)
}
end
end
It’s important to remember that you’ll need to pass a block to the gsub method. You can’t do something like this instead
text.gsub( /([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})/i, mail_to('\\1@\\2', '\\1@\\2', :encode=>:hex) )
It will work except the encode will fail. It will evaluate the ‘\\1@\\2′ strings rather than as dynamic variables.
You can then use this function in your views
<%= emailitize @job.how_to_apply %>
More information is available in the Rails and Ruby docs:
http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#M001887
http://ruby-doc.org/core/classes/String.html#M000817


