refactored templates
This commit is contained in:
@@ -195,3 +195,12 @@ def hide_active_banner():
|
||||
@flask_login.login_required
|
||||
def confused_notifications():
|
||||
return render_template("confused.html")
|
||||
|
||||
|
||||
@admin_bp.route("/dashboard")
|
||||
@flask_login.login_required
|
||||
def dashboard():
|
||||
return render_template(
|
||||
'dashboard.html',
|
||||
grafana_url='/dashboard/d/tutor-tool'
|
||||
)
|
||||
|
||||
@@ -1,229 +1,144 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Deck Admin</title>
|
||||
{% extends "admin_base.html" %}
|
||||
{% from "macros/ui.html" import course_switcher, delete_button, styled_field %}
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
{% set active_page = 'admin' %}
|
||||
{% set title = 'Deck Admin' %}
|
||||
|
||||
{# Override left nav to include course switcher #}
|
||||
{% block nav_left_extra %}
|
||||
{{ course_switcher(courses, active_course_name, '/admin/switch_course') }}
|
||||
{% endblock %}
|
||||
|
||||
</head>
|
||||
<body class="bg-background text-text min-h-screen font-sans">
|
||||
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||
<div class="flex items-center space-x-6 rtl:space-x-reverse">
|
||||
<a href="{{ url_for('main.index') }}" class="flex items-center">
|
||||
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Tutortool</span>
|
||||
</a>
|
||||
{% block admin_content %}
|
||||
<div class="container mx-auto px-6 py-10 space-y-12">
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-10">
|
||||
|
||||
<div class="relative group">
|
||||
<button class="flex items-center text-gray-900 dark:text-white hover:text-blue-700 dark:hover:text-blue-500 font-medium py-2 px-3 rounded-lg bg-transparent">
|
||||
{{active_course_name}}
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="absolute z-10 hidden group-hover:block w-44 bg-white divide-y divide-gray-100 rounded-lg shadow dark:bg-gray-700">
|
||||
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200">
|
||||
{% for course in courses %}
|
||||
<li>
|
||||
<form method="POST" action="/admin/switch_course/{{ course.id }}">
|
||||
<button type="submit">{{ course.name }}</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{# ── Deck Form + Decks ─────────────────────────────────────── #}
|
||||
<div class="bg-surface rounded-xl p-6 shadow-lg space-y-6">
|
||||
<h2 class="text-2xl font-semibold">Add New Deck</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ deck_form.hidden_tag() }}
|
||||
{{ styled_field(deck_form.name) }}
|
||||
{{ styled_field(deck_form.deck, {'multiple': true}) }}
|
||||
{{ styled_field(deck_form.description) }}
|
||||
<div>
|
||||
{{ deck_form.submit_deck(class="w-full bg-primary hover:bg-blue-700 text-white py-2 px-4 rounded-lg") }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="w-auto" id="navbar-default">
|
||||
<ul class="flex flex-row space-x-8 rtl:space-x-reverse font-medium p-0 border-0 bg-white dark:bg-gray-900">
|
||||
<li>
|
||||
<a href="{{ url_for('admin.admin') }}" class="rounded-sm text-blue-700 dark:text-blue-500 font-semibold" aria-current="page">Deck Admin</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ url_for('admin.banner') }}" class="text-gray-900 dark:text-white hover:text-blue-700 dark:hover:text-blue-500">Banner</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ url_for('admin.confused_notifications') }}" class="text-gray-900 dark:text-white hover:text-blue-700 dark:hover:text-blue-500">Confused</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h2 class="text-2xl font-semibold pt-6">Existing Decks</h2>
|
||||
{% if decks %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full table-auto text-left text-sm">
|
||||
<thead class="text-muted border-b border-border">
|
||||
<tr>
|
||||
<th class="px-4 py-2">Name</th>
|
||||
<th class="px-4 py-2">Passwords</th>
|
||||
<th class="px-4 py-2">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for deck in decks %}
|
||||
<tr class="border-b border-border hover:bg-background/30">
|
||||
<td class="px-4 py-2 font-medium">{{ deck.name }}</td>
|
||||
<td class="px-4 py-2">
|
||||
{% if deck.passwords %}
|
||||
<ul class="list-disc list-inside text-muted">
|
||||
{% for password in deck.passwords %}
|
||||
<li>{{ password.value }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<em class="text-muted">None</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
{{ delete_button(url_for('admin.delete_deck', deck_id=deck.id)) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container mx-auto px-6 py-10 space-y-12">
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-10">
|
||||
|
||||
<!-- Deck Form + Decks -->
|
||||
<div class="bg-surface rounded-xl p-6 shadow-lg space-y-6">
|
||||
<h2 class="text-2xl font-semibold">Add New Deck</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ deck_form.hidden_tag() }}
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ deck_form.name.label }}</label>
|
||||
{{ deck_form.name(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ deck_form.deck.label }}</label>
|
||||
{{ deck_form.deck(multiple=True, class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ deck_form.description.label }}</label>
|
||||
{{ deck_form.description(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ deck_form.submit_deck(class="w-full bg-primary hover:bg-blue-700 text-white py-2 px-4 rounded-lg") }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Existing Decks Table -->
|
||||
<h2 class="text-2xl font-semibold pt-6">Existing Decks</h2>
|
||||
{% if decks %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full table-auto text-left text-sm">
|
||||
<thead class="text-muted border-b border-border">
|
||||
<tr>
|
||||
<th class="px-4 py-2">Name</th>
|
||||
<th class="px-4 py-2">Passwords</th>
|
||||
<th class="px-4 py-2">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for deck in decks %}
|
||||
<tr class="border-b border-border hover:bg-background/30">
|
||||
<td class="px-4 py-2 font-medium">{{ deck.name }}</td>
|
||||
<td class="px-4 py-2">
|
||||
{% if deck.passwords %}
|
||||
<ul class="list-disc list-inside text-muted">
|
||||
{% for password in deck.passwords %}
|
||||
<li>{{ password.value }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<em class="text-muted">None</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<form method="POST" action="{{ url_for('admin.delete_deck', deck_id=deck.id) }}">
|
||||
<button type="submit" class="bg-red-600 hover:bg-red-700 text-white px-3 py-1 rounded-lg text-sm">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No decks available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Password Form + Passwords -->
|
||||
<div class="bg-surface rounded-xl p-6 shadow-lg space-y-6">
|
||||
<h2 class="text-2xl font-semibold">Add New Password</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ password_form.hidden_tag() }}
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ password_form.value.label }}</label>
|
||||
{{ password_form.value(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ password_form.expires_at.label }}</label>
|
||||
{{ password_form.expires_at(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary", type="datetime-local") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ password_form.decks.label }}</label>
|
||||
{{ password_form.decks(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{{ password_form.submit_password(class="w-full bg-primary hover:bg-blue-700 text-white py-2 px-4 rounded-lg") }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Existing Passwords Table -->
|
||||
<h2 class="text-2xl font-semibold pt-6">Existing Passwords</h2>
|
||||
{% if passwords %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full table-auto text-left text-sm">
|
||||
<thead class="text-muted border-b border-border">
|
||||
<tr>
|
||||
<th class="px-4 py-2">Password</th>
|
||||
<th class="px-4 py-2">Expires</th>
|
||||
<th class="px-4 py-2">Decks</th>
|
||||
<th class="px-4 py-2">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for password in passwords %}
|
||||
<tr class="border-b border-border hover:bg-background/30">
|
||||
<td class="px-4 py-2 font-medium">{{ password.value }}</td>
|
||||
<td class="px-4 py-2 local-time"
|
||||
data-utc="{{ password.expires_at.strftime('%Y-%m-%dT%H:%M:%SZ') if password.expires_at }}">
|
||||
{{ password.expires_at }}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
{% if password.decks %}
|
||||
<ul class="list-disc list-inside text-muted">
|
||||
{% for deck in password.decks %}
|
||||
<li>{{ deck.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<em class="text-muted">None</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<form method="POST" action="{{ url_for('admin.delete_password', password_id=password.id) }}">
|
||||
<button type="submit" class="bg-red-600 hover:bg-red-700 text-white px-3 py-1 rounded-lg text-sm">Delete</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No passwords available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No decks available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
<script>
|
||||
document.querySelectorAll('.local-time').forEach(el => {
|
||||
{# ── Password Form + Passwords ──────────────────────────────── #}
|
||||
<div class="bg-surface rounded-xl p-6 shadow-lg space-y-6">
|
||||
<h2 class="text-2xl font-semibold">Add New Password</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ password_form.hidden_tag() }}
|
||||
{{ styled_field(password_form.value) }}
|
||||
{{ styled_field(password_form.expires_at, {'type': 'datetime-local'}) }}
|
||||
{{ styled_field(password_form.decks) }}
|
||||
<div>
|
||||
{{ password_form.submit_password(class="w-full bg-primary hover:bg-blue-700 text-white py-2 px-4 rounded-lg") }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<h2 class="text-2xl font-semibold pt-6">Existing Passwords</h2>
|
||||
{% if passwords %}
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full table-auto text-left text-sm">
|
||||
<thead class="text-muted border-b border-border">
|
||||
<tr>
|
||||
<th class="px-4 py-2">Password</th>
|
||||
<th class="px-4 py-2">Expires</th>
|
||||
<th class="px-4 py-2">Decks</th>
|
||||
<th class="px-4 py-2">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for password in passwords %}
|
||||
<tr class="border-b border-border hover:bg-background/30">
|
||||
<td class="px-4 py-2 font-medium">{{ password.value }}</td>
|
||||
<td class="px-4 py-2 local-time"
|
||||
data-utc="{{ password.expires_at.strftime('%Y-%m-%dT%H:%M:%SZ') if password.expires_at }}">
|
||||
{{ password.expires_at }}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
{% if password.decks %}
|
||||
<ul class="list-disc list-inside text-muted">
|
||||
{% for deck in password.decks %}
|
||||
<li>{{ deck.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<em class="text-muted">None</em>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
{{ delete_button(url_for('admin.delete_password', password_id=password.id)) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No passwords available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock admin_content %}
|
||||
|
||||
{% block scripts_extra %}
|
||||
<script>
|
||||
document.querySelectorAll('.local-time').forEach(el => {
|
||||
const utcStr = el.getAttribute('data-utc');
|
||||
if (utcStr) {
|
||||
// Now utcStr is "2026-02-17T02:44:23Z"
|
||||
const date = new Date(utcStr);
|
||||
|
||||
if (!isNaN(date)) {
|
||||
el.textContent = date.toLocaleString('de-DE', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
const date = new Date(utcStr);
|
||||
if (!isNaN(date)) {
|
||||
el.textContent = date.toLocaleString('de-DE', {
|
||||
day: '2-digit', month: '2-digit', year: 'numeric',
|
||||
hour: '2-digit', minute: '2-digit'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
54
app/templates/admin_base.html
Normal file
54
app/templates/admin_base.html
Normal file
@@ -0,0 +1,54 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{#
|
||||
Admin base layout.
|
||||
Child templates can set `active_page` to one of: 'admin', 'banner', 'confused'
|
||||
to highlight the correct nav link.
|
||||
#}
|
||||
|
||||
{% block body %}
|
||||
{% block admin_nav %}
|
||||
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||
|
||||
{# Left side: logo + optional course switcher #}
|
||||
<div class="flex items-center space-x-6 rtl:space-x-reverse">
|
||||
<a href="{{ url_for('main.index') }}" class="flex items-center">
|
||||
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Tutortool</span>
|
||||
</a>
|
||||
|
||||
{% block nav_left_extra %}{% endblock %}
|
||||
</div>
|
||||
|
||||
{# Right side: nav links #}
|
||||
<div class="w-auto" id="navbar-default">
|
||||
<ul class="flex flex-row space-x-8 rtl:space-x-reverse font-medium p-0 border-0 bg-white dark:bg-gray-900">
|
||||
{% set nav_links = [
|
||||
('admin.admin', 'Deck Admin', 'admin'),
|
||||
('admin.banner', 'Banner', 'banner'),
|
||||
('admin.confused_notifications','Confused', 'confused'),
|
||||
('admin.dashboard', 'Dashboard', 'dashboard')
|
||||
] %}
|
||||
{% for endpoint, label, page_id in nav_links %}
|
||||
{% if active_page == page_id %}
|
||||
<li>
|
||||
<a href="{{ url_for(endpoint) }}"
|
||||
class="rounded-sm text-blue-700 dark:text-blue-500 font-semibold"
|
||||
aria-current="page">{{ label }}</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<a href="{{ url_for(endpoint) }}"
|
||||
class="text-gray-900 dark:text-white hover:text-blue-700 dark:hover:text-blue-500">{{ label }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</nav>
|
||||
{% endblock admin_nav %}
|
||||
|
||||
{% block admin_content %}{% endblock %}
|
||||
{% endblock body %}
|
||||
@@ -1,101 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
</head>
|
||||
<body class="bg-gray-900 text-gray-100 min-h-screen flex items-center justify-center">
|
||||
{% extends "base.html" %}
|
||||
{% from "macros/ui.html" import flash_messages %}
|
||||
|
||||
<div class="w-full max-w-sm p-6 bg-gray-800 rounded-2xl shadow-lg">
|
||||
<h2 class="text-2xl font-bold mb-6 text-center text-white">Admin Login</h2>
|
||||
{% set title = 'Admin Login' %}
|
||||
|
||||
<!-- Display Flash Messages -->
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="mb-4">
|
||||
{% for category, message in messages %}
|
||||
<div class="text-sm p-3 rounded-md {{ 'bg-red-600' if category == 'error' else 'bg-green-600' }} text-white">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block body_class %}bg-gray-900 text-gray-100 min-h-screen flex items-center justify-center{% endblock %}
|
||||
|
||||
<form method="POST" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
{% block body %}
|
||||
<div class="w-full max-w-sm p-6 bg-gray-800 rounded-2xl shadow-lg">
|
||||
<h2 class="text-2xl font-bold mb-6 text-center text-white">Admin Login</h2>
|
||||
|
||||
<!-- Username Field -->
|
||||
<div class="mb-4">
|
||||
<label for="user_name" class="block text-sm font-medium mb-1 text-gray-200">
|
||||
{{ form.user_name.label.text }}
|
||||
</label>
|
||||
{{ form.user_name(class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500") }}
|
||||
{% for error in form.user_name.errors %}
|
||||
<p class="text-red-400 text-sm mt-1">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ flash_messages() }}
|
||||
|
||||
<!-- Password Field with Toggle -->
|
||||
<div class="mb-6">
|
||||
<label for="password" class="block text-sm font-medium mb-1 text-gray-200">
|
||||
{{ form.password.label.text }}
|
||||
</label>
|
||||
<div class="relative">
|
||||
{{ form.password(
|
||||
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500",
|
||||
id="password"
|
||||
) }}
|
||||
<button type="button"
|
||||
onclick="togglePassword()"
|
||||
class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-white"
|
||||
tabindex="-1"
|
||||
aria-label="Toggle password visibility">
|
||||
<svg id="eyeIcon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% for error in form.password.errors %}
|
||||
<p class="text-red-400 text-sm mt-1">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<form method="POST" novalidate>
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div>
|
||||
<button type="submit"
|
||||
class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg shadow-md transition duration-300">
|
||||
Log In
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{# Username #}
|
||||
<div class="mb-4">
|
||||
<label for="user_name" class="block text-sm font-medium mb-1 text-gray-200">
|
||||
{{ form.user_name.label.text }}
|
||||
</label>
|
||||
{{ form.user_name(class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500") }}
|
||||
{% for error in form.user_name.errors %}
|
||||
<p class="text-red-400 text-sm mt-1">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Password Toggle Script -->
|
||||
<script>
|
||||
function togglePassword() {
|
||||
const passwordInput = document.getElementById("password");
|
||||
const icon = document.getElementById("eyeIcon");
|
||||
const isHidden = passwordInput.type === "password";
|
||||
passwordInput.type = isHidden ? "text" : "password";
|
||||
icon.innerHTML = isHidden
|
||||
? `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.542-7a9.953 9.953 0 012.159-3.362m2.649-2.35A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.542 7a9.953 9.953 0 01-4.042 4.442M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M3 3l18 18" />`
|
||||
: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />`;
|
||||
}
|
||||
</script>
|
||||
{# Password with visibility toggle #}
|
||||
<div class="mb-6">
|
||||
<label for="password" class="block text-sm font-medium mb-1 text-gray-200">
|
||||
{{ form.password.label.text }}
|
||||
</label>
|
||||
<div class="relative">
|
||||
{{ form.password(
|
||||
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500",
|
||||
id="password"
|
||||
) }}
|
||||
<button type="button"
|
||||
onclick="togglePassword()"
|
||||
class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-white"
|
||||
tabindex="-1"
|
||||
aria-label="Toggle password visibility">
|
||||
<svg id="eyeIcon" xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 24 24" stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% for error in form.password.errors %}
|
||||
<p class="text-red-400 text-sm mt-1">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<button type="submit"
|
||||
class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-lg shadow-md transition duration-300">
|
||||
Log In
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}{% endblock %}{# No Flowbite needed #}
|
||||
|
||||
{% block scripts_extra %}
|
||||
<script>
|
||||
function togglePassword() {
|
||||
const input = document.getElementById("password");
|
||||
const icon = document.getElementById("eyeIcon");
|
||||
const hide = input.type === "password";
|
||||
input.type = hide ? "text" : "password";
|
||||
icon.innerHTML = hide
|
||||
? `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.542-7a9.953 9.953 0 012.159-3.362m2.649-2.35A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.542 7a9.953 9.953 0 01-4.042 4.442M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M3 3l18 18" />`
|
||||
: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />`;
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,105 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Banner</title>
|
||||
{% extends "admin_base.html" %}
|
||||
{% from "macros/ui.html" import styled_field %}
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
{% set active_page = 'banner' %}
|
||||
{% set title = 'Banner' %}
|
||||
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
{% block admin_content %}
|
||||
<main class="max-w-5xl mx-auto px-6 py-10 space-y-12">
|
||||
|
||||
</head>
|
||||
|
||||
<body class="bg-background text-text min-h-screen font-sans">
|
||||
|
||||
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||
<a href="{{url_for('main.index')}}" class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Tutortool</span>
|
||||
</a>
|
||||
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
|
||||
<ul class="font-medium flex flex-col justify-between md:justify-evenly p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
|
||||
<li>
|
||||
<a href="{{url_for('admin.admin')}}"
|
||||
class="block py-2 px-3 text-gray-900 rounded-sm hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent">
|
||||
Deck Admin
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{url_for('admin.banner')}}"
|
||||
class="block py-2 px-3 text-white bg-blue-700 rounded-sm md:bg-transparent md:text-blue-700 md:p-0 dark:text-white md:dark:text-blue-500"
|
||||
aria-current="page">
|
||||
Banner
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{url_for('admin.confused_notifications')}}"
|
||||
class="block py-2 px-3 text-gray-900 rounded-sm hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent">
|
||||
Confused
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{# ── Banner Form ───────────────────────────────────────────────── #}
|
||||
<section class="flex justify-center">
|
||||
<div class="w-full max-w-md">
|
||||
<div class="bg-surface border border-border rounded-lg shadow-md p-6">
|
||||
<h2 class="text-xl font-semibold text-center mb-4">Enter new Banner</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ banner_form.hidden_tag() }}
|
||||
{{ styled_field(banner_form.content) }}
|
||||
<button type="submit"
|
||||
class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition">
|
||||
Add message
|
||||
</button>
|
||||
</form>
|
||||
{% if error %}
|
||||
<p class="text-red-500 text-center mt-3">{{ error }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</section>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="max-w-5xl mx-auto px-6 py-10 space-y-12">
|
||||
|
||||
<!-- Banner Form -->
|
||||
<section class="flex justify-center">
|
||||
<div class="w-full max-w-md">
|
||||
<div class="bg-surface border border-border rounded-lg shadow-md p-6">
|
||||
<h2 class="text-xl font-semibold text-center mb-4">Enter new Banner</h2>
|
||||
<form method="POST" class="space-y-4">
|
||||
{{ banner_form.hidden_tag() }}
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ banner_form.content.label }}</label>
|
||||
{{ banner_form.content(class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary") }}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition">
|
||||
Add message
|
||||
{# ── Banner List ───────────────────────────────────────────────── #}
|
||||
{% if banners %}
|
||||
<section>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for banner in banners %}
|
||||
<div class="block bg-surface border border-border rounded-xl p-5 shadow-sm hover:border-primary hover:bg-background transition">
|
||||
<h3 class="text-lg font-semibold mb-1">{{ banner.content }}</h3>
|
||||
{% if banner.is_active %}
|
||||
<form method="POST" action="{{ url_for('admin.hide_active_banner') }}">
|
||||
<button type="submit" class="w-full bg-red-600 hover:bg-red-700 text-white py-2 rounded-md transition">
|
||||
Hide
|
||||
</button>
|
||||
</form>
|
||||
{% if error %}
|
||||
<p class="text-red-500 text-center mt-3">{{ error }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% else %}
|
||||
<form method="POST" action="{{ url_for('admin.set_active_banner', banner_id=banner.id) }}">
|
||||
<button type="submit" class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition">
|
||||
Show banner
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No banners created yet.</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- Banners -->
|
||||
{% if banners %}
|
||||
<section>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for banner in banners %}
|
||||
<div class="block bg-surface border border-border rounded-xl p-5 shadow-sm hover:border-primary hover:bg-background transition">
|
||||
<h3 class="text-lg font-semibold mb-1">{{ banner.content }}</h3>
|
||||
{% if banner.is_active %}
|
||||
<form method="POST" action="{{ url_for('admin.hide_active_banner') }}">
|
||||
<button type="submit" class="w-full bg-red-600 hover:bg-red-700 text-white py-2 rounded-md transition">Hide</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<form method="POST", action="{{ url_for('admin.set_active_banner', banner_id=banner.id)}}">
|
||||
<button type="submit" class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition">
|
||||
Show banner
|
||||
</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No banners created yet.</p>
|
||||
{% endif %}
|
||||
|
||||
</main>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</main>
|
||||
{% endblock admin_content %}
|
||||
|
||||
24
app/templates/base.html
Normal file
24
app/templates/base.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>{% block title %}Tutortool{% endblock %}</title>
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
|
||||
{% block head_extra %}{% endblock %}
|
||||
</head>
|
||||
<body class="{% block body_class %}bg-background text-text min-h-screen font-sans{% endblock %}">
|
||||
|
||||
{% block body %}{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts_extra %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
13
app/templates/centered_layout.html
Normal file
13
app/templates/centered_layout.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{# Centered card layout used by login, register, and set_token pages. #}
|
||||
|
||||
{% block body_class %}flex items-center justify-center min-h-screen bg-background{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="bg-gray-800 p-8 rounded-lg shadow-lg max-w-md w-full border border-gray-700">
|
||||
{% block card_content %}{% endblock %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}{% endblock %}{# No Flowbite needed on auth pages #}
|
||||
@@ -1,99 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Live Confusion Alerts</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
{% extends "admin_base.html" %}
|
||||
|
||||
{% set active_page = 'confused' %}
|
||||
{% set title = 'Live Confusion Alerts' %}
|
||||
|
||||
{% block head_extra %}
|
||||
<script src="{{ url_for('static', filename='js/socket.io.min.js') }}"></script>
|
||||
</head>
|
||||
<body class="bg-background min-h-screen">
|
||||
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||
<a href="{{url_for('main.index')}}" class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||
<span class="self-center text-2xl font-semibold whitespace-nowrap dark:text-white">Tutortool</span>
|
||||
</a>
|
||||
<div class="hidden w-full md:block md:w-auto" id="navbar-default">
|
||||
<ul class="font-medium flex flex-col justify-between md:justify-evenly p-4 md:p-0 mt-4 border border-gray-100 rounded-lg bg-gray-50 md:flex-row md:space-x-8 rtl:space-x-reverse md:mt-0 md:border-0 md:bg-white dark:bg-gray-800 md:dark:bg-gray-900 dark:border-gray-700">
|
||||
<li>
|
||||
<a href="{{url_for('admin.admin')}}"
|
||||
class="block py-2 px-3 text-gray-900 rounded-sm hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent">
|
||||
Deck Admin
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{url_for('admin.banner')}}"
|
||||
class="block py-2 px-3 text-gray-900 rounded-sm hover:bg-gray-100 md:hover:bg-transparent md:border-0 md:hover:text-blue-700 md:p-0 dark:text-white md:dark:hover:text-blue-500 dark:hover:bg-gray-700 dark:hover:text-white md:dark:hover:bg-transparent">
|
||||
Banner
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{url_for('admin.confused_notifications')}}"
|
||||
class="block py-2 px-3 text-white bg-blue-700 rounded-sm md:bg-transparent md:text-blue-700 md:p-0 dark:text-white md:dark:text-blue-500"
|
||||
aria-current="page">
|
||||
Confused
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
<div class="max-w-3xl mx-auto mt-12 px-4">
|
||||
<h1 class="text-3xl font-bold mb-6 dark:text-white">Live Confusion Alerts</h1>
|
||||
<div id="notif-list" class="space-y-4 text-gray-700">
|
||||
<p class="italic text-gray-500">Waiting for students to click "I'm confused…"</p>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
{% endblock admin_content %}
|
||||
|
||||
{% block scripts %}{% endblock %}{# No Flowbite needed #}
|
||||
|
||||
<div class="max-w-3xl mx-auto mt-12 px-4">
|
||||
<h1 class="text-3xl font-bold mb-6 dark:text-white">Live Confusion Alerts</h1>
|
||||
<div id="notif-list" class="space-y-4 text-gray-700">
|
||||
<p class="italic text-gray-500">Waiting for students to click “I’m confused…”</p>
|
||||
</div>
|
||||
</div>
|
||||
{% block scripts_extra %}
|
||||
<script>
|
||||
const notifList = document.getElementById("notif-list");
|
||||
const socket = io({ transports: ['websocket'] });
|
||||
|
||||
<!-- Socket.IO client (served by your Flask-SocketIO) -->
|
||||
<script>
|
||||
const notifList = document.getElementById("notif-list");
|
||||
const socket = io({ transports: ['websocket'] });
|
||||
socket.on("confused", data => {
|
||||
if (notifList.children.length === 1 &&
|
||||
notifList.children[0].classList.contains("italic")) {
|
||||
notifList.innerHTML = "";
|
||||
}
|
||||
|
||||
socket.on("confused", data => {
|
||||
// Remove placeholder if it’s still there
|
||||
if (notifList.children.length === 1 &&
|
||||
notifList.children[0].classList.contains("italic")) {
|
||||
notifList.innerHTML = "";
|
||||
}
|
||||
const box = document.createElement("div");
|
||||
box.className = [
|
||||
"flex items-start",
|
||||
"bg-red-50 border border-red-400",
|
||||
"text-red-800 px-4 py-3 rounded-lg shadow",
|
||||
"relative"
|
||||
].join(" ");
|
||||
|
||||
// Build a new alert box
|
||||
const box = document.createElement("div");
|
||||
box.className = [
|
||||
"flex items-start",
|
||||
"bg-red-50 border border-red-400",
|
||||
"text-red-800 px-4 py-3 rounded-lg shadow",
|
||||
"relative"
|
||||
].join(" ");
|
||||
const who = data.who || "Someone";
|
||||
const now = new Date().toLocaleTimeString();
|
||||
box.innerHTML = `
|
||||
<div class="flex-1">
|
||||
<strong class="font-semibold">Confused!</strong>
|
||||
<p>${who} clicked "I'm confused." at ${now}</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Message text
|
||||
const who = data.who || "Someone";
|
||||
const now = new Date().toLocaleTimeString();
|
||||
box.innerHTML = `
|
||||
<div class="flex-1">
|
||||
<strong class="font-semibold">Confused!</strong>
|
||||
<p>${who} clicked “I’m confused.” at ${now}</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Close button
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "ml-4 text-red-600 hover:text-red-900 focus:outline-none";
|
||||
btn.setAttribute("aria-label", "Dismiss");
|
||||
btn.innerHTML = "×";
|
||||
btn.onclick = () => box.remove();
|
||||
|
||||
box.appendChild(btn);
|
||||
|
||||
// Prepend new alert
|
||||
notifList.prepend(box);
|
||||
|
||||
// Auto‐remove after 20 s
|
||||
setTimeout(() => box.remove(), 20000);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
const btn = document.createElement("button");
|
||||
btn.className = "ml-4 text-red-600 hover:text-red-900 focus:outline-none";
|
||||
btn.setAttribute("aria-label", "Dismiss");
|
||||
btn.innerHTML = "×";
|
||||
btn.onclick = () => box.remove();
|
||||
box.appendChild(btn);
|
||||
|
||||
notifList.prepend(box);
|
||||
setTimeout(() => box.remove(), 20000);
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
14
app/templates/dashboard.html
Normal file
14
app/templates/dashboard.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends "admin_base.html" %}
|
||||
|
||||
{% set active_page = 'dashboard' %}
|
||||
{% set title = 'Dashboard' %}
|
||||
|
||||
{% block admin_content %}
|
||||
<div class="flex flex-col" style="height: calc(100vh - 57px);">
|
||||
<iframe
|
||||
src="{{ grafana_url }}?kiosk"
|
||||
class="w-full flex-1 border-0"
|
||||
allowfullscreen>
|
||||
</iframe>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -1,60 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="dark">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tutorial Materials</title>
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
{% extends "base.html" %}
|
||||
{% from "macros/ui.html" import course_switcher %}
|
||||
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
|
||||
{% set title = 'Tutorial Materials' %}
|
||||
|
||||
{% block head_extra %}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.1/socket.io.min.js"></script>
|
||||
|
||||
<script src="https://unpkg.com/htmx.org@1.9.10"></script>
|
||||
</head>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<body class="bg-background text-text min-h-screen font-sans">
|
||||
|
||||
<!-- Header -->
|
||||
{# ── Header ────────────────────────────────────────────────────── #}
|
||||
<header class="bg-surface border-b border-border shadow-sm">
|
||||
<div class="w-full px-6 py-4 flex items-center justify-between" >
|
||||
<div class="w-full px-6 py-3 flex items-center justify-between gap-4">
|
||||
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="text-gray-700 dark:text-gray-200 text-base font-medium whitespace-nowrap">
|
||||
User: {{ user_name }}
|
||||
{# Left: user + logout #}
|
||||
<div class="flex items-center gap-2 min-w-0">
|
||||
<span class="text-gray-700 dark:text-gray-200 text-sm font-medium truncate">
|
||||
{{ user_name }}
|
||||
</span>
|
||||
|
||||
<form method="POST" action="/logout">
|
||||
<button
|
||||
type="submit"
|
||||
class="text-sm text-white bg-red-600 px-3 py-1 rounded-md hover:bg-red-700 transition"
|
||||
>
|
||||
<button type="submit"
|
||||
class="text-xs text-white bg-red-600 px-2.5 py-1 rounded-md hover:bg-red-700 transition">
|
||||
Logout
|
||||
</button>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="flex items-center space-x-3">
|
||||
<a href="https://zulip.in.tum.de/#narrow/channel/3234-ITSec-Tutorium-Simon-Bu.C3.9Fmann" target="_blank">
|
||||
<img src="{{ url_for('static', filename='zulip_icon.svg') }}" class="h-8 w-8">
|
||||
</a>
|
||||
<a href="https://discordapp.com/users/306086176585154560" target="_blank" class="mr-6">
|
||||
<img src="{{ url_for('static', filename='discord_icon.svg') }}" class="h-8 w-8">
|
||||
</a>
|
||||
|
||||
{# Center: course switcher #}
|
||||
<div class="flex justify-center">
|
||||
{{ course_switcher(courses, active_course_name, '/switch_course') }}
|
||||
</div>
|
||||
|
||||
{# Right: social links + admin #}
|
||||
<div class="flex items-center gap-3">
|
||||
<a href="https://zulip.in.tum.de/#narrow/channel/3234-ITSec-Tutorium-Simon-Bu.C3.9Fmann" target="_blank">
|
||||
<img src="{{ url_for('static', filename='zulip_icon.svg') }}" class="h-7 w-7">
|
||||
</a>
|
||||
<a href="https://discordapp.com/users/306086176585154560" target="_blank">
|
||||
<img src="{{ url_for('static', filename='discord_icon.svg') }}" class="h-7 w-7">
|
||||
</a>
|
||||
<a href="{{ url_for('admin.admin') }}">
|
||||
<button class="bg-primary hover:bg-blue-700 text-white px-3 py-1 rounded-md transition">
|
||||
<button class="bg-primary hover:bg-blue-700 text-white text-sm px-3 py-1 rounded-md transition">
|
||||
Admin
|
||||
</button>
|
||||
</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</header> <!-- Main Content -->
|
||||
</header>
|
||||
|
||||
{# ── Main Content ──────────────────────────────────────────────── #}
|
||||
<main class="max-w-5xl mx-auto px-6 py-10 space-y-12">
|
||||
|
||||
|
||||
{% if active_banner %}
|
||||
<section class="flex justify-center">
|
||||
<div class="p-4 text-sm text-yellow-800 rounded-lg bg-yellow-50 dark:bg-gray-800 dark:text-yellow-300" role="alert">
|
||||
@@ -63,30 +60,8 @@
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<div class="flex justify-center">
|
||||
<div class="relative group">
|
||||
<button class="flex items-center text-gray-900 dark:text-white hover:text-blue-700 dark:hover:text-blue-500 font-medium py-1 px-3 rounded-lg bg-transparent text-2xl">
|
||||
{{active_course_name}}
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div class="absolute hidden group-hover:block bg-white divide-y divide-gray-100 rounded-lg shadow dark:bg-gray-700 z-50">
|
||||
<ul class="py-2 px-4 text-sm text-gray-700 dark:text-gray-200">
|
||||
{% for course in courses %}
|
||||
<li>
|
||||
<form method="POST" action="/switch_course/{{ course.id }}">
|
||||
<button type="submit"> {{ course.name }}</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Password Form -->
|
||||
{# ── Password Form ─────────────────────────────────────────── #}
|
||||
<section class="flex justify-center">
|
||||
<div class="w-full max-w-md">
|
||||
<div class="bg-surface border border-border rounded-lg shadow-md p-6">
|
||||
@@ -100,68 +75,66 @@
|
||||
autofocus
|
||||
class="w-full px-4 py-3 rounded-md bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary"
|
||||
/>
|
||||
<button
|
||||
type="submit"
|
||||
class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition"
|
||||
>
|
||||
<button type="submit"
|
||||
class="w-full bg-primary hover:bg-blue-700 text-white py-2 rounded-md transition">
|
||||
Unlock
|
||||
</button>
|
||||
</form>
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="flashed-messages">
|
||||
{% for category, message in messages %}
|
||||
{% if category == 'error' %}
|
||||
<p class="text-red-500 text-center mt-3">{{ message }}</p>
|
||||
{% elif category == 'expired' %}
|
||||
<p class="text-orange-500 text-center mt-3">{{ message }}</p>
|
||||
{% else %}
|
||||
<p class="text-gray-500 text-center mt-3">{{ message }}</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if messages %}
|
||||
<div class="flashed-messages mt-3 space-y-2">
|
||||
{% for category, message in messages %}
|
||||
{% if category == 'error' %}
|
||||
<p class="text-red-500 text-center">{{ message }}</p>
|
||||
{% elif category == 'expired' %}
|
||||
<p class="text-orange-500 text-center">{{ message }}</p>
|
||||
{% else %}
|
||||
<p class="text-gray-500 text-center">{{ message }}</p>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Deck Cards -->
|
||||
{# ── Deck Cards ────────────────────────────────────────────── #}
|
||||
{% if decks %}
|
||||
<section>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||
{% for deck in decks %}
|
||||
<div class="bg-surface border border-border rounded-xl shadow-sm transition hover:shadow-lg flex flex-col">
|
||||
|
||||
<div class="flex items-center p-5 gap-4">
|
||||
|
||||
<a href="/slides/{{deck.course.folder}}/{{ deck.deck }}/{{ deck.index_file}}"
|
||||
class="flex-grow block border-r border-border pr-4 hover:border-primary transition rounded-xl">
|
||||
<h3 class="text-lg font-semibold mb-1">{{ deck.name }}</h3>
|
||||
<p class="text-muted text-sm">{{ deck.description }}</p>
|
||||
</a>
|
||||
{% if deck.export_file %}
|
||||
<a href="/slides/{{deck.course.folder}}/{{ deck.deck }}/export"
|
||||
class="inline-flex items-center justify-center flex-shrink-0 h-10 w-10 text-on-primary hover:bg-primary/90 transition"
|
||||
download title="Download Presentation">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="flex items-stretch p-5 gap-4">
|
||||
|
||||
<a href="/slides/{{ deck.course.folder }}/{{ deck.deck }}/{{ deck.index_file }}"
|
||||
class="flex-grow block hover:text-primary transition">
|
||||
<h3 class="text-lg font-semibold mb-1">{{ deck.name }}</h3>
|
||||
<p class="text-muted text-sm">{{ deck.description }}</p>
|
||||
</a>
|
||||
|
||||
{% if deck.export_file %}
|
||||
<div class="w-px bg-border self-stretch"></div>
|
||||
|
||||
<a href="/slides/{{ deck.course.folder }}/{{ deck.deck }}/export"
|
||||
class="inline-flex items-center justify-center flex-shrink-0 w-10 text-muted hover:text-primary transition"
|
||||
download title="Download Presentation">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24"
|
||||
stroke="currentColor" stroke-width="2">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
||||
</svg>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% else %}
|
||||
<p class="text-center text-muted">No decks unlocked yet.</p>
|
||||
{% endif %}
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock body %}
|
||||
|
||||
133
app/templates/macros/ui.html
Normal file
133
app/templates/macros/ui.html
Normal file
@@ -0,0 +1,133 @@
|
||||
{#
|
||||
Reusable UI macros for Tutortool templates.
|
||||
Usage: {% from "macros/ui.html" import flash_messages, styled_field, text_input %}
|
||||
#}
|
||||
|
||||
|
||||
{# Renders all flashed messages with colour-coded styling. #}
|
||||
{% macro flash_messages() %}
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="space-y-3 mb-6">
|
||||
{% for category, message in messages %}
|
||||
{% if category == 'error' %}
|
||||
{% set alert_class = 'bg-red-900 border-red-400 text-red-100' %}
|
||||
{% elif category == 'expired' %}
|
||||
{% set alert_class = 'bg-orange-900 border-orange-400 text-orange-100' %}
|
||||
{% else %}
|
||||
{% set alert_class = 'bg-green-900 border-green-400 text-green-100' %}
|
||||
{% endif %}
|
||||
<div class="p-3 border rounded-lg {{ alert_class }}" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{#
|
||||
Renders a WTForms field with a label and standard Tailwind styling.
|
||||
Pass extra_kwargs as a dict for additional HTML attributes (e.g. type, multiple).
|
||||
#}
|
||||
{% macro styled_field(field, extra_kwargs={}) %}
|
||||
<div>
|
||||
<label class="block mb-1 text-sm font-medium">{{ field.label }}</label>
|
||||
{{ field(
|
||||
class="w-full rounded-lg p-3 bg-background border border-border text-text placeholder-muted focus:outline-none focus:ring-2 focus:ring-primary",
|
||||
**extra_kwargs
|
||||
) }}
|
||||
{% for error in field.errors %}
|
||||
<p class="text-red-400 text-sm mt-1">{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{#
|
||||
Renders a plain <input> (not WTForms) with standard styling.
|
||||
`type` defaults to 'text'.
|
||||
#}
|
||||
{% macro text_input(name, label, placeholder='', type='text', required=true, autofocus=false) %}
|
||||
<div class="mb-4">
|
||||
<label for="{{ name }}" class="block text-sm font-medium text-gray-400 mb-2">{{ label }}</label>
|
||||
<input
|
||||
type="{{ type }}"
|
||||
id="{{ name }}"
|
||||
name="{{ name }}"
|
||||
placeholder="{{ placeholder }}"
|
||||
{% if required %}required{% endif %}
|
||||
{% if autofocus %}autofocus{% endif %}
|
||||
class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{# Renders a delete button wrapped in a form. #}
|
||||
{% macro delete_button(action_url, label='Delete') %}
|
||||
<form method="POST" action="{{ action_url }}">
|
||||
<button type="submit" class="bg-red-600 hover:bg-red-700 text-white px-3 py-1 rounded-lg text-sm">
|
||||
{{ label }}
|
||||
</button>
|
||||
</form>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{# Course-switcher dropdown (used in admin and index pages). #}
|
||||
{% macro course_switcher(courses, active_course_name, switch_url_prefix) %}
|
||||
<div class="relative" id="course-switcher">
|
||||
<button
|
||||
type="button"
|
||||
onclick="toggleCourseSwitcher()"
|
||||
class="flex items-center gap-2 px-4 py-1.5 rounded-lg border border-border bg-surface
|
||||
text-sm font-medium text-text hover:border-primary hover:text-primary transition whitespace-nowrap">
|
||||
<span id="course-switcher-label">{{ active_course_name }}</span>
|
||||
<svg class="w-3.5 h-3.5 text-muted transition-transform duration-200" id="course-switcher-chevron"
|
||||
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
</button>
|
||||
|
||||
<div id="course-switcher-menu"
|
||||
class="hidden absolute left-1/2 -translate-x-1/2 mt-2 w-52 z-50
|
||||
bg-surface border border-border rounded-xl shadow-lg overflow-hidden whitespace-nowrap">
|
||||
{% for course in courses %}
|
||||
<form method="POST" action="{{ switch_url_prefix }}/{{ course.id }}">
|
||||
<button type="submit"
|
||||
class="w-full text-left px-4 py-2.5 text-sm
|
||||
{% if course.name == active_course_name %}
|
||||
text-primary font-semibold bg-primary/10
|
||||
{% else %}
|
||||
text-text hover:bg-background hover:text-primary
|
||||
{% endif %}
|
||||
transition">
|
||||
{{ course.name }}
|
||||
</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function toggleCourseSwitcher() {
|
||||
const menu = document.getElementById('course-switcher-menu');
|
||||
const chevron = document.getElementById('course-switcher-chevron');
|
||||
const isOpen = !menu.classList.contains('hidden');
|
||||
menu.classList.toggle('hidden', isOpen);
|
||||
chevron.style.transform = isOpen ? '' : 'rotate(180deg)';
|
||||
|
||||
if (!isOpen) {
|
||||
// Close when clicking outside
|
||||
document.addEventListener('click', function handler(e) {
|
||||
if (!document.getElementById('course-switcher').contains(e.target)) {
|
||||
menu.classList.add('hidden');
|
||||
chevron.style.transform = '';
|
||||
document.removeEventListener('click', handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endmacro %}
|
||||
@@ -1,61 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register for Tutortool</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
</head>
|
||||
<body class="flex items-center justify-center min-h-screen bg-background">
|
||||
<div class="bg-gray-800 p-8 rounded-lg shadow-lg max-w-md w-full border border-gray-700">
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-3xl font-bold text-white mb-2">Create an Account</h1>
|
||||
<p class="text-muted text-sm">Choose a username to get started.</p>
|
||||
</div>
|
||||
{% extends "centered_layout.html" %}
|
||||
{% from "macros/ui.html" import flash_messages, text_input %}
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="space-y-3 mb-6">
|
||||
{% for category, message in messages %}
|
||||
{% set alert_class = 'bg-red-900 border-red-400 text-red-100' if category == 'error' else 'bg-green-900 border-green-400 text-green-100' %}
|
||||
<div class="p-3 border rounded-lg {{ alert_class }}" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% set title = 'Register – Tutortool' %}
|
||||
|
||||
<form action="/register" method="POST" class="space-y-6">
|
||||
<!-- Flask-WTF form fields will be injected here -->
|
||||
<div class="mb-4">
|
||||
<label for="username" class="block text-sm font-medium text-gray-400 mb-2">Username</label>
|
||||
<input type="text" id="username" name="username" placeholder="Your unique username" required class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
{% block card_content %}
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-3xl font-bold text-white mb-2">Create an Account</h1>
|
||||
<p class="text-muted text-sm">Choose a username to get started.</p>
|
||||
</div>
|
||||
|
||||
<div class="bg-gray-700 p-4 rounded-lg border border-gray-600 space-y-3">
|
||||
<h3 class="text-sm font-semibold text-gray-200">Important Information</h3>
|
||||
<p class="text-xs text-gray-400">
|
||||
Your username is tied to the slides using a browser cookie. If you clear your cookies, you can regain access to your slides by logging in with the same username.
|
||||
</p>
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" id="acknowledge" name="acknowledge" required class="h-4 w-4 text-blue-500 rounded border-gray-300 focus:ring-blue-500">
|
||||
<label for="acknowledge" class="ml-2 block text-sm text-gray-400">
|
||||
I understand and agree
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition-colors">
|
||||
Register
|
||||
</button>
|
||||
</form>
|
||||
{{ flash_messages() }}
|
||||
|
||||
<p class="text-center mt-4 text-sm text-text">
|
||||
Already have an account? <a href="/set_token" class="text-blue-400 hover:underline">Log In</a>
|
||||
</p>
|
||||
<form action="/register" method="POST" class="space-y-6">
|
||||
{{ text_input('username', 'Username', placeholder='Your unique username') }}
|
||||
|
||||
<div class="bg-gray-700 p-4 rounded-lg border border-gray-600 space-y-3">
|
||||
<h3 class="text-sm font-semibold text-gray-200">Important Information</h3>
|
||||
<p class="text-xs text-gray-400">
|
||||
Your username is tied to the slides using a browser cookie. If you clear your cookies,
|
||||
you can regain access to your slides by logging in with the same username.
|
||||
</p>
|
||||
<div class="flex items-center">
|
||||
<input type="checkbox" id="acknowledge" name="acknowledge" required
|
||||
class="h-4 w-4 text-blue-500 rounded border-gray-300 focus:ring-blue-500">
|
||||
<label for="acknowledge" class="ml-2 block text-sm text-gray-400">
|
||||
I understand and agree
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<button type="submit"
|
||||
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition-colors">
|
||||
Register
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="text-center mt-4 text-sm text-text">
|
||||
Already have an account?
|
||||
<a href="/set_token" class="text-blue-400 hover:underline">Log In</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,47 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Register for Tutortool</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/output.css') }}">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
</head>
|
||||
<body class="flex items-center justify-center min-h-screen bg-background">
|
||||
<div class="bg-gray-800 p-8 rounded-lg shadow-lg max-w-md w-full border border-gray-700">
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-3xl font-bold text-white mb-2">Login</h1>
|
||||
</div>
|
||||
{% extends "centered_layout.html" %}
|
||||
{% from "macros/ui.html" import flash_messages, text_input %}
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
<div class="space-y-3 mb-6">
|
||||
{% for category, message in messages %}
|
||||
{% set alert_class = 'bg-red-900 border-red-400 text-red-100' if category == 'error' else 'bg-green-900 border-green-400 text-green-100' %}
|
||||
<div class="p-3 border rounded-lg {{ alert_class }}" role="alert">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<form action="/set_token" method="POST" class="space-y-6">
|
||||
<!-- Flask-WTF form fields will be injected here -->
|
||||
<div class="mb-4">
|
||||
<label for="username" class="block text-sm font-medium text-gray-400 mb-2">Username</label>
|
||||
<input type="text" id="username" name="username" placeholder="Your unique username" required class="w-full px-4 py-2 bg-gray-700 border border-gray-600 rounded-lg text-white focus:outline-none focus:ring-2 focus:ring-blue-500">
|
||||
</div>
|
||||
|
||||
<button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition-colors">
|
||||
Login
|
||||
</button>
|
||||
</form>
|
||||
{% set title = 'Login – Tutortool' %}
|
||||
|
||||
<p class="text-center mt-4 text-sm text-text">
|
||||
Do not have an Account? <a href="/register" class="text-blue-400 hover:underline">Create one</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% block card_content %}
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-3xl font-bold text-white mb-2">Login</h1>
|
||||
</div>
|
||||
|
||||
{{ flash_messages() }}
|
||||
|
||||
<form action="/set_token" method="POST" class="space-y-6">
|
||||
{{ text_input('username', 'Username', placeholder='Your unique username') }}
|
||||
|
||||
<button type="submit"
|
||||
class="w-full bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-lg transition-colors">
|
||||
Login
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="text-center mt-4 text-sm text-text">
|
||||
Do not have an Account?
|
||||
<a href="/register" class="text-blue-400 hover:underline">Create one</a>
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user