mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-24 14:46:27 -08:00
custom css...hopefully
This commit is contained in:
parent
2c5984d628
commit
78de4764bc
1
assets/icons/paint.svg
Normal file
1
assets/icons/paint.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="M12 2.25a.75.75 0 0 0-1.5 0V3.5a2.24 2.24 0 0 0-.841.53L2.78 10.91a2.25 2.25 0 0 0 0 3.182L7.66 18.97a2.25 2.25 0 0 0 3.182 0l6.879-6.879a2.25 2.25 0 0 0 0-3.182L12.84 4.03A2.24 2.24 0 0 0 12 3.5V2.25Zm-1.5 3.06v1.44a.75.75 0 0 0 1.5 0V5.31l4.659 4.66a.75.75 0 0 1 0 1.06l-.97.97H3.812l.029-.03L10.5 5.31ZM19.521 13.602a.874.874 0 0 0-1.542 0l-2.008 3.766C14.85 19.466 16.372 22 18.75 22s3.898-2.534 2.78-4.632l-2.009-3.766Z" fill="#DDDDDD"/></svg>
|
After Width: | Height: | Size: 552 B |
|
@ -17,6 +17,11 @@
|
||||||
href="/static/style/downloads.css"
|
href="/static/style/downloads.css"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="/auth/customCSS"
|
||||||
|
>
|
||||||
|
|
||||||
<link
|
<link
|
||||||
rel="icon"
|
rel="icon"
|
||||||
type="image/svg"
|
type="image/svg"
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
href="/static/assets/icons/error.svg"
|
href="/static/assets/icons/error.svg"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="/auth/customCSS"
|
||||||
|
>
|
||||||
|
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, user-scalable=0"
|
content="width=device-width, initial-scale=1.0, user-scalable=0"
|
||||||
|
|
|
@ -20,6 +20,11 @@
|
||||||
href="/static/assets/icons/icon_temp.svg"
|
href="/static/assets/icons/icon_temp.svg"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="/auth/customCSS"
|
||||||
|
>
|
||||||
|
|
||||||
<meta
|
<meta
|
||||||
name="viewport"
|
name="viewport"
|
||||||
content="width=device-width, initial-scale=1.0, user-scalable=0"
|
content="width=device-width, initial-scale=1.0, user-scalable=0"
|
||||||
|
|
|
@ -199,6 +199,8 @@ let fgRQH = async (req:express.Request,res:express.Response) => {
|
||||||
ServeError(res,err.status,err.message)
|
ServeError(res,err.status,err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
ServeError(res, 404, "file not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ export interface Account {
|
||||||
files : string[]
|
files : string[]
|
||||||
admin : boolean
|
admin : boolean
|
||||||
defaultFileVisibility : FileVisibility
|
defaultFileVisibility : FileVisibility
|
||||||
|
customCSS? : string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function create(username:string,pwd:string,admin:boolean=false):Promise<string> {
|
export function create(username:string,pwd:string,admin:boolean=false):Promise<string> {
|
||||||
|
|
|
@ -119,6 +119,11 @@ export default class Files {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.files[uploadId] && this.files[uploadId].reserved) {
|
||||||
|
reject({status:400,message:"already uploading this file. if your file is stuck in this state, contact an administrator"});
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.name.length > 128) {
|
if (settings.name.length > 128) {
|
||||||
reject({status:400,message:"name too long"});
|
reject({status:400,message:"name too long"});
|
||||||
return
|
return
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as Accounts from "../lib/accounts";
|
||||||
import * as auth from "../lib/auth";
|
import * as auth from "../lib/auth";
|
||||||
|
|
||||||
import ServeError from "../lib/errors";
|
import ServeError from "../lib/errors";
|
||||||
import Files, { FileVisibility } from "../lib/files";
|
import Files, { FileVisibility, id_check_regex } from "../lib/files";
|
||||||
|
|
||||||
let parser = bodyParser.json({
|
let parser = bodyParser.json({
|
||||||
type: ["text/plain","application/json"]
|
type: ["text/plain","application/json"]
|
||||||
|
@ -124,7 +124,7 @@ authRoutes.post("/dfv", parser, (req,res) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (['public','private','anonymous'].find(e => e == req.body.defaultFileVisibility)) {
|
if (['public','private','anonymous'].includes(req.body.defaultFileVisibility)) {
|
||||||
acc.defaultFileVisibility = req.body.defaultFileVisibility
|
acc.defaultFileVisibility = req.body.defaultFileVisibility
|
||||||
Accounts.save()
|
Accounts.save()
|
||||||
res.send(`dfv has been set to ${acc.defaultFileVisibility}`)
|
res.send(`dfv has been set to ${acc.defaultFileVisibility}`)
|
||||||
|
@ -134,6 +134,26 @@ authRoutes.post("/dfv", parser, (req,res) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
authRoutes.post("/customcss", parser, (req,res) => {
|
||||||
|
let acc = Accounts.getFromToken(req.cookies.auth)
|
||||||
|
if (!acc) {
|
||||||
|
ServeError(res, 401, "not logged in")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof req.body.fileId != "string") return
|
||||||
|
|
||||||
|
if (id_check_regex.test(req.body.fileId) && req.body.fileId.length <= config.maxUploadIdLength) {
|
||||||
|
acc.customCSS = req.body.fileId
|
||||||
|
if (!req.body.fileId) delete acc.customCSS
|
||||||
|
Accounts.save()
|
||||||
|
res.send(`custom css saved`)
|
||||||
|
} else {
|
||||||
|
res.status(400)
|
||||||
|
res.send("invalid fileid")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
authRoutes.post("/delete_account", parser, (req,res) => {
|
authRoutes.post("/delete_account", parser, (req,res) => {
|
||||||
let acc = Accounts.getFromToken(req.cookies.auth)
|
let acc = Accounts.getFromToken(req.cookies.auth)
|
||||||
if (!acc) {
|
if (!acc) {
|
||||||
|
@ -244,3 +264,21 @@ authRoutes.get("/me", (req,res) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
authRoutes.get("/customCSS", (req,res) => {
|
||||||
|
if (!auth.validate(req.cookies.auth)) {
|
||||||
|
ServeError(res, 401, "not logged in")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// lazy rn so
|
||||||
|
|
||||||
|
let acc = Accounts.getFromToken(req.cookies.auth)
|
||||||
|
if (acc) {
|
||||||
|
if (acc.customCSS) {
|
||||||
|
res.redirect(`/file/${acc.customCSS}`)
|
||||||
|
} else {
|
||||||
|
res.send("")
|
||||||
|
}
|
||||||
|
} else res.send("")
|
||||||
|
})
|
|
@ -65,9 +65,6 @@ fileApiRoutes.post("/manage", parser, (req,res) => {
|
||||||
let fp = files.getFilePointer(e)
|
let fp = files.getFilePointer(e)
|
||||||
|
|
||||||
if (fp.reserved) {
|
if (fp.reserved) {
|
||||||
if (req.body.target.length == 1) {
|
|
||||||
ServeError(res, 400, `cannot modify a file that is being uploaded, please contact an administrator if your file is stuck in this state.`)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,3 +117,33 @@ export function pwdChng(optPicker) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function customcss(optPicker) {
|
||||||
|
optPicker.picker("Set custom CSS",[
|
||||||
|
{
|
||||||
|
name: "Enter a file ID",
|
||||||
|
icon: "/static/assets/icons/file.svg",
|
||||||
|
id: "fileid",
|
||||||
|
inputSettings: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "OK",
|
||||||
|
icon: "/static/assets/icons/update.svg",
|
||||||
|
description: "Refresh to apply changes",
|
||||||
|
id: true
|
||||||
|
}
|
||||||
|
]).then((exp) => {
|
||||||
|
if (exp && exp.selected) {
|
||||||
|
fetch(`/auth/customcss`,{method:"POST", body:JSON.stringify({
|
||||||
|
fileId:exp.fileid
|
||||||
|
})}).then((response) => {
|
||||||
|
|
||||||
|
if (response.status != 200) {
|
||||||
|
optPicker.picker(`${response.status} ${response.statusText}`,[])
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchAccountData()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
|
@ -165,6 +165,15 @@
|
||||||
<p>Log out<span><br />Session expires {new Date($account.sessionExpires).toLocaleDateString()}</span></p>
|
<p>Log out<span><br />Session expires {new Date($account.sessionExpires).toLocaleDateString()}</span></p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div class="category">
|
||||||
|
<p>Customization</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button on:click={() => accOpts.customcss(optPicker)}>
|
||||||
|
<img src="/static/assets/icons/paint.svg" alt="logout_all">
|
||||||
|
<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>
|
||||||
|
|
||||||
{#if $account.admin}
|
{#if $account.admin}
|
||||||
|
|
||||||
<div class="category">
|
<div class="category">
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
{#if file.reserved}
|
{#if file.reserved}
|
||||||
<br />
|
<br />
|
||||||
<img src="/static/assets/icons/update.svg" alt="uploading"/>
|
<img src="/static/assets/icons/update.svg" alt="uploading"/>
|
||||||
This file is currently being uploaded. Please wait.
|
Uploading...
|
||||||
{/if}
|
{/if}
|
||||||
{#if file.tag}
|
{#if file.tag}
|
||||||
<br />
|
<br />
|
||||||
|
|
Loading…
Reference in a new issue