changed file ext vars from '.ext' to 'ext'
This commit is contained in:
parent
e9eb5e5638
commit
69741dfc1d
4 changed files with 18 additions and 18 deletions
|
@ -161,10 +161,10 @@ module.exports = {
|
||||||
},
|
},
|
||||||
serveOrShowAsset (fileInfo, extension, method, headers, originalUrl, ip, res) {
|
serveOrShowAsset (fileInfo, extension, method, headers, originalUrl, ip, res) {
|
||||||
// add file extension to the file info
|
// add file extension to the file info
|
||||||
if (extension === '.gifv') {
|
if (extension === 'gifv') {
|
||||||
fileInfo['fileExt'] = '.gifv';
|
fileInfo['fileExt'] = 'gifv';
|
||||||
} else {
|
} else {
|
||||||
fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.'));
|
fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.') + 1);
|
||||||
}
|
}
|
||||||
// serve or show
|
// serve or show
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
|
|
@ -36,18 +36,18 @@ module.exports = (app) => {
|
||||||
let claimId = null;
|
let claimId = null;
|
||||||
let channelId = null;
|
let channelId = null;
|
||||||
let method;
|
let method;
|
||||||
let extension;
|
let fileExtension;
|
||||||
// parse the name
|
// parse the name
|
||||||
const positionOfExtension = name.indexOf('.');
|
const positionOfExtension = name.indexOf('.');
|
||||||
if (positionOfExtension >= 0) {
|
if (positionOfExtension >= 0) {
|
||||||
extension = name.substring(positionOfExtension);
|
fileExtension = name.substring(positionOfExtension + 1);
|
||||||
name = name.substring(0, positionOfExtension);
|
name = name.substring(0, positionOfExtension);
|
||||||
/* patch because twitter player preview adds '>' before file extension */
|
/* patch because twitter player preview adds '>' before file extension */
|
||||||
if (name.indexOf('>') >= 0) {
|
if (name.indexOf('>') >= 0) {
|
||||||
name = name.substring(0, name.indexOf('>'));
|
name = name.substring(0, name.indexOf('>'));
|
||||||
}
|
}
|
||||||
/* end patch */
|
/* end patch */
|
||||||
logger.debug('file extension =', extension);
|
logger.debug('file extension =', fileExtension);
|
||||||
if (headers['accept'] && headers['accept'].split(',').includes('text/html')) {
|
if (headers['accept'] && headers['accept'].split(',').includes('text/html')) {
|
||||||
method = SHOWLITE;
|
method = SHOWLITE;
|
||||||
} else {
|
} else {
|
||||||
|
@ -88,7 +88,7 @@ module.exports = (app) => {
|
||||||
if (!fileInfo) {
|
if (!fileInfo) {
|
||||||
res.status(200).render('noClaims');
|
res.status(200).render('noClaims');
|
||||||
} else {
|
} else {
|
||||||
return serveOrShowAsset(fileInfo, extension, method, headers, originalUrl, ip, res);
|
return serveOrShowAsset(fileInfo, fileExtension, method, headers, originalUrl, ip, res);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 3. update the file
|
// 3. update the file
|
||||||
|
@ -139,7 +139,7 @@ module.exports = (app) => {
|
||||||
if (headers['accept'] && headers['accept'].split(',').includes('text/html')) {
|
if (headers['accept'] && headers['accept'].split(',').includes('text/html')) {
|
||||||
method = SHOWLITE;
|
method = SHOWLITE;
|
||||||
}
|
}
|
||||||
fileExtension = name.substring(name.indexOf('.'));
|
fileExtension = name.substring(name.indexOf('.') + 1);
|
||||||
name = name.substring(0, name.indexOf('.'));
|
name = name.substring(0, name.indexOf('.'));
|
||||||
logger.debug('file extension =', fileExtension);
|
logger.debug('file extension =', fileExtension);
|
||||||
} else {
|
} else {
|
||||||
|
@ -157,7 +157,7 @@ module.exports = (app) => {
|
||||||
if (!fileInfo) {
|
if (!fileInfo) {
|
||||||
res.status(200).render('noClaims');
|
res.status(200).render('noClaims');
|
||||||
} else {
|
} else {
|
||||||
return serveOrShowAsset(fileInfo, null, method, headers, originalUrl, ip, res);
|
return serveOrShowAsset(fileInfo, fileExtension, method, headers, originalUrl, ip, res);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 3. update the database
|
// 3. update the database
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div id="asset-placeholder">
|
<div id="asset-placeholder">
|
||||||
<a href="/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}}">
|
<a href="/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}">
|
||||||
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
||||||
{{#ifConditional fileInfo.fileExt '===' '.gifv'}}
|
{{#ifConditional fileInfo.fileExt '===' 'gifv'}}
|
||||||
<video class="show-asset" autoplay loop muted>
|
<video class="show-asset" autoplay loop muted>
|
||||||
<source src="/media/{{fileInfo.fileName}}">
|
<source src="/media/{{fileInfo.fileName}}">
|
||||||
{{!--fallback--}}
|
{{!--fallback--}}
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
<h2 class="subheader">Links</h2>
|
<h2 class="subheader">Links</h2>
|
||||||
{{!--short direct link to asset--}}
|
{{!--short direct link to asset--}}
|
||||||
<div class="share-option">
|
<div class="share-option">
|
||||||
<a href="/{{fileInfo.shortId}}/{{fileInfo.name}}{{fileInfo.fileExt}}">Permanent Short Link</a> (most convenient)
|
<a href="/{{fileInfo.shortId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}">Permanent Short Link</a> (most convenient)
|
||||||
<div class="input-error" id="input-error-copy-short-link" hidden="true"></div>
|
<div class="input-error" id="input-error-copy-short-link" hidden="true"></div>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="text" id="short-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.shortId}}/{{fileInfo.name}}{{fileInfo.fileExt}}" onclick="select()"/>
|
<input type="text" id="short-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.shortId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}" onclick="select()"/>
|
||||||
<button class="copy-button" data-elementtocopy="short-link" onclick="copyToClipboard(event)">copy</button>
|
<button class="copy-button" data-elementtocopy="short-link" onclick="copyToClipboard(event)">copy</button>
|
||||||
</div>
|
</div>
|
||||||
{{!-- link to show route for asset--}}
|
{{!-- link to show route for asset--}}
|
||||||
<div class="share-option">
|
<div class="share-option">
|
||||||
<a href="/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}}">Permanent Long Link</a> (fastest service)
|
<a href="/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}">Permanent Long Link</a> (fastest service)
|
||||||
<div class="input-error" id="input-error-copy-long-link" hidden="true"></div>
|
<div class="input-error" id="input-error-copy-long-link" hidden="true"></div>
|
||||||
</br>
|
</br>
|
||||||
<input type="text" id="long-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}}"/>
|
<input type="text" id="long-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}"/>
|
||||||
<button class="copy-button" data-elementtocopy="long-link" onclick="copyToClipboard(event)">copy</button>
|
<button class="copy-button" data-elementtocopy="long-link" onclick="copyToClipboard(event)">copy</button>
|
||||||
</div>
|
</div>
|
||||||
{{!-- html text for embedding asset--}}
|
{{!-- html text for embedding asset--}}
|
||||||
|
@ -26,9 +26,9 @@
|
||||||
<div class="input-error" id="input-error-copy-embed-text" hidden="true"></div>
|
<div class="input-error" id="input-error-copy-embed-text" hidden="true"></div>
|
||||||
<br/>
|
<br/>
|
||||||
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
|
||||||
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='<video width="100%" controls src="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}}"/></video>'/>
|
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='<video width="100%" controls src="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}"/></video>'/>
|
||||||
{{else}}
|
{{else}}
|
||||||
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='<img src="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}}" />'/>
|
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='<img src="https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}}" />'/>
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
<button class="copy-button" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
|
<button class="copy-button" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
Markdown
|
Markdown
|
||||||
<div class="input-error" id="input-error-copy-markdown-text" hidden="true"></div>
|
<div class="input-error" id="input-error-copy-markdown-text" hidden="true"></div>
|
||||||
<br/>
|
<br/>
|
||||||
<input type="text" id="markdown-text" class="link" readonly onclick="select()" spellcheck="false" value='![{{fileInfo.name}}](https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}{{fileInfo.fileExt}})'/>
|
<input type="text" id="markdown-text" class="link" readonly onclick="select()" spellcheck="false" value='![{{fileInfo.name}}](https://spee.ch/{{fileInfo.claimId}}/{{fileInfo.name}}.{{fileInfo.fileExt}})'/>
|
||||||
<button class="copy-button" data-elementtocopy="markdown-text" onclick="copyToClipboard(event)">copy</button>
|
<button class="copy-button" data-elementtocopy="markdown-text" onclick="copyToClipboard(event)">copy</button>
|
||||||
</div>
|
</div>
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue