Initial commit
This commit is contained in:
commit
1286a3d991
7 changed files with 1485 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
1351
Cargo.lock
generated
Normal file
1351
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "embedgen"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.4.0"
|
||||
serde = { version = "1.0.188", features = ["derive"] }
|
||||
serde_json = "1.0.107"
|
||||
tokio = { version = "1.32.0", features = ["full"] }
|
||||
tracing = "0.1.37"
|
||||
tracing-subscriber = "0.3.17"
|
26
LICENSE
Normal file
26
LICENSE
Normal file
|
@ -0,0 +1,26 @@
|
|||
GLWTS(Good Luck With That Shit) Public License
|
||||
Copyright (c) Every-fucking-one, except the Author
|
||||
|
||||
Everyone is permitted to copy, distribute, modify, merge, sell, publish,
|
||||
sublicense or whatever the fuck they want with this software but at their
|
||||
OWN RISK.
|
||||
|
||||
Preamble
|
||||
|
||||
The author has absolutely no fucking clue what the code in this project
|
||||
does. It might just fucking work or not, there is no third option.
|
||||
|
||||
|
||||
GOOD LUCK WITH THAT SHIT PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION
|
||||
|
||||
0. You just DO WHATEVER THE FUCK YOU WANT TO as long as you NEVER LEAVE
|
||||
A FUCKING TRACE TO TRACK THE AUTHOR of the original product to blame for
|
||||
or held responsible.
|
||||
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Good luck and Godspeed.
|
18
src/index.html
Normal file
18
src/index.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang='en' style='background-color: #222;'>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta http-equiv='refresh' content='0;{{REDIRECT}}' />
|
||||
<!-- <meta property='og:title' content='{{TITLE}}' /> -->
|
||||
<meta property='og:description' content='{{DESCRIPTION}}' />
|
||||
<!-- <meta property='og:site_name' content='{{SITENAME}}' /> -->
|
||||
<meta property='og:image' content='{{IMAGE}}' />
|
||||
<meta content="#{{COLOR}}" data-react-helmet="true" name="theme-color" />
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<link type="application/json+oembed" href="https://e.davidon.top/json?title={{TITLE}}&title_url={{TITURL}}&provider={{PROV}}&provider_url={{PROVURL}}">
|
||||
<title>Embed Generator</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
67
src/main.rs
Normal file
67
src/main.rs
Normal file
|
@ -0,0 +1,67 @@
|
|||
use actix_web::{HttpServer, App, get, web, Responder, HttpResponse};
|
||||
use serde::Deserialize;
|
||||
|
||||
pub static HTML: &'static str = include_str!("./index.html");
|
||||
pub static JSON: &'static str = include_str!("./prov.json");
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Params {
|
||||
redirect: Option<String>,
|
||||
title: Option<String>,
|
||||
description: Option<String>,
|
||||
sitename: Option<String>,
|
||||
image: Option<String>,
|
||||
color: Option<String>,
|
||||
title_url: Option<String>,
|
||||
sitename_url: Option<String>,
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
async fn index(info: web::Query<Params>) -> impl Responder {
|
||||
let info = info.into_inner();
|
||||
|
||||
HttpResponse::Ok().content_type("text/html").body(HTML
|
||||
.replace("{{REDIRECT}}", &info.redirect.unwrap_or("https://davidon.top".to_string()))
|
||||
.replace("{{TITLE}}", &info.title.unwrap_or_default())
|
||||
.replace("{{DESCRIPTION}}", &info.description.unwrap_or_default())
|
||||
.replace("{{PROV}}", &info.sitename.unwrap_or_default())
|
||||
.replace("{{IMAGE}}", &info.image.unwrap_or_default())
|
||||
.replace("{{COLOR}}", &info.color.unwrap_or_default())
|
||||
.replace("{{TITURL}}", &info.title_url.unwrap_or_default())
|
||||
.replace("{{PROVURL}}", &info.sitename_url.unwrap_or_default())
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ParamsJson {
|
||||
title: Option<String>,
|
||||
title_url: Option<String>,
|
||||
provider: Option<String>,
|
||||
provider_url: Option<String>,
|
||||
}
|
||||
|
||||
#[get("/json")]
|
||||
async fn json(info: web::Query<ParamsJson>) -> impl Responder {
|
||||
let info = info.into_inner();
|
||||
|
||||
HttpResponse::Ok().content_type("application/json").body(JSON
|
||||
.replace("{{TITLE}}", &info.title.unwrap_or_default())
|
||||
.replace("{{TITURL}}", &info.title_url.unwrap_or_default())
|
||||
.replace("{{PROV}}", &info.provider.unwrap_or_default())
|
||||
.replace("{{PROVURL}}", &info.provider_url.unwrap_or_default())
|
||||
)
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(index)
|
||||
.service(json)
|
||||
})
|
||||
.bind(("127.0.0.1", 3596))?
|
||||
.run()
|
||||
.await
|
||||
}
|
8
src/prov.json
Normal file
8
src/prov.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"success": true,
|
||||
"version": "1.0",
|
||||
"author_name": "{{TITLE}}",
|
||||
"author_url": "{{TITURL}}",
|
||||
"provider_name": "{{PROV}}",
|
||||
"provider_url": "{{PROVURL}}"
|
||||
}
|
Loading…
Reference in a new issue