From 451f436a583c81002ad2e8ceab41110df7a8f9bf Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 25 Nov 2023 17:15:34 -0500 Subject: [PATCH] linter fixes --- .forgejo/workflows/config/.pylintrc | 6 +++ .forgejo/workflows/config/.yamllint | 6 +++ .forgejo/workflows/lint.yml | 2 +- poetry.lock | 6 +-- pyproject.toml | 1 + src/main.py | 28 +++++------ src/static/styles/core.css | 8 +-- src/static/styles/pages/index.css | 20 ++++---- src/static/styles/utils/login-logout.css | 62 ++++++++++++------------ src/templates/hello.html | 27 ----------- src/templates/index.html | 10 ++-- src/templates/utils/login-logout.html | 14 +++--- 12 files changed, 90 insertions(+), 100 deletions(-) create mode 100644 .forgejo/workflows/config/.pylintrc delete mode 100644 src/templates/hello.html diff --git a/.forgejo/workflows/config/.pylintrc b/.forgejo/workflows/config/.pylintrc new file mode 100644 index 0000000..74eb333 --- /dev/null +++ b/.forgejo/workflows/config/.pylintrc @@ -0,0 +1,6 @@ + [MESSAGES CONTROL] + disable= + missing-module-docstring, + missing-function-docstring, + missing-class-docstring, + line-too-long diff --git a/.forgejo/workflows/config/.yamllint b/.forgejo/workflows/config/.yamllint index 31a64d4..b3c4ec0 100644 --- a/.forgejo/workflows/config/.yamllint +++ b/.forgejo/workflows/config/.yamllint @@ -1,5 +1,11 @@ extends: default +rules: + - line-length: + max: 120 + - document-start: disable + - truthy: disable + ignore: - node_modules/ - __pycache__/ diff --git a/.forgejo/workflows/lint.yml b/.forgejo/workflows/lint.yml index 9da1f48..2252507 100644 --- a/.forgejo/workflows/lint.yml +++ b/.forgejo/workflows/lint.yml @@ -27,7 +27,7 @@ jobs: - name: Analyzing Python files with Pylint run: | export PATH="$HOME/.local/bin:$PATH" - poetry run pylint $(git ls-files '*.py') + poetry run pylint --rcfile .forgejo/workflows/config/.pylintrc $(git ls-files '*.py') - name: Analyzing HTML templates with djLint if: ${{ !cancelled() }} run: | diff --git a/poetry.lock b/poetry.lock index e965a23..d7d9d40 100644 --- a/poetry.lock +++ b/poetry.lock @@ -300,13 +300,13 @@ files = [ [[package]] name = "idna" -version = "3.5" +version = "3.6" description = "Internationalized Domain Names in Applications (IDNA)" optional = false python-versions = ">=3.5" files = [ - {file = "idna-3.5-py3-none-any.whl", hash = "sha256:79b8f0ac92d2351be5f6122356c9a592c96d81c9a79e4b488bf2a6a15f88057a"}, - {file = "idna-3.5.tar.gz", hash = "sha256:27009fe2735bf8723353582d48575b23c533cc2c2de7b5a68908d91b5eb18d08"}, + {file = "idna-3.6-py3-none-any.whl", hash = "sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f"}, + {file = "idna-3.6.tar.gz", hash = "sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 8c4d897..85c49be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,7 @@ yamllint = "^1.33.0" [tool.djlint] profile="jinja" +ignore="H006" [build-system] requires = ["poetry-core"] diff --git a/src/main.py b/src/main.py index fab8838..d79afda 100644 --- a/src/main.py +++ b/src/main.py @@ -17,9 +17,21 @@ app.config["DISCORD_BOT_TOKEN"] = config['discord']['bot_token'] 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']) + +@app.route("/me/") +@requires_authorization +def me(): + return redirect(url_for(".index")) + @app.route("/login/") def login(): - return discord.create_session() + return discord.create_session(scope=['identify', 'guilds', 'guilds.members.read']) @app.route("/logout/") def logout(): @@ -33,20 +45,8 @@ def callback(): @app.errorhandler(Unauthorized) @app.errorhandler(AccessDenied) -def redirect_unauthorized(e): +def redirect_unauthorized(): return redirect(url_for(".index")) -@app.route("/") -def index(): - if discord.authorized: - user = discord.fetch_user() - print(user.default_avatar_url, user.username, user.discriminator) - return render_template('index.html', name=config['name'], user=user) - return render_template('index.html', name=config['name']) - -@app.route("/hello") -def hello(): - return render_template('hello.html', name="Flask") - if __name__ == '__main__': app.run(host="0.0.0.0", port=config['port'], debug=True) diff --git a/src/static/styles/core.css b/src/static/styles/core.css index d614c0f..3c36a7f 100644 --- a/src/static/styles/core.css +++ b/src/static/styles/core.css @@ -1,9 +1,9 @@ body { - background-color: #2e3440; - color: #fff; - font-family: Arial, sans-serif; + background-color: #2e3440; + color: #fff; + font-family: Arial, sans-serif; } .txt-danger, .txt-danger:hover, .txt-danger:visited, .txt-danger:active { - color: #ff0000 !important; + color: #f00 !important; } diff --git a/src/static/styles/pages/index.css b/src/static/styles/pages/index.css index d1aad5a..bc1a490 100644 --- a/src/static/styles/pages/index.css +++ b/src/static/styles/pages/index.css @@ -1,20 +1,20 @@ @import url('../core.css'); #menu { - position: fixed; - left: 0; - top: 0; - bottom: 0; - width: 200px; - background-color: #3b4252; - padding: 20px; + position: fixed; + left: 0; + top: 0; + bottom: 0; + width: 200px; + background-color: #3b4252; + padding: 20px; } #menu ul { - list-style-type: none; - padding: 0; + list-style-type: none; + padding: 0; } #menu li { - margin-bottom: 10px; + margin-bottom: 10px; } diff --git a/src/static/styles/utils/login-logout.css b/src/static/styles/utils/login-logout.css index acc6778..d825cbb 100644 --- a/src/static/styles/utils/login-logout.css +++ b/src/static/styles/utils/login-logout.css @@ -1,42 +1,44 @@ .dropdown-content { - display: none; - position: relative; - background-color: #81B8F9; - margin-left: 10px; - min-width: 160px; - box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); - z-index: 1; - } + display: none; + position: relative; + background-color: #81B8F9; + margin-left: 10px; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgb(0, 0, 0 / 20%); + z-index: 1; +} .dropdown-content a { - color: white; - padding: 12px 16px; - text-decoration: none; - display: block; - } + color: white; + padding: 12px 16px; + text-decoration: none; + display: block; +} .dropdown-content a:hover {background-color: #7289da;} #logout:hover .dropdown-content {display: block;} +.log-button { + background-color: #7289da; + color: #fff; + border: none; + padding: 3px 5px; + border-radius: 5px; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + position: absolute; + right: 0; + margin-right: 20px; +} + .log-button:hover {background-color: #6C91F6;} -.log-button { - background-color: #7289da; - color: #fff; - border: none; - padding: 3px 5px; - border-radius: 5px; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - position: absolute; - right: 0; - margin-right: 20px; -} .log-button-icon { - border-radius: 50%; - width: 40px; - margin-right: 10px; + border-radius: 50%; + width: 40px; + height: 40px; + margin-right: 10px; } diff --git a/src/templates/hello.html b/src/templates/hello.html deleted file mode 100644 index 745a32d..0000000 --- a/src/templates/hello.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - {{ name }} - - - -

{{ name }}

- - diff --git a/src/templates/index.html b/src/templates/index.html index bf4aac8..8990d8d 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,8 +1,10 @@ - + - Audit Log - + Discord Event Log + + + - {% include 'utils/login-logout.html' %} + {% include "utils/login-logout.html" %} diff --git a/src/templates/utils/login-logout.html b/src/templates/utils/login-logout.html index 3bf1cb5..14f0b6f 100644 --- a/src/templates/utils/login-logout.html +++ b/src/templates/utils/login-logout.html @@ -1,18 +1,18 @@ - + {% if not user %}
{% elif user %} -
+