Compare commits

..

No commits in common. "master" and "master" have entirely different histories.

5 changed files with 12 additions and 133 deletions

88
Cargo.lock generated
View file

@ -513,19 +513,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@ -645,12 +632,6 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "http"
version = "0.2.12"
@ -674,12 +655,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "idna"
version = "0.5.0"
@ -700,17 +675,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "is-terminal"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "itoa"
version = "1.0.10"
@ -890,16 +854,6 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "pretty_env_logger"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c"
dependencies = [
"env_logger",
"log",
]
[[package]]
name = "proc-macro2"
version = "1.0.79"
@ -1135,23 +1089,12 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "thirappu-vizha"
version = "0.1.0"
dependencies = [
"actix-web",
"clap",
"log",
"pretty_env_logger",
"serde",
"serde_json",
"url",
@ -1311,37 +1254,6 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.48.0"

View file

@ -8,8 +8,6 @@ edition = "2021"
[dependencies]
actix-web = "4.5.1"
clap = { version = "4", features = ["derive"] }
log = "0.4.21"
pretty_env_logger = "0.5.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
url = { version = "2.5.0", features = ["serde"] }

View file

Before

Width:  |  Height:  |  Size: 428 KiB

After

Width:  |  Height:  |  Size: 428 KiB

View file

@ -2,7 +2,6 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
use std::fmt::Display;
use std::os::unix::fs::symlink as unix_symlink;
use std::process::Command;
@ -10,38 +9,30 @@ use actix_web::web::ServiceConfig;
use actix_web::HttpResponse;
use actix_web::{get, http::header, post, web, App, HttpServer, Responder};
use clap::Parser;
use log::info;
use url::Url;
fn thirappu(ribbon: &str, store: &str) {
let ribbon_link = format!("/etc/nginx/sites-enabled/{ribbon}");
let ribbon = format!("/etc/nginx/sites-enabled/{ribbon}");
let store_original = format!("/etc/nginx/sites-available/{store}");
let store_link = format!("/etc/nginx/sites-enabled/{store}");
std::fs::remove_file(ribbon_link).unwrap();
info!("removed store");
std::fs::remove_file(ribbon).unwrap();
unix_symlink(store_original, store_link).unwrap();
info!("Linked store");
Command::new("nginx")
.args(["-s", "reload"])
.output()
.unwrap();
info!("nginx reloaded");
}
fn reset(ribbon: &str, store: &str) {
let ribbon_link = format!("/etc/nginx/sites-enabled/{ribbon}");
let ribbon_original = format!("/etc/nginx/sites-available/{ribbon}");
let ribbon_original = format!("/etc/nginx/sites-available/{store}");
let store_link = format!("/etc/nginx/sites-enabled/{store}");
info!("resetting vizha: store_link {store_link} ribbon_link: {ribbon_link} ribbon_original: {ribbon_original}");
std::fs::remove_file(store_link).unwrap();
info!("Removed store link");
unix_symlink(ribbon_original, ribbon_link).unwrap();
info!("Linked ribbon");
Command::new("nginx")
.args(["-s", "reload"])
.output()
.unwrap();
info!("nginx reloaded");
}
#[derive(Parser, Debug, Clone)]
@ -62,19 +53,6 @@ struct Args {
store_weburl: Url,
}
impl Display for Args {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"port: {} ribbon: {} store: {} store_weburl: {}",
self.port,
self.ribbon,
self.store,
self.store_weburl.to_string()
)
}
}
#[get("/reset")]
async fn reset_get() -> impl Responder {
let reset = include_str!("./reset.html");
@ -89,7 +67,7 @@ async fn reset_post(ctx: web::Data<Args>) -> impl Responder {
reset(&ctx.ribbon, &ctx.store);
HttpResponse::Found()
.append_header((header::LOCATION, ctx.store_weburl.to_string()))
.append_header((header::LOCATION, "/"))
.finish()
}
@ -104,7 +82,7 @@ async fn open_post(ctx: web::Data<Args>) -> impl Responder {
#[get("/curtain.jpeg")]
async fn curtain_jpeg() -> impl Responder {
let curtain = include_bytes!("./curtain.jpeg");
let curtain = include_bytes!("./curatain.jpeg");
let curtain = actix_web::web::Bytes::from_static(curtain);
@ -130,16 +108,7 @@ fn services(cfg: &mut ServiceConfig) {
#[actix_web::main] // or #[tokio::main]
async fn main() -> std::io::Result<()> {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
}
pretty_env_logger::init();
let args = Args::parse();
info!("Starting server with {args}");
let data = web::Data::new(args.clone());
HttpServer::new(move || App::new().app_data(data.clone()).configure(services))
.bind(("127.0.0.1", args.port))?

View file

@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<div id='curtain'>
<h1>Please wait while the store is being provisioned</h1>
<h1 id="countdown">5</h1>
<h1 id="countdown">10</h1>
<div class='left'></div>
<div class='right'></div>
@ -81,7 +81,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
width: 50%;
height: 100%;
filter: brightness(180%);
background-image: url("./curtain.jpeg");
background-image: url("./curatain-min.jpeg");
background-size: cover;
background-repeat: no-repeat;
}
@ -283,13 +283,13 @@ SPDX-License-Identifier: AGPL-3.0-or-later
function detectSpaceKey(event) {
if(event.keyCode == 13) {
showTime();
fetch("/", {method: "post"}).then(() =>
startCountdown()
);
var form = document.createElement("form");
form.setAttribute("action", "/");
form.setAttribute("method", "post");
}
// startCountdown();
}
function showTime() {