init repo

This commit is contained in:
b1ek 2024-04-21 15:06:58 +10:00
commit 6aaea5cb6e
Signed by: blek
GPG Key ID: 14546221E3595D0C
6 changed files with 1323 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1214
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

11
Cargo.toml Normal file
View File

@ -0,0 +1,11 @@
[package]
name = "invite-maker"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
askama = "0.12.1"
tokio = { version = "1.37.0", features = ["full"] }
warp = "0.3.7"

13
Dockerfile Normal file
View File

@ -0,0 +1,13 @@
FROM rust:alpine3.19 as builder
WORKDIR /opt/build
COPY . .
RUN cargo b -r
FROM alpine:3.19
COPY . /usr/share/invite-maker-src
COPY --from=builder /opt/build/target/invite-maker /usr/bin/invite-maker
CMD [ "/usr/bin/invite-maker" ]

31
src/main.rs Normal file
View File

@ -0,0 +1,31 @@
use std::{env, net::SocketAddrV4};
use askama::Template;
use warp::{http::StatusCode, reject::Rejection, reply::{html, json, with_status, Reply}, Filter};
#[derive(Debug, Clone, Template)]
#[template(path = "invite.html")]
struct Invite {
pub name: String
}
async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
let inv = Invite { name };
let rendered = inv.render();
if let Err(err) = rendered {
Ok(
Box::new(
with_status(json(&err.to_string()), StatusCode::INTERNAL_SERVER_ERROR)
)
)
} else {
Ok(Box::new(html(rendered.unwrap())))
}
}
#[tokio::main]
async fn main() {
let route = warp::path!("gen" / String).and_then(gen);
warp::serve(route).bind(env::var("LISTEN").unwrap_or("0.0.0.0:80".into()).parse::<SocketAddrV4>().expect("Invalid LISTEN url")).await;
}

53
templates/invite.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>you have been invited to blek! cc!</title>
<style>
html, body {
font-family: 'Cantarell', 'Open Sans', 'Segoe UI', sans-serif;
background: #222;
color: white
}
</style>
</head>
<body>
<h1>you have been invited to join blek! cc!</h1>
<p>
a trusted member {{ name }} has invited you to join blek! cc
</p>
<p>
if you want to create an account, please follow these instructions:
</p>
<ul>
<li>if you don't have a GPG key, make one. use an email that you have stable access to</li>
<li>send an email to
<code>cc@blek.codes</code>
to apply for an account. include a copy of this email</li>
<li>you will be invited to an interview after. the interview is about getting to know you, so don't be scared
</li>
<li>if your application is approved, you will recieve an email</li>
</ul>
<h3>how do you know that this invite is authentic</h3>
<p>
if at least one if this is true, it is authentic:
</p>
<ul>
<li>this email is GPG signed by a cc.blek.codes mail account. ensure that the key is trusted</li>
<li>this email came from a cc.blek.codes mailbox</li>
<li>ask the admin at cc.blek.codes</li>
</ul>
<h3>what blek!cc gives you</h3>
<p>this subject is here so you understand if you even want to go through registration</p>
<ul>
<li>free website hosting at [name].cc.blek.codes</li>
<li>mailbox or alias @ cc.blek.codes</li>
<li>possibly other services not mentioned here. this template is not often updated</li>
</ul>
<p>if you do not want an account, ignore this email</p>
<script data-cfasync="false" src="/cdn-cgi/scripts/5c5dd728/cloudflare-static/email-decode.min.js"></script>
</body>
</html>