mirror of
https://github.com/RYGhub/royalnet.git
synced 2025-02-17 10:53:57 +00:00
Add basic gravatar support
This commit is contained in:
parent
e5d3d040de
commit
ada0f4badb
5 changed files with 24 additions and 3 deletions
10
db.py
10
db.py
|
@ -21,9 +21,10 @@ import loldata
|
||||||
from dirty import Dirty
|
from dirty import Dirty
|
||||||
import query_discord_music
|
import query_discord_music
|
||||||
from flask import escape
|
from flask import escape
|
||||||
|
import libgravatar
|
||||||
|
import configparser
|
||||||
|
|
||||||
# Init the config reader
|
# Init the config reader
|
||||||
import configparser
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read("config.ini")
|
config.read("config.ini")
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ class Royal(Base):
|
||||||
role = Column(String)
|
role = Column(String)
|
||||||
fiorygi = Column(Integer, default=0)
|
fiorygi = Column(Integer, default=0)
|
||||||
member_since = Column(Date)
|
member_since = Column(Date)
|
||||||
|
email = Column(String)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(session: Session, username: str):
|
def create(session: Session, username: str):
|
||||||
|
@ -58,6 +60,12 @@ class Royal(Base):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<db.Royal {self.username}>"
|
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):
|
class Telegram(Base):
|
||||||
__tablename__ = "telegram"
|
__tablename__ = "telegram"
|
||||||
|
|
|
@ -15,4 +15,5 @@ praw
|
||||||
dice
|
dice
|
||||||
raven[flask]
|
raven[flask]
|
||||||
coloredlogs
|
coloredlogs
|
||||||
sentry_sdk
|
sentry_sdk
|
||||||
|
libgravatar
|
|
@ -241,6 +241,13 @@ img {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.gravatar {
|
||||||
|
border-radius: 16px;
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
.whatsthis {
|
.whatsthis {
|
||||||
font-size: large;
|
font-size: large;
|
||||||
}
|
}
|
||||||
|
@ -713,6 +720,10 @@ img {
|
||||||
grid-column-start: 1;
|
grid-column-start: 1;
|
||||||
grid-column-end: 3;
|
grid-column-end: 3;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
|
.player-image {
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.member-status {
|
.member-status {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="login-status">
|
<span class="login-status">
|
||||||
{% if g.user is not none %}
|
{% 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 href="{{ url_for('page_profile', name=g.user.username) }}">{{ g.user.username }}</a>
|
||||||
<a class="btn" href="{{ url_for('page_logout') }}">Logout</a>
|
<a class="btn" href="{{ url_for('page_logout') }}">Logout</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="game-panel">
|
<div class="game-panel">
|
||||||
<div class="game-grid ryg">
|
<div class="game-grid ryg">
|
||||||
<div class="player">
|
<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>
|
||||||
<div class="member-status">
|
<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>
|
<span class="role">{{ record.role }}</span> dal <span class="member-since">{% if record.member_since %}{{ record.member_since }}{% else %}????-??-??{% endif %}</span>
|
||||||
|
|
Loading…
Add table
Reference in a new issue