1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-05 20:27:45 +00:00

Add Bootstrap styling to most web pages

I haven't changed any of the content yet, only included the Boostrap CSS
and unified their base template.
This commit is contained in:
Joshua Goins 2025-05-03 11:56:27 -04:00
parent 91ebe38de1
commit f2c009b9a7
15 changed files with 155 additions and 55 deletions

67
Cargo.lock generated
View file

@ -427,6 +427,12 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-sink"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
[[package]]
name = "futures-task"
version = "0.3.31"
@ -514,6 +520,12 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "http-range-header"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c"
[[package]]
name = "httparse"
version = "1.10.1"
@ -757,6 +769,7 @@ dependencies = [
"serde_json",
"serde_yaml_ng",
"tokio",
"tower-http",
"tracing",
"tracing-subscriber",
"zip",
@ -887,6 +900,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "minijinja"
version = "2.9.0"
@ -1457,6 +1480,19 @@ dependencies = [
"syn 2.0.100",
]
[[package]]
name = "tokio-util"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"pin-project-lite",
"tokio",
]
[[package]]
name = "tower"
version = "0.5.2"
@ -1472,6 +1508,31 @@ dependencies = [
"tower-service",
]
[[package]]
name = "tower-http"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697"
dependencies = [
"bitflags 2.9.0",
"bytes",
"futures-util",
"http",
"http-body",
"http-body-util",
"http-range-header",
"httpdate",
"mime",
"mime_guess",
"percent-encoding",
"pin-project-lite",
"tokio",
"tokio-util",
"tower-layer",
"tower-service",
"tracing",
]
[[package]]
name = "tower-layer"
version = "0.3.3"
@ -1526,6 +1587,12 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c"
[[package]]
name = "unicase"
version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
[[package]]
name = "unicode-ident"
version = "1.0.18"

View file

@ -71,7 +71,7 @@ tracing-subscriber = { version = "0.3", features = ["fmt"], default-features = f
fastrand = { version = "2.3", features = ["std"], default-features = false }
# HTML templates used in the web servers
minijinja = { version = "2.9", features = ["serde", "loader"], default-features = false }
minijinja = { version = "2.9", features = ["serde", "loader", "multi_template"], default-features = false }
# Serialization of packets
binrw = { version = "0.14", features = ["std"], default-features = false }
@ -100,3 +100,6 @@ reqwest = { version = "0.12", default-features = false }
# For RCON
rkon = { version = "0.1" }
# For serving static files on the website
tower-http = { version = "0.6", features = ["fs"] }

6
resources/static/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,8 @@
{% extends "layout.html" %}
{% block title %}Manage Account{% endblock %}
{% block body %}
<p>Managing account {{ username }}</p>
<a href="/account/app/svc/logout">Logout</a>
<a href="/account/app/svc/mbrPasswd">Change Password</a>
@ -9,3 +14,4 @@
<input type="file" id="charbak" name="charbak" accept="application/zip" />
<button type='submit'>Upload</button>
</form>
{% endblock %}

View file

@ -1,3 +1,8 @@
{% extends "layout.html" %}
{% block title %}Kawari Admin Panel{% endblock %}
{% block body %}
<p>Gate open:{{ worlds_open }}</p>
<p>Gate open:{{ login_open }}</p>
<p>Boot patch location:{{ boot_patch_location }}</p>
@ -15,4 +20,5 @@
<input type='text' id='boot_patch_location' name='boot_patch_location'/>
</label>
<button type='submit'>Apply</button>
</form>
</form>
{% endblock %}

View file

@ -1,11 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kawari - Change Password</title>
</head>
<body>
{% extends "layout.html" %}
{% block title %}Kawari - Change Password{% endblock %}
{% block body %}
<form method='post'>
<label for="old_password">Old Password:</label><br>
<input type='text' id='old_password' name='old_password'/><br>
@ -13,6 +10,4 @@
<input type='text' id='new_ppassword' name='new_password'/><br>
<button type='submit'>Submit</button>
</form>
</body>
</html>
{% endblock %}

View file

@ -0,0 +1,10 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}some website{% endblock %}</title>
<link href="/static/bootstrap.min.css" rel="stylesheet">
</head>
<body>{% block body %}{% endblock %}</body>
</html>

View file

@ -1,11 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kawari - Login</title>
</head>
<body>
{% extends "layout.html" %}
{% block title %}Kawari - Login{% endblock %}
{% block body %}
<form method='post'>
<label for="username">Username:</label><br>
<input type='text' id='username' name='username'/><br>
@ -14,5 +11,4 @@
<button type='submit'>Login</button>
</form>
</body>
</html>
{% endblock %}

