mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 22:56:26 -08:00
🚀🎉 Bump to beta
This commit is contained in:
parent
98f86b6427
commit
45da932326
1
assets/icons/image.svg
Normal file
1
assets/icons/image.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m11.475 13.718.083-.071a.75.75 0 0 1 .874-.007l.093.078 6.928 6.8A3.235 3.235 0 0 1 17.75 21H6.25a3.235 3.235 0 0 1-1.703-.481l6.928-6.801.083-.071-.083.07ZM17.75 3A3.25 3.25 0 0 1 21 6.25v11.5c0 .627-.178 1.213-.485 1.71l-6.939-6.813-.128-.116a2.25 2.25 0 0 0-2.889-.006l-.135.123-6.939 6.811A3.235 3.235 0 0 1 3 17.75V6.25A3.25 3.25 0 0 1 6.25 3h11.5Zm-1.998 3a2.252 2.252 0 1 0 0 4.504 2.252 2.252 0 0 0 0-4.504Zm0 1.5a.752.752 0 1 1 0 1.504.752.752 0 0 1 0-1.504Z" fill="#DDDDDD"/></svg>
|
After Width: | Height: | Size: 595 B |
1
assets/icons/pound.svg
Normal file
1
assets/icons/pound.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.985 3.165a1 1 0 0 0-1.973-.33l-.86 5.163L3.998 8a1 1 0 1 0 .002 2l3.817-.002-.667 4L3 14a1 1 0 1 0 0 2l3.817-.002-.807 4.838a1 1 0 1 0 1.973.329l.862-5.167 4.975-.003-.806 4.84a1 1 0 1 0 1.972.33l.862-5.17L20 15.992a1 1 0 0 0 0-2l-3.819.001.667-4.001L21 9.99a1 1 0 0 0 0-2l-3.818.002.804-4.827a1 1 0 1 0-1.972-.33l-.86 5.159-4.975.003.806-4.832Zm-1.14 6.832 4.976-.003-.667 4.001-4.976.002.667-4Z" fill="#DDDDDD"/></svg>
|
After Width: | Height: | Size: 528 B |
1
assets/icons/small_image.svg
Normal file
1
assets/icons/small_image.svg
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21.25 13a.75.75 0 0 1 .743.648l.007.102v5a3.25 3.25 0 0 1-3.066 3.245L18.75 22h-4.668c.536-.385.973-.9 1.265-1.499l3.403-.001a1.75 1.75 0 0 0 1.744-1.607l.006-.143v-5a.75.75 0 0 1 .75-.75ZM9.447 17.165l.114.103 4.085 4.086.023.019A3.235 3.235 0 0 1 11.75 22h-6.5a3.235 3.235 0 0 1-1.92-.627l.024-.02 4.085-4.085.114-.103a1.5 1.5 0 0 1 1.894 0ZM11.75 9A3.25 3.25 0 0 1 15 12.25v6.5c0 .718-.233 1.382-.627 1.92l-.02-.024-4.085-4.085-.13-.122a2.5 2.5 0 0 0-3.269-.006l-.137.128-4.086 4.085-.019.023A3.235 3.235 0 0 1 2 18.75v-6.5A3.25 3.25 0 0 1 5.25 9h6.5ZM11 12a1 1 0 1 0 0 2 1 1 0 0 0 0-2Zm7.75-10a3.25 3.25 0 0 1 3.245 3.066L22 5.25v5a.75.75 0 0 1-1.493.102l-.007-.102v-5a1.75 1.75 0 0 0-1.606-1.744L18.75 3.5h-5a.75.75 0 0 1-.102-1.493L13.75 2h5Zm-8.5 0a.75.75 0 0 1 .102 1.493l-.102.007h-5a1.75 1.75 0 0 0-1.744 1.606L3.5 5.25v3.402c-.6.292-1.114.73-1.5 1.266V5.25a3.25 3.25 0 0 1 3.066-3.245L5.25 2h5Z" fill="#DDDDDD"/></svg>
|
After Width: | Height: | Size: 1 KiB |
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "monofile",
|
"name": "monofile",
|
||||||
"version": "1.3.0-alpha",
|
"version": "1.3.0-beta",
|
||||||
"description": "Discord-based file sharing",
|
"description": "Discord-based file sharing",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
href="/static/assets/icons/file_icon.svg"
|
href="/static/assets/icons/file_icon.svg"
|
||||||
>
|
>
|
||||||
|
|
||||||
<meta name="theme-color" content="rgb(30, 33, 36)">
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="appContent">
|
<div id="appContent">
|
||||||
|
|
|
@ -136,6 +136,7 @@ app.get("/download/:fileId",(req,res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.readFile(process.cwd()+"/pages/download.html",(err,buf) => {
|
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}
|
if (err) {res.sendStatus(500);console.log(err);return}
|
||||||
res.send(
|
res.send(
|
||||||
buf.toString()
|
buf.toString()
|
||||||
|
@ -149,6 +150,7 @@ app.get("/download/:fileId",(req,res) => {
|
||||||
.replace(/\>/g,">")
|
.replace(/\>/g,">")
|
||||||
)
|
)
|
||||||
.replace(/\<\!\-\-metaTags\-\-\>/g,
|
.replace(/\<\!\-\-metaTags\-\-\>/g,
|
||||||
|
(
|
||||||
file.mime.startsWith("image/")
|
file.mime.startsWith("image/")
|
||||||
? `<meta name="og:image" content="https://${req.headers.host}/file/${req.params.fileId}" />`
|
? `<meta name="og:image" content="https://${req.headers.host}/file/${req.params.fileId}" />`
|
||||||
: (
|
: (
|
||||||
|
@ -160,6 +162,13 @@ app.get("/download/:fileId",(req,res) => {
|
||||||
: ""
|
: ""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
+ (
|
||||||
|
fileOwner?.embed?.largeImage
|
||||||
|
? `<meta name="twitter:image" content="/assets/reallycoolfish.jpg">`
|
||||||
|
: ""
|
||||||
|
)
|
||||||
|
+ `\n<meta name="theme-color" content="${fileOwner?.embed?.color && (req.headers["user-agent"]||"").includes("Discordbot") ? `#${fileOwner.embed.color}` : "rgb(30, 33, 36)"}">`
|
||||||
|
)
|
||||||
.replace(/\<\!\-\-preview\-\-\>/g,
|
.replace(/\<\!\-\-preview\-\-\>/g,
|
||||||
file.mime.startsWith("image/")
|
file.mime.startsWith("image/")
|
||||||
? `<div style="min-height:10px"></div><img src="/file/${req.params.fileId}" />`
|
? `<div style="min-height:10px"></div><img src="/file/${req.params.fileId}" />`
|
||||||
|
@ -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 {
|
} else {
|
||||||
|
|
|
@ -20,6 +20,11 @@ export interface Account {
|
||||||
admin : boolean
|
admin : boolean
|
||||||
defaultFileVisibility : FileVisibility
|
defaultFileVisibility : FileVisibility
|
||||||
customCSS? : string
|
customCSS? : string
|
||||||
|
|
||||||
|
embed? : {
|
||||||
|
color? : string
|
||||||
|
largeImage? : boolean
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function create(username:string,pwd:string,admin:boolean=false):Promise<string> {
|
export function create(username:string,pwd:string,admin:boolean=false):Promise<string> {
|
||||||
|
|
|
@ -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) => {
|
authRoutes.post("/delete_account", parser, async (req,res) => {
|
||||||
let acc = Accounts.getFromToken(req.cookies.auth)
|
let acc = Accounts.getFromToken(req.cookies.auth)
|
||||||
if (!acc) {
|
if (!acc) {
|
||||||
|
|
|
@ -206,3 +206,65 @@ 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()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -171,6 +171,16 @@
|
||||||
<p>Set custom CSS<span><br />{@html $account.customCSS ? `Using file ID <span class="number">${$account.customCSS}</span>` : "No custom CSS set"}</span></p>
|
<p>Set custom CSS<span><br />{@html $account.customCSS ? `Using file ID <span class="number">${$account.customCSS}</span>` : "No custom CSS set"}</span></p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button on:click={() => accOpts.embedColor(optPicker)}>
|
||||||
|
<img src="/static/assets/icons/pound.svg" alt="embedColor">
|
||||||
|
<p>Set custom embed color<span><br />{@html $account?.embed?.color ? `Using custom color <span class="number">${$account?.embed?.color}</span>` : ""}</span></p>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button on:click={() => accOpts.embedSize(optPicker)}>
|
||||||
|
<img src="/static/assets/icons/image.svg" alt="embedSize">
|
||||||
|
<p>Set embed image size <span><br />Images currently appear {$account?.embed?.largeImage ? `large` : "small"} in embeds</span></p>
|
||||||
|
</button>
|
||||||
|
|
||||||
{#if $refreshNeeded}
|
{#if $refreshNeeded}
|
||||||
<button on:click={() => window.location.reload(true)} transition:fade={{duration: 200}}>
|
<button on:click={() => window.location.reload(true)} transition:fade={{duration: 200}}>
|
||||||
<img src="/static/assets/icons/refresh.svg" alt="refresh">
|
<img src="/static/assets/icons/refresh.svg" alt="refresh">
|
||||||
|
|
Loading…
Reference in a new issue