Stash
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Michel Roux 2022-07-05 18:23:05 +02:00
parent 5a4575abf5
commit 3cc1037c76
7 changed files with 88 additions and 35 deletions

View File

@ -97,6 +97,17 @@ def days_before_failure():
return nextDelta.days
@app.errorhandler(500)
async def errorhandler(error: Exception):
print(f"\33[31m{error}\33[m")
return await render_template("error.html.j2", error=str(error)), 500
@app.errorhandler(404)
async def not_found(error: Exception):
return await render_template("error.html.j2", error=str(error)), 404
@app.context_processor
def context_processor():
return dict(days_before_failure=days_before_failure(), _=i18n, bot=client.user)
@ -118,7 +129,9 @@ async def login():
if token is not None:
return redirect(url_for(".guilds"))
discord = make_oauth_session(host_url=request.host_url, scope=["guilds"])
discord = make_oauth_session(
host_url=request.host_url, scope=["identify", "guilds"]
)
authorization_url, state = discord.authorization_url(AUTHORIZATION_BASE_URL)
session["oauth2_state"] = state
return redirect(authorization_url)
@ -148,13 +161,19 @@ async def guilds():
return redirect(url_for(".login"))
discord = make_oauth_session(host_url=request.host_url, token=token)
guilds = discord.get(API_BASE_URL + "/users/@me/guilds").json()
user = discord.get(API_BASE_URL + "/users/@me")
guilds = discord.get(API_BASE_URL + "/users/@me/guilds")
return await render_template("guilds.html.j2", guilds=guilds)
if user.status_code != 200 or guilds.status_code != 200:
return redirect(url_for(".login"))
return await render_template(
"guilds.html.j2", guilds=guilds.json(), user=user.json()
)
@app.route("/<guild_id>.ics")
async def ical(guild_id):
async def ical(guild_id: str):
guild = get_guild_by_id(guild_id)
if guild is None:
return redirect(url_for(".login"))

View File

@ -22,7 +22,6 @@ body {
#content {
min-width: 280px;
max-width: 400px;
min-height: 400px;
background-color: #18191c;
border-radius: 5px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.24);

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

View File

@ -0,0 +1,21 @@
{% extends "base.html.j2" %}
{% block content %}
<div id="box">
<div id="avatars">
<img src="{{ url_for('static', filename='img/deadlink.png') }}"
alt="{{ _('Link is dead') }}"
height="179"
width="173"/>
</div>
<hr />
<span id="details">
{{ error }}
</span>
</div>
<div id="buttons">
<a href="{{ url_for('index') }}">
<i class="fa fa-arrow-left"></i>
{{ _('Back to the beginning') }}
</a>
</div>
{% endblock content %}

View File

@ -0,0 +1,30 @@
<ul id="details">
<li>
<a href="https://discord.com/users/133305654512320513" target="_blank">
<i class="fa fa-user-plus"></i>
{{ _('Add author on Discord') }}
</a>
</li>
<li>
<a href="http://www.wtfpl.net" target="_blank">
<i class="fa fa-book"></i>
{{ _('Read the licence') }}
</a>
</li>
<li>
<a href="https://git.crystalyx.net/Xefir/Divent" target="_blank">
<i class="fa fa-code-fork"></i>
{{ _('View the source code') }}
</a>
</li>
<li>
<a href="https://hub.docker.com/r/xefir/divent" target="_blank">
<i class="fa fa-cubes"></i>
{{ _('Host it yourself') }}
</a>
</li>
<li>
<i class="fa fa-heartbeat"></i>
{{ _('Next castastrophic life failure in about %days% days') | replace('%days%', days_before_failure) }}
</li>
</ul>

View File

@ -1,5 +1,18 @@
{% extends "base.html.j2" %}
{% block content %}
<div id="box">
<div id="avatars">
<img src="{{ bot.display_avatar }}"
alt="{{ _('Bot Logo') }}"
width="80"
height="80"/>
<span id="dots">...</span>
<img src="{{ user.avatar }}"
alt="{{ _('User Logo') }}"
width="80"
height="80"/>
</div>
</div>
<select name="guild">
{% for guild in guilds %}
<option value="{{ guild.id }}">

View File

@ -22,36 +22,7 @@
</li>
</ul>
<hr />
<ul id="details">
<li>
<a href="https://discord.com/users/133305654512320513" target="_blank">
<i class="fa fa-user-plus"></i>
{{ _('Add author on Discord') }}
</a>
</li>
<li>
<a href="http://www.wtfpl.net" target="_blank">
<i class="fa fa-book"></i>
{{ _('Read the licence') }}
</a>
</li>
<li>
<a href="https://git.crystalyx.net/Xefir/Divent" target="_blank">
<i class="fa fa-code-fork"></i>
{{ _('View the source code') }}
</a>
</li>
<li>
<a href="https://hub.docker.com/r/xefir/divent" target="_blank">
<i class="fa fa-cubes"></i>
{{ _('Host it yourself') }}
</a>
</li>
<li>
<i class="fa fa-heartbeat"></i>
{{ _('Next castastrophic life failure in about %days% days') | replace('%days%', days_before_failure) }}
</li>
</ul>
{% include 'footer.html.j2' %}
</div>
<div id="buttons">
<a href="{{ url_for('login') }}">{{ _("Let's go!") }}</a>