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;
|
use sqlx::postgres::PgPool;
|
||||||
|
|
||||||
const UPLOAD_HTML: &str = include_str!("../template/upload.html");
|
const UPLOAD_HTML: &str = include_str!("../template/upload.html");
|
||||||
const UPLOAD_SHORT_HTML: &str = include_str!("../template/upload-short.html");
|
|
||||||
|
|
||||||
const ID_CHARS: &[char] = &[
|
const ID_CHARS: &[char] = &[
|
||||||
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
'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> {
|
pub async fn uploaded(req: web::HttpRequest) -> Result<HttpResponse, Error> {
|
||||||
let id = req.match_info().query("id");
|
let id = req.match_info().query("id");
|
||||||
let name = req.match_info().get("name");
|
let name = req.match_info().get("name");
|
||||||
let upload_html = if name.is_some() {
|
let url = get_file_url(&req, id, name);
|
||||||
UPLOAD_SHORT_HTML
|
let upload_html = UPLOAD_HTML.replace("{url}", url.as_str());
|
||||||
.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()
|
Ok(HttpResponse::Ok()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(upload_html))
|
.body(upload_html))
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
if (navigator.clipboard) {
|
const button = document.getElementById("copy");
|
||||||
const buttons = document.querySelectorAll("button[data-copy], a[data-copy]");
|
button.classList.remove("hidden");
|
||||||
for (const button of buttons) {
|
button.onclick = () => {
|
||||||
button.classList.remove("hidden");
|
if (!navigator.clipboard) {
|
||||||
button.onclick = () => {
|
button.innerText = "nicht unterstützt";
|
||||||
const target = document.querySelector(button.getAttribute("data-copy"));
|
return;
|
||||||
navigator.clipboard.writeText(target.textContent).then(
|
|
||||||
(_) => (button.innerText = "kopiert!"),
|
|
||||||
(_) => (button.innerText = "nicht unterstützt")
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
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-weight: normal;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
margin-right: 0.5rem;
|
margin-right: 0.5rem;
|
||||||
margin-top: 1rem;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h1><a href="/">datatrash</a></h1>
|
<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 />
|
<br />
|
||||||
<a class="main button" href="?dl">herunterladen</a>
|
<a class="main button" href="?dl">herunterladen</a>
|
||||||
<button id="copy" data-copy="#text" class="button hidden">
|
<button id="copy" class="button hidden">text kopieren</button>
|
||||||
text kopieren
|
|
||||||
</button>
|
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<a
|
<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>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h1><a href="/">datatrash</a></h1>
|
<h1><a href="/">datatrash</a></h1>
|
||||||
<p>link: <a id="link" href="{link}">{link}</a></p>
|
<p>
|
||||||
<button id="copy" data-copy="#link" class="main button hidden">
|
datei-link:
|
||||||
link kopieren
|
<a id="link" class="copy-content" href="{url}">{url}</a>
|
||||||
</button>
|
</p>
|
||||||
|
<button id="copy" class="main button hidden">link kopieren</button>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<a
|
<a
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
<main>
|
<main>
|
||||||
<h1><a href="/">datatrash</a></h1>
|
<h1><a href="/">datatrash</a></h1>
|
||||||
<a
|
<a
|
||||||
id="link"
|
class="large-link copy-content"
|
||||||
class="large-link"
|
|
||||||
href="{link_attribute}"
|
href="{link_attribute}"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>{link_content}</a
|
>{link_content}</a
|
||||||
|
@ -20,9 +19,7 @@
|
||||||
<a class="main button" href="{link_attribute}" rel="noopener noreferrer">
|
<a class="main button" href="{link_attribute}" rel="noopener noreferrer">
|
||||||
link öffnen
|
link öffnen
|
||||||
</a>
|
</a>
|
||||||
<button id="copy" data-copy="#link" class="button hidden">
|
<button id="copy" class="button hidden">link kopieren</button>
|
||||||
link kopieren
|
|
||||||
</button>
|
|
||||||
<a class="button" href="?dl">als text herunterladen</a>
|
<a class="button" href="?dl">als text herunterladen</a>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
Loading…
Reference in New Issue