diff --git a/.gitignore b/.gitignore index 373d26e6..a8b32f1e 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ _yardoc doc/ tests/coverage config.yml +.DS_Store diff --git a/Gemfile.lock b/Gemfile.lock index c449aa5d..b1714a9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app.rb b/app.rb index 53d14aff..90226142 100644 --- a/app.rb +++ b/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 diff --git a/migrations/003_create_tags.rb b/migrations/003_create_tags.rb new file mode 100644 index 00000000..14765bba --- /dev/null +++ b/migrations/003_create_tags.rb @@ -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 \ No newline at end of file diff --git a/migrations/004_create_site_tags.rb b/migrations/004_create_site_tags.rb new file mode 100644 index 00000000..66d61b72 --- /dev/null +++ b/migrations/004_create_site_tags.rb @@ -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 \ No newline at end of file diff --git a/models/site.rb b/models/site.rb index 4083aa90..d104dd4f 100644 --- a/models/site.rb +++ b/models/site.rb @@ -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 \ No newline at end of file diff --git a/public/css/styles.css b/public/css/styles.css index e69de29b..62aa663d 100644 --- a/public/css/styles.css +++ b/public/css/styles.css @@ -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; +} \ No newline at end of file diff --git a/public/sites/.gitignore b/public/sites/.gitignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/public/sites/.gitignore @@ -0,0 +1 @@ +* diff --git a/views/index.slim b/views/index.slim index 8a67e216..6fa5e75c 100644 --- a/views/index.slim +++ b/views/index.slim @@ -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. Click here to contribute! div.text-center h1: a href="/new" JOIN NOW + + h5 style="margin-top: 30px" Returning users: Sign In diff --git a/views/layout.slim b/views/layout.slim index 584b8c06..5d337d49 100644 --- a/views/layout.slim +++ b/views/layout.slim @@ -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" Sign in - flash.keys.each do |key| div class="alert alert-#{key}" diff --git a/views/new.slim b/views/new.slim index 0a9ff1fd..c028362b 100644 --- a/views/new.slim +++ b/views/new.slim @@ -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.
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/ .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. We will not give your email to anybody. + p Now you can enter an e-mail address. You don't have to provide one, but we will not be able to reset your password without it, so don't lose your username and password if you leave this blank! .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. Separate multiple tags with commas. 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" \ No newline at end of file diff --git a/views/signin.slim b/views/signin.slim new file mode 100644 index 00000000..11e8720e --- /dev/null +++ b/views/signin.slim @@ -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. \ No newline at end of file