feat: allow using the generated ID in the web viewer (closes #181)

pull/186/head
tycrek 2 years ago
parent dcd93b6fc3
commit fe79d84662
No known key found for this signature in database
GPG Key ID: FF8A54DCE404885A

@ -8,7 +8,7 @@ import { Request, Response } from 'express';
import { deleteS3 } from '../storage';
import { SkynetDelete, SkynetDownload } from '../skynet';
import { path, log, getTrueHttp, getTrueDomain, formatBytes, formatTimestamp, getS3url, getDirectUrl, getResourceColor, replaceholder } from '../utils';
const { diskFilePath, s3enabled, viewDirect, useSia }: Config = fs.readJsonSync(path('config.json'));
const { diskFilePath, s3enabled, viewDirect, useIdInViewer, idInViewerExtension, useSia }: Config = fs.readJsonSync(path('config.json'));
const { CODE_UNAUTHORIZED, CODE_NOT_FOUND, }: MagicNumbers = fs.readJsonSync(path('MagicNumbers.json'));
import { data } from '../data';
import { users } from '../auth';
@ -47,7 +47,7 @@ router.get('/', (req: Request, res: Response, next) => data().get(req.ass.resour
// Send the view to the client
res.render('view', {
fileIs: fileData.is,
title: escape(fileData.originalname),
title: useIdInViewer ? `${resourceId}${idInViewerExtension ? `${fileData.ext}` : ''}` : escape(fileData.originalname),
mimetype: fileData.mimetype,
uploader: users.find(user => user.unid === fileData.uploader)?.username || 'Unknown',
timestamp: formatTimestamp(fileData.timestamp, fileData.timeoffset),

@ -12,6 +12,8 @@ const config = {
spaceReplace: '_',
mediaStrict: false,
viewDirect: false,
useIdInViewer: false,
idInViewerExtension: false,
dataEngine: '@tycrek/papito',
frontendName: 'ass-x',
useSia: false,
@ -168,6 +170,18 @@ function doSetup() {
default: config.viewDirect,
required: false
},
useIdInViewer: {
description: 'Use the ID in the web viewer instead of the filename',
type: 'boolean',
default: config.useIdInViewer,
required: false
},
idInViewerExtension: {
description: '(Only applies if "useIdInViewer" is true) Include the file extension in the ID in the web viewer',
type: 'boolean',
default: config.idInViewerExtension,
required: false
},
dataEngine: {
description: 'Data engine to use (must match an npm package name. If unsure, leave blank)',
type: 'string',

@ -12,6 +12,8 @@ declare module 'ass-json' {
gfyIdSize: number
mediaStrict: boolean
viewDirect: boolean
useIdInViewer: boolean
idInViewerExtension: boolean
dataEngine: string
frontendName: string
indexFile: string

Loading…
Cancel
Save