mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
Working on signup and signin
This commit is contained in:
parent
50882756d0
commit
4ddd244588
12 changed files with 105 additions and 11 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -18,3 +18,4 @@ _yardoc
|
|||
doc/
|
||||
tests/coverage
|
||||
config.yml
|
||||
.DS_Store
|
||||
|
|
|
@ -82,6 +82,9 @@ DEPENDENCIES
|
|||
fabrication
|
||||
faker
|
||||
hiredis
|
||||
jdbc-postgres
|
||||
jruby-openssl
|
||||
json
|
||||
minitest
|
||||
minitest-reporters
|
||||
mocha
|
||||
|
@ -92,6 +95,7 @@ DEPENDENCIES
|
|||
rack-test
|
||||
rake
|
||||
redis
|
||||
ruby-debug
|
||||
sequel
|
||||
shotgun
|
||||
simplecov
|
||||
|
|
6
app.rb
6
app.rb
|
@ -13,6 +13,10 @@ get '/dashboard' do
|
|||
slim :'dashboard'
|
||||
end
|
||||
|
||||
get '/signin' do
|
||||
slim :'signin'
|
||||
end
|
||||
|
||||
post '/create' do
|
||||
@site = Site.new username: params[:username], password: params[:password], email: params[:email]
|
||||
if @site.valid?
|
||||
|
@ -39,7 +43,7 @@ post '/signin' do
|
|||
redirect '/dashboard'
|
||||
else
|
||||
flash[:error] = 'Invalid login.'
|
||||
redirect '/'
|
||||
redirect '/signin'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
13
migrations/003_create_tags.rb
Normal file
13
migrations/003_create_tags.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.create_table! :tags do
|
||||
primary_key :id
|
||||
String :name
|
||||
DateTime :created_at
|
||||
end
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_table :tags
|
||||
}
|
||||
end
|
12
migrations/004_create_site_tags.rb
Normal file
12
migrations/004_create_site_tags.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.create_table! :site_tags do
|
||||
Integer :site_id
|
||||
Integer :tag_id
|
||||
end
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_table :site_tags
|
||||
}
|
||||
end
|
|
@ -34,17 +34,17 @@ class Site < Sequel::Model
|
|||
super
|
||||
|
||||
if values[:username].nil? || values[:username].empty?
|
||||
errors.add :username, 'valid username is required'
|
||||
errors.add :username, 'A valid username is required.'
|
||||
end
|
||||
|
||||
# Check for existing user
|
||||
user = self.class.select(:username).filter(username: values[:username]).first
|
||||
if !user.nil? && (user.id != values[:id])
|
||||
errors.add :username, 'this username is already taken'
|
||||
errors.add :username, 'This username is already taken. Try using another one.'
|
||||
end
|
||||
|
||||
if values[:password].nil? || (@password_length && @password_length < MINIMUM_PASSWORD_LENGTH)
|
||||
errors.add :password, "password must be at least #{MINIMUM_PASSWORD_LENGTH} characters"
|
||||
errors.add :password, "Password must be at least #{MINIMUM_PASSWORD_LENGTH} characters."
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
::-webkit-input-placeholder { /* WebKit browsers */
|
||||
color: #999;
|
||||
}
|
||||
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
|
||||
color: #999;
|
||||
}
|
||||
::-moz-placeholder { /* Mozilla Firefox 19+ */
|
||||
color: #999;
|
||||
}
|
||||
:-ms-input-placeholder { /* Internet Explorer 10+ */
|
||||
color: #999;
|
||||
}
|
||||
|
||||
textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"], .uneditable-input {
|
||||
color: #000000;
|
||||
}
|
1
public/sites/.gitignore
vendored
Normal file
1
public/sites/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
h1 Your free home page is waiting.. once again.
|
||||
|
||||
h2 NeoCities allows you to create your own free home page!
|
||||
h3 NeoCities allows you to create your own free home page.
|
||||
|
||||
div style="margin-top: 30px"
|
||||
|
||||
|
@ -26,4 +26,6 @@
|
|||
td Hopefully with donations. If you feel this is a useful service, help us pay the bills to run it. <a href="/donate">Click here to contribute!</a>
|
||||
div.text-center
|
||||
h1: a href="/new" JOIN NOW
|
||||
|
||||
h5 style="margin-top: 30px" Returning users: <a href="/signin">Sign In</a>
|
||||
|
||||
|
|
|
@ -17,6 +17,12 @@ html
|
|||
.navbar
|
||||
.navbar-inner
|
||||
a.brand href="/" NeoCities
|
||||
ul.nav.pull-right
|
||||
- if signed_in?
|
||||
li.navbar-text: strong style="color: #7AB800" #{session[:username]}
|
||||
li: a href="/signout" style="color: #B94A48" Signout
|
||||
- else
|
||||
li: a href="/signin" <b>Sign in</b>
|
||||
|
||||
- flash.keys.each do |key|
|
||||
div class="alert alert-#{key}"
|
||||
|
|
|
@ -1,18 +1,26 @@
|
|||
|
||||
- if !@site.errors.empty?
|
||||
.row
|
||||
.span8.offset2
|
||||
.alert.alert-block.alert-error
|
||||
p Please correct the following errors:
|
||||
- @site.errors.each do |error|
|
||||
p = error.last.first
|
||||
|
||||
.row
|
||||
.span8.offset3
|
||||
form method="POST" action="/create"
|
||||
h2 Create a new Home Page
|
||||
|
||||
|
||||
.row
|
||||
.span6
|
||||
p First, enter a username. This will be used to login to your site.
|
||||
p First, enter a username. This will be used to login to your site.<br>It will also be the path of your web site.
|
||||
|
||||
.row
|
||||
.span1
|
||||
h5 Username
|
||||
.span6
|
||||
input name="username" type="text" style="color: #000000" placeholder="bulbasaur1000"
|
||||
p http://neocities.org/<input name="username" type="text" placeholder="yourusername">
|
||||
|
||||
.row
|
||||
.span6
|
||||
|
@ -22,17 +30,30 @@
|
|||
.span1
|
||||
h5 Password
|
||||
.span6
|
||||
input name="password" type="password" style="color: #000000"
|
||||
input name="password" type="password"
|
||||
|
||||
.row
|
||||
.span6
|
||||
p Now, you can enter an e-mail address if you want to be able to reset your password incase you lose it. This is optional, but recommended. <b>We will not give your email to anybody</b>.
|
||||
p Now you can enter an e-mail address. You don't have to provide one, but <b>we will not be able to reset your password without it, so don't lose your username and password if you leave this blank!</b>
|
||||
.row
|
||||
.span1
|
||||
h5 Email
|
||||
.span6
|
||||
input name="email" type="text" style="color: #000000" placeholder="youremail@example.com"
|
||||
input name="email" type="text" placeholder="youremail@example.com"
|
||||
|
||||
|
||||
.row
|
||||
.span6
|
||||
p
|
||||
| Enter some tags! Tags will allow others to find your site based on your interests, or your site's theme. <b>Separate multiple tags with commas</b>. Don't think too hard about this, you can change them later. You can have a maximum of ten tags, and there is a two word per tag maximum.
|
||||
|
||||
.row
|
||||
.span1
|
||||
h5 Tags
|
||||
.span6
|
||||
p: input name="tags" type="text" style="width: 400px" placeholder="pokemon, video games, bulbasaur"
|
||||
|
||||
|
||||
.row style="margin-top: 30px"
|
||||
.span3.offset1
|
||||
input.btn.btn-success.btn-large type="submit" value="Create Home Page"
|
14
views/signin.slim
Normal file
14
views/signin.slim
Normal file
|
@ -0,0 +1,14 @@
|
|||
.text-center
|
||||
.row
|
||||
.span12
|
||||
h1 Welcome back!
|
||||
.row
|
||||
.span12
|
||||
form method="POST" action="/signin"
|
||||
fieldset
|
||||
div: input name="username" type="text" placeholder="Your username"
|
||||
div: input name="password" type="password" placeholder="Your password"
|
||||
div: button class="btn btn-large btn-success" href="#" style="margin-top: 10px" Sign in
|
||||
.row
|
||||
.span12
|
||||
a href="/new" I don't have an account yet.
|
Loading…
Add table
Reference in a new issue