Skip to content

Commit

Permalink
Add devise and styling
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-ende committed Feb 7, 2020
1 parent c2b0c37 commit 5f5089f
Show file tree
Hide file tree
Showing 27 changed files with 954 additions and 7 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ gem 'jbuilder', '~> 2.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
gem 'devise'
gem 'twitter-bootstrap-rails'
gem 'devise-i18n'
gem 'devise-bootstrap-views'
gem 'jquery-rails'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
Expand Down
38 changes: 38 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GEM
zeitwerk (~> 2.2)
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
bcrypt (3.1.13)
bindex (0.8.1)
bootsnap (1.4.5)
msgpack (~> 1.0)
Expand All @@ -72,16 +73,37 @@ GEM
regexp_parser (~> 1.5)
xpath (~> 3.2)
childprocess (3.0.0)
commonjs (0.2.7)
concurrent-ruby (1.1.5)
crass (1.0.6)
devise (4.7.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
devise-bootstrap-views (1.1.0)
devise-i18n (1.9.0)
devise (>= 4.7.1)
erubi (1.9.0)
execjs (2.7.0)
ffi (1.12.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
jbuilder (2.9.1)
activesupport (>= 4.2.0)
jquery-rails (4.3.5)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
less (2.6.0)
commonjs (~> 0.2.7)
less-rails (4.0.0)
actionpack (>= 4)
less (~> 2.6.0)
sprockets (>= 2)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
Expand All @@ -102,6 +124,7 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.7)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pg (1.2.2)
public_suffix (4.0.3)
puma (4.3.1)
Expand Down Expand Up @@ -142,6 +165,9 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (1.6.0)
responders (3.0.0)
actionpack (>= 5.0)
railties (>= 5.0)
ruby_dep (1.5.0)
rubyzip (2.2.0)
sass-rails (6.0.0)
Expand Down Expand Up @@ -175,8 +201,15 @@ GEM
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
twitter-bootstrap-rails (3.2.2)
actionpack (>= 3.1)
execjs (>= 2.2.2, >= 2.2)
less-rails (>= 2.5.0)
railties (>= 3.1)
tzinfo (1.2.6)
thread_safe (~> 0.1)
warden (1.2.8)
rack (>= 2.0.6)
web-console (4.0.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -204,7 +237,11 @@ DEPENDENCIES
bootsnap (>= 1.4.2)
byebug
capybara (>= 2.15)
devise
devise-bootstrap-views
devise-i18n
jbuilder (~> 2.7)
jquery-rails
listen (>= 3.0.5, < 3.2)
pg
puma (~> 4.1)
Expand All @@ -215,6 +252,7 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0.0)
sqlite3 (~> 1.4)
turbolinks (~> 5)
twitter-bootstrap-rails
tzinfo-data
web-console (>= 3.3.0)
webdrivers
Expand Down
1 change: 1 addition & 0 deletions app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link application.js
11 changes: 11 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require rails-ujs
//= require jquery
//= require twitter/bootstrap
//= require turbolinks
//= require_tree .
4 changes: 4 additions & 0 deletions app/assets/javascripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jQuery(function() {
$("a[rel~=popover], .has-popover").popover();
$("a[rel~=tooltip], .has-tooltip").tooltip();
});
7 changes: 7 additions & 0 deletions app/assets/stylesheets/bootstrap_and_overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
=require twitter-bootstrap-static/bootstrap
Use Font Awesome icons (default)
To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
=require twitter-bootstrap-static/fontawesome
*/
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
1 change: 1 addition & 0 deletions app/controllers/welcome_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class WelcomeController < ApplicationController
skip_before_action :authenticate_user!, only: [:index]
def index

end
Expand Down
6 changes: 6 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :validatable
end
16 changes: 16 additions & 0 deletions app/views/devise/confirmations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1><%= t('.resend_confirmation_instructions') %></h1>

<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= bootstrap_devise_error_messages! %>

<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email), class: 'form-control' %>
</div>

