refactored html
This commit is contained in:
parent
d92f4886ab
commit
134da8da5c
9 changed files with 188 additions and 125 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -139,3 +139,4 @@ cython_debug/
|
||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
/target
|
/target
|
||||||
|
/cache
|
70
Cargo.lock
generated
70
Cargo.lock
generated
|
@ -66,7 +66,7 @@ dependencies = [
|
||||||
"http",
|
"http",
|
||||||
"httparse",
|
"httparse",
|
||||||
"httpdate",
|
"httpdate",
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"language-tags",
|
"language-tags",
|
||||||
"local-channel",
|
"local-channel",
|
||||||
"mime",
|
"mime",
|
||||||
|
@ -176,7 +176,7 @@ dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http",
|
"http",
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"language-tags",
|
"language-tags",
|
||||||
"log",
|
"log",
|
||||||
"mime",
|
"mime",
|
||||||
|
@ -686,7 +686,7 @@ checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"fnv",
|
"fnv",
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -739,7 +739,7 @@ dependencies = [
|
||||||
"http-body",
|
"http-body",
|
||||||
"httparse",
|
"httparse",
|
||||||
"httpdate",
|
"httpdate",
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -820,6 +820,12 @@ version = "2.5.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745"
|
checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "0.4.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.4"
|
version = "1.0.4"
|
||||||
|
@ -908,6 +914,28 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "maud"
|
||||||
|
version = "0.24.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "19aff2cd19eb4b93df29efa602652513b0f731f1d3474f6e377f763fddf61e58"
|
||||||
|
dependencies = [
|
||||||
|
"itoa 0.4.8",
|
||||||
|
"maud_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "maud_macros"
|
||||||
|
version = "0.24.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5c114f6f24b08fdd4a25d2fb87a8b140df56b577723247b382e8b04c583f2eb"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "me-site"
|
name = "me-site"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
@ -918,6 +946,7 @@ dependencies = [
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"gnupg",
|
"gnupg",
|
||||||
"log",
|
"log",
|
||||||
|
"maud",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
@ -1124,6 +1153,30 @@ version = "0.2.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro-error-attr",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro-error-attr"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.47"
|
version = "1.0.47"
|
||||||
|
@ -1336,7 +1389,7 @@ version = "1.0.89"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -1348,7 +1401,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -1449,7 +1502,7 @@ version = "0.3.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376"
|
checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa 1.0.4",
|
||||||
"serde",
|
"serde",
|
||||||
"time-core",
|
"time-core",
|
||||||
"time-macros",
|
"time-macros",
|
||||||
|
@ -1738,10 +1791,11 @@ checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-base"
|
name = "web-base"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://git.hydrar.de/jmarya/web-base#d7ca4a0dd03f6f803b3059a357b8b53bf2c847a6"
|
source = "git+https://git.hydrar.de/jmarya/web-base#dd70137cb7557931cddbe700a0f49ecca35c2988"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-web",
|
"actix-web",
|
||||||
|
"maud",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
|
@ -16,3 +16,4 @@ web-base = { git = "https://git.hydrar.de/jmarya/web-base" }
|
||||||
serde = {version = "1.0.147", features = ["derive"] }
|
serde = {version = "1.0.147", features = ["derive"] }
|
||||||
serde_json = "1.0.87"
|
serde_json = "1.0.87"
|
||||||
reqwest = "0.11"
|
reqwest = "0.11"
|
||||||
|
maud = "0.24.0"
|
||||||
|
|
|
@ -10,8 +10,8 @@ FROM debian
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install -y gnupg ca-certificates
|
RUN apt-get install -y gnupg ca-certificates
|
||||||
|
|
||||||
COPY --from=builder /app/target/release/me-site /app/me-site
|
COPY --from=builder /app/target/release/me-site /me-site
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
CMD ["/app/me-site"]
|
CMD ["/me-site"]
|
||||||
|
|
|
@ -18,8 +18,8 @@ fn read_json_file(f: &str) -> Option<Value> {
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn new() -> Config {
|
pub fn new() -> Config {
|
||||||
let v = read_json_file("/config/config.json").expect("could not read config file");
|
let v = read_json_file("./config/config.json").expect("could not read config file");
|
||||||
let c = read_json_file("/config/colors.json");
|
let c = read_json_file("./config/colors.json");
|
||||||
Config { root: v, color: c }
|
Config { root: v, color: c }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,16 @@ use std::io::Write;
|
||||||
pub fn encrypt(msg: String) -> String {
|
pub fn encrypt(msg: String) -> String {
|
||||||
let pgp = gnupg::GnuPG::new().unwrap();
|
let pgp = gnupg::GnuPG::new().unwrap();
|
||||||
let pub_key = pgp
|
let pub_key = pgp
|
||||||
.import_key(&std::fs::read_to_string("/config/pub.key").unwrap())
|
.import_key(&std::fs::read_to_string("./config/pub.key").unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let c = pgp.encrypt(&pub_key, &msg).unwrap();
|
let c = pgp.encrypt(&pub_key, &msg).unwrap();
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn save_msg(msg: String, name: &str) {
|
pub fn save_msg(msg: String, name: &str) {
|
||||||
std::fs::create_dir_all("/data/messages").expect("couldn't create msg dir");
|
std::fs::create_dir_all("./data/messages").expect("couldn't create msg dir");
|
||||||
let time = chrono::offset::Utc::now();
|
let time = chrono::offset::Utc::now();
|
||||||
let time = time.format("%Y-%m-%d.%H-%M").to_string();
|
let time = time.format("%Y-%m-%d.%H-%M").to_string();
|
||||||
let mut f = std::fs::File::create(format!("/data/messages/{name}-{time}.asc")).unwrap();
|
let mut f = std::fs::File::create(format!("./data/messages/{name}-{time}.asc")).unwrap();
|
||||||
f.write_all(encrypt(msg).as_bytes()).unwrap();
|
f.write_all(encrypt(msg).as_bytes()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,10 @@ use actix_web::*;
|
||||||
|
|
||||||
#[get("/assets/wall")]
|
#[get("/assets/wall")]
|
||||||
pub(crate) async fn wallpaper() -> Result<NamedFile> {
|
pub(crate) async fn wallpaper() -> Result<NamedFile> {
|
||||||
Ok(NamedFile::open("/config/wall.avif")?)
|
Ok(NamedFile::open("./config/wall.avif")?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/assets/me")]
|
#[get("/assets/me")]
|
||||||
pub(crate) async fn me_img() -> Result<NamedFile> {
|
pub(crate) async fn me_img() -> Result<NamedFile> {
|
||||||
Ok(NamedFile::open("/config/me.avif")?)
|
Ok(NamedFile::open("./config/me.avif")?)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
use maud::{html, PreEscaped};
|
||||||
|
|
||||||
pub(crate) async fn build_site(
|
pub(crate) async fn build_site(
|
||||||
content: String,
|
content: String,
|
||||||
|
@ -9,11 +10,11 @@ pub(crate) async fn build_site(
|
||||||
shadow: bool,
|
shadow: bool,
|
||||||
config: &Data<Config>,
|
config: &Data<Config>,
|
||||||
) -> HttpResponse<String> {
|
) -> HttpResponse<String> {
|
||||||
const BOOTSTRAP: &str = r#"
|
let BOOTSTRAP = html! {
|
||||||
<link href="/bootstrap.min.css" rel="stylesheet">
|
link href="/bootstrap.min.css" rel="stylesheet";
|
||||||
<link href="/bootstrap-icons.css" rel="stylesheet">
|
link href="/bootstrap-icons.css" rel="stylesheet";
|
||||||
<link href="/bootstrap.bundle.min.js" rel="stylesheet">
|
link href="/bootstrap.bundle.min.js" rel="stylesheet";
|
||||||
"#;
|
};
|
||||||
|
|
||||||
let mut c_class = "bg-dark text-white justify-content-center text-center".to_string();
|
let mut c_class = "bg-dark text-white justify-content-center text-center".to_string();
|
||||||
let mut c_style = "".to_string();
|
let mut c_style = "".to_string();
|
||||||
|
@ -25,31 +26,28 @@ pub(crate) async fn build_site(
|
||||||
g_style = format!("a {{text-decoration: none; font-weight: bold; color: {fg}}}");
|
g_style = format!("a {{text-decoration: none; font-weight: bold; color: {fg}}}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if std::path::Path::new("/config/wall.avif").exists() {
|
if std::path::Path::new("./config/wall.avif").exists() {
|
||||||
c_style.push_str("background-image: url('assets/wall');background-size:cover;");
|
c_style.push_str("background-image: url('assets/wall');background-size:cover;");
|
||||||
}
|
}
|
||||||
if shadow {
|
if shadow {
|
||||||
c_style.push_str("text-shadow: 1px 1px 3px black;");
|
c_style.push_str("text-shadow: 1px 1px 3px black;");
|
||||||
}
|
}
|
||||||
|
|
||||||
let r = format!(
|
let r = html! {
|
||||||
"
|
(maud::DOCTYPE)
|
||||||
<!DOCTYPE html>
|
html {
|
||||||
<html>
|
head {
|
||||||
<head>
|
title {
|
||||||
<title> {title} </title>
|
(title)
|
||||||
<meta name=\"viewport\" content=\"user-scalable=no, width=device-width, initial-scale=1.0\">
|
};
|
||||||
{BOOTSTRAP}
|
(BOOTSTRAP)
|
||||||
</head>
|
};
|
||||||
<body style=\"{c_style}\" class=\"{c_class}\">
|
body style=(c_style) class=(c_class) {
|
||||||
<style>
|
style { (g_style) };
|
||||||
{g_style}
|
(PreEscaped(content))
|
||||||
</style>
|
}
|
||||||
{content}
|
};
|
||||||
</body>
|
};
|
||||||
</html>
|
|
||||||
"
|
|
||||||
);
|
|
||||||
|
|
||||||
return HttpResponse::Ok().message_body(r).unwrap();
|
return HttpResponse::Ok().message_body(r.into_string()).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ use crate::{config, pages};
|
||||||
use actix_web::http::header;
|
use actix_web::http::header;
|
||||||
use actix_web::web::Form;
|
use actix_web::web::Form;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
use maud::{html, PreEscaped};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
@ -20,45 +21,45 @@ pub async fn message_post(r: HttpRequest, f: Form<MessageForm>) -> impl Responde
|
||||||
config.clone(),
|
config.clone(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
return HttpResponse::Found()
|
return web_base::func::redirect("/message");
|
||||||
.append_header(("Location", "/message"))
|
|
||||||
.finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/message")]
|
#[get("/message")]
|
||||||
pub async fn message_page(r: HttpRequest) -> impl Responder {
|
pub async fn message_page(r: HttpRequest) -> impl Responder {
|
||||||
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
||||||
let host = web_base::func::get_host(&r);
|
let host = web_base::func::get_host(&r);
|
||||||
let resp = format!(
|
|
||||||
r#"
|
let resp = html! {
|
||||||
<div class="container" style="margin-top: 25px"><h1>Message</h1>
|
div class="container" style="margin-top: 25px" {
|
||||||
<br>
|
h1 { "Message" };
|
||||||
<form action="http://{host}/message" method="post" autocomplete="off">
|
br;
|
||||||
<input value="" type="text" required name="msg_name" placeholder="Name" class="form-control bg-dark text-white" style="margin-bottom: 15px">
|
|
||||||
<textarea placeholder="Message" required name="message" cols="10" rows="10" class="form-control bg-dark text-white" style="margin-bottom: 15px;">
|
form action=(format!("http://{host}")) method="post" autocomplete="off" {
|
||||||
</textarea>
|
input value="" type="text" required name="msg_name" placeholder="Name" class="form-control bg-dark text-white" style="margin-bottom: 15px";
|
||||||
<input value="Send Message" type="submit" required name="submit" class="btn btn-danger text-white text-decoration-none">
|
textarea placeholder="Message" required name="message" cols="10" rows="10" class="form-control bg-dark text-white" style="margin-bottom: 15px;";
|
||||||
</form>
|
input value="Send Message" type="submit" required name="submit" class="btn btn-danger text-white text-decoration-none";
|
||||||
</div>
|
}
|
||||||
"#
|
}
|
||||||
);
|
};
|
||||||
return pages::html_fn::build_site(resp, "Message", false, true, config).await;
|
|
||||||
|
return pages::html_fn::build_site(resp.into_string(), "Message", false, true, config).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/mirrors.txt")]
|
#[get("/mirrors.txt")]
|
||||||
pub async fn mirrors(r: HttpRequest) -> impl Responder {
|
pub async fn mirrors(r: HttpRequest) -> impl Responder {
|
||||||
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
||||||
if let Ok(mirror_file) = std::fs::File::open("/config/mirrors.txt") {
|
if let Ok(mirror_file) = std::fs::File::open("./config/mirrors.txt") {
|
||||||
let content = std::io::read_to_string(mirror_file).unwrap();
|
let content = std::io::read_to_string(mirror_file).unwrap();
|
||||||
if web_base::func::is_browser(&r) {
|
if web_base::func::is_browser(&r) {
|
||||||
let resp = format!(
|
let resp = html! {
|
||||||
r#"
|
div style="margin: 25px;" {
|
||||||
<div style="margin: 25px;">
|
pre {
|
||||||
<pre> {content} </pre>
|
(content)
|
||||||
</div>
|
};
|
||||||
"#
|
}
|
||||||
);
|
};
|
||||||
return pages::html_fn::build_site(resp, "Mirrors", false, true, config).await;
|
return pages::html_fn::build_site(resp.into_string(), "Mirrors", false, true, config)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
let res: HttpResponse<String> = HttpResponse::Ok().message_body(content).unwrap();
|
let res: HttpResponse<String> = HttpResponse::Ok().message_body(content).unwrap();
|
||||||
return res;
|
return res;
|
||||||
|
@ -74,28 +75,30 @@ pub async fn public_key(r: HttpRequest) -> impl Responder {
|
||||||
if web_base::func::is_browser(&r) {
|
if web_base::func::is_browser(&r) {
|
||||||
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
let config: &web::Data<config::Config> = r.app_data().unwrap();
|
||||||
let host = format!("http://{}", web_base::func::get_host(&r));
|
let host = format!("http://{}", web_base::func::get_host(&r));
|
||||||
let key = std::io::read_to_string(std::fs::File::open("/config/pub.key").unwrap()).unwrap();
|
let key =
|
||||||
|
std::io::read_to_string(std::fs::File::open("./config/pub.key").unwrap()).unwrap();
|
||||||
|
|
||||||
let pgp = gnupg::GnuPG::new().unwrap();
|
let pgp = gnupg::GnuPG::new().unwrap();
|
||||||
let key_name = pgp.import_key(&key).unwrap().name;
|
let key_name = pgp.import_key(&key).unwrap().name;
|
||||||
|
|
||||||
let key = key.replace("\n", "<br>");
|
let key = key.replace("\n", "<br>");
|
||||||
let resp = format!(
|
|
||||||
r#"
|
let resp = html! {
|
||||||
<div class="container" style="margin-top: 25px">
|
div class="container" style="margin-top: 25px" {
|
||||||
<div class="alert alert-info">
|
div class="alert alert-info" {
|
||||||
<b>To Import: </b>
|
b { "To Import: " };
|
||||||
<span style="display: block;font-family: monospace,monospace;margin-top: 10px; font-size: 20px;overflow-wrap: break-word;">
|
span style="display: block;font-family: monospace,monospace;margin-top: 10px; font-size: 20px;overflow-wrap: break-word;" { (format!("curl -sL \"{host}/public_key\"|gpg --import")) };
|
||||||
curl -sL "{host}/public_key"|gpg --import</span>
|
};
|
||||||
</div>
|
h4 class="container card" style="padding-top: 10px; padding-bottom: 10px; background: black; margin-bottom: 15px;" { (key_name) };
|
||||||
<h4 class="container card" style="padding-top: 10px; padding-bottom: 10px; background: black; margin-bottom: 15px;"> {key_name} </h4>
|
};
|
||||||
</div>
|
div class="container card bg-primary" {
|
||||||
<div class="container card bg-primary"><p> {key} </p></div>
|
p { (PreEscaped(key)) }
|
||||||
"#
|
}
|
||||||
);
|
};
|
||||||
return pages::html_fn::build_site(resp, "Public Key", true, false, config).await;
|
|
||||||
|
return pages::html_fn::build_site(resp.into_string(), "Public Key", true, false, config)
|
||||||
|
.await;
|
||||||
}
|
}
|
||||||
if let Ok(key_f) = std::fs::File::open("/config/pub.key") {
|
if let Ok(key_f) = std::fs::File::open("./config/pub.key") {
|
||||||
if let Ok(key_data) = std::io::read_to_string(key_f) {
|
if let Ok(key_data) = std::io::read_to_string(key_f) {
|
||||||
let res: HttpResponse<String> = HttpResponse::Ok()
|
let res: HttpResponse<String> = HttpResponse::Ok()
|
||||||
.insert_header(header::ContentType::plaintext())
|
.insert_header(header::ContentType::plaintext())
|
||||||
|
@ -113,42 +116,43 @@ curl -sL "{host}/public_key"|gpg --import</span>
|
||||||
|
|
||||||
fn build_information_block(conf: &web::Data<config::Config>) -> String {
|
fn build_information_block(conf: &web::Data<config::Config>) -> String {
|
||||||
let name = conf.name().unwrap();
|
let name = conf.name().unwrap();
|
||||||
format!(
|
return html! {
|
||||||
r#"
|
div class="container border-dark" style="margin-top: 20px" {
|
||||||
<div class="container border-dark" style="margin-top: 20px">
|
img src="/assets/me" height="200" width="200" alt="Me" class="rounded";
|
||||||
<img src="/assets/me" height=200 width=200 alt="Me" class="rounded">
|
br;br;
|
||||||
<br><br>
|
h1 { (name) };
|
||||||
<h1> {name} </h1>
|
hr;
|
||||||
<hr>
|
}
|
||||||
</div>
|
}
|
||||||
"#
|
.into_string();
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
||||||
if let Some(email) = conf.email() {
|
if let Some(email) = conf.email() {
|
||||||
let pgp_key_message = match std::path::Path::new("/config/pub.key").exists() {
|
let pgp_key_message = match std::path::Path::new("./config/pub.key").exists() {
|
||||||
true => {
|
true => html! {
|
||||||
r#"
|
a href="/public_key" { "My PGP Key" };
|
||||||
<a href="/public_key"> My PGP Key </a>
|
br;
|
||||||
<br>
|
a href="/message" { "Write a message" };
|
||||||
<a href="/message"> Write a message </a>
|
br;br;
|
||||||
<br><br>
|
|
||||||
"#
|
|
||||||
}
|
}
|
||||||
false => "",
|
.into_string(),
|
||||||
|
false => "".to_string(),
|
||||||
};
|
};
|
||||||
return format!(
|
|
||||||
r#"
|
return html! {
|
||||||
<div class="container border-dark">
|
div class="container border-dark" {
|
||||||
<h1> <span class="bi bi-person-lines-fill" style="vertical-align: middle;"> </span> Contact </h1>
|
h1 {
|
||||||
<hr>
|
span class="bi bi-person-lines-fill" style="vertical-align: middle;";
|
||||||
{pgp_key_message}
|
span { "Contact" };
|
||||||
<a href="mailto:{email}"> {email} </a>
|
};
|
||||||
<hr>
|
hr;
|
||||||
</div>
|
(PreEscaped(pgp_key_message));
|
||||||
"#
|
a href=(format!("mailto:{email}")) { (email) };
|
||||||
);
|
hr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.into_string();
|
||||||
} else {
|
} else {
|
||||||
return "".to_string();
|
return "".to_string();
|
||||||
}
|
}
|
||||||
|
@ -156,15 +160,20 @@ fn build_contact_block(conf: &web::Data<config::Config>) -> String {
|
||||||
|
|
||||||
fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
fn build_donation_block(conf: &web::Data<config::Config>) -> String {
|
||||||
if let Some(xmr_addr) = conf.xmr_address() {
|
if let Some(xmr_addr) = conf.xmr_address() {
|
||||||
format!(
|
html! {
|
||||||
r#"
|
div class="container" style="margin-top: 20px" {
|
||||||
<div class="container" style="margin-top: 20px">
|
h1 {
|
||||||
<h1> <span class="bi bi-cash-coin"> </span> Donation </h1>
|
span class="bi bi-cash-coin";
|
||||||
<hr>
|
span { "Donation" };
|
||||||
<p> <b> Monero: </b> <span style="color: orange;overflow-wrap: break-word;"> {xmr_addr} </span> </p>
|
};
|
||||||
</div>
|
hr;
|
||||||
"#
|
p {
|
||||||
)
|
b { "Monero: " };
|
||||||
|
span style="color: orange;overflow-wrap: break-word;" { (xmr_addr) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.into_string()
|
||||||
} else {
|
} else {
|
||||||
return "".to_string();
|
return "".to_string();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue