quick and dirty follows/followings pages

This commit is contained in:
Kyle Drake 2015-03-23 16:45:34 -07:00
parent ca5d21d56b
commit 326650b4e3
4 changed files with 168 additions and 3 deletions

View file

@ -36,6 +36,20 @@ post '/site/:username/set_editor_theme' do
'ok'
end
get '/site/:username/follows' do |username|
@site = Site[username: username]
not_found if @site.nil?
@sites = @site.followings.collect {|f| f.site}
erb :'site/follows'
end
get '/site/:username/followers' do |username|
@site = Site[username: username]
not_found if @site.nil?
@sites = @site.follows.collect {|f| f.actioning_site}
erb :'site/followers'
end
post '/site/:username/comment' do |username|
require_login
@ -134,4 +148,4 @@ post '/site/:username/block' do |username|
else
redirect request.referer
end
end
end

View file

@ -1,7 +1,7 @@
<% site_followings = site.followings %>
<% if (!is_current_site && !site_followings.empty?) || is_current_site %>
<div class="following-list">
<h3><%= is_current_site ? 'You follow' : 'This site follows' %></h3>
<h3><a href="/site/<%= site.username %>/follows"><%= is_current_site ? 'You follow' : 'This site follows' %></h3>
<% if site_followings.empty? %>
<p>You are not following any sites yet. Add some by <a href="/browse">browsing sites</a> or looking at your tags.
<% else %>
@ -15,7 +15,7 @@
<% site_follows = site.follows %>
<% if (!is_current_site && !site_follows.empty?) || is_current_site %>
<div class="follower-list">
<h3>Followers</h3>
<h3><a href="/site/<%= site.username %>/followers">Followers</a></h3>
<% if site_follows.empty? %>
No followers yet.
<% else %>

75
views/site/followers.erb Normal file
View file

@ -0,0 +1,75 @@
<div class="header-Outro with-columns browse-page">
<div class="row content">
<div class="col col-100">
<h1>Sites following <a href="/site/<%= @site.username %>"><%= @site.title %></a></h1>
</div>
</div>
</div>
<div class="browse-page">
<% if @sites.length == 0 %>
<div class="row website-Gallery content int-Gall" style="padding-left: 30px;">
<h3>No followers yet.</h3>
<p>Try another search, or <a href="/browse">browse all sites</a>!</p>
</div>
<% else %>
<ul class="row website-Gallery content int-Gall">
<% @sites.each_with_index do |site| %>
<li>
<a href="<%= site.uri %>" class="neo-Screen-Shot" title="<%= site.title %>">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '540x405') %>) no-repeat;">
<img src="/img/placeholder.png" alt="<%= site.title %>" />
</span>
</a>
<div class="title">
<a href="<%= site.uri %>" title="<%= site.title %>"><%= site.title.shorten(30) %></a>
</div>
<div class="site-info">
<div class="username">
<a href="/site/<%= site.username %>" title="Profile">
<i class="fa fa-user"><% if site.supporter? %><i class="fa fa-heart"></i><% end %></i><%= site.username %>
</a>
</div>
<div class="site-stats">
<a href="/site/<%= site.username %>">
<span class="show-on-mobile">
<i class="fa fa-eye"></i>
</span>
<% if params[:sort_by] == 'hits' %>
<%= site.hits.format_large_number %><span class="hide-on-mobile">&nbsp;hit<%= site.hits == 1 ? '' : 's' %></span>
<% else %>
<%= site.views.format_large_number %><span class="hide-on-mobile">&nbsp;view<%= site.views == 1 ? '' : 's' %></span>
<% end %>
</a>
</div>
<div class="site-tags">
<% if site.tags.count > 0 %>
<i class="fa fa-tag"></i>
<% site.tags.each_with_index do |tag, index| %>
<a class="" href="/browse?tag=<%= Rack::Utils.escape tag.name %>"><%= tag.name %></a><% if index != site.tags.length - 1 %>,<% end %>
<% end %>
<% end %>
</div>
<% if signed_in? && current_site.is_admin %>
<div class="admin">
<form action="/admin/banhammer" target="_blank" method="POST" onsubmit="return confirm('Confirm ban of <%= site.username %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="username" value="<%= site.username %>">
<button>Ban</button>
</form>
<form action="/admin/mark_nsfw" target="_blank" method="POST" onsubmit="return confirm('Confirm NSFW marking of <%= site.username %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="username" value="<%= site.username %>">
<button>Mark NSFW</button>
</form>
</div>
<% end %>
</div>
</li>
<% end %>
</ul>
<% end %>
</div>

76
views/site/follows.erb Normal file
View file

@ -0,0 +1,76 @@
<div class="header-Outro with-columns browse-page">
<div class="row content">
<div class="col col-100">
<h1>Sites <a href="/site/<%= @site.username %>"><%= @site.title %></a> follows</h1>
</div>
</div>
</div>
<div class="browse-page">
<% if @sites.length == 0 %>
<div class="row website-Gallery content int-Gall" style="padding-left: 30px;">
<h3>No follows yet.</h3>
<% if current_site == @site %>
<p>You should start <a href="/browse">following some sites</a>!</p>
<% end %>
</div>
<% else %>
<ul class="row website-Gallery content int-Gall">
<% @sites.each_with_index do |site| %>
<li>
<a href="<%= site.uri %>" class="neo-Screen-Shot" title="<%= site.title %>">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '540x405') %>) no-repeat;">
<img src="/img/placeholder.png" alt="<%= site.title %>" />
</span>
</a>
<div class="title">
<a href="<%= site.uri %>" title="<%= site.title %>"><%= site.title.shorten(30) %></a>
</div>
<div class="site-info">
<div class="username">
<a href="/site/<%= site.username %>" title="Profile">
<i class="fa fa-user"><% if site.supporter? %><i class="fa fa-heart"></i><% end %></i><%= site.username %>
</a>
</div>
<div class="site-stats">
<a href="/site/<%= site.username %>">
<span class="show-on-mobile">
<i class="fa fa-eye"></i>
</span>
<% if params[:sort_by] == 'hits' %>
<%= site.hits.format_large_number %><span class="hide-on-mobile">&nbsp;hit<%= site.hits == 1 ? '' : 's' %></span>
<% else %>
<%= site.views.format_large_number %><span class="hide-on-mobile">&nbsp;view<%= site.views == 1 ? '' : 's' %></span>
<% end %>
</a>
</div>
<div class="site-tags">
<% if site.tags.count > 0 %>
<i class="fa fa-tag"></i>
<% site.tags.each_with_index do |tag, index| %>
<a class="" href="/browse?tag=<%= Rack::Utils.escape tag.name %>"><%= tag.name %></a><% if index != site.tags.length - 1 %>,<% end %>
<% end %>
<% end %>
</div>
<% if signed_in? && current_site.is_admin %>
<div class="admin">
<form action="/admin/banhammer" target="_blank" method="POST" onsubmit="return confirm('Confirm ban of <%= site.username %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="username" value="<%= site.username %>">
<button>Ban</button>
</form>
<form action="/admin/mark_nsfw" target="_blank" method="POST" onsubmit="return confirm('Confirm NSFW marking of <%= site.username %>');">
<%== csrf_token_input_html %>
<input type="hidden" name="username" value="<%= site.username %>">
<button>Mark NSFW</button>
</form>
</div>
<% end %>
</div>
</li>
<% end %>
</ul>
<% end %>
</div>