<div class="form-group">
<%= f.submit t('.resend_confirmation_instructions'), class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'devise/shared/links' %>
26 changes: 26 additions & 0 deletions app/views/devise/passwords/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<h1><%= t('.change_your_password') %></h1>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= bootstrap_devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>

<div class="form-group">
<%= f.label :password, t('.new_password') %>
<%= f.password_field :password, autofocus: true, class: 'form-control' %>

<% if @minimum_password_length %>
<small class="form-text text-muted"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></small>
<% end %>
</div>

<div class="form-group">
<%= f.label :password_confirmation, t('.confirm_new_password') %>
<%= f.password_field :password_confirmation, autocomplete: 'off', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.submit t('.change_my_password'), class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'devise/shared/links' %>
16 changes: 16 additions & 0 deletions app/views/devise/passwords/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1><%= t('.forgot_your_password') %></h1>

<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= bootstrap_devise_error_messages! %>

<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.submit t('.send_me_reset_password_instructions'), class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'devise/shared/links' %>
37 changes: 37 additions & 0 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<h1><%= t('.title', resource: resource_name.to_s.humanize) %></h1>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= bootstrap_devise_error_messages! %>

<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'new-password', class: 'form-control' %>

<small class="form-text text-muted"><%= t('.leave_blank_if_you_don_t_want_to_change_it') %></small>
</div>

<div class="form-group">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.label :current_password %>
<%= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control' %>

<small class="form-text text-muted"><%= t('.we_need_your_current_password_to_confirm_your_changes') %></small>
</div>

<div class="form-group">
<%= f.submit t('.update'), class: 'btn btn-primary' %>
</div>
<% end %>

<p><%= t('.unhappy') %>? <%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete %>.</p>

<%= link_to t('.back'), :back %>
30 changes: 30 additions & 0 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<h1><%= t('.sign_up') %></h1>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= bootstrap_devise_error_messages! %>

<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %>

<% if @minimum_password_length %>
<small class="form-text text-muted"><%= t('devise.shared.minimum_password_length', count: @minimum_password_length) %></small>
<% end %>
</div>

<div class="form-group">
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, autocomplete: 'current-password', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.submit t('.sign_up'), class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'devise/shared/links' %>
28 changes: 28 additions & 0 deletions app/views/devise/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<h1><%= t('.sign_in') %></h1>

<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.label :password %>
<%= f.password_field :password, autocomplete: 'current-password', class: 'form-control' %>
</div>

<% if devise_mapping.rememberable? %>
<div class="form-group form-check">
<%= f.check_box :remember_me, class: 'form-check-input' %>
<%= f.label :remember_me, class: 'form-check-label' do %>
<%= resource.class.human_attribute_name('remember_me') %>
<% end %>
</div>
<% end %>

<div class="form-group">
<%= f.submit t('.sign_in'), class: 'btn btn-primary' %>
</div>
<% end %>

<%= render 'devise/shared/links' %>
27 changes: 27 additions & 0 deletions app/views/devise/shared/_links.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="form-group">
<%- if controller_name != 'sessions' %>
<%= link_to t(".sign_in"), new_session_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to t(".sign_up"), new_registration_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to t(".forgot_your_password"), new_password_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to t('.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to t('.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name) %><br />
<% end -%>

<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to t('.sign_in_with_provider', provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
</div>
16 changes: 16 additions & 0 deletions app/views/devise/unlocks/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<h1><%= t('.resend_unlock_instructions') %></h1>

<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= bootstrap_devise_error_messages! %>

<div class="form-group">
<%= f.label :email %>
<%= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' %>
</div>

<div class="form-group">
<%= f.submit t('.resend_unlock_instructions'), class: 'btn btn-primary'%>
</div>
<% end %>

<%= render 'devise/shared/links' %>
Loading

0 comments on commit 5f5089f

Please sign in to comment.