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
|
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?
|
params.delete 'tag' if params[:tag].nil? || params[:tag].strip.empty?
|
||||||
|
|
||||||
|
if is_education?
|
||||||
|
site_dataset = education_sites_dataset
|
||||||
|
else
|
||||||
site_dataset = browse_sites_dataset
|
site_dataset = browse_sites_dataset
|
||||||
|
end
|
||||||
|
|
||||||
site_dataset = site_dataset.paginate @current_page, Site::BROWSE_PAGINATION_LENGTH
|
site_dataset = site_dataset.paginate @current_page, Site::BROWSE_PAGINATION_LENGTH
|
||||||
@page_count = site_dataset.page_count || 1
|
@page_count = site_dataset.page_count || 1
|
||||||
@sites = site_dataset.all
|
@sites = site_dataset.all
|
||||||
|
@ -10,11 +20,14 @@ get '/browse/?' do
|
||||||
erb :browse
|
erb :browse
|
||||||
end
|
end
|
||||||
|
|
||||||
def browse_sites_dataset
|
def education_sites_dataset
|
||||||
@current_page = params[:current_page]
|
site_dataset = Site.filter is_deleted: false
|
||||||
@current_page = @current_page.to_i
|
site_dataset = site_dataset.association_join(:tags).select_all(:sites)
|
||||||
@current_page = 1 if @current_page == 0
|
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)
|
site_dataset = Site.filter(is_deleted: false, is_banned: false, is_crashing: false).filter(site_changed: true)
|
||||||
|
|
||||||
if current_site
|
if current_site
|
||||||
|
|
|
@ -2,6 +2,8 @@ get '/?' do
|
||||||
if current_site
|
if current_site
|
||||||
require_login
|
require_login
|
||||||
|
|
||||||
|
redirect '/dashboard' if current_site.is_education
|
||||||
|
|
||||||
@suggestions = current_site.suggestions
|
@suggestions = current_site.suggestions
|
||||||
|
|
||||||
@current_page = params[:current_page].to_i
|
@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.
|
# TODO: There should probably be a "this site was deleted" page.
|
||||||
not_found if site.nil? || site.is_banned || site.is_deleted
|
not_found if site.nil? || site.is_banned || site.is_deleted
|
||||||
|
|
||||||
|
redirect '/' if site.is_education
|
||||||
|
|
||||||
@title = site.title
|
@title = site.title
|
||||||
|
|
||||||
@current_page = params[:current_page]
|
@current_page = params[:current_page]
|
||||||
|
|
|
@ -15,6 +15,10 @@ def csrf_token
|
||||||
session[:_csrf_token] ||= SecureRandom.base64(32)
|
session[:_csrf_token] ||= SecureRandom.base64(32)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_education?
|
||||||
|
current_site && current_site.is_education
|
||||||
|
end
|
||||||
|
|
||||||
def require_login
|
def require_login
|
||||||
redirect '/' unless signed_in?
|
redirect '/' unless signed_in?
|
||||||
if session[:banned] || current_site.is_banned || parent_site.is_banned
|
if session[:banned] || current_site.is_banned || parent_site.is_banned
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe 'signup' do
|
||||||
it 'succeeds with valid data' do
|
it 'succeeds with valid data' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_button 'Create My Site'
|
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'
|
index_file_path = File.join Site::SITE_FILES_ROOT, @site[:username], 'index.html'
|
||||||
File.exist?(index_file_path).must_equal true
|
File.exist?(index_file_path).must_equal true
|
||||||
|
|
|
@ -10,9 +10,11 @@
|
||||||
<ul class="tiny h-Nav">
|
<ul class="tiny h-Nav">
|
||||||
<li><a href="/about">About</a></li>
|
<li><a href="/about">About</a></li>
|
||||||
<li><a href="/donate">Donate</a></li>
|
<li><a href="/donate">Donate</a></li>
|
||||||
|
<% unless is_education? %>
|
||||||
<li><a href="/blog">Blog</a></li>
|
<li><a href="/blog">Blog</a></li>
|
||||||
<li><a href="/api">API</a></li>
|
<li><a href="/api">API</a></li>
|
||||||
<li><a href="/press">Press</a></li>
|
<li><a href="/press">Press</a></li>
|
||||||
|
<% end %>
|
||||||
<li><a href="/terms" rel="nofollow">Terms</a></li>
|
<li><a href="/terms" rel="nofollow">Terms</a></li>
|
||||||
<li><a href="/privacy" rel="nofollow">Privacy</a></li>
|
<li><a href="/privacy" rel="nofollow">Privacy</a></li>
|
||||||
<li><a href="/contact" rel="nofollow">Contact</a></li>
|
<li><a href="/contact" rel="nofollow">Contact</a></li>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
|
<% unless is_education? %>
|
||||||
<li><a href="/site/<%= current_site.username %>">Profile</a></li>
|
<li><a href="/site/<%= current_site.username %>">Profile</a></li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/?activity=mine"><span class="float-Left">Activity</span>
|
<a href="/?activity=mine"><span class="float-Left">Activity</span>
|
||||||
|
@ -39,6 +40,7 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
|
<% end %>
|
||||||
<li><a href="/dashboard">Edit Site</a></li>
|
<li><a href="/dashboard">Edit Site</a></li>
|
||||||
<li><a href="<%= current_site.uri %>" target="_blank">View Site</a></li>
|
<li><a href="<%= current_site.uri %>" target="_blank">View Site</a></li>
|
||||||
<li class="divider"></li>
|
<li class="divider"></li>
|
||||||
|
|
|
@ -6,12 +6,16 @@
|
||||||
<li>
|
<li>
|
||||||
<a href="/browse">Websites</a>
|
<a href="/browse">Websites</a>
|
||||||
</li>
|
</li>
|
||||||
|
<% unless is_education? %>
|
||||||
<li>
|
<li>
|
||||||
<a href="/activity">Activity</a>
|
<a href="/activity">Activity</a>
|
||||||
</li>
|
</li>
|
||||||
|
<% end %>
|
||||||
<li>
|
<li>
|
||||||
<a href="/tutorials">Learn</a>
|
<a href="/tutorials">Learn</a>
|
||||||
</li>
|
</li>
|
||||||
|
<% unless is_education? %>
|
||||||
<li>
|
<li>
|
||||||
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
|
<a href="/plan">Support Us<i class="fa fa-heart"><i class="fa fa-heart"></i></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -6,7 +6,11 @@
|
||||||
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
||||||
if(errors.length == 0) {
|
if(errors.length == 0) {
|
||||||
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
||||||
|
if($('input[name=is_education]').val() == 'true') {
|
||||||
|
window.location.href = '/dashboard'
|
||||||
|
} else {
|
||||||
window.location.href = '/welcome'
|
window.location.href = '/welcome'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
for(var i=0; i<errors.length;i++) {
|
for(var i=0; i<errors.length;i++) {
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
<form id="search_criteria" action="/browse" method="GET">
|
<form id="search_criteria" action="/browse" method="GET">
|
||||||
<div class="col col-50 filter">
|
<div class="col col-50 filter">
|
||||||
<fieldset class="grouping">
|
<fieldset class="grouping">
|
||||||
|
<% unless is_education? %>
|
||||||
<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">
|
||||||
<select name="sort_by" id="sort_by" class="input-Select">
|
<select name="sort_by" id="sort_by" class="input-Select">
|
||||||
|
@ -33,20 +34,24 @@
|
||||||
<option value="random" <%= params[:sort_by] == 'random' ? 'selected' : '' %>>Random</option>
|
<option value="random" <%= params[:sort_by] == 'random' ? 'selected' : '' %>>Random</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<div>
|
<div>
|
||||||
<input name="is_nsfw" type="checkbox" value="true" <%= params[:is_nsfw].to_s == 'true' ? 'checked' : '' %>> Show 18+ content
|
<input name="is_nsfw" type="checkbox" value="true" <%= params[:is_nsfw].to_s == 'true' ? 'checked' : '' %>> Show 18+ content
|
||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
<input class="btn-Action" type="submit" value="Update">
|
<input class="btn-Action" type="submit" value="Update">
|
||||||
|
<% end %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="col col-50 filter">
|
<div class="col col-50 filter">
|
||||||
<form method="GET" action="browse">
|
<form method="GET" action="browse">
|
||||||
<fieldset class="grouping">
|
<fieldset class="grouping">
|
||||||
|
<% unless is_education? %>
|
||||||
<label class="text-Label" for="tag"><span class="hide-on-mobile">Search by </span>Tag:</label>
|
<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 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">
|
<input style="vertical-align: -4px;margin-left: 4px;" type="submit" class="btn-Action" value="Search">
|
||||||
|
<% end %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -142,6 +147,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% unless is_education? %>
|
||||||
<div class="row website-Gallery content int-Gall tags">
|
<div class="row website-Gallery content int-Gall tags">
|
||||||
<h3>Popular Tags</h3>
|
<h3>Popular Tags</h3>
|
||||||
<p>
|
<p>
|
||||||
|
@ -150,4 +156,5 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
<% end %>
|
<% 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>.
|
<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>
|
<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>
|
<li><strong><%= current_site.views.format_large_number %></strong> views</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -188,8 +188,10 @@
|
||||||
<% if !current_site.plan_feature(:no_file_restrictions) %>
|
<% if !current_site.plan_feature(:no_file_restrictions) %>
|
||||||
<a href="/site_files/allowed_types">Allowed file types</a> |
|
<a href="/site_files/allowed_types">Allowed file types</a> |
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="/site_files/<%= current_site.username %>.zip">Download entire site</a> |
|
<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>
|
<% unless is_education? %>
|
||||||
|
| <a href="/site_files/mount_info">Mount your site as a drive on your computer!</a>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue