Merge branch 'main' of https://github.com/WaveringAna/embedder
This commit is contained in:
commit
3afaf34132
7 changed files with 169 additions and 38 deletions
20
README.md
20
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)
|
||||
|
|
|
@ -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%;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
|
|
89
public/js/index.js
Normal file
89
public/js/index.js
Normal file
|
@ -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)
|
||||
}
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -7,24 +7,6 @@
|
|||
<link rel="stylesheet" href="/css/base.css">
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<link rel="stylesheet" href="/css/app.css">
|
||||
<script>
|
||||
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;
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="todoapp">
|
||||
|
@ -41,9 +23,13 @@ function absolutePath (href) {
|
|||
<header class="header">
|
||||
<h1>Embedder</h1>
|
||||
<form action="/" method="post" encType="multipart/form-data">
|
||||
<input class="new-todo" type="text" name="title" placeholder="File Title (optional)">
|
||||
<input class="new-todo" type="file" name="fileupload">
|
||||
<input type="submit">
|
||||
<!---->
|
||||
<div id="dropArea">
|
||||
<p class="dragregion">Upload a file or drag n' drop into the dashed region</p>
|
||||
<div id="gallery"></div>
|
||||
<p class="dragregion"><input class="" type="file" id="fileupload" name="fileupload"><input type="submit"></p>
|
||||
<p class="dragregion">Click the file to copy the url</p>
|
||||
</div>
|
||||
</form>
|
||||
</header>
|
||||
<% if (Count > 0) { %>
|
||||
|
@ -53,8 +39,8 @@ function absolutePath (href) {
|
|||
<li>
|
||||
<form action="<%= file.url %>" method="post">
|
||||
<div class="view">
|
||||
<img src="/uploads/<%=file.path %>" height="400" onclick="copyURI(event)">
|
||||
<label ondblclick="this.closest('li').className = this.closest('li').className + ' editing'; this.closest('li').querySelector('input.edit').focus(); this.closest('li').querySelector('input.edit').value = ''; this.closest('li').querySelector('input.edit').value = '<%= file.path %>';"><%= file.path %></label>
|
||||
<img class="image" src="/uploads/<%=file.path %>" width="100%" onclick="copyURI(event)">
|
||||
<label text-align:"center"><%= file.path %></label>
|
||||
<button class="destroy" form="delete-<%= file.path %>"></button>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -70,5 +56,6 @@ function absolutePath (href) {
|
|||
<p><a href="https://l.nekomimi.pet/project">Created by Wavering Ana</a></p>
|
||||
<p><a href="https://github.com/WaveringAna/Embedder">Github</a></p>
|
||||
</footer>
|
||||
<script src="/js/index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue