mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
implement education version of Neocities
This commit is contained in:
parent
c5d62b19a3
commit
977ba19610
12 changed files with 91 additions and 49 deletions
|
@ -1,6 +1,16 @@
|
|||
get '/browse/?' do
|
||||
@current_page = params[:current_page]
|
||||
@current_page = @current_page.to_i
|
||||
@current_page = 1 if @current_page == 0
|
||||
|
||||
params.delete 'tag' if params[:tag].nil? || params[:tag].strip.empty?
|
||||
site_dataset = browse_sites_dataset
|
||||
|
||||
if is_education?
|
||||
site_dataset = education_sites_dataset
|
||||
else
|
||||
site_dataset = browse_sites_dataset
|
||||
end
|
||||
|
||||
site_dataset = site_dataset.paginate @current_page, Site::BROWSE_PAGINATION_LENGTH
|
||||
@page_count = site_dataset.page_count || 1
|
||||
@sites = site_dataset.all
|
||||
|
@ -10,11 +20,14 @@ get '/browse/?' do
|
|||
erb :browse
|
||||
end
|
||||
|
||||
def browse_sites_dataset
|
||||
@current_page = params[:current_page]
|
||||
@current_page = @current_page.to_i
|
||||
@current_page = 1 if @current_page == 0
|
||||
def education_sites_dataset
|
||||
site_dataset = Site.filter is_deleted: false
|
||||
site_dataset = site_dataset.association_join(:tags).select_all(:sites)
|
||||
params[:tag] = current_site.tags.first.name
|
||||
site_dataset.where! ['tags.name = ?', params[:tag]]
|
||||
end
|
||||
|
||||
def browse_sites_dataset
|
||||
site_dataset = Site.filter(is_deleted: false, is_banned: false, is_crashing: false).filter(site_changed: true)
|
||||
|
||||
if current_site
|
||||
|
|
|
@ -2,6 +2,8 @@ get '/?' do
|
|||
if current_site
|
||||
require_login
|
||||
|
||||
redirect '/dashboard' if current_site.is_education
|
||||
|
||||
@suggestions = current_site.suggestions
|
||||
|
||||
@current_page = params[:current_page].to_i
|
||||
|
|
|
@ -9,6 +9,8 @@ get '/site/:username/?' do |username|
|
|||
# TODO: There should probably be a "this site was deleted" page.
|
||||
not_found if site.nil? || site.is_banned || site.is_deleted
|
||||
|
||||
redirect '/' if site.is_education
|
||||
|
||||
@title = site.title
|
||||
|
||||
@current_page = params[:current_page]
|
||||
|
|
|
@ -15,6 +15,10 @@ def csrf_token
|
|||
session[:_csrf_token] ||= SecureRandom.base64(32)
|
||||
end
|
||||
|
||||
def is_education?
|
||||
current_site && current_site.is_education
|
||||
end
|
||||
|
||||
def require_login
|
||||
redirect '/' unless signed_in?
|
||||
if session[:banned] || current_site.is_banned || parent_site.is_banned
|
||||
|
|
|
@ -30,7 +30,7 @@ describe 'signup' do
|
|||
it 'succeeds with valid data' do
|
||||
fill_in_valid
|
||||
click_button 'Create My Site'
|
||||
page.must_have_content 'Welcome to Neocities'
|
||||
page.must_have_content /Welcome to your new site/
|
||||
|
||||
index_file_path = File.join Site::SITE_FILES_ROOT, @site[:username], 'index.html'
|
||||
File.exist?(index_file_path).must_equal true
|
||||
|
|
|
@ -10,9 +10,11 @@
|
|||
<ul class="tiny h-Nav">
|
||||
<li><a href="/about">About</a></li>
|
||||
<li><a href="/donate">Donate</a></li>
|
||||
<li><a href="/blog">Blog</a></li>
|
||||
<li><a href="/api">API</a></li>
|
||||
<li><a href="/press">Press</a></li>
|
||||
<% unless is_education? %>
|
||||
<li><a href="/blog">Blog</a></li>
|
||||
<li><a href="/api">API</a></li>
|
||||
<li><a href="/press">Press</a></li>
|
||||
<% end %>
|
||||
<li><a href="/terms" rel="nofollow">Terms</a></li>
|
||||
<li><a href="/privacy" rel="nofollow">Privacy</a></li>
|
||||
<li><a href="/contact" rel="nofollow">Contact</a></li>
|
||||
|
|
|
@ -30,15 +30,17 @@
|
|||
</span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/site/<%= current_site.username %>">Profile</a></li>
|
||||
<li>
|
||||
<a href="/?activity=mine"><span class="float-Left">Activity</span>
|
||||
<% if current_site.unseen_notifications_count > 0 %>
|
||||
<span class="notification-value"><%= current_site.unseen_notifications_count %></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<% unless is_education? %>
|
||||
<li><a href="/site/<%= current_site.username %>">Profile</a></li>
|
||||
<li>
|
||||
<a href="/?activity=mine"><span class="float-Left">Activity</span>
|
||||
<% if current_site.unseen_notifications_count > 0 %>
|
||||
<span class="notification-value"><%= current_site.unseen_notifications_count %></span>
|
||||
<% end %>
|
||||
</a>
|
||||
</li>
|
||||
<li class="divider"></li>
|
||||
<% end %>
|
||||
<li><a href="/dashboard">Edit Site</a></li>
|
||||
<li><a href="<%= current_site.uri %>" target="_blank">View Site</a></li>
|
||||
<li class="divider"></li>
|
||||
|
|
|
@ -6,12 +6,16 @@
|
|||
<li>
|
||||
<a href="/browse">Websites</a>
|
||||
</li>
|
||||
<% unless is_education? %>
|
||||
<li>
|
||||
<a href="/activity">Activity</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li>
|
||||
<a href="/tutorials">Learn</a>
|
||||
</li>
|
||||
<% unless is_education? %>
|
||||
<li>
|
||||
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
||||
if(errors.length == 0) {
|
||||
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
||||
window.location.href = '/welcome'
|
||||
if($('input[name=is_education]').val() == 'true') {
|
||||
window.location.href = '/dashboard'
|
||||
} else {
|
||||
window.location.href = '/welcome'
|
||||
}
|
||||
})
|
||||
} else {
|
||||
for(var i=0; i<errors.length;i++) {
|
||||
|
|
|
@ -21,32 +21,37 @@
|
|||
<form id="search_criteria" action="/browse" method="GET">
|
||||
<div class="col col-50 filter">
|
||||
<fieldset class="grouping">
|
||||
<label class="text-Label" for="sort_by">Sort by:</label>
|
||||
<div class="select-Container">
|
||||
<select name="sort_by" id="sort_by" class="input-Select">
|
||||
<option value="last_updated" <%= params[:sort_by] == 'last_updated' ? 'selected' : '' %>>Last Updated</option>
|
||||
<option value="featured" <%= params[:sort_by] == 'featured' ? 'selected' : '' %>>Featured</option>
|
||||
<option value="views" <%= params[:sort_by] == 'views' ? 'selected' : '' %>>Most Views</option>
|
||||
<option value="hits" <%= params[:sort_by] == 'hits' ? 'selected' : '' %>>Most Hits</option>
|
||||
<option value="newest" <%= params[:sort_by] == 'newest' ? 'selected' : '' %>>Newest</option>
|
||||
<option value="oldest" <%= params[:sort_by] == 'oldest' ? 'selected' : '' %>>Oldest</option>
|
||||
<option value="random" <%= params[:sort_by] == 'random' ? 'selected' : '' %>>Random</option>
|
||||
</select>
|
||||
</div>
|
||||
<!--
|
||||
<div>
|
||||
<input name="is_nsfw" type="checkbox" value="true" <%= params[:is_nsfw].to_s == 'true' ? 'checked' : '' %>> Show 18+ content
|
||||
</div>
|
||||
-->
|
||||
<% unless is_education? %>
|
||||
<label class="text-Label" for="sort_by">Sort by:</label>
|
||||
<div class="select-Container">
|
||||
<select name="sort_by" id="sort_by" class="input-Select">
|
||||
<option value="last_updated" <%= params[:sort_by] == 'last_updated' ? 'selected' : '' %>>Last Updated</option>
|
||||
<option value="featured" <%= params[:sort_by] == 'featured' ? 'selected' : '' %>>Featured</option>
|
||||
<option value="views" <%= params[:sort_by] == 'views' ? 'selected' : '' %>>Most Views</option>
|
||||
<option value="hits" <%= params[:sort_by] == 'hits' ? 'selected' : '' %>>Most Hits</option>
|
||||
<option value="newest" <%= params[:sort_by] == 'newest' ? 'selected' : '' %>>Newest</option>
|
||||
<option value="oldest" <%= params[:sort_by] == 'oldest' ? 'selected' : '' %>>Oldest</option>
|
||||
<option value="random" <%= params[:sort_by] == 'random' ? 'selected' : '' %>>Random</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div>
|
||||
<input name="is_nsfw" type="checkbox" value="true" <%= params[:is_nsfw].to_s == 'true' ? 'checked' : '' %>> Show 18+ content
|
||||
</div>
|
||||
-->
|
||||
<input class="btn-Action" type="submit" value="Update">
|
||||
<% end %>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="col col-50 filter">
|
||||
<form method="GET" action="browse">
|
||||
<fieldset class="grouping">
|
||||
<label class="text-Label" for="tag"><span class="hide-on-mobile">Search by </span>Tag:</label>
|
||||
<input class="input-Area typeahead" id="tag" name="tag" type="text" placeholder="pokemon" value="<%= params[:tag] %>" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" dir="auto">
|
||||
<input style="vertical-align: -4px;margin-left: 4px;" type="submit" class="btn-Action" value="Search">
|
||||
<% unless is_education? %>
|
||||
<label class="text-Label" for="tag"><span class="hide-on-mobile">Search by </span>Tag:</label>
|
||||
<input class="input-Area typeahead" id="tag" name="tag" type="text" placeholder="pokemon" value="<%= params[:tag] %>" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" dir="auto">
|
||||
<input style="vertical-align: -4px;margin-left: 4px;" type="submit" class="btn-Action" value="Search">
|
||||
<% end %>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -142,12 +147,14 @@
|
|||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% unless is_education? %>
|
||||
<div class="row website-Gallery content int-Gall tags">
|
||||
<h3>Popular Tags</h3>
|
||||
<p>
|
||||
<% Tag.popular_names(100).each do |tag| %>
|
||||
<a href="/browse?tag=<%= Rack::Utils.escape tag[:name] %>"><%= tag[:name] %></a>
|
||||
<% end %>
|
||||
</p>
|
||||
<h3>Popular Tags</h3>
|
||||
<p>
|
||||
<% Tag.popular_names(100).each do |tag| %>
|
||||
<a href="/browse?tag=<%= Rack::Utils.escape tag[:name] %>"><%= tag[:name] %></a>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<% end %>
|
||||
<li>Using <strong><%= current_site.space_percentage_used %>% (<%= current_site.total_space_used.to_space_pretty %>) of your <%= current_site.maximum_space.to_space_pretty %></strong>.
|
||||
<br>
|
||||
<% if !current_site.supporter? %>Need more space? <a href="/plan">Become a Supporter!</a><% end %></li>
|
||||
<% unless current_site.is_education || current_site.supporter? %>Need more space? <a href="/plan">Become a Supporter!</a><% end %></li>
|
||||
<li><strong><%= current_site.views.format_large_number %></strong> views</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -188,8 +188,10 @@
|
|||
<% if !current_site.plan_feature(:no_file_restrictions) %>
|
||||
<a href="/site_files/allowed_types">Allowed file types</a> |
|
||||
<% end %>
|
||||
<a href="/site_files/<%= current_site.username %>.zip">Download entire site</a> |
|
||||
<a href="/site_files/mount_info">Mount your site as a drive on your computer!</a>
|
||||
<a href="/site_files/<%= current_site.username %>.zip">Download entire site</a>
|
||||
<% unless is_education? %>
|
||||
| <a href="/site_files/mount_info">Mount your site as a drive on your computer!</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue