updated show route with short url

This commit is contained in:
bill bittner 2017-07-17 13:54:50 -07:00
parent af8242a3c6
commit 13471edda4
4 changed files with 40 additions and 42 deletions

View file

@ -208,7 +208,7 @@ module.exports = {
updateFileIfNeeded(uri, name, claimId, result.dataValues.outpoint, result.dataValues.outpoint);
// 3. if a match was not found use the daemon to retrieve the claim & return the db data once it is created
} else {
logger.debug('No result found in File table,');
logger.debug('No result found in File table');
lbryApi
.resolveUri(uri)
.then(result => {

View file

@ -5,13 +5,13 @@ const siofu = require('socketio-file-upload');
const expressHandlebars = require('express-handlebars');
const Handlebars = require('handlebars');
const config = require('config');
const winston = require('winston');
const logger = require('winston');
const hostedContentPath = config.get('Database.DownloadDirectory');
// configure logging
const logLevel = config.get('Logging.LogLevel');
require('./config/loggerSetup.js')(winston, logLevel);
require('./config/loggerSetup.js')(logger, logLevel);
// set port
const PORT = 3000;
@ -29,7 +29,7 @@ app.use(bodyParser.json()); // for parsing application/json
app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(siofu.router);
app.use((req, res, next) => { // logging middleware
winston.verbose(`Request on ${req.originalUrl} from ${req.ip}`);
logger.verbose(`Request on ${req.originalUrl} from ${req.ip}`);
next();
});
@ -74,6 +74,9 @@ const hbs = expressHandlebars.create({
return options.inverse(this);
}
},
firstCharacter (word) {
return word.substring(0, 1);
},
},
});
app.engine('handlebars', hbs.engine);
@ -94,10 +97,10 @@ const server = require('./routes/sockets-routes.js')(app, siofu, hostedContentPa
db.sequelize.sync()
.then(() => {
server.listen(PORT, () => {
winston.info('Trusting proxy?', app.get('trust proxy'));
winston.info(`Server is listening on PORT ${PORT}`);
logger.info('Trusting proxy?', app.get('trust proxy'));
logger.info(`Server is listening on PORT ${PORT}`);
});
})
.catch((error) => {
winston.log('Error syncing sequelize db:', error);
logger.log('Error syncing sequelize db:', error);
});

View file

@ -4,45 +4,45 @@
</div>
<div class="panel links">
<h2 class="subheader">Links</h2>
{{!--direct link to asset--}}
<a href="/{{fileInfo.name}}/{{fileInfo.claimId}}">Direct Link</a>
<div class="input-error" id="input-error-copy-direct-link" hidden="true"></div>
<br/>
<input type="text" id="direct-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}" onclick="select()"/>
<button class="copy-button" data-elementtocopy="direct-link" onclick="copyToClipboard(event)">copy</button>
<br/>
<br/>
{{!--short direct link to asset--}}
<div class="share-option">
<a href="/{{fileInfo.name}}/{{firstCharacter fileInfo.claimId}}">Direct Link</a>
<div class="input-error" id="input-error-copy-direct-link" hidden="true"></div>
<br/>
<input type="text" id="direct-link" class="link" readonly spellcheck="false" value="https://spee.ch/{{fileInfo.name}}/{{firstCharacter fileInfo.claimId}}" onclick="select()"/>
<button class="copy-button" data-elementtocopy="direct-link" onclick="copyToClipboard(event)">copy</button>
</div>
{{!-- link to show route for asset--}}
<div class="share-option">
<a href="/show/{{fileInfo.name}}/{{firstCharacter fileInfo.claimId}}">Details Link</a>
<div class="input-error" id="input-error-copy-show-link" hidden="true"></div>
</br>
<input type="text" id="show-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/show/{{fileInfo.name}}/{{firstCharacter fileInfo.claimId}}"/>
<button class="copy-button" data-elementtocopy="show-link" onclick="copyToClipboard(event)">copy</button>
</div>
{{!-- html text for embedding asset--}}
<div class="share-option">
Embed HTML
<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>'/>
{{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}}" />'/>
{{/ifConditional}}
<button class="copy-button" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
</div>
{{!--markdown text using asset--}}
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}}
{{else}}
<div class="share-option">
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}})'/>
<button class="copy-button" data-elementtocopy="markdown-text" onclick="copyToClipboard(event)">copy</button>
<br/>
<br/>
</div>
{{/ifConditional}}
{{!-- html text for embedding asset--}}
Embed HTML
<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 autoplay controls>&lt;source src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}" />&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}}" />'/>
{{/ifConditional}}
<button class="copy-button" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
<br/>
<br/>
{{!-- link to show route for asset--}}
<a href="/show/{{fileInfo.name}}/{{fileInfo.claimId}}">Details Link</a>
<div class="input-error" id="input-error-copy-show-link" hidden="true"></div>
</br>
<input type="text" id="show-link" class="link" readonly onclick="select()" spellcheck="false" value="https://spee.ch/show/{{fileInfo.name}}/{{fileInfo.claimId}}"/>
<button class="copy-button" data-elementtocopy="show-link" onclick="copyToClipboard(event)">copy</button>
<br/>
<br/>
</div>
<div class="panel">
<h2 class="subheader">Metadata</h2>

View file

@ -10,11 +10,6 @@
</div>
<script type ="text/javascript">
function focusThisInput(event){
}
function copyToClipboard(event){
var elementToCopy = event.target.dataset.elementtocopy;
var element = document.getElementById(elementToCopy);