tag support for browse, show site name on bottom

This commit is contained in:
Kyle Drake 2014-06-04 23:58:16 -07:00
parent 4155211051
commit 13988ad74a
4 changed files with 40 additions and 24 deletions

5
app.rb
View file

@ -253,6 +253,11 @@ get '/browse' do
site_dataset.filter! is_nsfw: (params[:is_nsfw] == 'true' ? true : false) site_dataset.filter! is_nsfw: (params[:is_nsfw] == 'true' ? true : false)
if params[:tag]
site_dataset = site_dataset.association_join(:tags)
site_dataset.where! ['tags.name = ?', params[:tag]]
end
@page_count = site_dataset.page_count || 1 @page_count = site_dataset.page_count || 1
@sites = site_dataset.all @sites = site_dataset.all
erb :browse erb :browse

View file

@ -213,7 +213,6 @@ class Site < Sequel::Model
end end
def store_file(filename, uploaded) def store_file(filename, uploaded)
# If the uploaded file matches an existing file, no actual change has happened.
if File.exist?(file_path(filename)) && if File.exist?(file_path(filename)) &&
Digest::SHA2.file(file_path(filename)).digest == Digest::SHA2.file(uploaded.path).digest Digest::SHA2.file(file_path(filename)).digest == Digest::SHA2.file(uploaded.path).digest
return false return false

View file

@ -6,14 +6,18 @@
<div class="header-Outro"> <div class="header-Outro">
<div class="row content"> <div class="row content">
<h1>Websites on Neocities</h1> <% if params[:tag] %>
<h1>Sites tagged <%= params[:tag] %>
<% else %>
<h1>Sites on Neocities</h1>
<% end %>
<h3 class="subtitle"></h3> <h3 class="subtitle"></h3>
</div> </div>
</div> </div>
<div class="row content"> <div class="row content">
<div class="col col-50"> <div class="col col-50">
<form id="search_criteria" action="/browse" method="GET"> <form id="search_criteria" action="/browse" method="GET">
<fieldset class="grouping"> <fieldset class="grouping">
<label class="text-Label" for="sort_by">Sort By:</label> <label class="text-Label" for="sort_by">Sort By:</label>
<div class="select-Container"> <div class="select-Container">
@ -36,27 +40,35 @@
</fieldset> </fieldset>
</form> </form>
</div> </div>
<div class="col col-50"> <div class="col col-50">
<p>If you like a site, don't forget to follow it!<br>Visitor counts are updated hourly.</p>
<p>If you like a site, don't forget to bookmark it!<br>Visitor counts are updated hourly.</p> <% unless signed_in? %>
<a class="btn-Action" href="/new" title="create a Neocities.org site today!">Create your Neocities site now</a> <a class="btn-Action" href="/new" title="create a Neocities.org site today!">Create your Neocities site now</a>
<% end %>
</div> </div>
</div> <!-- end .row.content --> </div> <!-- end .row.content -->
<br /> <br />
<ul class="row website-Gallery content int-Gall"> <% if @sites.length == 0 %>
<% @sites.each do |site| %> <div class="row content single-Col">
<li> <h2>No active sites found.<br>Try another search!</h2>
<a href="http://<%= site.username %>.neocities.org" class="neo-Screen-Shot" target="_blank" title="Website of <%= site.username %>"> </div>
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '270x162') %>) no-repeat;"> <% else %>
<img src="/img/placeholder.png" alt="<%= site.username %>" /> <ul class="row website-Gallery content int-Gall">
</span> <% @sites.each do |site| %>
</a> <li>
</li> <a href="http://<%= site.username %>.neocities.org" class="neo-Screen-Shot" target="_blank" title="Website of <%= site.username %>">
<% end %> <span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '270x162') %>) no-repeat;">
</ul> <img src="/img/placeholder.png" alt="<%= site.username %>" />
</span>
</a>
<span style="float: left"><a href="/site/<%= site.username %>"><%= site.title %></a></span><span style="float: right"><a href="/site/<%= site.username %>"><%= site.hits %> hit<%= site.hits == 1 ? '' : 's' %></a></span>
</li>
<% end %>
</ul>
<% end %>
<% if params[:sort_by] != 'random' %> <% if params[:sort_by] != 'random' %>
<% if @page_count > 1 %> <% if @page_count > 1 %>
<div class="txt-Center content eps"> <div class="txt-Center content eps">
@ -67,7 +79,7 @@
<% 1.upto(@page_count) do |num| %> <% 1.upto(@page_count) do |num| %>
<a href="#" onclick="getPage(<%= num %>); return false" style="<%= num == @current_page ? 'text-decoration: none' : '' %>"><%= num %></a>&nbsp; <a href="#" onclick="getPage(<%= num %>); return false" style="<%= num == @current_page ? 'text-decoration: none' : '' %>"><%= num %></a>&nbsp;
<% end %> <% end %>
<% if @current_page != @page_count %> <% if @current_page != @page_count %>
<a href="#" onclick="getPage(<%= @current_page + 1 %>); return false"><i class="icon-arrow-right" style="text-decoration: none"></i></a> <a href="#" onclick="getPage(<%= @current_page + 1 %>); return false"><i class="icon-arrow-right" style="text-decoration: none"></i></a>
<% end %> <% end %>

View file

@ -3,13 +3,13 @@
<div class="col col-50 signup-Area large"> <div class="col col-50 signup-Area large">
<div class="signup-Form"> <div class="signup-Form">
<fieldset class="content"> <fieldset class="content">
<img class="screenshot" src="<%= site.screenshot_url('index.html', '348x205') %>" style="width: 358px;height: 215px;"> <a href="http://<%= site.username %>.neocities.org"><img class="screenshot" src="<%= site.screenshot_url('index.html', '348x205') %>" style="width: 358px;height: 215px;"></a>
</fieldset> </fieldset>
</div> </div>
</div> </div>
<div class="col col-50"> <div class="col col-50">
<h2 class="eps title-with-badge"><span><%= site.title %></span> <% if site.supporter? && !site.ended_supporter? %><a href="/plan" class="supporter-badge" title="Neocities Supporter"></a> <% end %></h2> <h2 class="eps title-with-badge"><span><%= site.title %></span> <% if site.supporter? && !site.ended_supporter? %><a href="/plan" class="supporter-badge" title="Neocities Supporter"></a> <% end %></h2>
<p class="site-url"><a href="http://<%= site.username %>.neocities.org" target="_blank">http://<%= site.username %>.neocities.org</a></p> <p class="site-url"><a href="http://<%= site.username %>.neocities.org">http://<%= site.username %>.neocities.org</a></p>
<div class="stats"> <div class="stats">
<div class="stat"><strong><%= site.hits_english %></strong> <span>hits</span></div> <div class="stat"><strong><%= site.hits_english %></strong> <span>hits</span></div>
<div class="stat"><strong><%= site.follows_dataset.count %></strong> <span>followers</span></div> <div class="stat"><strong><%= site.follows_dataset.count %></strong> <span>followers</span></div>