Prototype user profile pages.
This commit is contained in:
parent
2e41f7da53
commit
abe474487a
8 changed files with 42 additions and 8 deletions
0
uwume/assets/user/content.txt
Normal file
0
uwume/assets/user/content.txt
Normal file
|
@ -1,6 +1,7 @@
|
||||||
from flask import request
|
from flask import request
|
||||||
from os import getcwd
|
from os import getcwd
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
from re import search
|
||||||
|
|
||||||
|
|
||||||
def is_docker():
|
def is_docker():
|
||||||
|
@ -32,4 +33,9 @@ def get_static_paths():
|
||||||
if(str(request.url_rule) == '/'):
|
if(str(request.url_rule) == '/'):
|
||||||
return (f'static/css/index.css', f'static/js/index.js')
|
return (f'static/css/index.css', f'static/js/index.js')
|
||||||
else:
|
else:
|
||||||
|
if('<' in str(request.url_rule)):
|
||||||
|
delete = search('<.*>', str(request.url_rule))
|
||||||
|
delete = '/' + delete.group(0)
|
||||||
|
new_path = str(request.url_rule).replace(delete, '')
|
||||||
|
return (f'static/css{new_path}/index.css', f'static/js{new_path}/index.js')
|
||||||
return (f'static/css{request.url_rule}/index.css', f'static/js{request.url_rule}/index.js')
|
return (f'static/css{request.url_rule}/index.css', f'static/js{request.url_rule}/index.js')
|
||||||
|
|
0
uwume/static/css/user/index.css
Normal file
0
uwume/static/css/user/index.css
Normal file
0
uwume/static/js/user/index.js
Normal file
0
uwume/static/js/user/index.js
Normal file
|
@ -2,11 +2,11 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" type="image/png" href="static/assets/favicon.png" />
|
<link rel="icon" type="image/png" href="/static/assets/favicon.png" />
|
||||||
<link rel="stylesheet" href="static/materialize/css/materialize.min.css" />
|
<link rel="stylesheet" href="/static/materialize/css/materialize.min.css" />
|
||||||
<script src="static/materialize/js/materialize.min.js"></script>
|
<script src="/static/materialize/js/materialize.min.js"></script>
|
||||||
<link rel="stylesheet" type="text/css" href="{{ static_paths[0] }}" />
|
<link rel="stylesheet" type="text/css" href="/{{ static_paths[0] }}" />
|
||||||
<script type="text/javascript" src="{{ static_paths[1] }}"></script>
|
<script type="text/javascript" src="/{{ static_paths[1] }}"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="grey darken-4">
|
<body class="grey darken-4">
|
||||||
<title>UwU Me!{{ optional_title_status }}</title>
|
<title>UwU Me!{{ optional_title_status }}</title>
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
<h5 class="grey-text text-lighten-1 center">
|
<h5 class="grey-text text-lighten-1 center">
|
||||||
Sign Up Page
|
Sign Up Page
|
||||||
</h5>
|
</h5>
|
||||||
{% endblock %} {% block content %}
|
{% endblock %} {% block content %} {% for message in get_flashed_messages() %}
|
||||||
{% for message in get_flashed_messages() %}
|
|
||||||
<div class="card-panel red accent-1">
|
<div class="card-panel red accent-1">
|
||||||
<p>
|
<p>
|
||||||
{{ message }}
|
{{ message }}
|
||||||
|
|
21
uwume/templates/user/index.html
Normal file
21
uwume/templates/user/index.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{% extends 'index.html' %} {% block header %}
|
||||||
|
<h1 class="blue-grey-text text-lighten-5 center">
|
||||||
|
UwU {{ this_user }}!
|
||||||
|
</h1>
|
||||||
|
<h5 class="grey-text text-lighten-1 center">
|
||||||
|
Say UwU to them!
|
||||||
|
</h5>
|
||||||
|
{% endblock %} {% block content %}
|
||||||
|
<div class="card-panel grey darken-3">
|
||||||
|
<div class="center">
|
||||||
|
<button class="waves-effect waves-light btn blue darken-2" href="/">
|
||||||
|
UwU
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{% for item in content_text %}
|
||||||
|
<p class="blue-grey-text text-lighten-5">
|
||||||
|
{{ item }}
|
||||||
|
</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -37,6 +37,14 @@ def load_user(request):
|
||||||
return User(request, User.user_database[request][1])
|
return User(request, User.user_database[request][1])
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/user/<username>', methods=['GET'])
|
||||||
|
def user_page(username):
|
||||||
|
error = ''
|
||||||
|
if(request.method == 'GET'):
|
||||||
|
return render_template('user/index.html', this_user=username, static_paths=get_static_paths(), content_text=get_content_text())
|
||||||
|
return f'ERROR: {error}'
|
||||||
|
|
||||||
|
|
||||||
@app.route('/home', methods=['GET'])
|
@app.route('/home', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def home():
|
def home():
|
||||||
|
@ -67,7 +75,7 @@ def login():
|
||||||
if(request.method == 'POST'):
|
if(request.method == 'POST'):
|
||||||
username = request.form['username']
|
username = request.form['username']
|
||||||
password = request.form['password']
|
password = request.form['password']
|
||||||
if(username in User.user_database.keys()):
|
if(username in User.user_database.keys() and password == User.user_database.get(username)[1]):
|
||||||
userClass = User(username, password)
|
userClass = User(username, password)
|
||||||
login_user(userClass)
|
login_user(userClass)
|
||||||
return redirect('home')
|
return redirect('home')
|
||||||
|
|
Reference in a new issue