add new followers from last month to site profiles

This commit is contained in:
Kyle Drake 2023-05-11 13:23:22 -05:00
parent e908bab348
commit d1f60254a6
3 changed files with 24 additions and 3 deletions

View file

@ -1448,6 +1448,10 @@ class Site < Sequel::Model
paginate(current_page, limit)
end
def newest_follows
follows_dataset.where(:follows__created_at => (1.month.ago..Time.now)).all
end
def host
!domain.empty? ? domain : "#{username}.neocities.org"
end

View file

@ -10,6 +10,23 @@
<script src="/js/news/event.js"></script>
<script src="/js/news/site.js"></script>
<% follow_events = site.newest_follows %>
<% unless follow_events.empty? %>
<div class="news-item follow">
<div class="icon"><a href="/site/<%= site.username %>" title="<%= site.username %>" class="avatar" style="background-image: url(<%= site.screenshot_url 'index.html', '50x50' %>);"></a></div>
<div class="text">
<strong>New Followers</strong>
</div>
<div class="content">
<% follow_events.first.site.newest_follows.each_with_index do |event,i| %>
<a href="/site/<%= event.actioning_site.username %>" class="user" title="<%= event.actioning_site.title %>"><i class="fa fa-user"><% if event.actioning_site.supporter? %><i class="fa fa-heart"></i><% end %></i><%= event.actioning_site.username %></a><% unless follow_events.length == i+1 %>, <% end %>
<% end %>
</div>
</div>
<% end %>
<% events.each do |event| %>
<% if event.profile_comment_id %>
<div class="news-item comment" id="event_<%= event.id %>">
@ -39,7 +56,7 @@
<% end %>
sent a <strong><%= tip.amount_string %></strong> tip to
site/actioning_site.username
<% if current_site && event_site.id == current_site.id %>
<a href="/site/<%= current_site.username %>" class="you">you</a>!
<% else %>

View file

@ -74,9 +74,9 @@
</p>
<% end %>
</div>
<%== erb :'_news', layout: false, locals: {site: @site, events: @latest_events} %>
<%== erb :'_news', layout: false, locals: {site: site, events: @latest_events} %>
<% else %>
<div class="site-profile-padding"><%== erb :'_news', layout: false, locals: {site: @site, events: @latest_events} %></div>
<div class="site-profile-padding"><%== erb :'_news', layout: false, locals: {site: site, events: @latest_events} %></div>
<% end %>
</div>