diff --git a/README.md b/README.md index 5eb76d3..777e6f2 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,9 @@ TOKEN=KILL-YOURSELF.NOW - [X] 1.2.2 clean up this shitty code - [X] 1.2.3 bugfixes - [ ] 1.3.0 new ui; accounts; utility endpoints; multi file uploads -- [ ] 1.3.1 self-destruct option -- [ ] 1.3.2 disable cloning of local ips +- [ ] 1.3.1 organize svelte code +- [ ] 1.3.2 self-destructing files +- [ ] 1.3.3 disable cloning of local ips - [ ] 1.4.0 admin panel - [ ] 2.0.0 rewrite using theUnfunny's code as a base/rewrite using monofile-core diff --git a/src/server/index.ts b/src/server/index.ts index 04735f8..6a4f961 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -53,7 +53,13 @@ app.get("/", function(req,res) { app.post("/upload",multerSetup.single('file'),async (req,res) => { if (req.file) { try { - files.uploadFile({name:req.file.originalname,mime:req.file.mimetype,uploadId:req.header("monofile-upload-id")},req.file.buffer) + let prm = req.header("monofile-params") + let params:{[key:string]:any} = {} + if (prm) { + params = JSON.parse(prm) + } + + files.uploadFile({uploadId:params.uploadId,name:req.file.originalname,mime:req.file.mimetype},req.file.buffer) .then((uID) => res.send(uID)) .catch((stat) => { res.status(stat.status); diff --git a/src/style/app/uploader/add_new_files.scss b/src/style/app/uploader/add_new_files.scss index 21167ce..248e30e 100644 --- a/src/style/app/uploader/add_new_files.scss +++ b/src/style/app/uploader/add_new_files.scss @@ -4,10 +4,6 @@ border: 1px solid gray; padding: 0px 0px 10px 0px; - @media screen and (max-width: 500px) { - width:100%; - } - p { font-family: "Fira Code", monospace; text-align: left; @@ -77,6 +73,7 @@ position:relative; background-color:#262626; + transition-duration:250ms; input[type=file] { opacity: 0; @@ -98,6 +95,11 @@ padding:0px; margin: 0px; } + + &:hover { + transition-duration:250ms; + background-color:#292929; + } } } } diff --git a/src/style/app/uploader/file.scss b/src/style/app/uploader/file.scss new file mode 100644 index 0000000..520ba48 --- /dev/null +++ b/src/style/app/uploader/file.scss @@ -0,0 +1,59 @@ +// should probably start using mixins for thingss like this + +#uploadWindow { + .file { + background-color:#191919; + border: 1px solid gray; + padding: 10px; + overflow:clip; + position:relative; + + h2 { + font-size: 16px; + margin: 0px; + font-weight:600; + width:calc( 100% - 20px ); + } + + input[type=text] { + background-color:#333333; + color:#DDDDDD; + border:none; + outline:none; + padding:5px; + position:relative; + + width:100%; + transition-duration:250ms; + + @media screen and (max-width: 500px) { + font-size:16px; + padding:10px; + } + } + + .buttonContainer { + display:flex; + column-gap:10px; + + button { + flex-basis: 50%; + flex-grow: 1; + padding:5px; + } + } + + .uploadingContainer { + color: #AAAAAA; + } + + .hitbox { + opacity:0; + position:absolute; + left:0px; + top:0px; + height:100%; + width:100%; + } + } +} \ No newline at end of file diff --git a/src/style/app/uploads.scss b/src/style/app/uploads.scss index 0e294f1..22de104 100644 --- a/src/style/app/uploads.scss +++ b/src/style/app/uploads.scss @@ -1,4 +1,5 @@ @use "uploader/add_new_files"; +@use "uploader/file"; #uploadWindow { position:absolute; @@ -6,8 +7,13 @@ top:50%; transform:translate(-50%,-50%); padding:10px 15px 10px 15px; + display:flex; + flex-direction: column; width:350px; + @media screen and (min-width:500px) { + max-height: calc( 100% - 80px ); + } background-color:#222222; color:#ddd; @@ -30,6 +36,32 @@ font-family: "Inconsolata", monospace; } + .uploadContainer { + overflow:auto; + } + + button { + cursor:pointer; + background-color:#393939; + color:#DDDDDD; + border:none; + outline:none; + padding:5px; + transition-duration: 250ms; + /*overflow:clip;*/ + + @media screen and (max-width: 500px) { + font-size:16px; + padding:10px; + } + + &:hover { + transition-duration: 250ms; + background-color:#434343; + color: #ffffff; + } + } + @media screen and (max-width: 500px) { width: calc( 100% - 20px ); height: calc( 100% - 20px ); diff --git a/src/svelte/elem/UploadWindow.svelte b/src/svelte/elem/UploadWindow.svelte index e9e30b2..debde11 100644 --- a/src/svelte/elem/UploadWindow.svelte +++ b/src/svelte/elem/UploadWindow.svelte @@ -1,19 +1,145 @@ @@ -23,21 +149,75 @@ {ServerStats.version ? `v${ServerStats.version}` : "•••"}  —  Discord based file sharing

-
- {#each Array.from(uploads.entries()) as upload (upload[0])} -
- +
+ + + +
+ {#each Object.entries(uploads) as upload (upload[0])} + +
+
+

{upload[1].name} {upload[1].type}{@html upload[1].type == "upload" ? ` (${Math.round(upload[1].file.size/1048576)}MB)` : ""}

+ + {#if upload[1].maximized && !uploadInProgress} +
+
+ +
+
+ + +
+
+ {:else if !uploadInProgress} + + {:else} +
+ {#if !upload[1].uploadStatus.fileId} +

{upload[1].uploadStatus.error ?? "Uploading..."}

+ {/if} + + {#if upload[1].uploadStatus.fileId} +
+ {#if !upload[1].viewingUrl} +
+ + +
+ {:else} +
+ + +
+ {/if} + {/if} +
+ {/if} +
+
{/each}
- -
- {#if uploads.size < 1} - + {#if uploadInProgress == false} + +
+ {#if Object.keys(uploads).length > 0} + +
+ {/if} {/if} - -

Hosting {ServerStats.files || "•••"} files @@ -47,7 +227,7 @@

- Made with ❤ by @nbitzzsource + Made with {Math.floor(Math.random()*10)==0 ? "🐟" : "❤"} by @nbitzzsource

\ No newline at end of file diff --git a/src/svelte/elem/transition/_void.js b/src/svelte/elem/transition/_void.js new file mode 100644 index 0000000..8bf599c --- /dev/null +++ b/src/svelte/elem/transition/_void.js @@ -0,0 +1,20 @@ +import { circIn, circOut } from "svelte/easing" + +export function _void(node, { duration, easingFunc, op }) { + let rect = node.getBoundingClientRect() + + return { + duration: duration||300, + css: t => { + let eased = (easingFunc || circIn)(t) + + return ` + white-space: nowrap; + height: ${(eased)*(rect.height)}px; + padding: 0px; + opacity:${eased}; + overflow: clip; + ` + } + } +} \ No newline at end of file diff --git a/src/svelte/elem/uploader/AttachmentZone.svelte b/src/svelte/elem/uploader/AttachmentZone.svelte index 277ef65..98b9046 100644 --- a/src/svelte/elem/uploader/AttachmentZone.svelte +++ b/src/svelte/elem/uploader/AttachmentZone.svelte @@ -1,5 +1,7 @@