From c5d3e116d90b7cd2685cd82010e13500f32af6de Mon Sep 17 00:00:00 2001 From: JKBGL <44818773+JKBGL@users.noreply.github.com> Date: Mon, 26 Jul 2021 16:08:05 +0300 Subject: [PATCH] Cleanup & small fixes - Generalized the names for the backgrounds & banners folders. - Fixed mode select not working for profile and leaderboard pages. - Changed some spelling in the statuses (profile.js) - settings/style - added a simple fix to prevent the avatar preview from going out of the page frame. - home/style - added a simple fix for the main text not having padding on mobile layouts. - Comment out the Information tab from the header since the docs endpoint has been disabled temporarily. - Change the admin dashboard page to use the regular header. (located in components/navbar.html) -Jakatebel --- .../{profbackground => backgrounds}/.gitkeep | 0 .data/{profbanner => banners}/.gitkeep | 0 blueprints/frontend.py | 22 ++--- objects/utils.py | 4 +- static/css/pages/home.css | 3 + static/css/pages/settings/style.css | 3 + static/js/pages/leaderboard.js | 18 ++-- static/js/pages/profile.js | 28 +++--- templates/admin/base.html | 90 +------------------ templates/components/navbar.html | 4 +- templates/leaderboard.html | 2 +- templates/profile.html | 4 +- 12 files changed, 49 insertions(+), 129 deletions(-) rename .data/{profbackground => backgrounds}/.gitkeep (100%) rename .data/{profbanner => banners}/.gitkeep (100%) diff --git a/.data/profbackground/.gitkeep b/.data/backgrounds/.gitkeep similarity index 100% rename from .data/profbackground/.gitkeep rename to .data/backgrounds/.gitkeep diff --git a/.data/profbanner/.gitkeep b/.data/banners/.gitkeep similarity index 100% rename from .data/profbanner/.gitkeep rename to .data/banners/.gitkeep diff --git a/blueprints/frontend.py b/blueprints/frontend.py index 05b84072..1a16dc92 100644 --- a/blueprints/frontend.py +++ b/blueprints/frontend.py @@ -34,7 +34,7 @@ def login_required(func): @wraps(func) async def wrapper(*args, **kwargs): if not session: - return await flash('error', 'You must be logged in to access that page', 'login') + return await flash('error', 'You must be logged in to access that page.', 'login') return await func(*args, **kwargs) return wrapper @@ -183,7 +183,7 @@ async def settings_custom_post(): if not file_extension in ALLOWED_EXTENSIONS: return await flash_with_customizations('error', f'The banner you select must be either a .JPG, .JPEG, .PNG or .GIF file!', 'settings/custom') - banner_file_no_ext = os.path.join(f'.data/profbanner', f'{session["user_data"]["id"]}') + banner_file_no_ext = os.path.join(f'.data/banners', f'{session["user_data"]["id"]}') # remove old picture for ext in ALLOWED_EXTENSIONS: @@ -198,7 +198,7 @@ async def settings_custom_post(): if not file_extension in ALLOWED_EXTENSIONS: return await flash_with_customizations('error', f'The background you select must be either a .JPG, .JPEG, .PNG or .GIF file!', 'settings/custom') - background_file_no_ext = os.path.join(f'.data/profbackground', f'{session["user_data"]["id"]}') + background_file_no_ext = os.path.join(f'.data/backgrounds', f'{session["user_data"]["id"]}') # remove old picture for ext in ALLOWED_EXTENSIONS: @@ -289,7 +289,7 @@ async def settings_password_post(): # logout session.pop('authenticated', None) session.pop('user_data', None) - return await flash('success', 'Your password has been changed! Please login again.', 'login') + return await flash('success', 'Your password has been changed! Please log in again.', 'login') @frontend.route('/u/') async def profile(id): @@ -401,7 +401,7 @@ async def login_post(): if not user_info['priv'] & Privileges.Normal: if glob.config.debug: log(f"{username}'s login failed - banned.", Ansi.RED) - return await flash('error', 'You are banned!', 'login') + return await flash('error', 'Your account is restricted. You are not allowed to log in.', 'login') # login successful; store session data if glob.config.debug: @@ -582,25 +582,25 @@ async def instagram_redirect(): return redirect(glob.config.instagram) # profile customisation -BANNERS_PATH = Path.cwd() / '.data/profbanner' -BACKGROUND_PATH = Path.cwd() / '.data/profbackground' -@frontend.route('/profbanner/') +BANNERS_PATH = Path.cwd() / '.data/banners' +BACKGROUND_PATH = Path.cwd() / '.data/backgrounds' +@frontend.route('/banners/') async def get_profile_banner(user_id: int): # Check if avatar exists for ext in ('jpg', 'jpeg', 'png', 'gif'): path = BANNERS_PATH / f'{user_id}.{ext}' if path.exists(): - return await send_file(f'.data/profbanner/{user_id}.{ext}') + return await send_file(path) return b'{"status":404}' -@frontend.route('/profbackground/') +@frontend.route('/backgrounds/') async def get_profile_background(user_id: int): # Check if avatar exists for ext in ('jpg', 'jpeg', 'png', 'gif'): path = BACKGROUND_PATH / f'{user_id}.{ext}' if path.exists(): - return await send_file(f'.data/profbackground/{user_id}.{ext}') + return await send_file(path) return b'{"status":404}' diff --git a/objects/utils.py b/objects/utils.py index 98197d9e..98f52f92 100644 --- a/objects/utils.py +++ b/objects/utils.py @@ -123,8 +123,8 @@ def get_level(totalScore: int) -> int: # Not our level, calculate score for next level level += 1 -BANNERS_PATH = Path.cwd() / '.data/profbanner' -BACKGROUND_PATH = Path.cwd() / '.data/profbackground' +BANNERS_PATH = Path.cwd() / '.data/banners' +BACKGROUND_PATH = Path.cwd() / '.data/backgrounds' def has_profile_customizations(user_id: int = 0) -> dict[str, bool]: # check for custom banner image file for ext in ('jpg', 'jpeg', 'png', 'gif'): diff --git a/static/css/pages/home.css b/static/css/pages/home.css index 4794f2ba..51307169 100644 --- a/static/css/pages/home.css +++ b/static/css/pages/home.css @@ -43,6 +43,9 @@ .gulag-avatar { display: none; } + #home-hero .columns.flex-vcenter { + padding: 0 20px; + } .main-block { width: initial; height: 285px; diff --git a/static/css/pages/settings/style.css b/static/css/pages/settings/style.css index 60260713..70ff91b5 100644 --- a/static/css/pages/settings/style.css +++ b/static/css/pages/settings/style.css @@ -973,6 +973,9 @@ input:checked+label.checkbox:hover { .main-block { width: 770px; } + .avatar-flex { + flex-direction: column; + } } @media screen and (max-width: 770px) { diff --git a/static/js/pages/leaderboard.js b/static/js/pages/leaderboard.js index b85c1db9..ac2f9f90 100644 --- a/static/js/pages/leaderboard.js +++ b/static/js/pages/leaderboard.js @@ -60,15 +60,15 @@ new Vue({ return x1 + x2; }, StrtoGulagInt() { - switch (this.mode, this.mods) { - case 'std', 'vn': return 0; - case 'taiko', 'vn': return 1; - case 'catch', 'vn': return 2; - case 'mania', 'vn': return 3; - case 'std', 'rx': return 4; - case 'taiko', 'rx': return 5; - case 'catch', 'rx': return 6; - case 'std', 'ap': return 7; + switch (this.mode + "|" + this.mods) { + case 'std|vn': return 0; + case 'taiko|vn': return 1; + case 'catch|vn': return 2; + case 'mania|vn': return 3; + case 'std|rx': return 4; + case 'taiko|rx': return 5; + case 'catch|rx': return 6; + case 'std|ap': return 7; default: return -1; } }, diff --git a/static/js/pages/profile.js b/static/js/pages/profile.js index 56f7925e..d3354b96 100644 --- a/static/js/pages/profile.js +++ b/static/js/pages/profile.js @@ -123,20 +123,20 @@ new Vue({ }, actionIntToStr(d) { switch (d.action) { - case 0: return 'Idle: ๐Ÿ” Selecting a song'; - case 1: return 'Idle: ๐ŸŒ™ AFK'; + case 0: return 'Idle: ๐Ÿ” Song Select'; + case 1: return '๐ŸŒ™ AFK'; case 2: return `Playing: ๐ŸŽถ ${d.info_text}`; case 3: return `Editing: ๐Ÿ”จ ${d.info_text}`; case 4: return `Modding: ๐Ÿ”จ ${d.info_text}`; - case 5: return `In Multiplayer: Selecting ๐Ÿฏ ${d.info_text} โ›”๏ธ`; + case 5: return 'In Multiplayer: Song Select'; case 6: return `Watching: ๐Ÿ‘“ ${d.info_text}`; // 7 not used case 8: return `Testing: ๐ŸŽพ ${d.info_text}`; case 9: return `Submitting: ๐Ÿงผ ${d.info_text}`; - case 10: return `Paused: ๐Ÿšซ ${d.info_text}`; + // 10 paused, never used case 11: return 'Idle: ๐Ÿข In multiplayer lobby'; case 12: return `In Multiplayer: Playing ๐ŸŒ ${d.info_text} ๐ŸŽถ`; - case 13: return 'Idle: ๐Ÿซ’ Downloading some beatmaps in osu!direct'; + case 13: return 'Idle: ๐Ÿ” Searching for beatmaps in osu!direct'; default: return 'Unknown: ๐Ÿš” not yet implemented!'; } }, @@ -159,15 +159,15 @@ new Vue({ return dDisplay + hDisplay + mDisplay; }, StrtoGulagInt() { - switch (this.mode, this.mods) { - case 'std', 'vn': return 0; - case 'taiko', 'vn': return 1; - case 'catch', 'vn': return 2; - case 'mania', 'vn': return 3; - case 'std', 'rx': return 4; - case 'taiko', 'rx': return 5; - case 'catch', 'rx': return 6; - case 'std', 'ap': return 7; + switch (this.mode + "|" + this.mods) { + case 'std|vn': return 0; + case 'taiko|vn': return 1; + case 'catch|vn': return 2; + case 'mania|vn': return 3; + case 'std|rx': return 4; + case 'taiko|rx': return 5; + case 'catch|rx': return 6; + case 'std|ap': return 7; default: return -1; } }, diff --git a/templates/admin/base.html b/templates/admin/base.html index f946701a..19f42b56 100644 --- a/templates/admin/base.html +++ b/templates/admin/base.html @@ -38,94 +38,8 @@ - - + + {% include './components/navbar.html' %}
diff --git a/templates/components/navbar.html b/templates/components/navbar.html index c720c7e0..8f82323f 100644 --- a/templates/components/navbar.html +++ b/templates/components/navbar.html @@ -21,7 +21,7 @@ Leaderboards -
- there are no scores to display! + there are no players to display!
diff --git a/templates/profile.html b/templates/profile.html index 6226ea9e..29f9a4a8 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -427,13 +427,13 @@

No beatmaps available

{% if user['customisation']['banner'] == True %} .profile-bg { min-height: 262px; - background: linear-gradient(hsl(var(--main), 25%, 25%, 20%), hsl(var(--main), 25%, 25%, 60%)), url("/profbanner/{{ user['id'] }}"); + background: linear-gradient(hsl(var(--main), 25%, 25%, 20%), hsl(var(--main), 25%, 25%, 60%)), url("/banners/{{ user['id'] }}"); background-size: cover; } {% endif %} {% if user['customisation']['background'] == True %} body { - background: linear-gradient(hsl(var(--main), 25%, 25%, 20%), hsl(var(--main), 10%, 10%)), url("/profbackground/{{ user['id'] }}"); + background: linear-gradient(hsl(var(--main), 25%, 25%, 20%), hsl(var(--main), 10%, 10%)), url("/backgrounds/{{ user['id'] }}"); background-size: cover; background-clip: content-box; }