add asciitrash copy and download button
This commit is contained in:
parent
8436ae4f4d
commit
07db070107
|
@ -110,7 +110,7 @@ async fn download(
|
|||
let mut path = config.files_dir.clone();
|
||||
path.push(&file_id);
|
||||
|
||||
if kind == FileKind::TEXT.to_string() {
|
||||
if kind == FileKind::TEXT.to_string() && !req.query_string().contains("raw") {
|
||||
let content = fs::read_to_string(path).await.map_err(|_| {
|
||||
error::ErrorInternalServerError("this file should be here but could not be found")
|
||||
})?;
|
||||
|
|
|
@ -30,7 +30,9 @@ label {
|
|||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
textarea,
|
||||
.button,
|
||||
.button:visited {
|
||||
background-color: #222222;
|
||||
color: #dddddd;
|
||||
padding: 0.5rem;
|
||||
|
@ -40,6 +42,19 @@ textarea {
|
|||
max-width: calc(100vw - 3rem - 4px);
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
.button {
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
background-color: #444444;
|
||||
}
|
||||
|
||||
.button.main {
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.button.main:hover {
|
||||
background-color: forestgreen;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<option value="2678400">1 monat</option>
|
||||
</select>
|
||||
<br />
|
||||
<input type="submit" value="Hochladen" />
|
||||
<input class="main button" type="submit" value="Hochladen" />
|
||||
</form>
|
||||
</main>
|
||||
</body>
|
||||
|
|
|
@ -9,7 +9,26 @@
|
|||
<body>
|
||||
<main>
|
||||
<h1><a href="/">datatrash</a></h1>
|
||||
<textarea rows="20" cols="120" readonly>{text}</textarea>
|
||||
<textarea id="text" rows="20" cols="120" readonly>{text}</textarea>
|
||||
<br />
|
||||
<a class="main button" href="?raw">Herunterladen</a>
|
||||
<button id="copy" class="button" onclick="copyToClipboard()">
|
||||
Text kopieren
|
||||
</button>
|
||||
</main>
|
||||
<script lang="javascript">
|
||||
function copyToClipboard() {
|
||||
const button = document.getElementById("copy");
|
||||
if (!navigator.clipboard) {
|
||||
button.innerText = "Nicht unterstützt";
|
||||
return;
|
||||
}
|
||||
const textarea = document.getElementById("text");
|
||||
navigator.clipboard.writeText(textarea.value).then(
|
||||
_ => { button.innerText = "Kopiert!"; },
|
||||
_ => { button.innerText = "Nicht unterstützt"; },
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue