Skip to content

Commit

Permalink
Merge pull request #76 from x10102/master
Browse files Browse the repository at this point in the history
Add the "Cyms VIP" theme
  • Loading branch information
x10102 authored Dec 23, 2024
2 parents f52079d + 9dea245 commit 73e72ff
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 8 deletions.
3 changes: 2 additions & 1 deletion blueprints/articles.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Builtins
from datetime import datetime
from http import HTTPStatus
from logging import info

# External
Expand Down Expand Up @@ -77,7 +78,7 @@ def edit_article(aid: int):

article = dbs.get_article(aid)
if not article:
abort(404)
abort(HTTPStatus.NOT_FOUND)

if request.method == "GET":
fdata = {'title': article.name, 'words': article.words, 'bonus': article.bonus, 'link': article.link, 'translator': article.author.nickname}
Expand Down
5 changes: 3 additions & 2 deletions blueprints/debug.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from http import HTTPStatus
from logging import critical, warning, error
from flask import Blueprint, redirect, url_for, current_app, request, render_template, send_from_directory, flash, abort
from flask_login import login_required, current_user
Expand Down Expand Up @@ -56,9 +57,9 @@ def export_database():
@DebugTools.route('/debug/raise_error')
def raise_error():
error("Error handling test")
abort(500)
abort(HTTPStatus.INTERNAL_SERVER_ERROR)

@DebugTools.route('/debug/raise_critical')
def raise_critical_error():
critical("Critical error handling test")
abort(500)
abort(HTTPStatus.INTERNAL_SERVER_ERROR)
1 change: 0 additions & 1 deletion blueprints/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def get_template(template_type: EmbedType, theme: str = "default"):
# Don't abort on invalid theme, just use the default
return f"embeds/{template_type}/default.j2"

# TODO: Move this to separate Blueprint
@EmbedController.route('/user/<int:uid>/embed', methods=["GET"])
def user_badge(uid: int):
embed_type = request.args.get("type", type=str, default=EmbedType.TRANSLATOR)
Expand Down
7 changes: 4 additions & 3 deletions blueprints/users.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from http import HTTPStatus
from flask import Blueprint, url_for, redirect, session, request, render_template, abort, flash
from forms import NewUserForm, EditUserForm
from flask_login import current_user, login_required
Expand Down Expand Up @@ -41,7 +42,7 @@ def add_user():
@UserController.route('/user/<int:uid>/edit', methods=["GET", "POST"])
@login_required
def edit_user(uid: int):
user = dbs.get_user(uid) or abort(404)
user = dbs.get_user(uid) or abort(HTTPStatus.NOT_FOUND)

if request.method == "GET":
fdata = {'nickname': user.nickname, 'wikidot': user.wikidot, 'discord': user.discord, 'login': int(user.password is not None)}
Expand All @@ -60,7 +61,7 @@ def edit_user(uid: int):
def user(uid: int):
sort = request.args.get('sort', 'latest', str)
page = request.args.get('p', 0, int)
user = dbs.get_user(uid) or abort(404)
user = dbs.get_user(uid) or abort(HTTPStatus.NOT_FOUND)
corrections = dbs.get_corrections_by_user(uid)
translations = dbs.get_translations_by_user(uid, sort, page)
originals = dbs.get_originals_by_user(uid)
Expand All @@ -69,7 +70,7 @@ def user(uid: int):
@UserController.route('/user/<int:uid>/delete', methods=["POST", "GET"])
@login_required
def delete_user(uid: int):
user = dbs.get_user(uid) or abort(404)
user = dbs.get_user(uid) or abort(HTTPStatus.NOT_FOUND)
name = user.nickname
dbs.delete_user(uid)
info(f"User {name} deleted by {current_user.nickname} (ID: {current_user.uid})")
Expand Down
2 changes: 1 addition & 1 deletion static/css/badge.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions templates/embeds/translator/vipcyms.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<head>
<link rel="stylesheet" href="{{url_for('static', filename='css/badge.css')}}">

</head>

<div class="relative flex flex-row items-center justify-start h-24 bg-black rounded-lg">
<img class="z-40 block h-full border border-white border-solid rounded-l-lg" src="{{ url_for('UserContent.get_avatar', uid=(user.discord or 0), s='full')}}">
<div class="flex flex-col flex-1 h-full pl-4 text-white bg-transparent rounded-r-lg">
<div id="particle-container" class="absolute top-0 left-0 w-full h-full"></div>
<h1 class="z-10 m-0 mt-1 text-xl font-bold text-white">{{user.wikidot}}</h1>
<p class="m-0 text-sm"><b>{{"%.1f" % stats.points}}</b> Překladatelských bodů</p>
<p class="m-0 text-sm"><b>{{stats.count}}</b> Přeložených článků</p>
<p class="m-0 text-sm">Poslední překlad: <b><a href="{{last.link}}" class="text-white transition-opacity hover:opacity-75" target="_top">{{last.name}}</b></a></p>
</div>
<div class="absolute top-0 right-0 block {{get_role_color(stats.points)}} text-white p-2 rounded-bl-lg font-semibold rounded-tr-lg">{{get_user_role(stats.points)}}</div>
<a href="https://scuttle.scp-wiki.cz" class="absolute bottom-0 text-xs text-white no-underline transition-opacity opacity-25 right-1 hover:opacity-100" target="_top">Powered by SCUTTLE</a>
<script src="https://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<script>
particlesJS("particle-container", { "particles": { "number": { "value": 200, "density": { "enable": true, "value_area": 500 } }, "color": { "value": "#ffffff" }, "shape": { "type": "circle", "stroke": { "width": 1, "color": "#000000" }, "polygon": { "nb_sides": 5 }, "image": { "src": "img/github.svg", "width": 100, "height": 100 } }, "opacity": { "value": 0.7, "random": true, "anim": { "enable": false, "speed": 0.5, "opacity_min": 0.1, "sync": false } }, "size": { "value": 0, "random": false, "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false } }, "line_linked": { "enable": true, "distance": 150, "color": "#ffffff", "opacity": 0.4, "width": 1 }, "move": { "enable": true, "speed": 0.5, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200 } } }, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": false, "mode": "repulse" }, "onclick": { "enable": true, "mode": "repulse" }, "resize": true }, "modes": { "grab": { "distance": 400, "line_linked": { "opacity": 1 } }, "bubble": { "distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3 }, "repulse": { "distance": 200, "duration": 0.4 }, "push": { "particles_nb": 4 }, "remove": { "particles_nb": 2 } } }, "retina_detect": true });
</script>
</div>

0 comments on commit 73e72ff

Please sign in to comment.