View file

@ -1,11 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kawari -Register</title>
</head>
<body>
{% extends "layout.html" %}
{% block title %}Kawari - Register{% endblock %}
{% block body %}
<form action='/oauth/oa/registlist' method='post'>
<label for="username">Username:</label><br>
<input type='text' id='username' name='username'/><br>
@ -13,6 +10,4 @@
<input type='text' id='password' name='password'/><br>
<button type='submit'>Register</button>
</form>
</body>
</html>
{% endblock %}

View file

@ -1,16 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kawari</title>
</head>
<body>
{% extends "layout.html" %}
{% block title %}Kawari{% endblock %}
{% block body %}
<p>Welcome to Kawari!</p>
<a href="http://{{ login_server }}/oauth/oa/oauthlogin">Login</a>
<a href="http://{{ login_server }}/oauth/oa/registligt">Signup</a>
<a href="/worldstatus">World Status</a>
</body>
</html>
{% endblock %}

View file

@ -1,13 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Kawari - World Status</title>
</head>
<body>
{% extends "layout.html" %}
{% block title %}Kawari - World Status{% endblock %}
{% block body %}
<p>Worlds open: {{ worlds_open }}</p>
<p>Login open: {{ login_open }}</p>
</body>
</html>
{% endblock %}

View file

@ -5,9 +5,16 @@ use kawari::config::get_config;
use minijinja::Environment;
use minijinja::context;
use serde::{Deserialize, Serialize};
use tower_http::services::ServeDir;
fn setup_default_environment() -> Environment<'static> {
let mut env = Environment::new();
env.add_template_owned(
"layout.html",
std::fs::read_to_string("resources/templates/layout.html")
.expect("Failed to find template!"),
)
.unwrap();
env.add_template_owned(
"admin.html",
std::fs::read_to_string("resources/templates/admin.html")
@ -74,7 +81,8 @@ async fn main() {
let app = Router::new()
.route("/", get(root))
.route("/apply", post(apply));
.route("/apply", post(apply))
.nest_service("/static", ServeDir::new("resources/static"));
let config = get_config();

View file

@ -7,6 +7,7 @@ use axum::{
use kawari::config::get_config;
use reqwest::{StatusCode, header};
use serde::{Deserialize, Serialize};
use tower_http::services::ServeDir;
#[derive(Debug, Clone, Serialize, Deserialize)]
struct GateStatus {
@ -153,7 +154,8 @@ async fn main() {
"/frontier-api/ffxivsupport/information/get_headline_all",
get(get_headline_all),
)
.fallback(fallback);
.fallback(fallback)
.nest_service("/static", ServeDir::new("resources/static"));
let config = get_config();

View file

@ -12,9 +12,16 @@ use kawari::lobby::send_custom_world_packet;
use kawari::login::{LoginDatabase, LoginError};
use minijinja::{Environment, context};
use serde::Deserialize;
use tower_http::services::ServeDir;
fn setup_default_environment() -> Environment<'static> {
let mut env = Environment::new();
env.add_template_owned(
"layout.html",
std::fs::read_to_string("resources/templates/layout.html")
.expect("Failed to find template!"),
)
.unwrap();
env.add_template_owned(
"login.html",
std::fs::read_to_string("resources/templates/login.html")
@ -283,7 +290,8 @@ async fn main() {
.route("/account/app/svc/logout", get(logout))
.route("/account/app/svc/mbrPasswd", get(change_password))
.route("/account/app/svc/mbrCancel", get(cancel_account))
.with_state(state);
.with_state(state)
.nest_service("/static", ServeDir::new("resources/static"));
let config = get_config();

View file

@ -4,9 +4,16 @@ use kawari::config::get_config;
use minijinja::Environment;
use minijinja::context;
use serde::{Deserialize, Serialize};
use tower_http::services::ServeDir;
fn setup_default_environment() -> Environment<'static> {
let mut env = Environment::new();
env.add_template_owned(
"layout.html",
std::fs::read_to_string("resources/templates/layout.html")
.expect("Failed to find template!"),
)
.unwrap();
env.add_template_owned(
"web.html",
std::fs::read_to_string("resources/templates/web.html").expect("Failed to find template!"),
@ -63,7 +70,8 @@ async fn main() {
let app = Router::new()
.route("/", get(root))
.route("/worldstatus", get(world_status));
.route("/worldstatus", get(world_status))
.nest_service("/static", ServeDir::new("resources/static"));
let config = get_config();