diff --git a/src/upload.rs b/src/upload.rs index 077c222..20003f8 100644 --- a/src/upload.rs +++ b/src/upload.rs @@ -16,6 +16,7 @@ use rand::prelude::SliceRandom; use sqlx::postgres::PgPool; const UPLOAD_HTML: &str = include_str!("../template/upload.html"); +const UPLOAD_SHORT_HTML: &str = include_str!("../template/upload-short.html"); const ID_CHARS: &[char] = &[ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', @@ -151,8 +152,13 @@ fn get_file_url(req: &web::HttpRequest, id: &str, name: Option<&str>) -> String pub async fn uploaded(req: web::HttpRequest) -> Result { let id = req.match_info().query("id"); let name = req.match_info().get("name"); - let url = get_file_url(&req, id, name); - let upload_html = UPLOAD_HTML.replace("{url}", url.as_str()); + let upload_html = if name.is_some() { + UPLOAD_SHORT_HTML + .replace("{link}", &get_file_url(&req, id, name)) + .replace("{shortlink}", &get_file_url(&req, id, None)) + } else { + UPLOAD_HTML.replace("{link}", &get_file_url(&req, id, name)) + }; Ok(HttpResponse::Ok() .content_type("text/html") .body(upload_html)) diff --git a/template/upload-short.html b/template/upload-short.html new file mode 100644 index 0000000..97ace66 --- /dev/null +++ b/template/upload-short.html @@ -0,0 +1,33 @@ + + + + datatrash + + + + + +
+

datatrash

+

link: {link}

+

shortlink: {shortlink}

+ + +
+ + + + diff --git a/template/upload.html b/template/upload.html index c9894dc..edc0381 100644 --- a/template/upload.html +++ b/template/upload.html @@ -9,7 +9,7 @@

datatrash

-

link: {url}

+

link: {link}