Skip to content

Instantly share code, notes, and snippets.

@no6v
Created August 31, 2011 23:47
Show Gist options
  • Save no6v/1185063 to your computer and use it in GitHub Desktop.
Save no6v/1185063 to your computer and use it in GitHub Desktop.
# replace t.co shortened url to origin if entity is available
Earthquake.init do
output_filter do |item|
text = item["text"]
entities = item["entities"]
if text and entities
[entities["urls"], entities["media"]].compact.flatten.each do |url_entity|
url, expanded_url = url_entity.values_at("url", "expanded_url")
text.gsub!(url, expanded_url)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment