Skip to content

Commit

Permalink
remove gravatar
Browse files Browse the repository at this point in the history
  • Loading branch information
nitely committed Sep 19, 2020
1 parent da0b4bd commit 7e288d3
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ <h2 class="headline">{% trans "Comment flagged" %}</h2>
<div class="comments_list">
<div class="comments_list__comment">
<div class="comment__img">
<img
class="comment__img__avatar"
src="{% get_gravatar_url user=flag.comment.user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color flag.comment.user_id %};"
>{{ flag.comment.user.st.nickname.0.upper }}</div>
</div>
<div class="comment__info">
<div class="comment__info__username">
Expand Down Expand Up @@ -82,9 +83,10 @@ <h2 class="headline">{% trans "Reporters" %}</h2>
<div class="comments_list">
<div class="comments_list__comment no-footer">
<div class="comment__img">
<img
class="comment__img__avatar"
src="{% get_gravatar_url user=f.user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color f.user_id %};"
>{{ f.user.st.nickname.0.upper }}</div>
</div>
<div class="comment__info">
<div class="comment__info__username">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ <h1 class="headline">{% trans "Comment history" %}</h1>
{% for c in comments %}
<div class="comments_list__comment no-footer">
<div class="comment__img">
<img
class="comment__img__avatar"
src="{% get_gravatar_url user=c.comment_fk.user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color c.comment_fk.user_id %};"
>{{ c.comment_fk.user.st.nickname.0.upper }}</div>
</div>
<div class="comment__info">
<div class="comment__info__username">
Expand Down
8 changes: 4 additions & 4 deletions spirit/comment/templates/spirit/comment/_render_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
data-pk="{{ c.pk }}"
>
<div class="comment__img">
<img
class="comment__img__avatar"
alt=""
src="{% get_gravatar_url user=c.user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color c.user_id %};"
>{{ c.user.st.nickname.0.upper }}</div>
</div>
<div class="comment__info">
{% spaceless %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h1 class="headline">Topic title here</h1>
<div class="comments_list">
<div class="comments_list__comment">
<div class="comment__img">
<img class="comment__img__avatar" src="avatar.png" />
<div class="comment__img__avatar no-pic">N</div>
</div>
<div class="comment__info">
<div class="comment__info__username">
Expand Down
24 changes: 24 additions & 0 deletions spirit/core/static/spirit/stylesheets/src/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,18 @@
height: 50px;
border-radius: 25px;
}
&.no-pic {
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
line-height: 22px;
background-color: var(--st-bg-user-pic);
@media #{$medium} {
font-size: 25px;
line-height: 25px;
}
}
}
.comment__info {
grid-area: io;
Expand Down Expand Up @@ -947,6 +959,18 @@ del.diff {
height: 200px;
border-radius: 100px;
}
&.no-pic {
display: flex;
align-items: center;
justify-content: center;
font-size: 50px;
line-height: 50px;
background-color: var(--st-bg-user-pic);
@media #{$medium} {
font-size: 100px;
line-height: 100px;
}
}
}
.profile__img__username {
font-size: rem(18px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $yellow: #ffffe9 !default;
--st-text-comment-badge: var(--st-text-sec);
--st-bg-comment-diff-ins: $light-green;
--st-bg-comment-diff-del: $light-red;
--st-bg-user-pic: var(--st-bg-sec);
--st-bg-admin-stat: var(--st-bg-qua);
--st-br-textarea: var(--st-bg-sec);
--st-br-input-focus: var(--st-highlight-prim);
Expand Down
2 changes: 1 addition & 1 deletion spirit/core/static/spirit/stylesheets/styles.all.min.css

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions spirit/core/static/spirit/stylesheets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
--st-text-comment-badge: var(--st-text-sec);
--st-bg-comment-diff-ins: #eaffea;
--st-bg-comment-diff-del: #fce2e2;
--st-bg-user-pic: var(--st-bg-sec);
--st-bg-admin-stat: var(--st-bg-qua);
--st-br-textarea: var(--st-bg-sec);
--st-br-input-focus: var(--st-highlight-prim);
Expand Down Expand Up @@ -4973,6 +4974,17 @@ html input[disabled] {
width: 50px;
height: 50px;
border-radius: 25px; } }
.spirit .comment__img__avatar.no-pic {
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
line-height: 22px;
background-color: var(--st-bg-user-pic); }
@media screen and (min-width: 768px) {
.spirit .comment__img__avatar.no-pic {
font-size: 25px;
line-height: 25px; } }
.spirit .comment__info {
grid-area: io;
font-size: 0.875rem;
Expand Down Expand Up @@ -5305,6 +5317,17 @@ html input[disabled] {
width: 200px;
height: 200px;
border-radius: 100px; } }
.spirit .profile__img__avatar.no-pic {
display: flex;
align-items: center;
justify-content: center;
font-size: 50px;
line-height: 50px;
background-color: var(--st-bg-user-pic); }
@media screen and (min-width: 768px) {
.spirit .profile__img__avatar.no-pic {
font-size: 100px;
line-height: 100px; } }
.spirit .profile__img__username {
font-size: 1.125rem; }
.spirit .profile__info {
Expand Down
10 changes: 3 additions & 7 deletions spirit/core/tags/avatar.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# -*- coding: utf-8 -*-

import math

from django.utils.encoding import smart_text

from .registry import register


@register.simple_tag()
def get_avatar_color(user):
# returns 0-215
return smart_text(int(215 * math.log10(user.pk)))
def get_avatar_color(user_id):
hue = (user_id % 37) * 10
return "hsl({}, 75%, 25%)".format(hue)
17 changes: 0 additions & 17 deletions spirit/core/tags/gravatar.py

This file was deleted.

2 changes: 0 additions & 2 deletions spirit/core/templatetags/spirit_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from ...topic.notification import tags as topic_notification
from ...topic.private import tags as topic_private
from ..tags import avatar
from ..tags import gravatar
from ..tags import messages
from ..tags import paginator
from ..tags import settings
Expand All @@ -25,7 +24,6 @@
'topic_notification',
'topic_private',
'avatar',
'gravatar',
'messages',
'paginator',
'settings',
Expand Down
28 changes: 28 additions & 0 deletions spirit/core/tests/tests_avatar.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-

from django.test import TestCase
from django.template import Template, Context

from . import utils


class AvatarTemplateTagTests(TestCase):
def setUp(self):
self.user = utils.create_user()

def test_get_avatar_color(self):
out = Template(
"{% load spirit_tags %}"
"{% get_avatar_color 0 %}"
).render(Context(autoescape=False))
self.assertEqual(out, "hsl(0, 75%, 25%)")
out = Template(
"{% load spirit_tags %}"
"{% get_avatar_color 36 %}"
).render(Context(autoescape=False))
self.assertEqual(out, "hsl(360, 75%, 25%)")
out = Template(
"{% load spirit_tags %}"
"{% get_avatar_color 37 %}"
).render(Context(autoescape=False))
self.assertEqual(out, "hsl(0, 75%, 25%)")
21 changes: 0 additions & 21 deletions spirit/core/tests/tests_gravatar.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ <h1 class="headline">{{ topic.title }}</h1>

<div id="reply" class="comments__reply">
<div class="comments__reply__img">
<img
alt=""
class="comment__img__avatar"
src="{% get_gravatar_url user=user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color user.pk %};"
>{{ user.st.nickname.0.upper }}</div>
</div>
<div class="comment__reply__info">
<a
Expand Down
8 changes: 4 additions & 4 deletions spirit/topic/templates/spirit/topic/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ <h1 class="headline">
{% if not topic.is_closed %}
<div id="reply" class="comments__reply">
<div class="comments__reply__img">
<img
alt=""
class="comment__img__avatar"
src="{% get_gravatar_url user=user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color user.pk %};"
>{{ user.st.nickname.0.upper }}</div>
</div>
<div class="comment__reply__info">
<a
Expand Down
7 changes: 4 additions & 3 deletions spirit/user/templates/spirit/user/_profile.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{% load spirit_tags i18n %}

<div class="profile__img">
<img
class="profile__img__avatar"
src="{% get_gravatar_url user=p_user size=200 %}" />
<div
class="profile__img__avatar no-pic"
style="background-color:{% get_avatar_color p_user.pk %};"
>{{ p_user.st.nickname.0.upper }}</div>
<div class="profile__img__username">{{ p_user.st.nickname }}</div>
</div>

Expand Down
8 changes: 4 additions & 4 deletions spirit/user/templates/spirit/user/_render_comments_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{% for c in comments %}
<div class="comments_list__comment no-footer">
<div class="comment__img">
<img
alt=""
class="comment__img__avatar"
src="{% get_gravatar_url user=c.user size=50 %}" />
<div
class="comment__img__avatar no-pic"
style="background-color:{% get_avatar_color c.user.pk %};"
>{{ c.user.st.nickname.0.upper }}</div>
</div>
<div class="comment__info">
<div class="comment__info__username">
Expand Down

0 comments on commit 7e288d3

Please sign in to comment.