From 35d55c1e7142feb336c6d28a2da4b34f06b66712 Mon Sep 17 00:00:00 2001 From: riggraz Date: Mon, 19 Aug 2019 17:42:13 +0200 Subject: [PATCH] Add gravatar picture to header --- app/javascript/stylesheets/application.scss | 4 ++++ app/javascript/stylesheets/navbar.scss | 12 +++++++++++- app/models/user.rb | 5 +++++ app/views/devise/registrations/edit.html.erb | 7 ++++--- app/views/devise/registrations/new.html.erb | 2 +- app/views/layouts/_header.html.erb | 5 +++-- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/javascript/stylesheets/application.scss b/app/javascript/stylesheets/application.scss index e4554c08..1b2aa131 100644 --- a/app/javascript/stylesheets/application.scss +++ b/app/javascript/stylesheets/application.scss @@ -4,4 +4,8 @@ .container { max-width: 920px; +} + +.gravatar { + border-radius: 16px; } \ No newline at end of file diff --git a/app/javascript/stylesheets/navbar.scss b/app/javascript/stylesheets/navbar.scss index 156e19dd..7762a990 100644 --- a/app/javascript/stylesheets/navbar.scss +++ b/app/javascript/stylesheets/navbar.scss @@ -9,4 +9,14 @@ font-size: 18pt; font-weight: 700; } -} \ No newline at end of file + + .fullname { + vertical-align: middle; + + color: black; + } + + .dropdown-toggle::after { + vertical-align: middle; + } +} diff --git a/app/models/user.rb b/app/models/user.rb index 45af2ee7..376c45c7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,6 +8,11 @@ class User < ApplicationRecord self.role ||= :user end + def gravatar_url + gravatar_id = Digest::MD5::hexdigest(email.downcase) + "https://secure.gravatar.com/avatar/#{gravatar_id}" + end + devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :confirmable diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 551fa1f5..401c7853 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,4 +1,4 @@ -

Edit <%= resource_name.to_s.humanize %>

+

Profile settings

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> @@ -11,6 +11,9 @@
<%= f.label :email %> <%= f.email_field :email, autocomplete: "email", class: "form-control" %> + + the email is gravatarized +
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> @@ -53,5 +56,3 @@

Cancel my account

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete, class: "btn btn-danger" %>

- -<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index bcbf01d0..4731fcc9 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -18,7 +18,7 @@ <%= f.password_field :password, autocomplete: "new-password", class: "form-control" %> <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum) + <%= @minimum_password_length %> characters minimum <% end %> diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 0b233b25..a36beeb0 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,6 +1,6 @@