Add sharex support, add favicon
This commit is contained in:
parent
9db1b687f0
commit
32e6e8ea58
12 changed files with 84 additions and 7 deletions
33
README.md
33
README.md
|
@ -17,7 +17,7 @@ Source:
|
|||
```Bash
|
||||
EBPASS=changeme
|
||||
EBPORT=4000
|
||||
EBSECRET=4jkdmakl2l #jwt session secret
|
||||
EBAPI_KEY=changeme #ShareX support
|
||||
|
||||
$ npm install
|
||||
$ node db.js
|
||||
|
@ -25,9 +25,34 @@ $ npm start
|
|||
```
|
||||
Default username is admin with the password being whatever EBPASS is
|
||||
|
||||
Docker
|
||||
ShareX support is enabled at "/upload", requires auth with key
|
||||
JSON
|
||||
```
|
||||
docker run -d -p "4000:4000" -e EBPORT=4000 -e EBPASS=pass -e EBSECRET=4jkdmakl2l waveringana/embedder:latest
|
||||
{
|
||||
"Version": "14.1.0",
|
||||
"Name": "embedder",
|
||||
"DestinationType": "ImageUploader, FileUploader",
|
||||
"RequestMethod": "POST",
|
||||
"RequestURL": "http://localhost:3000/sharex",
|
||||
"Headers": {
|
||||
"key": "changeme"
|
||||
},
|
||||
"Body": "MultipartFormData",
|
||||
"Arguments": {
|
||||
"fileupload": null
|
||||
},
|
||||
"FileFormName": "fileupload",
|
||||
"URL": null,
|
||||
"ThumbnailURL": null,
|
||||
"DeletionURL": null,
|
||||
"ErrorMessage": null
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Docker config
|
||||
```
|
||||
docker run -d -p "4000:4000" -e EBPORT=4000 -e EBPASS=changeme -e EBAPI_KEY=changeme waveringana/embedder:latest
|
||||
```
|
||||
|
||||
Docker Compose
|
||||
|
@ -40,7 +65,7 @@ services:
|
|||
environment:
|
||||
- EBPORT=4000
|
||||
- EBPASS=changeme
|
||||
- EBSECRET=4jkdmakl2l
|
||||
- EBAPI_KEY=changeme
|
||||
volumes:
|
||||
- embedderdb:/var/db
|
||||
- embedderuploads:/uploads
|
||||
|
|
BIN
public/android-chrome-192x192.png
Normal file
BIN
public/android-chrome-192x192.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
BIN
public/android-chrome-512x512.png
Normal file
BIN
public/android-chrome-512x512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 400 KiB |
BIN
public/apple-touch-icon.png
Normal file
BIN
public/apple-touch-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 63 KiB |
BIN
public/favicon-16x16.png
Normal file
BIN
public/favicon-16x16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 954 B |
BIN
public/favicon-32x32.png
Normal file
BIN
public/favicon-32x32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
1
public/site.webmanifest
Normal file
1
public/site.webmanifest
Normal file
|
@ -0,0 +1 @@
|
|||
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
|
|
@ -73,6 +73,26 @@ function fetchMedia(req, res, next) {
|
|||
});
|
||||
}
|
||||
|
||||
function checkAuth(req, res, next) {
|
||||
let auth = process.env.EBAPI_KEY || process.env.EBPASS || 'pleaseSetAPI_KEY';
|
||||
let key = null;
|
||||
|
||||
if (req.headers['key']) {
|
||||
key = req.headers['key'];
|
||||
} else {
|
||||
return res.status(400).send('{success: false, message: "No key provided", fix: "Provide a key"}');
|
||||
}
|
||||
|
||||
if (auth != key) {
|
||||
return res.status(401).send('{success: false, message: "Invalid key", fix: "Provide a valid key"}');
|
||||
}
|
||||
|
||||
shortKey = key.substr(0, 3) + '...';
|
||||
console.log('Authenicated user with key: ' + shortKey);
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
let router = express.Router();
|
||||
|
||||
router.get('/', function (req, res, next) {
|
||||
|
@ -91,7 +111,8 @@ router.post('/', upload.array('fileupload'), function(req, res, next) {
|
|||
|
||||
for (file in req.files) {
|
||||
db.run('INSERT INTO media (path) VALUES (?)', [req.files[file].filename], function (err) {
|
||||
if (err) { console.log(err)
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return next(err);
|
||||
}
|
||||
return res.redirect('/');
|
||||
|
@ -99,6 +120,24 @@ router.post('/', upload.array('fileupload'), function(req, res, next) {
|
|||
}
|
||||
});
|
||||
|
||||
router.post('/sharex', [checkAuth, upload.array('fileupload')], function(req, res, next) {
|
||||
if (!req.files || Object.keys(req.files).length === 0) {
|
||||
console.log(req);
|
||||
return res.status(400).send('No files were uploaded.');
|
||||
}
|
||||
|
||||
for (file in req.files) {
|
||||
db.run('INSERT INTO media (path) VALUES (?)', [req.files[file].filename], function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return next(err);
|
||||
}
|
||||
return res.send('Upload successful, path: /uploads/' + req.files[file].filename);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
router.post('/:id(\\d+)/delete', function(req, res, next) {
|
||||
db.all('SELECT path FROM media WHERE id = ?', [ req.params.id ], function(err, path) {
|
||||
if (err) { return next(err); }
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
<link rel="stylesheet" href="/css/base.css">
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<link rel="stylesheet" href="/css/home.css">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
</head>
|
||||
<body>
|
||||
<section class="todohome">
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
<link rel="stylesheet" href="/css/base.css">
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<link rel="stylesheet" href="/css/app.css">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
<%
|
||||
function extension(string) {
|
||||
return string.slice((string.lastIndexOf(".") - 2 >>> 0) + 2);
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
<link rel="stylesheet" href="/css/base.css">
|
||||
<link rel="stylesheet" href="/css/index.css">
|
||||
<link rel="stylesheet" href="/css/login.css">
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||||
<link rel="manifest" href="/site.webmanifest">
|
||||
</head>
|
||||
<body>
|
||||
<section class="prompt">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue