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)
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
@sites = site_dataset.all
erb :browse

View file

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

View file

@ -6,7 +6,11 @@
<div class="header-Outro">
<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>
</div>
</div>
@ -38,13 +42,19 @@
</div>
<div class="col col-50">
<p>If you like a site, don't forget to bookmark it!<br>Visitor counts are updated hourly.</p>
<p>If you like a site, don't forget to follow 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>
<% end %>
</div>
</div> <!-- end .row.content -->
<br />
<% if @sites.length == 0 %>
<div class="row content single-Col">
<h2>No active sites found.<br>Try another search!</h2>
</div>
<% else %>
<ul class="row website-Gallery content int-Gall">
<% @sites.each do |site| %>
<li>
@ -53,9 +63,11 @@
<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 @page_count > 1 %>

View file

@ -3,13 +3,13 @@
<div class="col col-50 signup-Area large">
<div class="signup-Form">
<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>
</div>
</div>
<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>
<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="stat"><strong><%= site.hits_english %></strong> <span>hits</span></div>
<div class="stat"><strong><%= site.follows_dataset.count %></strong> <span>followers</span></div>