User pages

This commit is contained in:
magmaus3 2022-10-30 15:48:09 +01:00
parent 9b615e195c
commit 04d4a1fa2c
Signed by: magmaus3
GPG key ID: 966755D3F4A9B251
3 changed files with 59 additions and 0 deletions

View file

@ -119,6 +119,24 @@ async def showLevel(level_id: int):
THUMB_URL=THUMB_URL,
)
@app.get("/user/{user_id}", response_class=HTMLResponse)
async def showUser(user_id: int):
template = template_env.get_template("userInfo.html")
try:
rq = httpx.get(BASE_URL + "/api/v1/user/" + str(user_id), timeout=10)
searchResults = rq.json()
print(rq.url)
except httpx.ReadTimeout:
return "Server timed out"
return template.render(
user=searchResults,
THUMB_URL=THUMB_URL,
)

View file

@ -0,0 +1,10 @@
.UserInfo {
margin: 1rem;
font-size: large;
}
.Username {
font-weight: bold;
border-bottom: 0.1rem solid white;
margin-bottom: 1rem;
}

View file

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/index.css">
<link rel="stylesheet" href="/static/main.css">
<link rel="stylesheet" href="/static/search/search.css">
<link rel="stylesheet" href="/static/search/searchResults.css">
<link rel="stylesheet" href="/static/user.css">
</head>
<body>
<div class="Search">
<div class="contentBox_">
<div class="header">User information</div>
<div class="splitter"></div>
<div class="UserInfo">
<div class="basic">
<div class="Username">{{ user['Username'] }}</div>
<div class="NumMapsClear">Clears: {{ user['NumMapsClear'] }}</div>
<div class="NumMapsCreated">Levels: {{ user['NumMapsCreated'] }}</div>
<div class="NumSpeedrunRecords">Records: {{ user['NumSpeedrunRecords'] }}</div>
</div>
<div class="userLevels"><a href="/search?q=author:{{ user['Username'] }}&sort=created_at&dir=asc&date=-1">Levels by this user</a></div>
</div>
</div>
</div>
</body>
</html>