<% content_for :head do %> <%= javascript_include_tag "graphing" %> <%= javascript_include_tag "tweets" %> <%= javascript_include_tag "//platform.twitter.com/widgets.js", charset: "utf-8", async: "async" %> <% end %> <% grouped_events = @agent.events.order("id desc").limit(2000).group_by {|e| e.payload[:filter] || e.payload[:match] }%> <% if grouped_events.length > 0 %> <% if @agent.options[:generate] == "events" %>

Recent Tweets

<% grouped_events.each do |filter, group| %>
<%= filter %>
<% group.each do |event| %> <% tweet = event.payload %> <% text = tweet.dig(:extended_tweet, :full_text) %> <% next unless text.present? %> <% screen_name = tweet.dig(:user, :screen_name) %>
<%= link_to "@#{screen_name}", "https://twitter.com/#{URI.encode(screen_name)}" %>: <%= text %> - <%= link_to l(Time.zone.parse(tweet[:created_at]), format: :long), "https://twitter.com/#{URI.encode(screen_name)}/status/#{URI.encode(tweet[:id_str])}" %> (<%= link_to 'event', event_path(id: event.id) %>)
<% end %>
<% end %> <% else %>

Recent Tweet Trends

<% grouped_events.each.with_index do |(filter, group), index| %>
<%= link_to filter, "https://twitter.com/search?q=#{CGI::escape filter}", :target => "blank" %>
<% end %> <% end %> <% else %>

No recent tweets found.

<% end %>