diff --git a/src/routes/submit.rs b/src/routes/submit.rs index 521a218..5369f11 100644 --- a/src/routes/submit.rs +++ b/src/routes/submit.rs @@ -6,7 +6,7 @@ use crate::models::paste_id::PasteId; #[derive(FromForm)] pub struct PasteIdForm { - val: String, + content: String, ext: String, } @@ -15,7 +15,7 @@ pub async fn submit(paste: Form) -> Redirect { let id = PasteId::new(6); let filename = format!("upload/{id}", id = id); - let content = &paste.val; + let content = &paste.content; let ext = &paste.ext; fs::write(&filename, content).expect("Unable to write to the file"); diff --git a/static/css/index.css b/static/css/index.css index 4dc1d75..3751b16 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -43,7 +43,7 @@ form.highlight { } textarea { - height: 100%; + height: 90%; width: 100%; background: none; @@ -100,6 +100,10 @@ button[type="submit"] { cursor: pointer; } +button[type="submit"]:hover { + background-color: #be7611; +} + #upload_card { display: none; } diff --git a/static/css/pretty.css b/static/css/pretty.css new file mode 100644 index 0000000..bafd56f --- /dev/null +++ b/static/css/pretty.css @@ -0,0 +1,34 @@ +.topRightBox { + position: fixed; + padding: 18px 10px; + color: #f29718; + background-color: #0f1419; + top: 0px; + right: 0px; + font-family: "Iosevka Web", monospace; + font-size: 20px; + -moz-user-select: none; + -khtml-user-select: none; + -webkit-user-select: none; + user-select: none; +} + +.topRightBox button { + color: inherit; + background-color: inherit; + margin: 0px 5px; + border: solid 0.2px; + border-color: #0f1419; + font-family: inherit; + font-size: inherit; + line-height: inherit; + cursor: pointer; +} + +.topRightBox button:hover { + color: #be7611; +} + +.rootBoot { + position: relative; +} diff --git a/static/js/index.js b/static/js/index.js index 62d6553..d05ec70 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -6,6 +6,15 @@ const textarea = document.querySelector('textarea'); const select = document.querySelector('select'); const submitButton = document.querySelector('button[type="submit"]'); +window.onload = () => { + if (localStorage["forkText"] !== null) { + const textArea = document.getElementById('textarea_content'); + textArea.textContent = localStorage["forkText"]; + localStorage.clear(); + onInput(); + } +} + const onInput = () => { submitButton.classList.toggle('hidden', !textarea.value); select.classList.toggle('hidden', !textarea.value); diff --git a/static/js/pretty.js b/static/js/pretty.js new file mode 100644 index 0000000..8fbfbea --- /dev/null +++ b/static/js/pretty.js @@ -0,0 +1,15 @@ +const homePage = document.location.origin; + +function forkClicked () { + const paste = document.getElementById('pasteContent'); + let text = paste.innerText; + localStorage["forkText"] = text; + + console.log(text); + + window.location = homePage; +} + +function newPasteClicked () { + window.location = homePage; +} \ No newline at end of file diff --git a/templates/index.html.tera b/templates/index.html.tera index 6e270c5..d3bb671 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -8,7 +8,7 @@
-