Skip to content

Commit bd30f3e

Browse files
committed
1.10.1
1 parent 604692c commit bd30f3e

File tree

9 files changed

+121
-66
lines changed

9 files changed

+121
-66
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Enabled at `/upload`. Requires authentication with key. `expire` key specifies d
5858
### Using Docker
5959

6060
```bash
61-
docker run -d -p "3000:3000" -e EBPORT=3000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.9.2
61+
docker run -d -p "3000:3000" -e EBPORT=3000 -e EBPASS=changeme -e EBAPI_KEY=changeme ghcr.io/waveringana/embedder:1.10.1
6262
```
6363

6464
### Docker Compose
@@ -76,7 +76,7 @@ services:
7676
volumes:
7777
- ./db:/var/db
7878
- ./uploads:/uploads
79-
image: ghcr.io/waveringana/embedder:1.9.2
79+
image: ghcr.io/waveringana/embedder:1.10.1
8080
```
8181
8282
## 📜 License

app/lib/ffmpeg.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export const ffmpegDownscale = (
123123
path: string,
124124
filename: string,
125125
extension: string,
126-
) => {
126+
): Promise<void> => {
127127
const startTime = Date.now();
128128
const outputOptions = [
129129
"-vf",
@@ -143,8 +143,11 @@ export const ffmpegDownscale = (
143143
.input(path)
144144
.outputOptions(outputOptions)
145145
.output(`uploads/720p-${filename}${extension}`)
146-
.on("progress", function(progress) {
147-
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
146+
.on("progress", function (progress) {
147+
fs.writeFileSync(
148+
progressFile,
149+
JSON.stringify({ progress: progress.percent / 100 }),
150+
);
148151
})
149152
.on("end", () => {
150153
console.log(
@@ -189,7 +192,7 @@ export const ffmpegConvert = (
189192
path: string,
190193
filename: string,
191194
extension: string,
192-
) => {
195+
): Promise<void> => {
193196
const startTime = Date.now();
194197
const outputOptions = [
195198
"-vf",
@@ -225,8 +228,11 @@ export const ffmpegConvert = (
225228
.output("uploads/")
226229
.outputFormat(outputFormat)
227230
.output(`uploads/${filename}${outputFormat}`)
228-
.on("progress", function(progress) {
229-
fs.writeFileSync(progressFile, JSON.stringify({ progress: progress.percent / 100 }));
231+
.on("progress", function (progress) {
232+
fs.writeFileSync(
233+
progressFile,
234+
JSON.stringify({ progress: progress.percent / 100 }),
235+
);
230236
})
231237
.on("end", function () {
232238
console.log(
@@ -246,7 +252,10 @@ export const ffProbe = async (
246252
extension: string,
247253
) => {
248254
return new Promise<FfprobeData>((resolve, reject) => {
249-
if (!videoExtensions.includes(extension) && !imageExtensions.includes(extension)) {
255+
if (
256+
!videoExtensions.includes(extension) &&
257+
!imageExtensions.includes(extension)
258+
) {
250259
console.log(`Extension is ${extension}`);
251260
reject(`Submitted file is neither a video nor an image: ${path}`);
252261
}

app/lib/middleware.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ export const checkSharexAuth: Middleware = (req, res, next) => {
4444
next();
4545
};
4646

47-
/**Creates oembed json file for embed metadata */
47+
/**
48+
* Creates oembed data for uploaded files
49+
*
50+
* @param {Express Request Object} Express request object
51+
* @param {Express Response Object} Express response object
52+
* @param {Express NextFunction variable} Express next function
53+
*
54+
*/
4855
export const createEmbedData: Middleware = async (req, res, next) => {
4956
const files = req.files as Express.Multer.File[];
5057
for (const file in files) {
@@ -90,7 +97,14 @@ export const createEmbedData: Middleware = async (req, res, next) => {
9097
next();
9198
};
9299

93-
/**Creates a 720p copy of video for smaller file */
100+
/**
101+
* Creates a 720p copy of uploaded videos
102+
*
103+
* @param {Express Request Object} req Express request object
104+
* @param {Express Response Object} res Express response object
105+
* @param {Express NextFunction} next Express next function
106+
*
107+
*/
94108
export const convertTo720p: Middleware = (req, res, next) => {
95109
const files = req.files as Express.Multer.File[];
96110
console.log("convert to 720p running");
@@ -103,7 +117,6 @@ export const convertTo720p: Middleware = (req, res, next) => {
103117
fileExtension !== ".gif"
104118
) {
105119
console.log(`${files[file].filename} is not a video file`);
106-
console.log(fileExtension);
107120
continue;
108121
}
109122

app/lib/multer.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const fileStorage = multer.diskStorage({
3333
console.log(err);
3434
callback(err, null);
3535
}
36+
3637
if (exists.length != 0) {
3738
const suffix = new Date().getTime() / 1000;
3839

@@ -41,15 +42,9 @@ export const fileStorage = multer.diskStorage({
4142
request.body.title == null ||
4243
request.body.title == undefined
4344
) {
44-
callback(
45-
null,
46-
filename + "-" + suffix + fileExtension,
47-
);
45+
callback(null, filename + "-" + suffix + fileExtension);
4846
} else {
49-
callback(
50-
null,
51-
request.body.title + "-" + suffix + fileExtension,
52-
);
47+
callback(null, request.body.title + "-" + suffix + fileExtension);
5348
}
5449
} else {
5550
if (
@@ -67,7 +62,7 @@ export const fileStorage = multer.diskStorage({
6762
},
6863
});
6964

70-
export const allowedMimeTypes = [
65+
export let allowedMimeTypes = [
7166
"image/png",
7267
"image/jpg",
7368
"image/jpeg",
@@ -80,6 +75,10 @@ export const allowedMimeTypes = [
8075
"audio/ogg",
8176
];
8277

78+
export const setAllowedMimeTypes = (mimeTypes: string[]): void => {
79+
allowedMimeTypes = mimeTypes;
80+
};
81+
8382
export const fileFilter = (
8483
request: Request,
8584
file: Express.Multer.File,
@@ -91,4 +90,3 @@ export const fileFilter = (
9190
callback(null, false);
9291
}
9392
};
94-

app/public/js/index.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
/* eslint-disable no-undef */
1+
/* eslint no-use-before-define: 0 */
22
/* eslint-env browser: true */
33

44
let newMediaList;
55

6+
const videoExtensions = [
7+
".mp4",
8+
".mov",
9+
".avi",
10+
".flv",
11+
".mkv",
12+
".wmv",
13+
".webm",
14+
];
15+
16+
const imageExtensions = [
17+
".jpg",
18+
".jpeg",
19+
".png",
20+
".gif",
21+
".bmp",
22+
".svg",
23+
".tiff",
24+
".webp",
25+
];
26+
27+
628
function copyURI(evt) {
729
evt.preventDefault();
830
navigator.clipboard

app/views/adduser.ejs

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1">
6-
<title>Embedder</title>
7-
<link rel="stylesheet" href="/css/base.css">
8-
<link rel="stylesheet" href="/css/index.css">
9-
<link rel="stylesheet" href="/css/login.css">
10-
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
11-
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
12-
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
13-
<link rel="manifest" href="/site.webmanifest">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Embedder</title>
7+
<link rel="stylesheet" href="/css/base.css" />
8+
<link rel="stylesheet" href="/css/index.css" />
9+
<link rel="stylesheet" href="/css/login.css" />
10+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
11+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
12+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
13+
<link rel="manifest" href="/site.webmanifest" />
1414
</head>
15-
<body>
16-
<section class="prompt">
17-
<h3>Embedder</h3>
18-
<h1>Add User</h1>
19-
<form action="/adduser" method="post">
20-
<section>
21-
<label for="username">Username</label>
22-
<input id="username" name="username" type="text" autocomplete="username" required autofocus>
23-
</section>
24-
<section>
25-
<label for="current-password">Password</label>
26-
<input id="current-password" name="password" type="password" autocomplete="current-password" required>
27-
</section>
28-
<button type="submit">Add User</button>
29-
</form>
30-
<hr>
31-
</section>
32-
<footer class="info">
33-
<p><a href="https://l.nekomimi.pet/project">Created by Wavering Ana</a></p>
34-
<p><a href="https://github.com/WaveringAna/Embedder">Github</a></p>
35-
</footer>
36-
</body>
15+
<body>
16+
<section class="prompt">
17+
<h3>Embedder</h3>
18+
<h1>Add User</h1>
19+
<form action="/adduser" method="post">
20+
<section>
21+
<label for="username">Username</label>
22+
<input
23+
id="username"
24+
name="username"
25+
type="text"
26+
autocomplete="username"
27+
required
28+
autofocus
29+
/>
30+
</section>
31+
<section>
32+
<label for="current-password">Password</label>
33+
<input
34+
id="current-password"
35+
name="password"
36+
type="password"
37+
autocomplete="current-password"
38+
required
39+
/>
40+
</section>
41+
<button type="submit">Add User</button>
42+
</form>
43+
<hr />
44+
</section>
45+
<footer class="info">
46+
<p>
47+
<a href="https://l.nekomimi.pet/project">Created by Wavering Ana</a>
48+
</p>
49+
<p><a href="https://github.com/WaveringAna/Embedder">Github</a></p>
50+
</footer>
51+
</body>
3752
</html>

app/views/gifv.ejs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ p {
8080
line-height: 1.6; /* Improve readability */
8181
}
8282
83-
/* Optionally, you can add media query for dark mode based on user's system preferences */
84-
@media (prefers-color-scheme: dark) {
85-
/* Dark mode styles */
86-
}
87-
8883
footer {
8984
text-align: center;
9085
padding: 20px;
@@ -108,6 +103,9 @@ footer a:hover {
108103
text-decoration: underline; /* Adds an underline on hover for better user experience */
109104
}
110105
106+
@media (prefers-color-scheme: light) {
107+
108+
}
111109
</style>
112110

113111
<body>
@@ -119,6 +117,6 @@ footer a:hover {
119117

120118
<footer>
121119
<p>Powered by <a href="https://github.com/waveringana/embedder">Embedder</a> created by <a href="https://github.com/waveringana">WaveringAna</a></p>
122-
</footer>
120+
</footer>
123121
</body>
124122
</html>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "embedder",
3-
"version": "1.9.2",
3+
"version": "1.10.1",
44
"private": true,
55
"description": "Media host for quick embeds to sites like discord",
66
"keywords": [

0 commit comments

Comments
 (0)