_show.html.erb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <% content_for :head do %>
  2. <%= javascript_include_tag "graphing" %>
  3. <% end %>
  4. <% grouped_events = @agent.events.order("id desc").limit(2000).group_by {|e| e.payload[:filter] || e.payload[:match] }%>
  5. <% if grouped_events.length > 0 %>
  6. <% if @agent.options[:generate] == "events" %>
  7. <h3>Recent Tweets</h3>
  8. <% grouped_events.each do |filter, group| %>
  9. <div class="filter-group tweets">
  10. <div class='filter'><%= filter %></div>
  11. <% group.each do |event| %>
  12. <% next unless event.payload[:text].present? %>
  13. <div class='tweet'>
  14. <%= event.payload[:text] %> - <%= link_to event.payload[:user][:screen_name], "http://twitter.com/#{event.payload[:user][:screen_name]}" %>
  15. </div>
  16. <% end %>
  17. </div>
  18. <% end %>
  19. <% else %>
  20. <h3>Recent Tweet Trends</h3>
  21. <% grouped_events.each.with_index do |(filter, group), index| %>
  22. <div class="filter-group counts">
  23. <div class='filter'><%= link_to filter, "https://twitter.com/search?q=#{CGI::escape filter}", :target => "blank" %></div>
  24. <div class="chart-container group-<%= index.to_s %>">
  25. <div class="y-axis"></div>
  26. <div class="chart"></div>
  27. <div class="timeline"></div>
  28. </div>
  29. <script>
  30. $(function() {
  31. var $chart = $(".chart-container.group-<%= index.to_s %>").last();
  32. var data = <%= Utils.jsonify(group.select {|e| e.payload[:count].present? }.sort_by {|e| e.payload[:time] }.map {|e| { :x => e.payload[:time].to_i, :y => e.payload[:count].to_i } }) %>;
  33. var name = <%= Utils.jsonify(filter) %>;
  34. renderGraph($chart, data, [], name);
  35. });
  36. </script>
  37. </div>
  38. <% end %>
  39. <% end %>
  40. <% else %>
  41. <p>
  42. No recent tweets found.
  43. </p>
  44. <% end %>