fix news feed and site profile event activity

This commit is contained in:
Kyle Drake 2014-10-23 15:39:10 -07:00
parent 15c60cb6a8
commit d83fbf81d3
3 changed files with 10 additions and 7 deletions

View file

@ -858,12 +858,17 @@ class Site < Sequel::Model
end
def latest_events(current_page=1, limit=10)
events_dataset.order(:created_at.desc).paginate(current_page, limit)
site_id = self.id
Event.where{Sequel.|({site_id: site_id}, {actioning_site_id: site_id})}.
order(:created_at.desc).
paginate(current_page, limit)
end
def news_feed(current_page=1, limit=10)
following_ids = self.followings_dataset.select(:site_id).all.collect {|f| f.site_id}
Event.filter(site_id: following_ids+[self.id]).
search_ids = following_ids+[self.id]
Event.where{Sequel.|({site_id: search_ids}, {actioning_site_id: search_ids})}.
order(:created_at.desc).
paginate(current_page, limit)
end

View file

@ -30,7 +30,7 @@
started following
<% if current_site && event_site.id == current_site.id %>
your site!
your site.
<% else %>
<a href="/site/<%= event_site.username %>" class="user" title="<%= event_site.title %>"><i class="fa fa-user"><% if event_site.supporter? && !event_site.ended_supporter? %><i class="fa fa-heart"></i><% end %></i><%= event_site.username %></a>
<% end %>
@ -60,7 +60,7 @@
<% site_change_filenames.each do |f| %>
<div class="file">
<div class="html-thumbnail <%= site_change_file_display_class f %>">
<a href="//<%= event_site.host %>/<%= f %>">
<a href="//<%= event_site.host %><%= f == 'index.html' ? '' : "/#{f}" %>">
<% if site_change_file_display_class(f) == 'html' %>
<img src="<%= event_site.screenshot_url(f, '210x158') %>">
<% elsif site_change_file_display_class(f) == 'image' %>

View file

@ -4,19 +4,17 @@
<div class="title">
<div class="icon" style="background-image:url(<%= actioning_site.screenshot_url('index.html', '100x100') %>);"></div>
<% if current_site && current_site.id == actioning_site.id && request.path == '/' %>
<% if current_site && current_site.id == actioning_site.id %>
You
<% else %>
<i class="fa fa-user"><% if actioning_site.supporter? && !actioning_site.ended_supporter? %><i class="fa fa-heart"></i><% end %></i><a href="/site/<%= actioning_site.username %>" class="user"><%= actioning_site.username %></a>
<% end %>
<% if request.path == '/' %>
<% if current_site && current_site.id == profile_comment.site_id %>
left a comment on <a href="/site/<%= current_site.username %>">your profile</a>:
<% else %>
left a comment on <i class="fa fa-user"><% if profile_comment.site.supporter? && !profile_comment.site.ended_supporter? %><i class="fa fa-heart"></i><% end %></i><a href="/site/<%= profile_comment.site.username %>" class="user"><%= profile_comment.site.username %></a><%= site.username[site.username.length-1] == 's' ? "" : "'s" %> profile:
<% end %>
<% end %>
<span class="date">
<a href="?event_id=<%= profile_comment.event.id %>"><%= profile_comment.created_at.ago %></a>
</span>