Skip to content

Commit

Permalink
Add player profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
BGMP committed Nov 14, 2023
1 parent b0cf963 commit 7a26247
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 5 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ gem 'redcarpet', '~> 3.6' # The safe
gem 'redis', '>= 4.0.1' # Use Redis adapter to run Action Cable in production
gem 'responders', '~> 3.1' # A set of Rails responders to dry up your application
gem 'rubocop', :require => false # A Ruby static code analyzer and formatter
gem 'sanitize', '~> 6.1' # HTML & CSS Sanitizer
gem 'sentry-rails', '~> 5.11' # A gem that provides Rails integration for the Sentry error logger
gem 'sprockets-rails', '~> 3.4', '>= 3.4.2' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem 'stimulus-rails', '~> 1.2', '>= 1.2.2' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev]
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ GEM
kaminari-i18n (0.5.0)
kaminari
rails
kramdown (2.4.0)
rexml
language_server-protocol (3.17.0.3)
loofah (2.21.4)
crass (~> 1.0.2)
Expand Down Expand Up @@ -313,6 +315,9 @@ GEM
ruby_parser (3.20.3)
sexp_processor (~> 4.16)
rubyzip (2.3.2)
sanitize (6.1.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
selenium-webdriver (4.10.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
Expand Down Expand Up @@ -390,6 +395,7 @@ DEPENDENCIES
jsbundling-rails (~> 1.1)
kaminari (~> 1.2, >= 1.2.2)
kaminari-i18n (~> 0.5.0)
kramdown (~> 2.4)
mongoid (~> 8.1, >= 8.1.2)
omniauth (~> 2.1, >= 2.1.1)
puma (>= 5.0)
Expand All @@ -400,6 +406,7 @@ DEPENDENCIES
responders (~> 3.1)
rspec-rails (~> 6.0, >= 6.0.3)
rubocop
sanitize (~> 6.1)
selenium-webdriver
sentry-rails (~> 5.11)
sprockets-rails (~> 3.4, >= 3.4.2)
Expand Down
185 changes: 182 additions & 3 deletions app/assets/stylesheets/profiles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,182 @@
// Place all the styles related to the Profiles controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/
#profile {
@media (min-width: 900px) and (max-width: 1000px) {
.hidden-sm {
display: none !important;
}
}

@media (max-width: 1000px) {
.hidden-xs {
display: none !important;
}
}

h3 {
small {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
"Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
color: #999;
font-weight: bold;
}
}

h4, h5, h6 {
margin-top: 10px;
margin-bottom: 10px;
}

.stats .well {
padding: 19px;
}

.well {
min-height: 20px;
padding: 19px;
margin-bottom: 20px;
background-color: #212121;
border: 1px solid #646464;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}

.stats .rank {
display: inline-block;
min-width: 130px;
height: 52px;
}

.stats .total {
display: inline-block;
width: 25%;
min-width: 65px;
padding-top: 20px;
}

.stats .rank .number {
font-size: 36px;
}

.stats .total .number {
font-size: 24px;
font-weight: bold;
}

.stats .rank .name {
font-size: 16px;
margin-bottom: 3px;
}

.stats .name {
font-weight: bold;
color: #999;
}

.stats .number {
font-weight: bold;
}

hr {
margin-top: 3px;
margin-bottom: 10px;
border: 0;
border-top: 1px solid #646464;
}

.info {
pre {
display: block;
padding: 9.5px;
margin: 0 0 10px;
font-size: 13px;
line-height: 1.42857143;
color: #cccccc;
word-break: break-all;
word-wrap: break-word;
border-radius: 4px;
background-color: #212121;
border-color: #212121;
}

blockquote {
color: #cccccc;
margin-left: 15px;
}
}

.username {
font-size: 35px;
font-weight: bold;

.verified-icon {
color: #2ECC71;
font-size: 31px;
}

.verified-name {
text-decoration: none;
color: #beb8bc;
}
}

.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
color: #fff;
background-color: #000;
border-color: #fff;
}

.nav-link:hover, .nav-link:focus {
border-color: #fff;
background-color: rgba(0, 0, 0, 0.5);
}

.nav-item {
a {
color: #bdbdbd;
}
}

.nav-tabs {
border-bottom: 1px solid #fff;
}

.stat-label {
color: #646464;
}

// Staff group badges
.label, .badge {
text-shadow: none;
}

.label {
display: inline;
padding: .2em .6em .3em;
font-size: 12px;
font-weight: 700;
line-height: 1;
color: #fff;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: .25em;
margin-bottom: 15px;
}

a.label:focus, a.label:hover {
color: #fff;
text-decoration: none;
cursor: pointer;
}

.span9 {
margin-bottom: 5px;
}

#about {
h1, h2, h3 {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
"Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}
}
}
5 changes: 5 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class UsersController < ApplicationController
include ProfilesHelper

before_action :authenticate_user!, :except => [:show, :stats]
before_action :authenticate_admin, :only => [:new, :import]

Expand All @@ -10,6 +12,9 @@ def members

def show
@user = User.find_by!(:username => params[:username])

# TODO: Find player position in current season/ranking
# @ranking
end

def new
Expand Down
17 changes: 17 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ def precision(input, value = 0)
("%.#{value}f" % input)
end

def count_all(array, values_to_count)
array.count { |el| values_to_count.include?(el) }
end

def ordinal_ending(n)
ending = case n % 100
when 11, 12, 13 then 'th'
else
case n % 10
when 1 then 'st'
when 2 then 'nd'
when 3 then 'rd'
else 'th'
end
end
end

# @param content [String] Content
# @return [String] Parsed html and/or markdown text
def render_pretty(content, config = Sanitize::Config::RELAXED)
Expand Down
11 changes: 11 additions & 0 deletions app/helpers/profiles_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
module ProfilesHelper
def render_safe(content)
do_safe(do_sanitize(content))
end

def do_safe(content)
content.html_safe
end

def do_sanitize(content)
Sanitize.clean(content, Sanitize::Config::RELAXED)
end
end
6 changes: 6 additions & 0 deletions app/views/users/_badges.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- if user.admin?
%a.label{:href => staff_path, :style => "background-color: #dd7921; color: white;"} Administrator
- if user.mod?
%a.label{:href => staff_path, :style => "background-color: #dd212d; color: white;"} Moderator
- if user.organizer?
%a.label{:href => staff_path, :style => "background-color: #2ecc71; color: white;"} Organizer
Loading

0 comments on commit 7a26247

Please sign in to comment.