1
0
forked from finn/site

avatar tweaks

This commit is contained in:
finn 2024-08-04 10:55:28 -07:00
parent 2f920f3b6f
commit 94434d4f8e
3 changed files with 6 additions and 4 deletions

View File

@ -52,8 +52,8 @@ class User(UserMixin, db.Model):
digest = hashlib.md5(self.email.lower().encode('utf-8')).hexdigest() digest = hashlib.md5(self.email.lower().encode('utf-8')).hexdigest()
basedir = os.path.abspath(os.path.dirname(__file__)) basedir = os.path.abspath(os.path.dirname(__file__))
pngloc = os.path.join(basedir, 'usercontent', 'identicon', str(digest) + '.png') pngloc = os.path.join(basedir, 'usercontent', 'identicon', str(digest) + '.png')
icongen = pydenticon.Generator(5, 5, digest=hashlib.md5, foreground=foreground, background=background) icongen = pydenticon.Generator(8, 5, digest=hashlib.md5, foreground=foreground, background=background)
pngicon = icongen.generate(self.email, 120, 120, padding=(10, 10, 10, 10), inverted=False, output_format="png") pngicon = icongen.generate(self.email, 150, 240, padding=(10, 10, 10, 10), inverted=False, output_format="png")
if write_png: if write_png:
pngfile = open(pngloc, "wb") pngfile = open(pngloc, "wb")
pngfile.write(pngicon) pngfile.write(pngicon)

View File

@ -1,6 +1,6 @@
<table> <table>
<tr valign="top"> <tr valign="top">
<td><img width="60" height=="60" src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}"></td> <td style="vertical-align: middle;"><img style="vertical-align: middle; width: 40px;" src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}"></td>
<td>{{ post.author.username }} says:<br>{{ post.body }}</td> <td>{{ post.author.username }} says:<br>{{ post.body }}</td>
</tr> </tr>
</table> </table>

View File

@ -3,7 +3,9 @@
{% block content %} {% block content %}
<table> <table>
<tr valign="top"> <tr valign="top">
<td><img src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}"></td> <td style="vertical-align: middle; text-align: center;">
<img style="vertical-align: middle;" src="data:image/png;base64,{{ user.gen_avatar(write_png=False) }}">
</td>
<td> <td>
<h1>User: {{ user.username }}</h1> <h1>User: {{ user.username }}</h1>
<h1>CUdebug: {{ current_user }}</h1> <h1>CUdebug: {{ current_user }}</h1>