mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
fix tag tests, start on education site creation, updated test code
This commit is contained in:
parent
f00e5d0757
commit
49defcd0c7
14 changed files with 627 additions and 623 deletions
26
Gemfile.lock
26
Gemfile.lock
|
@ -20,15 +20,15 @@ GEM
|
||||||
byebug (2.7.0)
|
byebug (2.7.0)
|
||||||
columnize (~> 0.3)
|
columnize (~> 0.3)
|
||||||
debugger-linecache (~> 1.2)
|
debugger-linecache (~> 1.2)
|
||||||
capybara (2.4.1)
|
capybara (2.4.4)
|
||||||
mime-types (>= 1.16)
|
mime-types (>= 1.16)
|
||||||
nokogiri (>= 1.3.3)
|
nokogiri (>= 1.3.3)
|
||||||
rack (>= 1.0.0)
|
rack (>= 1.0.0)
|
||||||
rack-test (>= 0.5.4)
|
rack-test (>= 0.5.4)
|
||||||
xpath (~> 2.0)
|
xpath (~> 2.0)
|
||||||
capybara_minitest_spec (1.0.1)
|
capybara_minitest_spec (1.0.5)
|
||||||
capybara (>= 2)
|
capybara (>= 2)
|
||||||
minitest (>= 2)
|
minitest (>= 4)
|
||||||
celluloid (0.15.2)
|
celluloid (0.15.2)
|
||||||
timers (~> 1.1.0)
|
timers (~> 1.1.0)
|
||||||
climate_control (0.0.3)
|
climate_control (0.0.3)
|
||||||
|
@ -99,8 +99,8 @@ GEM
|
||||||
metaclass (0.0.4)
|
metaclass (0.0.4)
|
||||||
method_source (0.8.2)
|
method_source (0.8.2)
|
||||||
mime-types (1.25.1)
|
mime-types (1.25.1)
|
||||||
mini_portile (0.6.0)
|
mini_portile (0.6.2)
|
||||||
minitest (5.3.1)
|
minitest (5.6.1)
|
||||||
minitest-reporters (1.0.2)
|
minitest-reporters (1.0.2)
|
||||||
ansi
|
ansi
|
||||||
builder
|
builder
|
||||||
|
@ -108,14 +108,14 @@ GEM
|
||||||
powerbar
|
powerbar
|
||||||
mocha (1.0.0)
|
mocha (1.0.0)
|
||||||
metaclass (~> 0.0.1)
|
metaclass (~> 0.0.1)
|
||||||
multi_json (1.10.1)
|
multi_json (1.11.0)
|
||||||
multipart-post (2.0.0)
|
multipart-post (2.0.0)
|
||||||
netrc (0.10.3)
|
netrc (0.10.3)
|
||||||
nokogiri (1.6.3.1)
|
nokogiri (1.6.6.2)
|
||||||
mini_portile (= 0.6.0)
|
mini_portile (~> 0.6.0)
|
||||||
pg (0.17.1)
|
pg (0.17.1)
|
||||||
phantomjs (1.9.7.1)
|
phantomjs (1.9.7.1)
|
||||||
poltergeist (1.5.1)
|
poltergeist (1.6.0)
|
||||||
capybara (~> 2.1)
|
capybara (~> 2.1)
|
||||||
cliver (~> 0.3.1)
|
cliver (~> 0.3.1)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
|
@ -133,14 +133,14 @@ GEM
|
||||||
pry (~> 0.9.12)
|
pry (~> 0.9.12)
|
||||||
puma (2.8.1)
|
puma (2.8.1)
|
||||||
rack (>= 1.1, < 2.0)
|
rack (>= 1.1, < 2.0)
|
||||||
rack (1.5.2)
|
rack (1.6.0)
|
||||||
rack-cache (1.2)
|
rack-cache (1.2)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-protection (1.5.2)
|
rack-protection (1.5.2)
|
||||||
rack
|
rack
|
||||||
rack-recaptcha (0.6.6)
|
rack-recaptcha (0.6.6)
|
||||||
json
|
json
|
||||||
rack-test (0.6.2)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rack_session_access (0.1.1)
|
rack_session_access (0.1.1)
|
||||||
builder (>= 2.0.0)
|
builder (>= 2.0.0)
|
||||||
|
@ -226,7 +226,9 @@ GEM
|
||||||
webmock (1.17.4)
|
webmock (1.17.4)
|
||||||
addressable (>= 2.2.7)
|
addressable (>= 2.2.7)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
websocket-driver (0.3.4)
|
websocket-driver (0.5.4)
|
||||||
|
websocket-extensions (>= 0.1.0)
|
||||||
|
websocket-extensions (0.1.2)
|
||||||
xpath (2.0.0)
|
xpath (2.0.0)
|
||||||
nokogiri (~> 1.3)
|
nokogiri (~> 1.3)
|
||||||
zipruby (0.3.6)
|
zipruby (0.3.6)
|
||||||
|
|
|
@ -7,6 +7,7 @@ end
|
||||||
|
|
||||||
post '/api/upload' do
|
post '/api/upload' do
|
||||||
require_api_credentials
|
require_api_credentials
|
||||||
|
|
||||||
files = []
|
files = []
|
||||||
params.each do |k,v|
|
params.each do |k,v|
|
||||||
next unless v.is_a?(Hash) && v[:tempfile]
|
next unless v.is_a?(Hash) && v[:tempfile]
|
||||||
|
|
|
@ -16,9 +16,11 @@ def new_recaptcha_valid?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
CREATE_MATCH_REGEX = /^username$|^password$|^email$|^new_tags_string$|^is_education$/
|
||||||
|
|
||||||
post '/create_validate_all' do
|
post '/create_validate_all' do
|
||||||
content_type :json
|
content_type :json
|
||||||
fields = params.select {|p| p.match /^username$|^password$|^email$|^new_tags_string$/}
|
fields = params.select {|p| p.match CREATE_MATCH_REGEX}
|
||||||
|
|
||||||
site = Site.new fields
|
site = Site.new fields
|
||||||
|
|
||||||
|
@ -33,11 +35,12 @@ end
|
||||||
post '/create_validate' do
|
post '/create_validate' do
|
||||||
content_type :json
|
content_type :json
|
||||||
|
|
||||||
if !params[:field].match /^username$|^password$|^email$|^new_tags_string$/
|
if !params[:field].match CREATE_MATCH_REGEX
|
||||||
return {error: 'not a valid field'}.to_json
|
return {error: 'not a valid field'}.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
site = Site.new(params[:field] => params[:value])
|
site = Site.new(params[:field] => params[:value])
|
||||||
|
site.is_education = params[:is_education]
|
||||||
site.valid?
|
site.valid?
|
||||||
|
|
||||||
field_sym = params[:field].to_sym
|
field_sym = params[:field].to_sym
|
||||||
|
@ -58,7 +61,8 @@ post '/create' do
|
||||||
username: params[:username],
|
username: params[:username],
|
||||||
password: params[:password],
|
password: params[:password],
|
||||||
email: params[:email],
|
email: params[:email],
|
||||||
new_tags_string: params[:tags],
|
new_tags_string: params[:new_tags_string],
|
||||||
|
is_education: params[:is_education] == 'true' ? true : false,
|
||||||
ip: request.ip
|
ip: request.ip
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ get '/?' do
|
||||||
@sites_count = SimpleCache.get :sites_count
|
@sites_count = SimpleCache.get :sites_count
|
||||||
end
|
end
|
||||||
|
|
||||||
erb :index, layout: false
|
erb :index, layout: :index_layout
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/welcome' do
|
get '/welcome' do
|
||||||
|
@ -44,7 +44,8 @@ get '/welcome' do
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/education' do
|
get '/education' do
|
||||||
erb :education, layout: false
|
redirect '/' if signed_in?
|
||||||
|
erb :education, layout: :index_layout
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/tutorials' do
|
get '/tutorials' do
|
||||||
|
|
9
migrations/064_add_education_to_sites.rb
Normal file
9
migrations/064_add_education_to_sites.rb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Sequel.migration do
|
||||||
|
up {
|
||||||
|
add_column :sites, :is_education, :boolean, default: false
|
||||||
|
}
|
||||||
|
|
||||||
|
down {
|
||||||
|
drop_column :sites, :is_education
|
||||||
|
}
|
||||||
|
end
|
|
@ -835,6 +835,18 @@ class Site < Sequel::Model
|
||||||
new_tags.compact!
|
new_tags.compact!
|
||||||
@new_filtered_tags = []
|
@new_filtered_tags = []
|
||||||
|
|
||||||
|
if values[:is_education] == true
|
||||||
|
if new?
|
||||||
|
if @new_tags_string.nil? || @new_tags_string.empty?
|
||||||
|
errors.add :new_tags_string, 'A Class Tag is required.'
|
||||||
|
end
|
||||||
|
|
||||||
|
if new_tags.length > 1
|
||||||
|
errors.add :new_tags_string, 'Must only have one tag'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
|
if ((new? ? 0 : tags_dataset.count) + new_tags.length > 5)
|
||||||
errors.add :new_tags_string, 'Cannot have more than 5 tags for your site.'
|
errors.add :new_tags_string, 'Cannot have more than 5 tags for your site.'
|
||||||
end
|
end
|
||||||
|
@ -861,7 +873,7 @@ class Site < Sequel::Model
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
next if tags.collect {|t| t.name}.include? tag
|
next if !new? && tags.collect {|t| t.name}.include?(tag)
|
||||||
|
|
||||||
@new_filtered_tags << tag
|
@new_filtered_tags << tag
|
||||||
@new_filtered_tags.uniq!
|
@new_filtered_tags.uniq!
|
||||||
|
|
61
tests/acceptance/education_tests.rb
Normal file
61
tests/acceptance/education_tests.rb
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
require_relative './environment.rb'
|
||||||
|
|
||||||
|
Capybara.register_driver :poltergeist do |app|
|
||||||
|
Capybara::Poltergeist::Driver.new(app, js_errors: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'signup' do
|
||||||
|
include Capybara::DSL
|
||||||
|
|
||||||
|
def fill_in_valid
|
||||||
|
@site = Fabricate.attributes_for(:site)
|
||||||
|
@class_tag = SecureRandom.uuid.gsub('-', '')[0..Tag::NAME_LENGTH_MAX-1]
|
||||||
|
fill_in 'username', with: @site[:username]
|
||||||
|
fill_in 'password', with: @site[:password]
|
||||||
|
fill_in 'email', with: @site[:email]
|
||||||
|
fill_in 'new_tags_string', with: @class_tag
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
Capybara.default_driver = :poltergeist
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
visit '/education'
|
||||||
|
page.must_have_content 'Neocities' # Used to force load wait
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
Capybara.default_driver = :rack_test
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'succeeds with valid data' do
|
||||||
|
fill_in_valid
|
||||||
|
click_button 'Create My Site'
|
||||||
|
page.must_have_content 'Welcome to Neocities'
|
||||||
|
|
||||||
|
index_file_path = File.join Site::SITE_FILES_ROOT, @site[:username], 'index.html'
|
||||||
|
File.exist?(index_file_path).must_equal true
|
||||||
|
|
||||||
|
site = Site[username: @site[:username]]
|
||||||
|
site.site_files.length.must_equal 4
|
||||||
|
site.site_changed.must_equal false
|
||||||
|
site.site_updated_at.must_equal nil
|
||||||
|
site.is_education.must_equal true
|
||||||
|
site.tags.length.must_equal 1
|
||||||
|
site.tags.first.name.must_equal @class_tag
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'fails to create for existing site' do
|
||||||
|
@existing_site = Fabricate :site
|
||||||
|
fill_in_valid
|
||||||
|
fill_in :username, with: @existing_site.username
|
||||||
|
click_button 'Create My Site'
|
||||||
|
page.must_have_content 'already taken'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'fails for multiple tags' do
|
||||||
|
fill_in_valid
|
||||||
|
fill_in :new_tags_string, with: 'derp, ie'
|
||||||
|
click_button 'Create My Site'
|
||||||
|
page.must_have_content 'Must only have one tag'
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,3 +5,5 @@ Capybara.app = Sinatra::Application
|
||||||
def teardown
|
def teardown
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Capybara.default_wait_time = 5
|
||||||
|
|
|
@ -30,6 +30,7 @@ describe 'signup' do
|
||||||
Capybara.default_driver = :poltergeist
|
Capybara.default_driver = :poltergeist
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
visit_signup
|
visit_signup
|
||||||
|
page.must_have_content 'Neocities' # Used to force load wait
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
@ -48,19 +49,15 @@ describe 'signup' do
|
||||||
site.site_files.length.must_equal 4
|
site.site_files.length.must_equal 4
|
||||||
site.site_changed.must_equal false
|
site.site_changed.must_equal false
|
||||||
site.site_updated_at.must_equal nil
|
site.site_updated_at.must_equal nil
|
||||||
|
site.is_education.must_equal false
|
||||||
|
|
||||||
site.ip.must_equal Site.hash_ip('127.0.0.1')
|
site.ip.must_equal Site.hash_ip('127.0.0.1')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails to create for existing site' do
|
it 'fails to create for existing site' do
|
||||||
|
@existing_site = Fabricate :site
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
click_signup_button
|
fill_in 'username', with: @existing_site.username
|
||||||
page.must_have_content 'Welcome to Neocities'
|
|
||||||
Capybara.reset_sessions!
|
|
||||||
visit_signup
|
|
||||||
sleep 0.3
|
|
||||||
fill_in 'username', with: @site[:username]
|
|
||||||
fill_in 'password', with: @site[:password]
|
|
||||||
click_signup_button
|
click_signup_button
|
||||||
page.must_have_content 'already taken'
|
page.must_have_content 'already taken'
|
||||||
end
|
end
|
||||||
|
@ -113,9 +110,6 @@ describe 'signup' do
|
||||||
page.must_have_content /email.+exists/
|
page.must_have_content /email.+exists/
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "$$$$$$$$$$$$$$$$$$$$$$ TODO FIX TAGS TESTS"
|
|
||||||
|
|
||||||
=begin
|
|
||||||
it 'succeeds with no tags' do
|
it 'succeeds with no tags' do
|
||||||
fill_in_valid
|
fill_in_valid
|
||||||
fill_in 'new_tags_string', with: ''
|
fill_in 'new_tags_string', with: ''
|
||||||
|
@ -179,9 +173,10 @@ puts "$$$$$$$$$$$$$$$$$$$$$$ TODO FIX TAGS TESTS"
|
||||||
fill_in 'new_tags_string', with: 'one, one'
|
fill_in 'new_tags_string', with: 'one, one'
|
||||||
click_signup_button
|
click_signup_button
|
||||||
|
|
||||||
site = Site.last
|
page.must_have_content /Welcome to Neocities/
|
||||||
|
|
||||||
|
site = Site[username: @site[:username]]
|
||||||
site.tags.length.must_equal 1
|
site.tags.length.must_equal 1
|
||||||
site.tags.first.name.must_equal 'one'
|
site.tags.first.name.must_equal 'one'
|
||||||
end
|
end
|
||||||
=end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,14 +167,6 @@ describe 'api upload' do
|
||||||
'/' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
'/' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
||||||
}
|
}
|
||||||
res[:error_type].must_equal 'invalid_file_type'
|
res[:error_type].must_equal 'invalid_file_type'
|
||||||
|
|
||||||
create_site
|
|
||||||
basic_authorize @user, @pass
|
|
||||||
post '/api/upload', {
|
|
||||||
'' => Rack::Test::UploadedFile.new('./tests/files/test.jpg', 'image/jpeg')
|
|
||||||
}
|
|
||||||
|
|
||||||
res[:error_type].must_equal 'missing_files'
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'fails for file with no extension' do
|
it 'fails for file with no extension' do
|
||||||
|
|
37
views/_index_signup_script.erb
Normal file
37
views/_index_signup_script.erb
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<script src="/js/app.min.js"></script>
|
||||||
|
<script src="/js/bootstrap.min.js"></script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
$('#createSiteForm').on('submit', function(obj) {
|
||||||
|
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
||||||
|
if(errors.length == 0) {
|
||||||
|
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
||||||
|
window.location.href = '/welcome'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
for(var i=0; i<errors.length;i++) {
|
||||||
|
if(errors[i][0] == 'captcha') {
|
||||||
|
var captchaDiv = $('#captcha-input')
|
||||||
|
captchaDiv.attr('data-original-title', errors[i][1])
|
||||||
|
captchaDiv.tooltip('show')
|
||||||
|
} else {
|
||||||
|
var ele = $('input[name='+errors[i][0]+']')
|
||||||
|
ele.attr('data-original-title', errors[i][1])
|
||||||
|
ele.tooltip('show')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
$('input[type=text],input[type=password]').on('change focusout', function(obj) {
|
||||||
|
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, is_education: $('input[name=is_education]')[0].value, csrf_token: '<%= csrf_token %>'}, function(res) {
|
||||||
|
if(res.result == 'ok') {
|
||||||
|
return $(obj.target).tooltip('hide')
|
||||||
|
}
|
||||||
|
|
||||||
|
$(obj.target).attr('data-original-title', res.error)
|
||||||
|
$(obj.target).tooltip('show')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -1,45 +1,3 @@
|
||||||
<!doctype html>
|
|
||||||
<!--[if IE 8 ]><html lang="en" class="ieAll ie8"><![endif]-->
|
|
||||||
<!--[if IE 9 ]><html lang="en" class="ieAll ie9"><![endif]-->
|
|
||||||
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
|
|
||||||
<title>Neocities for Education</title>
|
|
||||||
<meta itemprop="name" content="Neocities.org" />
|
|
||||||
<meta itemprop="description" content="Create your own free home page, and do whatever you want with it." />
|
|
||||||
<meta name="description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it." />
|
|
||||||
<meta name="keywords" content="free website, html, css, learn to code, free hosting, build a website, create a web page" />
|
|
||||||
|
|
||||||
<link rel="canonical" href="//neocities.org" />
|
|
||||||
|
|
||||||
<meta property="og:title" content="Neocities"/>
|
|
||||||
<meta property="og:site_name" content="Neocities | neocities.org"/>
|
|
||||||
<meta property="og:type" content="website"/>
|
|
||||||
<meta property="og:image" content=""/>
|
|
||||||
<meta property="og:url" content="//www.neocities.org"/>
|
|
||||||
<meta property="og:description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it."/>
|
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico?v=4" />
|
|
||||||
<link rel="apple-touch-icon-precomposed" href="#apple-icon-144.png" />
|
|
||||||
<link rel="apple-touch-startup-image" href="#startup.png" />
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Mobile Meta -->
|
|
||||||
<meta name="HandheldFriendly" content="True" />
|
|
||||||
<meta name="MobileOptimized" content="320" />
|
|
||||||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1" />
|
|
||||||
|
|
||||||
<link href="/css/neo.css" rel="stylesheet" type="text/css" media="all"/>
|
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script type="text/javascript" src="/js/html5.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
<script src="/js/jquery-1.11.0.min.js"></script>
|
|
||||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="hp education">
|
<body class="hp education">
|
||||||
<a id="new"></a>
|
<a id="new"></a>
|
||||||
|
|
||||||
|
@ -126,6 +84,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<form id="createSiteForm" class="signup-Form" onsubmit="return false">
|
<form id="createSiteForm" class="signup-Form" onsubmit="return false">
|
||||||
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
|
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
|
||||||
|
<input type="hidden" name="is_education" value="true">
|
||||||
<fieldset class="content">
|
<fieldset class="content">
|
||||||
<h2 class="gamma">Class Sign Up</h2>
|
<h2 class="gamma">Class Sign Up</h2>
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -277,41 +236,5 @@
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script src="/js/bootstrap.min.js"></script>
|
<%== erb :'_index_signup_script', layout: false %>
|
||||||
<script>
|
|
||||||
|
|
||||||
$('#createSiteForm').on('submit', function(obj) {
|
|
||||||
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
|
||||||
if(errors.length == 0) {
|
|
||||||
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
|
||||||
window.location.href = '/welcome'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
for(var i=0; i<errors.length;i++) {
|
|
||||||
if(errors[i][0] == 'captcha') {
|
|
||||||
var captchaDiv = $('#captcha-input')
|
|
||||||
captchaDiv.attr('data-original-title', errors[i][1])
|
|
||||||
captchaDiv.tooltip('show')
|
|
||||||
} else {
|
|
||||||
var ele = $('input[name='+errors[i][0]+']')
|
|
||||||
ele.attr('data-original-title', errors[i][1])
|
|
||||||
ele.tooltip('show')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
$('input[type=text],input[type=password]').on('change focusout', function(obj) {
|
|
||||||
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, csrf_token: '<%= csrf_token %>'}, function(res) {
|
|
||||||
if(res.result == 'ok') {
|
|
||||||
return $(obj.target).tooltip('hide')
|
|
||||||
}
|
|
||||||
|
|
||||||
$(obj.target).attr('data-original-title', res.error)
|
|
||||||
$(obj.target).tooltip('show')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,45 +1,3 @@
|
||||||
<!doctype html>
|
|
||||||
<!--[if IE 8 ]><html lang="en" class="ieAll ie8"><![endif]-->
|
|
||||||
<!--[if IE 9 ]><html lang="en" class="ieAll ie9"><![endif]-->
|
|
||||||
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
||||||
|
|
||||||
<title>Neocities: Create your free website now!</title>
|
|
||||||
<meta itemprop="name" content="Neocities.org" />
|
|
||||||
<meta itemprop="description" content="Create your own free home page, and do whatever you want with it." />
|
|
||||||
<meta name="description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it." />
|
|
||||||
<meta name="keywords" content="free website, html, css, learn to code, free hosting, build a website, create a web page" />
|
|
||||||
|
|
||||||
<link rel="canonical" href="//neocities.org" />
|
|
||||||
|
|
||||||
<meta property="og:title" content="Neocities"/>
|
|
||||||
<meta property="og:site_name" content="Neocities | neocities.org"/>
|
|
||||||
<meta property="og:type" content="website"/>
|
|
||||||
<meta property="og:image" content=""/>
|
|
||||||
<meta property="og:url" content="//www.neocities.org"/>
|
|
||||||
<meta property="og:description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it."/>
|
|
||||||
|
|
||||||
<link rel="shortcut icon" type="image/ico" href="/favicon.ico?v=4" />
|
|
||||||
<link rel="apple-touch-icon-precomposed" href="#apple-icon-144.png" />
|
|
||||||
<link rel="apple-touch-startup-image" href="#startup.png" />
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Mobile Meta -->
|
|
||||||
<meta name="HandheldFriendly" content="True" />
|
|
||||||
<meta name="MobileOptimized" content="320" />
|
|
||||||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1" />
|
|
||||||
|
|
||||||
<link href="/css/neo.css" rel="stylesheet" type="text/css" media="all"/>
|
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script type="text/javascript" src="/js/html5.min.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
<script src="/js/jquery-1.11.0.min.js"></script>
|
|
||||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="hp">
|
<body class="hp">
|
||||||
<a id="new"></a>
|
<a id="new"></a>
|
||||||
|
|
||||||
|
@ -138,6 +96,7 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<form id="createSiteForm" class="signup-Form" onsubmit="return false">
|
<form id="createSiteForm" class="signup-Form" onsubmit="return false">
|
||||||
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
|
<input type="hidden" name="csrf_token" value="<%= csrf_token %>">
|
||||||
|
<input type="hidden" name="is_education" value="false">
|
||||||
<fieldset class="content">
|
<fieldset class="content">
|
||||||
<h2 class="gamma">Sign up for free</h2>
|
<h2 class="gamma">Sign up for free</h2>
|
||||||
<hr />
|
<hr />
|
||||||
|
@ -356,47 +315,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%== erb :'_footer', layout: false %>
|
<%== erb :'_footer', layout: false %>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script src="/js/app.min.js"></script>
|
<%== erb :'_index_signup_script', layout: false %>
|
||||||
<script src="/js/bootstrap.min.js"></script>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
$('#createSiteForm').on('submit', function(obj) {
|
|
||||||
$.post('/create_validate_all', $(obj.target).serialize(), function(errors) {
|
|
||||||
if(errors.length == 0) {
|
|
||||||
$.post('/create', $('#createSiteForm').serialize(), function(res) {
|
|
||||||
window.location.href = '/welcome'
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
for(var i=0; i<errors.length;i++) {
|
|
||||||
if(errors[i][0] == 'captcha') {
|
|
||||||
var captchaDiv = $('#captcha-input')
|
|
||||||
captchaDiv.attr('data-original-title', errors[i][1])
|
|
||||||
captchaDiv.tooltip('show')
|
|
||||||
} else {
|
|
||||||
var ele = $('input[name='+errors[i][0]+']')
|
|
||||||
ele.attr('data-original-title', errors[i][1])
|
|
||||||
ele.tooltip('show')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
$('input[type=text],input[type=password]').on('change focusout', function(obj) {
|
|
||||||
$.post('/create_validate', {field: obj.target.name, value: obj.target.value, csrf_token: '<%= csrf_token %>'}, function(res) {
|
|
||||||
if(res.result == 'ok') {
|
|
||||||
return $(obj.target).tooltip('hide')
|
|
||||||
}
|
|
||||||
|
|
||||||
$(obj.target).attr('data-original-title', res.error)
|
|
||||||
$(obj.target).tooltip('show')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
|
45
views/index_layout.erb
Normal file
45
views/index_layout.erb
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<!doctype html>
|
||||||
|
<!--[if IE 8 ]><html lang="en" class="ieAll ie8"><![endif]-->
|
||||||
|
<!--[if IE 9 ]><html lang="en" class="ieAll ie9"><![endif]-->
|
||||||
|
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
|
||||||
|
<title>Neocities: Create your free website now!</title>
|
||||||
|
<meta itemprop="name" content="Neocities.org" />
|
||||||
|
<meta itemprop="description" content="Create your own free home page, and do whatever you want with it." />
|
||||||
|
<meta name="description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it." />
|
||||||
|
<meta name="keywords" content="free website, html, css, learn to code, free hosting, build a website, create a web page" />
|
||||||
|
|
||||||
|
<link rel="canonical" href="//neocities.org" />
|
||||||
|
|
||||||
|
<meta property="og:title" content="Neocities"/>
|
||||||
|
<meta property="og:site_name" content="Neocities | neocities.org"/>
|
||||||
|
<meta property="og:type" content="website"/>
|
||||||
|
<meta property="og:image" content=""/>
|
||||||
|
<meta property="og:url" content="//www.neocities.org"/>
|
||||||
|
<meta property="og:description" content="Neocities is the new Geocities. Create your own free home page, and do whatever you want with it."/>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" type="image/ico" href="/favicon.ico?v=4" />
|
||||||
|
<link rel="apple-touch-icon-precomposed" href="#apple-icon-144.png" />
|
||||||
|
<link rel="apple-touch-startup-image" href="#startup.png" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Mobile Meta -->
|
||||||
|
<meta name="HandheldFriendly" content="True" />
|
||||||
|
<meta name="MobileOptimized" content="320" />
|
||||||
|
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1" />
|
||||||
|
|
||||||
|
<link href="/css/neo.css" rel="stylesheet" type="text/css" media="all"/>
|
||||||
|
|
||||||
|
<!--[if lt IE 9]>
|
||||||
|
<script type="text/javascript" src="/js/html5.min.js"></script>
|
||||||
|
<![endif]-->
|
||||||
|
|
||||||
|
<script src="/js/jquery-1.11.0.min.js"></script>
|
||||||
|
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<%== yield %>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue