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 { deleteS3 } from '../storage';
import { SkynetDelete, SkynetDownload } from '../skynet'; import { SkynetDelete, SkynetDownload } from '../skynet';
import { path, log, getTrueHttp, getTrueDomain, formatBytes, formatTimestamp, getS3url, getDirectUrl, getResourceColor, replaceholder } from '../utils'; 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')); const { CODE_UNAUTHORIZED, CODE_NOT_FOUND, }: MagicNumbers = fs.readJsonSync(path('MagicNumbers.json'));
import { data } from '../data'; import { data } from '../data';
import { users } from '../auth'; 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 // Send the view to the client
res.render('view', { res.render('view', {
fileIs: fileData.is, fileIs: fileData.is,
title: escape(fileData.originalname), title: useIdInViewer ? `${resourceId}${idInViewerExtension ? `${fileData.ext}` : ''}` : escape(fileData.originalname),
mimetype: fileData.mimetype, mimetype: fileData.mimetype,
uploader: users.find(user => user.unid === fileData.uploader)?.username || 'Unknown', uploader: users.find(user => user.unid === fileData.uploader)?.username || 'Unknown',
timestamp: formatTimestamp(fileData.timestamp, fileData.timeoffset), timestamp: formatTimestamp(fileData.timestamp, fileData.timeoffset),

@ -12,6 +12,8 @@ const config = {
spaceReplace: '_', spaceReplace: '_',
mediaStrict: false, mediaStrict: false,
viewDirect: false, viewDirect: false,
useIdInViewer: false,
idInViewerExtension: false,
dataEngine: '@tycrek/papito', dataEngine: '@tycrek/papito',
frontendName: 'ass-x', frontendName: 'ass-x',
useSia: false, useSia: false,
@ -168,6 +170,18 @@ function doSetup() {
default: config.viewDirect, default: config.viewDirect,
required: false 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: { dataEngine: {
description: 'Data engine to use (must match an npm package name. If unsure, leave blank)', description: 'Data engine to use (must match an npm package name. If unsure, leave blank)',
type: 'string', type: 'string',

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

Loading…
Cancel
Save