diff --git a/assets/icons/image.svg b/assets/icons/image.svg
new file mode 100644
index 0000000..f2c72c3
--- /dev/null
+++ b/assets/icons/image.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/pound.svg b/assets/icons/pound.svg
new file mode 100644
index 0000000..22cba99
--- /dev/null
+++ b/assets/icons/pound.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/assets/icons/small_image.svg b/assets/icons/small_image.svg
new file mode 100644
index 0000000..ba66d1e
--- /dev/null
+++ b/assets/icons/small_image.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/package.json b/package.json
index 27e92c8..b6e9585 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "monofile",
- "version": "1.3.0-alpha",
+ "version": "1.3.0-beta",
"description": "Discord-based file sharing",
"main": "index.js",
"scripts": {
diff --git a/pages/download.html b/pages/download.html
index 1bb749a..d2cec08 100644
--- a/pages/download.html
+++ b/pages/download.html
@@ -28,8 +28,6 @@
href="/static/assets/icons/file_icon.svg"
>
-
-
diff --git a/src/server/index.ts b/src/server/index.ts
index 2dcb90d..709084d 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -136,6 +136,7 @@ app.get("/download/:fileId",(req,res) => {
}
fs.readFile(process.cwd()+"/pages/download.html",(err,buf) => {
+ let fileOwner = file.owner ? Accounts.getFromId(file.owner) : undefined;
if (err) {res.sendStatus(500);console.log(err);return}
res.send(
buf.toString()
@@ -149,16 +150,24 @@ app.get("/download/:fileId",(req,res) => {
.replace(/\>/g,">")
)
.replace(/\<\!\-\-metaTags\-\-\>/g,
- file.mime.startsWith("image/")
- ? `
`
- : (
- file.mime.startsWith("video/")
- ? `
-
-
-
`
+ (
+ file.mime.startsWith("image/")
+ ? `
`
+ : (
+ file.mime.startsWith("video/")
+ ? `
+
+
+
`
+ : ""
+ )
+ )
+ + (
+ fileOwner?.embed?.largeImage
+ ? `
`
: ""
)
+ + `\n
`
)
.replace(/\<\!\-\-preview\-\-\>/g,
file.mime.startsWith("image/")
@@ -173,7 +182,7 @@ app.get("/download/:fileId",(req,res) => {
)
)
)
- .replace(/\$Uploader/g,!file.owner||file.visibility=="anonymous" ? "Anonymous" : `@${Accounts.getFromId(file.owner)?.username || "Deleted User"}`)
+ .replace(/\$Uploader/g,!file.owner||file.visibility=="anonymous" ? "Anonymous" : `@${fileOwner?.username || "Deleted User"}`)
)
})
} else {
diff --git a/src/server/lib/accounts.ts b/src/server/lib/accounts.ts
index 1ec98e8..270ed18 100644
--- a/src/server/lib/accounts.ts
+++ b/src/server/lib/accounts.ts
@@ -20,6 +20,11 @@ export interface Account {
admin : boolean
defaultFileVisibility : FileVisibility
customCSS? : string
+
+ embed? : {
+ color? : string
+ largeImage? : boolean
+ }
}
export function create(username:string,pwd:string,admin:boolean=false):Promise
{
diff --git a/src/server/routes/authRoutes.ts b/src/server/routes/authRoutes.ts
index 982916f..ed25a09 100644
--- a/src/server/routes/authRoutes.ts
+++ b/src/server/routes/authRoutes.ts
@@ -163,6 +163,49 @@ authRoutes.post("/customcss", parser, (req,res) => {
}
})
+authRoutes.post("/embedcolor", parser, (req,res) => {
+ let acc = Accounts.getFromToken(req.cookies.auth)
+ if (!acc) {
+ ServeError(res, 401, "not logged in")
+ return
+ }
+
+ if (typeof req.body.color != "string") req.body.color = undefined;
+
+ if (
+
+ !req.body.color
+ || (req.body.color.toLowerCase().match(/[a-f0-9]/) == req.body.color)
+ && req.body.color.length == 6
+
+ ) {
+ if (!acc.embed) acc.embed = {}
+ acc.embed.color = req.body.color || undefined
+ if (!req.body.color) delete acc.embed.color
+ Accounts.save()
+ res.send(`custom embed color saved`)
+ } else {
+ res.status(400)
+ res.send("invalid hex code")
+ }
+})
+
+authRoutes.post("/embedsize", parser, (req,res) => {
+ let acc = Accounts.getFromToken(req.cookies.auth)
+ if (!acc) {
+ ServeError(res, 401, "not logged in")
+ return
+ }
+
+ if (typeof req.body.largeImage != "boolean") req.body.color = false;
+
+ if (!acc.embed) acc.embed = {}
+ acc.embed.largeImage = req.body.largeImage
+ if (!req.body.largeImage) delete acc.embed.largeImage
+ Accounts.save()
+ res.send(`custom embed image size saved`)
+})
+
authRoutes.post("/delete_account", parser, async (req,res) => {
let acc = Accounts.getFromToken(req.cookies.auth)
if (!acc) {
diff --git a/src/svelte/elem/prompts/account.js b/src/svelte/elem/prompts/account.js
index f3d5caa..b2584ab 100644
--- a/src/svelte/elem/prompts/account.js
+++ b/src/svelte/elem/prompts/account.js
@@ -205,4 +205,66 @@ export function customcss(optPicker) {
})
}
})
+}
+
+
+export function embedColor(optPicker) {
+ optPicker.picker("Set embed color",[
+ {
+ name: "FFFFFF",
+ icon: "/static/assets/icons/pound.svg",
+ id: "color",
+ inputSettings: {}
+ },
+ {
+ name: "OK",
+ icon: "/static/assets/icons/update.svg",
+ description: "",
+ id: true
+ }
+ ]).then((exp) => {
+ if (exp && exp.selected) {
+ fetch(`/auth/embedcolor`,{method:"POST", body:JSON.stringify({
+ color:exp.color
+ })}).then((response) => {
+
+ if (response.status != 200) {
+ optPicker.picker(`${response.status} ${response.statusText}`,[])
+ }
+
+ fetchAccountData()
+ })
+ }
+ })
+}
+
+
+export function embedSize(optPicker) {
+ optPicker.picker("Set embed image size",[
+ {
+ name: "Large",
+ icon: "/static/assets/icons/image.svg",
+ description: "",
+ id: true
+ },
+ {
+ name: "Small",
+ icon: "/static/assets/icons/small_image.svg",
+ description: "",
+ id: false
+ }
+ ]).then((exp) => {
+ if (exp && exp.selected !== null) {
+ fetch(`/auth/embedsize`,{method:"POST", body:JSON.stringify({
+ largeImage:exp.selected
+ })}).then((response) => {
+
+ if (response.status != 200) {
+ optPicker.picker(`${response.status} ${response.statusText}`,[])
+ }
+
+ fetchAccountData()
+ })
+ }
+ })
}
\ No newline at end of file
diff --git a/src/svelte/elem/pulldowns/Accounts.svelte b/src/svelte/elem/pulldowns/Accounts.svelte
index 32d2d91..2e76f43 100644
--- a/src/svelte/elem/pulldowns/Accounts.svelte
+++ b/src/svelte/elem/pulldowns/Accounts.svelte
@@ -171,6 +171,16 @@
Set custom CSS
{@html $account.customCSS ? `Using file ID ${$account.customCSS}` : "No custom CSS set"}
+
+
+
+
{#if $refreshNeeded}