redirect on publish is working

This commit is contained in:
bill bittner 2017-07-05 23:22:47 -07:00
parent 90da7a3637
commit 3186e667a2
7 changed files with 59 additions and 34 deletions

View file

@ -14,7 +14,7 @@
.main { .main {
float: left; float: left;
width: 75%; width: 65%;
margin-right: 1%; margin-right: 1%;
padding-right: 1%; padding-right: 1%;
border-right: 1px lightgrey solid; border-right: 1px lightgrey solid;
@ -23,7 +23,7 @@
.sidebar { .sidebar {
float: left; float: left;
width: 22%; width: 32%;
} }
footer { footer {
@ -105,6 +105,10 @@ table {
float: right; float: right;
} }
.wrap-words {
word-wrap: break-word;
}
@media (max-width: 1250px) { @media (max-width: 1250px) {
.wrapper { .wrapper {

View file

@ -16,7 +16,16 @@
.show-image, .show-video { .show-image, .show-video {
width: 100%; width: 100%;
padding-top: 1em; }
.table-metadata {
font-size: small;
}
.left-column {
width: 30%;
font-weight: bold;
vertical-align: top;
} }
/* learn more */ /* learn more */
@ -37,16 +46,17 @@
.example-image, .example-code { .example-image, .example-code {
float: left; float: left;
margin: 5px 15px 5px 0px; margin: 2%;
} }
.example-image { .example-image {
width: 20%; width: 21%;
} }
.example-code { .example-code {
padding: 2em; float: right;
width: 60%; padding: 4%;
width: 62%;
background-color: lightgrey; background-color: lightgrey;
font-family: monospace; font-family: monospace;
color: #666; color: #666;

View file

@ -168,26 +168,9 @@ socket.on('publish-complete', function(msg){
var publishResults; var publishResults;
var directUrl = '/' + msg.name + '/' + msg.result.claim_id; var directUrl = '/' + msg.name + '/' + msg.result.claim_id;
// build new publish area // build new publish area
publishResults = '<p>Your publish is complete! View it here:</p>'; publishResults = '<p>Your publish is complete! You are being redicted to it</p>';
publishResults += '<p><a target="_blank" href="' + directUrl + '">spee.ch' + directUrl + '</a></p>'; publishResults += '<p><a target="_blank" href="' + directUrl + '">if you do not get redirected, click here</a></p>';
publishResults += '<p><button class="copy-button">Copy to clipboard</button></p>';
publishResults += '<p><a target="_blank" href="https://explorer.lbry.io/#!/transaction/' + msg.result.txid + '">View the transaction details</a></p>';
publishResults += '<a href="/"><button>Reload</button></a></p>';
// update publish area // update publish area
document.getElementById('publish-active-area').innerHTML = publishResults; document.getElementById('publish-active-area').innerHTML = publishResults;
// update the link holder window.location.href = directUrl;
document.getElementById('direct-link-holder').innerText = 'https://spee.ch' + directUrl;
// enable copy-to-clipboard
var copyBtn = document.querySelector('.copy-button');
copyBtn.addEventListener('click', function(event) {
// select the text
var text = document.getElementById('direct-link-holder');
text.select();
try {
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
} catch (err) {
alert('Oops, unable to copy');
}
});
}); });

View file

@ -31,10 +31,10 @@ function serveFile ({ fileName, fileType, filePath }, res) {
res.status(200).sendFile(filePath, options); res.status(200).sendFile(filePath, options);
} }
function servePage ({ fileName, filePath }, res) { function servePage (fileInfo, res) {
logger.debug(`serving show page for ${fileName}`); logger.debug(`serving show page for ${fileInfo.fileName}`);
// set default options // set default options
res.status(200).render('show', { filePath }); res.status(200).render('show', { fileInfo });
} }
function sendAnalyticsAndLog (headers, ip, originalUrl) { function sendAnalyticsAndLog (headers, ip, originalUrl) {
@ -61,6 +61,7 @@ module.exports = (app) => {
const mimetypes = headers['accept'].split(','); const mimetypes = headers['accept'].split(',');
if (mimetypes.includes('text/html')) { if (mimetypes.includes('text/html')) {
postToStats('show', originalUrl, ip, 'success'); postToStats('show', originalUrl, ip, 'success');
logger.debug('fileInfo', fileInfo);
servePage(fileInfo, res); servePage(fileInfo, res);
} else { } else {
postToStats('serve', originalUrl, ip, 'success'); postToStats('serve', originalUrl, ip, 'success');

View file

@ -1,6 +1,7 @@
<div class="panel"> <div class="panel">
<div id="asset-placeholder" data-filepath="{{{filePath}}}"> <h2>{{fileInfo.name}}</h2>
<p> video loading... </p> <div id="asset-placeholder" data-filepath="{{{fileInfo.filePath}}}">
<p> loading... </p>
</div> </div>
</div> </div>

View file

@ -1,4 +1,13 @@
<div class="panel"> <div class="panel">
<h2>links</h2> <h2>links</h2>
<p>links go here</p> <table class="table-metadata" style="table-layout: fixed">
<tr>
<td class="left-column">Direct Link:</td>
<td><a href="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}">https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}</a></td>
</tr>
<tr>
<td class="left-column">Embed:</td>
<td><code>&lt;img src="https://spee.ch/{{fileInfo.name}}/{{fileInfo.claimId}}" /></code></td>
</tr>
</table>
</div> </div>

View file

@ -1,4 +1,21 @@
<div class="panel"> <div class="panel">
<h2>metadata</h2> <h2>metadata</h2>
<p>metadata goes here</p> <table class="table-metadata" style="table-layout: fixed">
<tr>
<td class="left-column">Name</td>
<td>{{fileInfo.name}}</td>
</tr>
<tr>
<td class="left-column">Claim Id</td>
<td>{{fileInfo.claimId}}</td>
</tr>
<tr>
<td class="left-column">File Name</td>
<td>{{fileInfo.fileName}}</td>
</tr>
<tr>
<td class="left-column">fileType</td>
<td>{{fileInfo.fileType}}</td>
</tr>
</table>
</div> </div>