Added setting to view direct resource in browser (merged #60)

pull/61/head
Josh Moore 3 years ago committed by GitHub
commit c6eff307b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -107,7 +107,7 @@ ass was designed with developers in mind. If you are a developer & want somethin
[Docker](#docker) is the recommended way to install ass, but you can also install it locally. [Docker](#docker) is the recommended way to install ass, but you can also install it locally.
1. You should have **Node.js 14 or later** & **npm 7 or later** installed. 1. You should have **Node.js 14** & **npm 7 or later** installed.
2. Clone this repo using `git clone https://github.com/tycrek/ass.git && cd ass/` 2. Clone this repo using `git clone https://github.com/tycrek/ass.git && cd ass/`
3. Run `npm i` to install the required dependencies 3. Run `npm i` to install the required dependencies
5. Run `npm start` to start ass. 5. Run `npm start` to start ass.

@ -2,7 +2,7 @@ const fs = require('fs-extra');
const escape = require('escape-html'); const escape = require('escape-html');
const fetch = require('node-fetch'); const fetch = require('node-fetch');
const { deleteS3 } = require('../storage'); const { deleteS3 } = require('../storage');
const { diskFilePath, s3enabled } = require('../config.json'); const { diskFilePath, s3enabled, viewDirect } = require('../config.json');
const { path, log, getTrueHttp, getTrueDomain, formatBytes, formatTimestamp, getS3url, getDirectUrl, getResourceColor, replaceholder } = require('../utils'); const { path, log, getTrueHttp, getTrueDomain, formatBytes, formatTimestamp, getS3url, getDirectUrl, getResourceColor, replaceholder } = require('../utils');
const { CODE_UNAUTHORIZED, CODE_NOT_FOUND, } = require('../MagicNumbers.json'); const { CODE_UNAUTHORIZED, CODE_NOT_FOUND, } = require('../MagicNumbers.json');
const data = require('../data'); const data = require('../data');
@ -47,7 +47,8 @@ router.get('/', (req, res, next) => data.get(req.ass.resourceId).then((fileData)
oembedUrl: `${getTrueHttp()}${getTrueDomain()}/${resourceId}/oembed`, oembedUrl: `${getTrueHttp()}${getTrueDomain()}/${resourceId}/oembed`,
ogtype: fileData.is.video ? 'video.other' : fileData.is.image ? 'image' : 'website', ogtype: fileData.is.video ? 'video.other' : fileData.is.image ? 'image' : 'website',
urlType: `og:${fileData.is.video ? 'video' : fileData.is.audio ? 'audio' : 'image'}`, urlType: `og:${fileData.is.video ? 'video' : fileData.is.audio ? 'audio' : 'image'}`,
opengraph: replaceholder(ogs.join('\n'), fileData.size, fileData.timestamp, fileData.originalname) opengraph: replaceholder(ogs.join('\n'), fileData.size, fileData.timestamp, fileData.originalname),
viewDirect
}); });
}).catch(next)); }).catch(next));

@ -10,6 +10,7 @@ const config = {
gfyIdSize: 2, gfyIdSize: 2,
resourceIdType: 'random', resourceIdType: 'random',
mediaStrict: false, mediaStrict: false,
viewDirect: false,
frontendName: 'ass-x', frontendName: 'ass-x',
indexFile: '', indexFile: '',
s3enabled: false, s3enabled: false,
@ -143,6 +144,12 @@ function doSetup() {
default: config.mediaStrict, default: config.mediaStrict,
required: false required: false
}, },
viewDirect: {
description: 'View uploads in browser as direct resource, rather than a viewing page',
type: 'boolean',
default: config.viewDirect,
required: false
},
frontendName: { frontendName: {
description: 'Name of your frontend (leave blank if not using frontends)', description: 'Name of your frontend (leave blank if not using frontends)',
type: 'string', type: 'string',

@ -20,6 +20,12 @@ html
// oEmbed (https://oembed.com/) // oEmbed (https://oembed.com/)
link(href=oembedUrl title='oEmbed' rel='alternate' type='application/json+oembed') link(href=oembedUrl title='oEmbed' rel='alternate' type='application/json+oembed')
// Direct resource redirect
if viewDirect
style.
* { display: none !important; }
meta(http-equiv='refresh' content=`0; url='${resourceAttr.src}'`)
body body
#container #container
#content #content

Loading…
Cancel
Save