added file extensions to the share links

This commit is contained in:
bill bittner 2017-07-25 00:49:40 -07:00
parent b0f43189a3
commit 89ae795b22
3 changed files with 11 additions and 8 deletions

View file

@ -28,6 +28,7 @@ module.exports = {
// 3. if a matching record is found locally, serve it
if (result) {
// return the data for the file to be served
result.dataValues['fileExt'] = result.fileName.substring(result.fileName.lastIndexOf('.'));
serveHelpers.getShortUrlByClaimId(name, claimId)
.then(shortUrl => {
result.dataValues['shortUrl'] = shortUrl;
@ -64,6 +65,7 @@ module.exports = {
if (result) {
logger.debug('local result found');
// return the data for the file to be served
result.dataValues['fileExt'] = result.fileName.substring(result.fileName.lastIndexOf('.'));
serveHelpers.getShortUrlByClaimId(name, claimId)
.then(shortUrl => {
result.dataValues['shortUrl'] = shortUrl;
@ -123,6 +125,7 @@ module.exports = {
// 3. if a match is found locally, serve that claim
if (result) {
// return the data for the file to be served
result.dataValues['fileExt'] = result.fileName.substring(result.fileName.lastIndexOf('.'));
result.dataValues['shortUrl'] = shortUrl;
resolve(result.dataValues);
// update the file, as needed

View file

@ -141,7 +141,7 @@ module.exports = (app) => {
} else if (dotIndex === -1) {
// google analytics
sendGoogleAnalytics('show', headers, ip, originalUrl);
// get and render the content
// begin image-show process
showClaimByName(params.name)
.then(fileInfo => {
// check to make sure a file was found

View file

@ -6,20 +6,20 @@
<h2 class="subheader">Links</h2>
{{!--short direct link to asset--}}
<div class="share-option">
<a href="/{{fileInfo.name}}/{{fileInfo.shortUrl}}">Permanent Short Link</a>
<a href="/{{fileInfo.name}}/{{fileInfo.shortUrl}}{{fileInfo.fileExt}}">Permanent Short Link</a>
(most convenient)
<div class="input-error" id="input-error-copy-short-link" hidden="true"></div>
<br/>
<input type="text" id="short-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{fileInfo.shortUrl}}" onclick="select()"/>
<input type="text" id="short-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{fileInfo.shortUrl}}{{fileInfo.fileExt}}" onclick="select()"/>
<button class="copy-button" data-elementtocopy="short-link" onclick="copyToClipboard(event)">copy</button>
</div>
{{!-- link to show route for asset--}}
<div class="share-option">
<a href="/{{fileInfo.name}}/{{fileInfo.claimId}}">Permanent Long Link</a>
<a href="/{{fileInfo.name}}/{{fileInfo.claimId}}{{fileInfo.fileExt}}">Permanent Long Link</a>
(fastest service)
<div class="input-error" id="input-error-copy-long-link" hidden="true"></div>
</br>
<input type="text" id="long-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}"/>
<input type="text" id="long-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}{{fileInfo.fileExt}}"/>
<button class="copy-button" data-elementtocopy="long-link" onclick="copyToClipboard(event)">copy</button>
</div>
{{!-- html text for embedding asset--}}
@ -28,9 +28,9 @@
<div class="input-error" id="input-error-copy-embed-text" hidden="true"></div>
<br/>
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='&lt;video width="100%" controls>&lt;source src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}" />&lt;/video>'/>
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='&lt;video width="100%" controls>&lt;source src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}{{fileInfo.fileExt}}" />&lt;/video>'/>
{{else}}
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='&lt;img src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}" />'/>
<input type="text" id="embed-text" class="link" readonly onclick="select()" spellcheck="false" value='&lt;img src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}{{fileInfo.fileExt}}" />'/>
{{/ifConditional}}
<button class="copy-button" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
</div>
@ -41,7 +41,7 @@
Markdown
<div class="input-error" id="input-error-copy-markdown-text" hidden="true"></div>
<br/>
<input type="text" id="markdown-text" class="link" readonly onclick="select()" spellcheck="false" value='![{{fileInfo.name}}](https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}})'/>
<input type="text" id="markdown-text" class="link" readonly onclick="select()" spellcheck="false" value='![{{fileInfo.name}}](https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}{{fileInfo.fileExt}})'/>
<button class="copy-button" data-elementtocopy="markdown-text" onclick="copyToClipboard(event)">copy</button>
</div>
{{/ifConditional}}