Compare commits
No commits in common. "48005123de46e78b59576f1648688a632e3154f8" and "530ae31c7754ece1220e485bf7bf57b74c2a2095" have entirely different histories.
48005123de
...
530ae31c77
|
@ -16,7 +16,6 @@ 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',
|
||||
|
@ -152,13 +151,8 @@ fn get_file_url(req: &web::HttpRequest, id: &str, name: Option<&str>) -> String
|
|||
pub async fn uploaded(req: web::HttpRequest) -> Result<HttpResponse, Error> {
|
||||
let id = req.match_info().query("id");
|
||||
let name = req.match_info().get("name");
|
||||
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))
|
||||
};
|
||||
let url = get_file_url(&req, id, name);
|
||||
let upload_html = UPLOAD_HTML.replace("{url}", url.as_str());
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("text/html")
|
||||
.body(upload_html))
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
if (navigator.clipboard) {
|
||||
const buttons = document.querySelectorAll("button[data-copy], a[data-copy]");
|
||||
for (const button of buttons) {
|
||||
button.classList.remove("hidden");
|
||||
button.onclick = () => {
|
||||
const target = document.querySelector(button.getAttribute("data-copy"));
|
||||
navigator.clipboard.writeText(target.textContent).then(
|
||||
(_) => (button.innerText = "kopiert!"),
|
||||
(_) => (button.innerText = "nicht unterstützt")
|
||||
);
|
||||
};
|
||||
const button = document.getElementById("copy");
|
||||
button.classList.remove("hidden");
|
||||
button.onclick = () => {
|
||||
if (!navigator.clipboard) {
|
||||
button.innerText = "nicht unterstützt";
|
||||
return;
|
||||
}
|
||||
}
|
||||
const content = document.getElementsByClassName("copy-content")[0];
|
||||
navigator.clipboard.writeText(content.textContent).then(
|
||||
(_) => {
|
||||
button.innerText = "kopiert!";
|
||||
},
|
||||
(_) => {
|
||||
button.innerText = "nicht unterstützt";
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
@ -101,7 +101,6 @@ input[type="checkbox"] {
|
|||
font-weight: normal;
|
||||
font-size: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
<body>
|
||||
<main>
|
||||
<h1><a href="/">datatrash</a></h1>
|
||||
<textarea id="text" rows="20" cols="120" readonly>{text}</textarea>
|
||||
<textarea id="text" rows="20" cols="120" class="copy-content" readonly>
|
||||
{text}</textarea
|
||||
>
|
||||
<br />
|
||||
<a class="main button" href="?dl">herunterladen</a>
|
||||
<button id="copy" data-copy="#text" class="button hidden">
|
||||
text kopieren
|
||||
</button>
|
||||
<button id="copy" class="button hidden">text kopieren</button>
|
||||
</main>
|
||||
<footer>
|
||||
<a
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de-DE">
|
||||
<head>
|
||||
<title>datatrash</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link href="/static/index.css" rel="stylesheet" />
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1><a href="/">datatrash</a></h1>
|
||||
<p>link: <a id="link" href="{link}">{link}</a></p>
|
||||
<p>shortlink: <a id="shortlink" href="{shortlink}">{shortlink}</a></p>
|
||||
<button id="copy" data-copy="#link" class="main button hidden">
|
||||
link kopieren
|
||||
</button>
|
||||
<button id="copy-short" data-copy="#shortlink" class="button hidden">
|
||||
shortlink kopieren
|
||||
</button>
|
||||
</main>
|
||||
<footer>
|
||||
<a
|
||||
class="repo"
|
||||
href="https://repos.ctdo.de/neri/datatrash"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
repo
|
||||
</a>
|
||||
</footer>
|
||||
<script src="/static/copy.js" lang="javascript"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -9,10 +9,11 @@
|
|||
<body>
|
||||
<main>
|
||||
<h1><a href="/">datatrash</a></h1>
|
||||
<p>link: <a id="link" href="{link}">{link}</a></p>
|
||||
<button id="copy" data-copy="#link" class="main button hidden">
|
||||
link kopieren
|
||||
</button>
|
||||
<p>
|
||||
datei-link:
|
||||
<a id="link" class="copy-content" href="{url}">{url}</a>
|
||||
</p>
|
||||
<button id="copy" class="main button hidden">link kopieren</button>
|
||||
</main>
|
||||
<footer>
|
||||
<a
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
<main>
|
||||
<h1><a href="/">datatrash</a></h1>
|
||||
<a
|
||||
id="link"
|
||||
class="large-link"
|
||||
class="large-link copy-content"
|
||||
href="{link_attribute}"
|
||||
rel="noopener noreferrer"
|
||||
>{link_content}</a
|
||||
|
@ -20,9 +19,7 @@
|
|||
<a class="main button" href="{link_attribute}" rel="noopener noreferrer">
|
||||
link öffnen
|
||||
</a>
|
||||
<button id="copy" data-copy="#link" class="button hidden">
|
||||
link kopieren
|
||||
</button>
|
||||
<button id="copy" class="button hidden">link kopieren</button>
|
||||
<a class="button" href="?dl">als text herunterladen</a>
|
||||
</main>
|
||||
<footer>
|
||||
|
|
Loading…
Reference in New Issue