Add gravatar to profile page. Attempt to make profile look nicer.

This commit is contained in:
Christoph Haas 2021-03-10 02:33:40 +01:00
parent d504e5e914
commit 4e07bf00fd
6 changed files with 116 additions and 47 deletions

View file

@ -146,3 +146,6 @@ gem 'omniauth-rails_csrf_protection'
# Role-based access
gem 'cancancan'
# Gravatars
gem 'gravtastic'

View file

@ -131,6 +131,7 @@ GEM
sprockets-es6 (>= 0.9.0)
globalid (0.4.2)
activesupport (>= 4.2.0)
gravtastic (3.2.6)
guard (2.16.2)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
@ -438,6 +439,7 @@ DEPENDENCIES
fastimage
font-awesome-rails
foundation-rails (~> 6.6)
gravtastic
guard-minitest
guard-rails
image_processing

View file

@ -611,3 +611,8 @@ a.black
.label.adminlabel.public { background-color: green !important};
.label.adminlabel.hidden { background-color: blue !important};
.label.adminlabel.unapproved { background-color: orange !important};
.gravatar {
border-radius: 50%;
width: 120px;
}

View file

@ -20,6 +20,9 @@ class User < ApplicationRecord
# :github
]
include Gravtastic
gravtastic size: 120
# Return a human-friendly string describing the user's SSO provider
def pretty_provider
case self.provider
@ -40,11 +43,24 @@ class User < ApplicationRecord
end
end
# Check if a user has been created on-the-fly and is just an
# anonymous user who uploaded a screenshot. They can turn this
# user record into a registered account though.
def is_anonymous?
self.provider == nil
def pretty_name
if self.pseudo
'Anonymous'
elsif self.name?
self.name
else
'Dr. Who'
end
end
def pretty_role
if self.pseudo
'Contributor'
elsif self.moderator_role
'Moderator'
elsif self.admin_role
'Admin'
end
end
def self.from_omniauth(auth)

View file

@ -1,16 +1,17 @@
= render partial: 'menu'
// Paginator and search bar
.grid-x
.small-6.medium-8.large-9.cell
// Paginator
= render(partial: 'packages/paginator', locals: {items: @logs})
/ .small-6.medium-4.large-3.cell
/ // Search form
/ = render 'packages/searchfield'
- if @logs
// Paginator
.grid-x
.small-6.medium-8.large-9.cell
// Paginator
= render(partial: 'packages/paginator', locals: {items: @logs})
table
thead
tr
@ -46,6 +47,12 @@
' -
td #{log.ip_address}
.grid-x
.small-6.medium-8.large-9.cell
// Paginator
= render(partial: 'packages/paginator', locals: {items: @logs})
- else
p Nothing here.

View file

@ -1,45 +1,81 @@
= render partial: 'menu'
h1 Your data
- unless current_user.name.blank?
h2 Your name
= current_user.name
/ h2 Number of screenshots you uploaded
/ p = current_user.screenshots.count
- unless current_user.email.blank?
h2 Your email address
p = current_user.email
p.help-text
' This web site recognizes you by your email address.
' Don't worry - it will not be shown or given to anyone.
- if current_user.provider == 'salsa'
h1 Information for Debian project members
p
|
You are recognized as a member of the Debian project.
Thanks for visiting. Your account has moderation privileges.
That means you can approve screenshots uploaded by visitors.
If screenshots are waiting for moderation you will see a
prominent red bar right at the top. You can also upload your
own screenshots which are going public instantly.
If you stumble upon screenshots that you find offending,
misleading or just useless then feel free to hide them.
Every screenshot will have a status label and action buttons
that are only visible to you.
- unless current_user.provider.blank?
h2 Account provider
p You logged in using #{current_user.pretty_provider}.
p
|
If you have any questions about this web site please contact
Christoph Haas (haas) or Paul Wise (pabs).
h2 Number of screenshots you uploaded
p = current_user.screenshots.count
h2 Your permissions
ul
- if can? :approve, Screenshot.new
li
=> fa_icon 'thumbs-up'
'approve uploaded screenshots
- if can? :destroy, Screenshot.new
li
=> fa_icon 'trash'
'delete screenshots
- if can? :hide, Screenshot.new
li
=> fa_icon 'eye-slash'
'hide screenshots from the public
- if can? :unhide, Screenshot.new
li
=> fa_icon 'eye'
'restore (unhide) screenshots for the public
- if can? :view, Log
li
=> fa_icon 'book'
'view logs
.grid-x
.cell.auto
.cell.small-8.card style="background-color: blue"
.card
.grid-x.grid-padding-x.grid-padding-y.align-middle
.cell.small-2
= image_tag current_user.gravatar_url, class: "gravatar"
.cell.small-6
h3 = current_user.pretty_name
- unless current_user.email.blank?
div
i = current_user.email
- unless current_user.provider.blank?
div Logged in via #{current_user.pretty_provider}.
.cell
hr
.card-section
h3 You are
p
= current_user.pretty_role
.cell
hr
.card-section
h3 Your permissions
ul
- if can? :approve, Screenshot.new
li
=> fa_icon 'thumbs-up'
'approve uploaded screenshots
- if can? :destroy, Screenshot.new
li
=> fa_icon 'trash'
'delete screenshots
- if can? :hide, Screenshot.new
li
=> fa_icon 'eye-slash'
'hide screenshots from the public
- if can? :unhide, Screenshot.new
li
=> fa_icon 'eye'
'restore (unhide) screenshots for the public
- if can? :view, Log
li
=> fa_icon 'book'
'view logs
.cell.auto