diff --git a/src/main.py b/src/main.py index 79157d8..27b6aa7 100644 --- a/src/main.py +++ b/src/main.py @@ -20,18 +20,22 @@ discord = DiscordOAuth2Session(app) @app.route("/") def index(): if discord.authorized: - user = discord.fetch_user() - return render_template('index.html', name=config['name'], user=user) + return render_template('index.html', name=config['name'], user=discord.fetch_user()) return render_template('index.html', name=config['name']) @app.route("/me/") @requires_authorization def me(): - return redirect(url_for(".index")) + print(discord.fetch_user().to_json()) + return render_template('me.html', name=config['name'], user=discord.fetch_user()) + +@app.route("/guilds/") +@requires_authorization +def guilds(): + return render_template('guilds.html', name=config['name'], user=discord.fetch_user()) @app.route("/login/") def login(): - discord.redirect_uri = request.host + "/callback/" return discord.create_session(scope=['identify', 'guilds', 'guilds.members.read']) @app.route("/logout/") @@ -42,7 +46,7 @@ def logout(): @app.route("/callback/") def callback(): discord.callback() - return redirect(url_for(".index")) + return redirect(url_for(".me")) @app.errorhandler(Unauthorized) @app.errorhandler(AccessDenied) diff --git a/src/static/styles/utils/login-logout.css b/src/static/styles/utils/login-logout.css index ff37000..ff1c396 100644 --- a/src/static/styles/utils/login-logout.css +++ b/src/static/styles/utils/login-logout.css @@ -23,7 +23,7 @@ background-color: #7289da; color: #fff; border: none; - padding: 3px 5px; + padding: 3px 3px; border-radius: 5px; cursor: pointer; display: flex; diff --git a/src/templates/guilds.html b/src/templates/guilds.html new file mode 100644 index 0000000..50c7084 --- /dev/null +++ b/src/templates/guilds.html @@ -0,0 +1,13 @@ + + + + Discord Event Log + + + + + + WIP + {% include "utils/login-logout.html" %} + + diff --git a/src/templates/me.html b/src/templates/me.html new file mode 100644 index 0000000..b96d6b3 --- /dev/null +++ b/src/templates/me.html @@ -0,0 +1,12 @@ + + + + Discord Event Log + + + + + + {% include "utils/login-logout.html" %} + + diff --git a/src/templates/utils/banner.html b/src/templates/utils/banner.html new file mode 100644 index 0000000..9955e42 --- /dev/null +++ b/src/templates/utils/banner.html @@ -0,0 +1,8 @@ +{% if user.banner %} + diff --git a/src/templates/utils/login-logout.html b/src/templates/utils/login-logout.html index 14f0b6f..5ad07bd 100644 --- a/src/templates/utils/login-logout.html +++ b/src/templates/utils/login-logout.html @@ -14,13 +14,24 @@ {% else %} User Avatar {% endif %} + {% if user.to_json()['global_name'] %} + {{ user.to_json()['global_name']}} + {% if user.discriminator != "0" %} + ({{ user.username }}#{{ user.discriminator }}) + {% else %} + ({{ user.username }}) + {% endif %} + {% else %} {% if user.discriminator != "0" %} {{ user.username }}#{{ user.discriminator }} {% else %} {{ user.username }} {% endif %} + {% endif %}