diff --git a/README.md b/README.md index bbe43df..bff929c 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,26 @@ docker build . -t embedder docker run -d -p "4000:4000" -e EBPORT=4000 -e EBPASS=pass -e EBSECRET=4jkdmakl2l embedder ``` +Docker Compose +``` +version: '3.3' +services: + embedder: + ports: + - '4000:4000' + environment: + - EBPORT=4000 + - EBPASS=changeme + volumes: + - embedderdb:/var/db + - embedderuploads:/uploads + image: embedder + network_mode: bridge +volumes: + embedderdb: + embedderuploads: +``` + ## License [The Unlicense](https://opensource.org/licenses/unlicense) diff --git a/public/css/app.css b/public/css/app.css index c84ddea..864564c 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -53,3 +53,23 @@ background-repeat: no-repeat; background-position: center left; } + +#dropArea { + border: 2px dashed #ccc; + border-radius: 20px; + width: 100%; + font-family: sans-serif; + padding: 50px 0px 50px 0px; +} + +#dropArea.highlight { + border-color: purple; +} + +.dragregion { + text-align: center; +} + +.image { + width: 100%; +} diff --git a/public/css/index.css b/public/css/index.css index d6dc71e..8238dbf 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -23,8 +23,8 @@ button { body { font: 14px 'Helvetica Neue', Helvetica, Arial, sans-serif; line-height: 1.4em; - background: #f5f5f5; - color: #111111; + background: #111111; + color: #f5f5f5; min-width: 230px; max-width: 550px; margin: 0 auto; @@ -33,12 +33,16 @@ body { font-weight: 300; } +.view .header { + background: #121122; +} + .hidden { display: none; } .todoapp { - background: #fff; + background: #121212; margin: 130px 0 40px 0; position: relative; box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), @@ -48,19 +52,22 @@ body { .todoapp input::-webkit-input-placeholder { font-style: italic; font-weight: 400; - color: rgba(0, 0, 0, 0.4); + color: #f5f5f5; + text-align: center; } .todoapp input::-moz-placeholder { font-style: italic; font-weight: 400; - color: rgba(0, 0, 0, 0.4); + color: #f5f5f5; + text-align: center; } .todoapp input::input-placeholder { font-style: italic; font-weight: 400; - color: rgba(0, 0, 0, 0.4); + color: #f5f5f5; + text-align: center; } .todoapp h1 { @@ -87,9 +94,6 @@ body { line-height: 1.4em; color: inherit; padding: 6px; - border: 1px solid #999; - box-shadow: inset 0 -1px 5px 0 rgba(0, 0, 0, 0.2); - box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } @@ -105,7 +109,6 @@ body { .main { position: relative; z-index: 2; - border-top: 1px solid #e6e6e6; } .toggle-all { @@ -153,7 +156,6 @@ body { .todo-list li { position: relative; font-size: 24px; - border-bottom: 1px solid #ededed; } .todo-list li:last-child { @@ -215,7 +217,7 @@ body { line-height: 1.2; transition: color 0.4s; font-weight: 400; - color: #484848; + color: #BB86FC; } .todo-list li.completed label { diff --git a/public/css/login.css b/public/css/login.css index 64e6cae..d33b643 100644 --- a/public/css/login.css +++ b/public/css/login.css @@ -2,7 +2,7 @@ max-width: 400px; margin: 50px auto; padding: 25px; - background: #fff; + background: #11111; border: 1px solid #e6e6e6; border-radius: 8px; } @@ -79,6 +79,8 @@ input { font-size: 14px; border: 1px solid #d9d9d9; border-radius: 5px; + background-color:#200; + color:#fff; } input[type=email]:not(:focus):invalid, diff --git a/public/js/index.js b/public/js/index.js new file mode 100644 index 0000000..93433ed --- /dev/null +++ b/public/js/index.js @@ -0,0 +1,89 @@ +function copyURI(evt) { + evt.preventDefault(); + navigator.clipboard.writeText(absolutePath(evt.target.getAttribute('src'))).then(() => { + /* clipboard successfully set */ + console.log("copied") + }, () => { + /* clipboard write failed */ + console.log("failed") + }); +} + +function absolutePath (href) { + let link = document.createElement("a"); + link.href = href; + return link.href; +} + +let dropArea = document.getElementById("dropArea"); + +;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => { + dropArea.addEventListener(eventName, preventDefaults, false) +}) + +function preventDefaults (e) { + e.preventDefault() + e.stopPropagation() +} + +;['dragenter', 'dragover'].forEach(eventName => { + dropArea.addEventListener(eventName, highlight, false) +}) + +;['dragleave', 'drop'].forEach(eventName => { + dropArea.addEventListener(eventName, unhighlight, false) +}) + +function highlight(e) { + dropArea.classList.add('highlight') +} + +function unhighlight(e) { + dropArea.classList.remove('highlight') +} + +dropArea.addEventListener('drop', handleDrop, false) + +function handleDrop(e) { + let dt = e.dataTransfer + let files = dt.files + handleFiles(files) +} + +function handleFiles(files) { + files = [...files] + files.forEach(uploadFile) + files.forEach(previewFile) +} + + +function previewFile(file) { + let reader = new FileReader() + reader.readAsDataURL(file) + reader.onloadend = function() { + let img = document.createElement('img'); + img.src = reader.result + img.className = "image"; + document.getElementById('gallery').appendChild(img) + console.log(document.getElementById('fileupload')) + document.getElementById('fileupload').src = img.src; + } +} + +function uploadFile(file) { + let xhr = new XMLHttpRequest(); + let formData = new FormData(); + xhr.open('POST', '/', true); + + xhr.addEventListener('readystatechange', function(e) { + if (xhr.readyState == 4 && xhr.status == 200) { + location.reload(); + } + else if (xhr.readyState == 4 && xhr.status != 200) { + // Error. Inform the user + } + }) + + formData.append('fileupload', file); + xhr.send(formData) +} diff --git a/routes/index.js b/routes/index.js index e412de3..74978d2 100644 --- a/routes/index.js +++ b/routes/index.js @@ -18,9 +18,20 @@ const storage = multer.diskStorage({ else cb(null, prefix + '-' + req.body.title + extension(file.originalname)) } -}) +}); -let upload = multer({ storage: storage }); +const fileFilter = function(req, file, cb) { + if (file.mimetype == "image/png" || file.mimetype == "image/jpg" || file.mimetype == "image/jpeg" || file.mimetype == "image/gif" || file.mimetype == "image/webp" + || file.mimetype == "video/mp4" || file.mimetype == "video/mov" || file.mimetype == "video/webm" + || file.mimetype == "audio/mpeg" || file.mimetype == "audio/ogg") { + cb(null, true) + } else { + cb(null, false); + //return cb(new Error('Only media files allowed')); + } + } + +let upload = multer({ storage: storage, fileFilter: fileFilter }); let db = require('../db'); diff --git a/views/index.ejs b/views/index.ejs index a4d51da..5fc7c92 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -7,24 +7,6 @@ -