Skip to content

Commit

Permalink
Merge pull request #14 from raffij/bugfixes/twitter-url-entities
Browse files Browse the repository at this point in the history
Added twitter url_entities to twitter block and fixed pluck when type is not found.
  • Loading branch information
cjbell committed Sep 27, 2013
2 parents 6404333 + 262aaf6 commit 5cd88ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/sir-trevor/blocks/_tweet_block.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="content-block tweet-block">
<%= link_to image_tag("//twitter.com/api/users/profile_image/#{ block[:user][:screen_name] }?size=bigger", :class => 'img'), "http://twitter.com/#{ block[:user][:screen_name] }" %>
<p><%= sanitize Twitter::Autolink.auto_link(block[:text]), tags: %w{a}, attributes: %w{href rel target} %></p>
<p><%= sanitize Twitter::Autolink.auto_link(block[:text], url_entities: (block[:entities].values_at(:urls, :media).flatten.compact.uniq rescue nil)), tags: %w{a}, attributes: %w{href rel target} %></p>
<cite>From <%= link_to "@#{ block[:user][:screen_name] }", "http://twitter.com/#{ block[:user][:screen_name] }" %> on Twitter:</cite>
<time datetime="<%= block[:created_at] %>">(<%= link_to Time.parse(block[:created_at]), "http://twitter.com/#{block[:user][:screen_name]}/status/#{block[:id_str]}" %>)</time>
</div>
2 changes: 1 addition & 1 deletion lib/sir-trevor/helpers/view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def pluck_sir_trevor_type(json, type)
hash = SirTrevor.parse_json(json)
if hash.has_key?(:data)
item = hash[:data].select { |item| item[:type] == type }
item.first[:text]
item.first[:text] if item.any?
end
end
end
Expand Down

0 comments on commit 5cd88ad

Please sign in to comment.