1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add basic gravatar support

This commit is contained in:
Steffo 2019-01-08 21:03:18 +01:00
parent e5d3d040de
commit ada0f4badb
5 changed files with 24 additions and 3 deletions

10
db.py
View file

@ -21,9 +21,10 @@ import loldata
from dirty import Dirty
import query_discord_music
from flask import escape
import libgravatar
import configparser
# Init the config reader
import configparser
config = configparser.ConfigParser()
config.read("config.ini")
@ -47,6 +48,7 @@ class Royal(Base):
role = Column(String)
fiorygi = Column(Integer, default=0)
member_since = Column(Date)
email = Column(String)
@staticmethod
def create(session: Session, username: str):
@ -58,6 +60,12 @@ class Royal(Base):
def __repr__(self):
return f"<db.Royal {self.username}>"
def get_gravatar_url(self):
if self.email is None:
return f"https://www.gravatar.com/avatar/{libgravatar.md5_hash(self.username)}?d=identicon&f=y"
gravatar = libgravatar.Gravatar(self.email)
return gravatar.get_image(default="identicon")
class Telegram(Base):
__tablename__ = "telegram"

View file

@ -15,4 +15,5 @@ praw
dice
raven[flask]
coloredlogs
sentry_sdk
sentry_sdk
libgravatar

View file

@ -241,6 +241,13 @@ img {
}
}
.gravatar {
border-radius: 16px;
width: 32px;
height: 32px;
vertical-align: middle;
}
.whatsthis {
font-size: large;
}
@ -713,6 +720,10 @@ img {
grid-column-start: 1;
grid-column-end: 3;
font-weight: bold;
.player-image {
border-radius: 16px;
}
}
.member-status {

View file

@ -24,6 +24,7 @@
{% endif %}
<span class="login-status">
{% if g.user is not none %}
<img src="{{ g.user.get_gravatar_url() }}" class="gravatar">
<a href="{{ url_for('page_profile', name=g.user.username) }}">{{ g.user.username }}</a>
<a class="btn" href="{{ url_for('page_logout') }}">Logout</a>
{% else %}

View file

@ -1,7 +1,7 @@
<div class="game-panel">
<div class="game-grid ryg">
<div class="player">
<span class="player-name"><a href="https://ryg.steffo.eu/profile/{{ record.username }}">{{ record.username }}</a></span>
<img class="player-image gravatar" src="{{ record.get_gravatar_url() }}"> <span class="player-name"><a href="https://ryg.steffo.eu/profile/{{ record.username }}">{{ record.username }}</a></span>
</div>
<div class="member-status">
<span class="role">{{ record.role }}</span> dal <span class="member-since">{% if record.member_since %}{{ record.member_since }}{% else %}????-??-??{% endif %}</span>