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,14 +6,18 @@
<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>
<div class="row content">
<div class="col col-50">
<form id="search_criteria" action="/browse" method="GET">
<form id="search_criteria" action="/browse" method="GET">
<fieldset class="grouping">
<label class="text-Label" for="sort_by">Sort By:</label>
<div class="select-Container">
@ -36,27 +40,35 @@
</fieldset>
</form>
</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>
<a class="btn-Action" href="/new" title="create a Neocities.org site today!">Create your Neocities site now</a>
<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 />
<ul class="row website-Gallery content int-Gall">
<% @sites.each do |site| %>
<li>
<a href="http://<%= site.username %>.neocities.org" class="neo-Screen-Shot" target="_blank" title="Website of <%= site.username %>">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '270x162') %>) no-repeat;">
<img src="/img/placeholder.png" alt="<%= site.username %>" />
</span>
</a>
</li>
<% end %>
</ul>
<% 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>
<a href="http://<%= site.username %>.neocities.org" class="neo-Screen-Shot" target="_blank" title="Website of <%= site.username %>">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '270x162') %>) no-repeat;">
<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 %>
<div class="txt-Center content eps">
@ -67,7 +79,7 @@
<% 1.upto(@page_count) do |num| %>
<a href="#" onclick="getPage(<%= num %>); return false" style="<%= num == @current_page ? 'text-decoration: none' : '' %>"><%= num %></a>&nbsp;
<% end %>
<% 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>
<% end %>

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>