mirror of
https://github.com/Fluffy-Bean/GameExpo23.git
synced 2025-05-25 04:14:53 +00:00
Update pfp preview on file uplaod
This commit is contained in:
parent
193c7d9d07
commit
5307946ce6
6 changed files with 53 additions and 28 deletions
|
@ -1,5 +1,3 @@
|
||||||
from random import randint
|
|
||||||
|
|
||||||
from flask import Flask, render_template, abort
|
from flask import Flask, render_template, abort
|
||||||
from flask_assets import Bundle
|
from flask_assets import Bundle
|
||||||
from werkzeug.exceptions import HTTPException
|
from werkzeug.exceptions import HTTPException
|
||||||
|
@ -53,8 +51,6 @@ def error_page(err):
|
||||||
abort(500)
|
abort(500)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
render_template(
|
render_template("error.html", error=err.code, msg=err.description),
|
||||||
"error.html", error=err.code, msg=err.description, image=str(randint(1, 3))
|
|
||||||
),
|
|
||||||
err.code,
|
err.code,
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
flex-direction: column
|
flex-direction: column
|
||||||
|
|
||||||
border: 1px solid RGBA($white, 0.1)
|
border: 1px solid RGBA($white, 0.1)
|
||||||
|
box-sizing: content-box
|
||||||
|
|
||||||
> img
|
> img
|
||||||
height: 10rem
|
height: 10rem
|
||||||
|
@ -67,7 +68,11 @@
|
||||||
gap: 0.5rem
|
gap: 0.5rem
|
||||||
|
|
||||||
> .text-input
|
> .text-input
|
||||||
margin: 0 !important
|
margin: 0
|
||||||
|
|
||||||
|
> button
|
||||||
|
margin: 0 0 0 auto
|
||||||
|
width: auto
|
||||||
|
|
||||||
@media (max-width: 621px)
|
@media (max-width: 621px)
|
||||||
.profile-settings
|
.profile-settings
|
||||||
|
@ -80,3 +85,7 @@
|
||||||
> img
|
> img
|
||||||
height: 13rem
|
height: 13rem
|
||||||
width: 13rem
|
width: 13rem
|
||||||
|
|
||||||
|
.other > button
|
||||||
|
margin: 0
|
||||||
|
width: 100%
|
|
@ -90,9 +90,16 @@ body
|
||||||
padding: 0.5rem
|
padding: 0.5rem
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
&.player
|
> a
|
||||||
color: RGB($secondary)
|
color: RGB($white)
|
||||||
text-shadow: 0 0 5px RGBA($secondary, 0.7)
|
text-decoration: none
|
||||||
|
|
||||||
|
&#you
|
||||||
|
color: RGB($primary)
|
||||||
|
text-shadow: 0 0 5px RGBA($primary, 0.4)
|
||||||
|
|
||||||
|
&:hover
|
||||||
|
text-decoration: underline
|
||||||
|
|
||||||
> i
|
> i
|
||||||
padding: 0.25rem
|
padding: 0.25rem
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
<div class="center-text">
|
<div class="center-text">
|
||||||
<h2>{{ error }}</h2>
|
<h2>{{ error }}</h2>
|
||||||
<p>{{ msg }}</p>
|
<p>{{ msg }}</p>
|
||||||
<image src="{{ url_for('static', filename='images/error/' + image + '.jpg') }}" alt="Error">
|
<image src="{{ url_for('static', filename='images/error.png') }}" alt="Error">
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -8,9 +8,9 @@
|
||||||
<div class="profile-settings">
|
<div class="profile-settings">
|
||||||
<div class="picture">
|
<div class="picture">
|
||||||
{% if current_user.picture %}
|
{% if current_user.picture %}
|
||||||
<img src="{{ url_for('api.upload_dir', filename=current_user.picture) }}" alt="Profile picture">
|
<img src="{{ url_for('api.upload_dir', filename=current_user.picture) }}" alt="Profile picture" id="picture-preview">
|
||||||
{% else %}
|
{% else %}
|
||||||
<img src="{{ url_for('static', filename='images/pfp.png') }}" alt="Profile picture">
|
<img src="{{ url_for('static', filename='images/pfp.png') }}" alt="Profile picture" id="picture-preview">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<label for="profile-picture">Profile Picture</label>
|
<label for="profile-picture">Profile Picture</label>
|
||||||
<input type="file" name="file" id="profile-picture">
|
<input type="file" name="file" id="profile-picture">
|
||||||
|
@ -60,9 +60,26 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% if not current_user.email %}
|
|
||||||
<script>
|
<script>
|
||||||
|
{% if not current_user.email %}
|
||||||
addFlashMessage("No Email set. If you loose your account, it will not be possible to recover it!", "error")
|
addFlashMessage("No Email set. If you loose your account, it will not be possible to recover it!", "error")
|
||||||
</script>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
// Adjusted from https://stackoverflow.com/a/3814285/14885829
|
||||||
|
document.getElementById('profile-picture').onchange = (event) => {
|
||||||
|
let tgt = event.target || window.event.srcElement,
|
||||||
|
files = tgt.files;
|
||||||
|
|
||||||
|
if (FileReader && files && files.length) {
|
||||||
|
let fr = new FileReader();
|
||||||
|
fr.onload = () => {
|
||||||
|
document.getElementById('picture-preview').src = fr.result;
|
||||||
|
}
|
||||||
|
fr.readAsDataURL(files[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addFlashMessage("Your browser could not show a preview of your profile picture!", "error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -45,11 +45,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="other">
|
<div class="other">
|
||||||
<h2>{{ user.username }}</h2>
|
<h2>{{ user.username }}</h2>
|
||||||
<p>Joined {{ user.joined_at.strftime('%Y-%m-%d') }}</p>
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
<p>Joined {{ user.joined_at|timesince }}</p>
|
||||||
<p>Best score: {{ scores[0].score | format_result }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -74,13 +71,12 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>{{ loop.index }}</td>
|
<td>{{ loop.index }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<td>
|
||||||
{% if score.users.id == current_user.id %}
|
<a
|
||||||
<td class="player">{{ score.users.username }}</td>
|
href="{{ url_for('views.index', user=score.users.username) }}"
|
||||||
{% else %}
|
{% if score.users.id == current_user.id %}id="you"{% endif %}
|
||||||
<td>{{ score.users.username }}</td>
|
>{{ score.users.username }}</a>
|
||||||
{% endif %}
|
</td>
|
||||||
|
|
||||||
<td>{{ score.score|format_result }}</td>
|
<td>{{ score.score|format_result }}</td>
|
||||||
<td>{{ score.scored_at.strftime('%Y-%m-%d') }}</td>
|
<td>{{ score.scored_at.strftime('%Y-%m-%d') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue