82 lines
2.2 KiB
Rust
82 lines
2.2 KiB
Rust
pub fn index_page(status: &str, checked: &str) -> String {
|
|
format!(
|
|
r#"
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Live Toggle</title>
|
|
<style>
|
|
body {{
|
|
font-family: Arial, sans-serif;
|
|
display: grid;
|
|
place-items: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
background: #111827;
|
|
color: #f9fafb;
|
|
}}
|
|
.card {{
|
|
background: #1f2937;
|
|
padding: 2rem 2.5rem;
|
|
border-radius: 12px;
|
|
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
|
|
}}
|
|
label {{
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
font-size: 1.1rem;
|
|
}}
|
|
p {{
|
|
margin-top: 1rem;
|
|
font-size: 1rem;
|
|
}}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card">
|
|
<form method="post" action="/toggle-live">
|
|
<label>
|
|
<input type="checkbox" name="live" value="true" {checked} onchange="this.form.submit()">
|
|
<span>live</span>
|
|
</label>
|
|
</form>
|
|
<p>Status: <strong>{status}</strong></p>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
"#
|
|
)
|
|
}
|
|
|
|
pub fn code1_success() -> String {
|
|
String::from(
|
|
r#"
|
|
<html>
|
|
<body>
|
|
<h1>CODE1 handled</h1>
|
|
<p>Authenticated with secret key.</p>
|
|
<p>Action: none</p>
|
|
<a href="/">Back to home</a>
|
|
</body>
|
|
</html>
|
|
"#,
|
|
)
|
|
}
|
|
|
|
pub fn code1_invalid(key: &str) -> String {
|
|
format!(
|
|
r#"
|
|
<html>
|
|
<body>
|
|
<h1>CODE1 rejected</h1>
|
|
<p>Invalid {key}.</p>
|
|
<p>Action: none</p>
|
|
<a href="/">Back to home</a>
|
|
</body>
|
|
</html>
|
|
"#
|
|
)
|
|
}
|