Added centralized templating system with static asset serving.
CI / Formatting (push) Successful in 13s
CI / Linting (push) Successful in 14s
CI / Tests (Python 3.12) (push) Failing after 29s
CI / Tests (Python 3.13) (push) Failing after 29s
CI / Tests (Python 3.14) (push) Failing after 26s
CI / Type Checking (push) Failing after 25s
CI / Spelling (push) Successful in 13s
CI / Formatting (push) Successful in 13s
CI / Linting (push) Successful in 14s
CI / Tests (Python 3.12) (push) Failing after 29s
CI / Tests (Python 3.13) (push) Failing after 29s
CI / Tests (Python 3.14) (push) Failing after 26s
CI / Type Checking (push) Failing after 25s
CI / Spelling (push) Successful in 13s
This commit is contained in:
@@ -14,19 +14,10 @@
|
||||
|
||||
"""Web routes for the custom commands module."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
from aiohttp import web
|
||||
|
||||
from owlbot.api import RouteContext, on_route
|
||||
|
||||
_template_dir = Path(__file__).resolve().parent / "templates"
|
||||
_jinja_env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(_template_dir),
|
||||
autoescape=True,
|
||||
)
|
||||
|
||||
|
||||
@on_route("/list", methods=["GET"])
|
||||
async def command_list_page(ctx: RouteContext) -> web.Response:
|
||||
@@ -63,7 +54,5 @@ async def command_list_page(ctx: RouteContext) -> web.Response:
|
||||
for row in rows
|
||||
]
|
||||
|
||||
template = _jinja_env.get_template("list.html")
|
||||
page = template.render(commands=commands, prefix=ctx.commands.prefix)
|
||||
|
||||
page = ctx.templates.render("list.html", commands=commands, prefix=prefix)
|
||||
return web.Response(text=page, content_type="text/html")
|
||||
|
||||
@@ -1,43 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Custom Commands</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2rem; }
|
||||
table { border-collapse: collapse; width: 100%; }
|
||||
th, td { border: 1px solid #ccc; padding: 0.5rem 0.75rem; text-align: left; }
|
||||
th { background: #f5f5f5; }
|
||||
td:nth-child(4), th:nth-child(4),
|
||||
td:nth-child(5), th:nth-child(5) { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Custom Commands</h1>
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Custom Commands{% endblock %}
|
||||
{% block content %}
|
||||
<h1 class="mb-3">Custom Commands</h1>
|
||||
{% if commands %}
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th>Command</th>
|
||||
<th>Aliases</th>
|
||||
<th>Response</th>
|
||||
<th>Cooldown</th>
|
||||
<th>Permissions</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for cmd in commands %}
|
||||
<tr>
|
||||
<td>{{ prefix }}{{ cmd.name }}</td>
|
||||
<td>{{ cmd.aliases }}</td>
|
||||
<td>{{ cmd.response }}</td>
|
||||
<td>{{ cmd.cooldown }}</td>
|
||||
<td>{{ cmd.permissions }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Command</th>
|
||||
<th>Aliases</th>
|
||||
<th>Response</th>
|
||||
<th class="text-center">Cooldown</th>
|
||||
<th class="text-center">Permissions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for cmd in commands %}
|
||||
<tr>
|
||||
<td>{{ prefix }}{{ cmd.name }}</td>
|
||||
<td>{{ cmd.aliases }}</td>
|
||||
<td>{{ cmd.response }}</td>
|
||||
<td class="text-center">{{ cmd.cooldown }}</td>
|
||||
<td class="text-center">{{ cmd.permissions }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No custom commands defined.</p>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
||||
@@ -18,9 +18,7 @@ Allows moderators to store quotes and anyone to recall random quotes.
|
||||
"""
|
||||
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
from aiohttp import web
|
||||
|
||||
from owlbot.api import (
|
||||
@@ -32,12 +30,6 @@ from owlbot.api import (
|
||||
on_setup,
|
||||
)
|
||||
|
||||
_template_dir = Path(__file__).resolve().parent / "templates"
|
||||
_jinja_env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(_template_dir),
|
||||
autoescape=True,
|
||||
)
|
||||
|
||||
|
||||
@on_setup
|
||||
async def setup(ctx: ModuleContext) -> None:
|
||||
@@ -84,9 +76,7 @@ async def quotes_list_page(ctx: RouteContext) -> web.Response:
|
||||
for row in rows
|
||||
]
|
||||
|
||||
template = _jinja_env.get_template("list.html")
|
||||
page = template.render(quotes=quotes)
|
||||
|
||||
page = ctx.templates.render("list.html", quotes=quotes)
|
||||
return web.Response(text=page, content_type="text/html")
|
||||
|
||||
|
||||
|
||||
@@ -1,40 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Quotes</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2rem; }
|
||||
table { border-collapse: collapse; width: 100%; }
|
||||
th, td { border: 1px solid #ccc; padding: 0.5rem 0.75rem; text-align: left; }
|
||||
th { background: #f5f5f5; }
|
||||
td:first-child, th:first-child { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Quotes</h1>
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Quotes{% endblock %}
|
||||
{% block content %}
|
||||
<h1 class="mb-3">Quotes</h1>
|
||||
{% if quotes %}
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th>#</th>
|
||||
<th>Quote</th>
|
||||
<th>Added By</th>
|
||||
<th>Date Added</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for quote in quotes %}
|
||||
<tr>
|
||||
<td>{{ quote.id }}</td>
|
||||
<td>{{ quote.text }}</td>
|
||||
<td>{{ quote.added_by }}</td>
|
||||
<td>{{ quote.date }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">#</th>
|
||||
<th>Quote</th>
|
||||
<th>Added By</th>
|
||||
<th>Date Added</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for quote in quotes %}
|
||||
<tr>
|
||||
<td class="text-center">{{ quote.id }}</td>
|
||||
<td>{{ quote.text }}</td>
|
||||
<td>{{ quote.added_by }}</td>
|
||||
<td>{{ quote.date }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No quotes have been added yet.</p>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
||||
@@ -15,19 +15,11 @@
|
||||
"""Web routes for the timers module."""
|
||||
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import jinja2
|
||||
from aiohttp import web
|
||||
|
||||
from owlbot.api import RouteContext, on_route
|
||||
|
||||
_template_dir = Path(__file__).resolve().parent / "templates"
|
||||
_jinja_env = jinja2.Environment(
|
||||
loader=jinja2.FileSystemLoader(_template_dir),
|
||||
autoescape=True,
|
||||
)
|
||||
|
||||
|
||||
@on_route("/list", methods=["GET"])
|
||||
async def timer_list_page(ctx: RouteContext) -> web.Response:
|
||||
@@ -67,7 +59,5 @@ async def timer_list_page(ctx: RouteContext) -> web.Response:
|
||||
}
|
||||
)
|
||||
|
||||
template = _jinja_env.get_template("list.html")
|
||||
page = template.render(timers=timers)
|
||||
|
||||
page = ctx.templates.render("list.html", timers=timers)
|
||||
return web.Response(text=page, content_type="text/html")
|
||||
|
||||
@@ -1,49 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Timers</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; margin: 2rem; }
|
||||
table { border-collapse: collapse; width: 100%; }
|
||||
th, td { border: 1px solid #ccc; padding: 0.5rem 0.75rem; text-align: left; }
|
||||
th { background: #f5f5f5; }
|
||||
td:first-child, th:first-child,
|
||||
td:nth-child(4), th:nth-child(4),
|
||||
td:nth-child(5), th:nth-child(5),
|
||||
td:nth-child(6), th:nth-child(6) { text-align: center; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Timers</h1>
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Timers{% endblock %}
|
||||
{% block content %}
|
||||
<h1 class="mb-3">Timers</h1>
|
||||
{% if timers %}
|
||||
<table>
|
||||
<thead><tr>
|
||||
<th>#</th>
|
||||
<th>Name</th>
|
||||
<th>Message</th>
|
||||
<th>Interval</th>
|
||||
<th>Min Lines</th>
|
||||
<th>Status</th>
|
||||
<th>Last Fired</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{% for timer in timers %}
|
||||
<tr>
|
||||
<td>{{ timer.id }}</td>
|
||||
<td>{{ timer.name }}</td>
|
||||
<td>{{ timer.message }}</td>
|
||||
<td>{{ timer.interval }}</td>
|
||||
<td>{{ timer.min_lines }}</td>
|
||||
<td>{{ timer.status }}</td>
|
||||
<td>{{ timer.last_fired }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<table class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">#</th>
|
||||
<th>Name</th>
|
||||
<th>Message</th>
|
||||
<th class="text-center">Interval</th>
|
||||
<th class="text-center">Min Lines</th>
|
||||
<th class="text-center">Status</th>
|
||||
<th>Last Fired</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for timer in timers %}
|
||||
<tr>
|
||||
<td class="text-center">{{ timer.id }}</td>
|
||||
<td>{{ timer.name }}</td>
|
||||
<td>{{ timer.message }}</td>
|
||||
<td class="text-center">{{ timer.interval }}</td>
|
||||
<td class="text-center">{{ timer.min_lines }}</td>
|
||||
<td class="text-center">{{ timer.status }}</td>
|
||||
<td>{{ timer.last_fired }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
<p>No timers have been created yet.</p>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user