From e18a71a73c1b724090db882a33b2053974e2a130 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Mon, 10 Apr 2023 11:31:34 -0500 Subject: [PATCH] Reorganize files, keep table from moving on alert --- actix/resources/index.html | 7 ++++--- actix/resources/{ => static}/404.html | 0 actix/resources/{ => static}/script.js | 9 +++++---- actix/resources/{ => static}/styles.css | 0 actix/src/auth.rs | 4 ++-- actix/src/main.rs | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) rename actix/resources/{ => static}/404.html (100%) rename actix/resources/{ => static}/script.js (94%) rename actix/resources/{ => static}/styles.css (100%) diff --git a/actix/resources/index.html b/actix/resources/index.html index 9fdfdb0..f9809b7 100644 --- a/actix/resources/index.html +++ b/actix/resources/index.html @@ -15,10 +15,10 @@ - + - + @@ -40,6 +40,7 @@
+

 

@@ -49,7 +50,7 @@
- Short URL (click to copy) + Short URL
(click to copy) Long URL Hits × diff --git a/actix/resources/404.html b/actix/resources/static/404.html similarity index 100% rename from actix/resources/404.html rename to actix/resources/static/404.html diff --git a/actix/resources/script.js b/actix/resources/static/script.js similarity index 94% rename from actix/resources/script.js rename to actix/resources/static/script.js index 354a490..8c2675d 100644 --- a/actix/resources/script.js +++ b/actix/resources/static/script.js @@ -48,7 +48,7 @@ const displayData = async (data) => { const table = document.querySelector("#url-table"); if (!window.isSecureContext) { const shortUrlHeader = document.getElementById("short-url-header"); - shortUrlHeader.innerHTML = "Short URL (right click and copy)"; + shortUrlHeader.innerHTML = "Short URL
(right click and copy)"; } table_box.style.visibility = "visible"; table.innerHTML = ''; // Clear @@ -57,10 +57,10 @@ const displayData = async (data) => { }; const showAlert = async (text, col) => { - document.getElementById("alertBox")?.remove(); + document.getElementById("alert-box")?.remove(); const controls = document.querySelector(".pure-controls"); const alertBox = document.createElement("p"); - alertBox.setAttribute("id", "alertBox"); + alertBox.setAttribute("id", "alert-box"); alertBox.setAttribute("style", `color:${col}`); alertBox.innerHTML = text; controls.appendChild(alertBox); @@ -121,7 +121,8 @@ const deleteButton = (shortUrl) => { btn.onclick = e => { e.preventDefault(); if (confirm("Do you want to delete the entry " + shortUrl + "?")) { - document.getElementById("alertBox")?.remove(); + document.getElementById("alert-box")?.remove(); + showAlert(" ", "black"); fetch(`/api/del/${shortUrl}`, { method: "DELETE" }).then(_ => refreshData()); diff --git a/actix/resources/styles.css b/actix/resources/static/styles.css similarity index 100% rename from actix/resources/styles.css rename to actix/resources/static/styles.css diff --git a/actix/src/auth.rs b/actix/src/auth.rs index 9d57339..df09b3f 100644 --- a/actix/src/auth.rs +++ b/actix/src/auth.rs @@ -32,7 +32,7 @@ fn check(token: Option) -> bool { .duration_since(SystemTime::UNIX_EPOCH) .expect("Time went backwards!") .as_secs(); - if token_text == "valid-session-token" && time_now < token_time + 1209600 { + if token_text == "session-token" && time_now < token_time + 1209600 { // There are 1209600 seconds in 14 days true } else { @@ -43,7 +43,7 @@ fn check(token: Option) -> bool { } pub fn gen_token() -> String { - let token_text = "valid-session-token".to_string(); + let token_text = "session-token".to_string(); let time = SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .expect("Time went backwards!") diff --git a/actix/src/main.rs b/actix/src/main.rs index 30d444b..d274080 100644 --- a/actix/src/main.rs +++ b/actix/src/main.rs @@ -59,7 +59,7 @@ async fn siteurl(session: Session) -> HttpResponse { // 404 error page #[get("/err/404")] async fn error404() -> impl Responder { - NamedFile::open_async("./resources/404.html").await + NamedFile::open_async("./resources/static/404.html").await } // Handle a given shortlink