Skip to content

Commit

Permalink
feat: allow using the generated ID in the web viewer (closes #181)
Browse files Browse the repository at this point in the history
  • Loading branch information
tycrek committed Dec 25, 2022
1 parent dcd93b6 commit fe79d84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/routers/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand Down
14 changes: 14 additions & 0 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const config = {
spaceReplace: '_',
mediaStrict: false,
viewDirect: false,
useIdInViewer: false,
idInViewerExtension: false,
dataEngine: '@tycrek/papito',
frontendName: 'ass-x',
useSia: false,
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/types/json.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ declare module 'ass-json' {
gfyIdSize: number
mediaStrict: boolean
viewDirect: boolean
useIdInViewer: boolean
idInViewerExtension: boolean
dataEngine: string
frontendName: string
indexFile: string
Expand Down

0 comments on commit fe79d84

Please sign in to comment.