mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
Merge branch 'master' into newdesignv2
This commit is contained in:
commit
bb47125de6
2 changed files with 69 additions and 19 deletions
19
app.rb
19
app.rb
|
@ -36,9 +36,24 @@ end
|
||||||
get '/browse' do
|
get '/browse' do
|
||||||
@current_page = params[:current_page] || 1
|
@current_page = params[:current_page] || 1
|
||||||
@current_page = @current_page.to_i
|
@current_page = @current_page.to_i
|
||||||
site_dataset = Site.order(:updated_at.desc, :hits.desc).filter(is_banned: false).filter(site_changed: true).paginate(@current_page, 300)
|
|
||||||
|
|
||||||
site_dataset.filter! is_nsfw: (!params[:is_nsfw].nil? ? true : false)
|
site_dataset = Site.filter(is_banned: false).filter(site_changed: true).paginate(@current_page, 300)
|
||||||
|
|
||||||
|
case params[:sort_by]
|
||||||
|
when 'hits'
|
||||||
|
site_dataset.order!(:hits.desc)
|
||||||
|
when 'newest'
|
||||||
|
site_dataset.order!(:created_at.desc)
|
||||||
|
when 'oldest'
|
||||||
|
site_dataset.order!(:created_at)
|
||||||
|
when 'random'
|
||||||
|
site_dataset.where! 'random() < 0.01'
|
||||||
|
else
|
||||||
|
params[:sort_by] = 'last_updated'
|
||||||
|
site_dataset.order!(:updated_at.desc, :hits.desc)
|
||||||
|
end
|
||||||
|
|
||||||
|
site_dataset.filter!(is_nsfw: true) if params[:is_nsfw] == 'true'
|
||||||
|
|
||||||
@page_count = site_dataset.page_count || 1
|
@page_count = site_dataset.page_count || 1
|
||||||
@sites = site_dataset.all
|
@sites = site_dataset.all
|
||||||
|
|
|
@ -1,34 +1,69 @@
|
||||||
|
<script type="text/javascript">
|
||||||
|
function getPage(currentPage) {
|
||||||
|
document.location.href = '/browse?current_page='+currentPage+'&'+$('#search_criteria').serialize();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<ul class="row website-Gallery">
|
<ul class="row website-Gallery">
|
||||||
|
|
||||||
<div>
|
<div class="row">
|
||||||
|
<div class="col col-50">
|
||||||
<h2>Web Sites on NeoCities</h2>
|
<h2>Web Sites on NeoCities</h2>
|
||||||
<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 bookmark it!<br>Visitor counts are updated hourly.</p>
|
||||||
<div style="margin-bottom: 40px; width: 280px;"><a class="btn-Action" style="padding-top: 10px; padding-bottom: 10px" href="/new">Create your NeoCities site now</a></div>
|
<div style="margin-bottom: 40px; width: 280px;"><a class="btn-Action" style="padding-top: 10px; padding-bottom: 10px" href="/new">Create your NeoCities site now</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col col-50" style="padding-top: 50px">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<select name="sort_by" class="input-Select">
|
||||||
|
<option value="last_updated" <%= 'selected' if params[:sort_by] == 'last_updated' %>>Last Updated</option>
|
||||||
|
<option value="hits" <%= 'selected' if params[:sort_by] == 'hits' %>>Most Hits</option>
|
||||||
|
<option value="newest" <%= 'selected' if params[:sort_by] == 'newest' %>>Newest</option>
|
||||||
|
<option value="oldest" <%= 'selected' if params[:sort_by] == 'oldest' %>>Oldest</option>
|
||||||
|
<option value="random" <%= 'selected' if params[:sort_by] == 'random' %>>Random</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<!--
|
||||||
|
<div>
|
||||||
|
<input name="is_nsfw" type="checkbox" value="true" <%= 'checked' if params[:is_nsfw].to_s == 'true' %>> Show 18+ content
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
<div style="margin-top: 10px">
|
||||||
|
<input class="btn-Action" type="submit" value="Update">
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<% @sites.each do |site| %>
|
<% @sites.each do |site| %>
|
||||||
<li>
|
<li>
|
||||||
<a href="http://<%= site.username %>.neocities.org" target="_blank">
|
<a href="http://<%= site.username %>.neocities.org" target="_blank">
|
||||||
<img src="http://neocities.org/site_screenshots/<%= site.username %>.jpg" />
|
<img src="http://neocities.org/site_screenshots/<%= site.username %>.jpg" width="208" height="125" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<% if params[:sort_by] != 'random' %>
|
||||||
<% if @page_count > 1 %>
|
<% if @page_count > 1 %>
|
||||||
<div style="font-size: 30pt">
|
<div style="font-size: 30pt">
|
||||||
<% if @current_page != 1 %>
|
<% if @current_page != 1 %>
|
||||||
<a href="/browse?current_page=<%= @current_page - 1 %>"><i class="icon-arrow-left" style="text-decoration: none"></i></a>
|
<a href="#" onclick="getPage(<%= @current_page - 1 %>); return false"><i class="icon-arrow-left" style="text-decoration: none"></i></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% 1.upto(@page_count) do |num| %>
|
<% 1.upto(@page_count) do |num| %>
|
||||||
<a href="/browse?current_page=<%= num %>" style="<%= "text-decoration: none" if num == @current_page %>"><%= num %></a>
|
<a href="#" onclick="getPage(<%= num %>); return false" style="<%= "text-decoration: none" if num == @current_page %>"><%= num %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if @current_page != @page_count %>
|
<% if @current_page != @page_count %>
|
||||||
<a href="/browse?current_page=<%= @current_page + 1 %>"><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 %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
</div> <!-- end .content -->
|
</div> <!-- end .content -->
|
Loading…
Add table
Reference in a new issue