updated host to be pulled from config file
This commit is contained in:
parent
19a6bf93e0
commit
df53760aea
14 changed files with 70 additions and 55 deletions
|
@ -22,4 +22,14 @@ module.exports = {
|
|||
files: {
|
||||
uploadDirectory: null, // enter file path to where uploads/publishes should be stored
|
||||
},
|
||||
site: {
|
||||
name : 'Spee.ch',
|
||||
host : 'https://spee.ch',
|
||||
description: 'Decentralized video and content hosting.',
|
||||
},
|
||||
publishing: {
|
||||
defaultTitle : 'Spee.h',
|
||||
defaultThumbnail : 'https://spee.ch/assets/img/video_thumb_default.png',
|
||||
defaultDescription: 'Open-source, decentralized image and video sharing.',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
|||
} else {
|
||||
message = error.response;
|
||||
}
|
||||
// check for spee.ch thrown errors
|
||||
// check for thrown errors
|
||||
} else if (error.message) {
|
||||
status = 400;
|
||||
message = error.message;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const Handlebars = require('handlebars');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const { site, analytics } = require('../config/speechConfig.js');
|
||||
|
||||
module.exports = {
|
||||
placeCommonHeaderTags () {
|
||||
const headerBoilerplate = `<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Spee.ch</title><link rel="stylesheet" href="/assets/css/reset.css" type="text/css"><link rel="stylesheet" href="/assets/css/general.css" type="text/css"><link rel="stylesheet" href="/assets/css/mediaQueries.css" type="text/css">`;
|
||||
const headerBoilerplate = `<meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>${site.title}</title><link rel="stylesheet" href="/assets/css/reset.css" type="text/css"><link rel="stylesheet" href="/assets/css/general.css" type="text/css"><link rel="stylesheet" href="/assets/css/mediaQueries.css" type="text/css">`;
|
||||
return new Handlebars.SafeString(headerBoilerplate);
|
||||
},
|
||||
googleAnalytics () {
|
||||
const googleApiKey = config.analytics.googleId;
|
||||
const googleApiKey = analytics.googleId;
|
||||
const gaCode = `<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
|
@ -19,7 +19,7 @@ module.exports = {
|
|||
addOpenGraph ({ ogTitle, contentType, ogDescription, thumbnail, showUrl, source, ogThumbnailContentType }) {
|
||||
const ogTitleTag = `<meta property="og:title" content="${ogTitle}" />`;
|
||||
const ogUrlTag = `<meta property="og:url" content="${showUrl}" />`;
|
||||
const ogSiteNameTag = `<meta property="og:site_name" content="Spee.ch" />`;
|
||||
const ogSiteNameTag = `<meta property="og:site_name" content="${site.title}" />`;
|
||||
const ogDescriptionTag = `<meta property="og:description" content="${ogDescription}" />`;
|
||||
const ogImageWidthTag = '<meta property="og:image:width" content="600" />';
|
||||
const ogImageHeightTag = '<meta property="og:image:height" content="315" />';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const logger = require('winston');
|
||||
const fs = require('fs');
|
||||
const db = require('../models');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const { site, wallet } = require('../config/speechConfig.js');
|
||||
|
||||
module.exports = {
|
||||
validateApiPublishRequest (body, files) {
|
||||
|
@ -72,7 +72,7 @@ module.exports = {
|
|||
},
|
||||
validateLicense (license) {
|
||||
if ((license.indexOf('Public Domain') === -1) && (license.indexOf('Creative Commons') === -1)) {
|
||||
throw new Error('Only posts with a "Public Domain" or "Creative Commons" license are eligible for publishing through spee.ch');
|
||||
throw new Error('Only posts with a "Public Domain" or "Creative Commons" license are eligible for publishing.');
|
||||
}
|
||||
},
|
||||
cleanseChannelName (channelName) {
|
||||
|
@ -105,12 +105,12 @@ module.exports = {
|
|||
metadata : {
|
||||
description,
|
||||
title,
|
||||
author : 'spee.ch',
|
||||
author : site.title,
|
||||
language: 'en',
|
||||
license,
|
||||
nsfw,
|
||||
},
|
||||
claim_address: config.wallet.lbryClaimAddress,
|
||||
claim_address: wallet.lbryClaimAddress,
|
||||
};
|
||||
// add thumbnail to channel if video
|
||||
if (thumbnail !== null) {
|
||||
|
@ -137,12 +137,12 @@ module.exports = {
|
|||
db.File.findAll({ where: { name } })
|
||||
.then(result => {
|
||||
if (result.length >= 1) {
|
||||
const claimAddress = config.wallet.lbryClaimAddress;
|
||||
// filter out any results that were not published from spee.ch's wallet address
|
||||
const claimAddress = wallet.lbryClaimAddress;
|
||||
// filter out any results that were not published from the site's wallet address
|
||||
const filteredResult = result.filter((claim) => {
|
||||
return (claim.address === claimAddress);
|
||||
});
|
||||
// return based on whether any non-spee.ch claims were left
|
||||
// return based on whether any claims were left
|
||||
if (filteredResult.length >= 1) {
|
||||
resolve(false);
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@ const logger = require('winston');
|
|||
|
||||
module.exports = {
|
||||
serveFile ({ filePath, fileType }, claimId, name, res) {
|
||||
logger.verbose(`serving ${name}#${claimId}`);
|
||||
logger.verbose(`serving file: ${filePath}`);
|
||||
// set response options
|
||||
const headerContentType = fileType || 'image/jpeg';
|
||||
const options = {
|
||||
|
@ -15,9 +15,11 @@ module.exports = {
|
|||
res.status(200).sendFile(filePath, options);
|
||||
},
|
||||
showFile (claimInfo, shortId, res) {
|
||||
logger.verbose(`showing claim: ${claimInfo.name}#${claimInfo.claimId}`);
|
||||
res.status(200).render('show', { layout: 'show', claimInfo, shortId });
|
||||
},
|
||||
showFileLite (claimInfo, shortId, res) {
|
||||
logger.verbose(`showlite claim: ${claimInfo.name}#${claimInfo.claimId}`);
|
||||
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId });
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const logger = require('winston');
|
||||
const { returnShortId } = require('../helpers/sequelizeHelpers.js');
|
||||
const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/video_thumb_default.png';
|
||||
const DEFAULT_TITLE = 'Spee<ch';
|
||||
const DEFAULT_DESCRIPTION = 'Decentralized video and content hosting.';
|
||||
const { publishing, site } = require('../config/speechConfig.js');
|
||||
const { defaultTitle, defaultThumbnail, defaultDescription } = publishing;
|
||||
const { host } = site;
|
||||
|
||||
function determineFileExtensionFromContentType (contentType) {
|
||||
switch (contentType) {
|
||||
|
@ -67,19 +67,20 @@ function determineOgThumbnailContentType (thumbnail) {
|
|||
}
|
||||
|
||||
function addOpengraphDataToClaim (claim) {
|
||||
claim['embedUrl'] = `https://spee.ch/embed/${claim.claimId}/${claim.name}`;
|
||||
claim['showUrl'] = `https://spee.ch/${claim.claimId}/${claim.name}`;
|
||||
claim['source'] = `https://spee.ch/${claim.claimId}/${claim.name}.${claim.fileExt}`;
|
||||
claim['directFileUrl'] = `https://spee.ch/${claim.claimId}/${claim.name}.${claim.fileExt}`;
|
||||
claim['ogTitle'] = determineOgTitle(claim.title, DEFAULT_TITLE);
|
||||
claim['ogDescription'] = determineOgDescription(claim.description, DEFAULT_DESCRIPTION);
|
||||
claim['host'] = host;
|
||||
claim['embedUrl'] = `${host}/${claim.claimId}/${claim.name}`;
|
||||
claim['showUrl'] = `${host}/${claim.claimId}/${claim.name}`;
|
||||
claim['source'] = `${host}/${claim.claimId}/${claim.name}.${claim.fileExt}`;
|
||||
claim['directFileUrl'] = `${host}/${claim.claimId}/${claim.name}.${claim.fileExt}`;
|
||||
claim['ogTitle'] = determineOgTitle(claim.title, defaultTitle);
|
||||
claim['ogDescription'] = determineOgDescription(claim.description, defaultDescription);
|
||||
claim['ogThumbnailContentType'] = determineOgThumbnailContentType(claim.thumbnail);
|
||||
return claim;
|
||||
};
|
||||
|
||||
function prepareClaimData (claim) {
|
||||
// logger.debug('preparing claim data based on resolved data:', claim);
|
||||
claim['thumbnail'] = determineThumbnail(claim.thumbnail, DEFAULT_THUMBNAIL);
|
||||
claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);
|
||||
claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);
|
||||
claim = addOpengraphDataToClaim(claim);
|
||||
return claim;
|
||||
|
@ -280,7 +281,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
|
|||
default:
|
||||
channelClaimsArray.forEach(claim => {
|
||||
claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);
|
||||
claim['thumbnail'] = determineThumbnail(claim.thumbnail, DEFAULT_THUMBNAIL);
|
||||
claim['thumbnail'] = determineThumbnail(claim.thumbnail, defaultThumbnail);
|
||||
return claim;
|
||||
});
|
||||
return resolve(channelClaimsArray);
|
||||
|
|
|
@ -78,7 +78,7 @@ const Asset = function () {
|
|||
this.isFileAvailable()
|
||||
.then(isAvailable => {
|
||||
if (!isAvailable) {
|
||||
console.log('file is not yet available on spee.ch');
|
||||
console.log('file is not yet available');
|
||||
that.showSearchMessage();
|
||||
return that.getAssetOnSpeech();
|
||||
}
|
||||
|
@ -136,4 +136,4 @@ const Asset = function () {
|
|||
xhr.send();
|
||||
})
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ function publishNewChannel (event) {
|
|||
validationFunctions.showError(channelNameErrorDisplayElement, error.message);
|
||||
} else {
|
||||
console.log('signup failure:', error);
|
||||
showChannelCreationError('Unfortunately, Spee.ch encountered an error while creating your channel. Please let us know in slack!');
|
||||
showChannelCreationError('Unfortunately, we encountered an error while creating your channel. Please let us know in slack!');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const logger = require('winston');
|
||||
const multipart = require('connect-multiparty');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const multipartMiddleware = multipart({uploadDir: config.files.uploadDirectory});
|
||||
const { files, site } = require('../config/speechConfig.js');
|
||||
const multipartMiddleware = multipart({uploadDir: files.uploadDirectory});
|
||||
const db = require('../models');
|
||||
const { publish } = require('../controllers/publishController.js');
|
||||
const { getClaimList, resolveUri, getClaim } = require('../helpers/lbryApi.js');
|
||||
|
@ -83,14 +83,14 @@ module.exports = (app) => {
|
|||
});
|
||||
});
|
||||
|
||||
// route to check whether spee.ch has published to a claim
|
||||
// route to check whether this site published to a claim
|
||||
app.get('/api/claim-is-available/:name', ({ params }, res) => {
|
||||
checkClaimNameAvailability(params.name)
|
||||
.then(result => {
|
||||
if (result === true) {
|
||||
res.status(200).json(true);
|
||||
} else {
|
||||
// logger.debug(`Rejecting '${params.name}' because that name has already been claimed on spee.ch`);
|
||||
// logger.debug(`Rejecting '${params.name}' because that name has already been claimed by this site`);
|
||||
res.status(200).json(false);
|
||||
}
|
||||
})
|
||||
|
@ -98,14 +98,14 @@ module.exports = (app) => {
|
|||
res.status(500).json(error);
|
||||
});
|
||||
});
|
||||
// route to check whether spee.ch has published to a channel
|
||||
// route to check whether site has published to a channel
|
||||
app.get('/api/channel-is-available/:name', ({ params }, res) => {
|
||||
checkChannelAvailability(params.name)
|
||||
.then(result => {
|
||||
if (result === true) {
|
||||
res.status(200).json(true);
|
||||
} else {
|
||||
// logger.debug(`Rejecting '${params.name}' because that channel has already been claimed on spee.ch`);
|
||||
// logger.debug(`Rejecting '${params.name}' because that channel has already been claimed`);
|
||||
res.status(200).json(false);
|
||||
}
|
||||
})
|
||||
|
@ -161,13 +161,13 @@ module.exports = (app) => {
|
|||
}
|
||||
channelPassword = body.channelPassword || null;
|
||||
skipAuth = false;
|
||||
// case 1: publish from spee.ch, client logged in
|
||||
// case 1: publish from client, client logged in
|
||||
if (user) {
|
||||
skipAuth = true;
|
||||
if (anonymous) {
|
||||
channelName = null;
|
||||
}
|
||||
// case 2: publish from api or spee.ch, client not logged in
|
||||
// case 2: publish from api or client, client not logged in
|
||||
} else {
|
||||
if (anonymous) {
|
||||
skipAuth = true;
|
||||
|
@ -187,7 +187,7 @@ module.exports = (app) => {
|
|||
})
|
||||
.then(result => {
|
||||
if (!result) {
|
||||
throw new Error('That name is already in use by spee.ch.');
|
||||
throw new Error('That name is already claimed by another user.');
|
||||
}
|
||||
// create publish parameters object
|
||||
return createPublishParams(filePath, name, title, description, license, nsfw, thumbnail, channelName);
|
||||
|
@ -202,7 +202,7 @@ module.exports = (app) => {
|
|||
success: true,
|
||||
message: {
|
||||
name,
|
||||
url : `spee.ch/${result.claim_id}/${name}`,
|
||||
url : `${site.host}/${result.claim_id}/${name}`,
|
||||
lbryTx: result,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const errorHandlers = require('../helpers/errorHandlers.js');
|
||||
const { getTrendingClaims, getRecentClaims } = require('../controllers/statsController.js');
|
||||
const { site } = require('../config/speechConfig.js');
|
||||
|
||||
module.exports = (app) => {
|
||||
// route to log out
|
||||
|
@ -15,7 +16,7 @@ module.exports = (app) => {
|
|||
res.status(200).render('login');
|
||||
}
|
||||
});
|
||||
// route to show 'about' page for spee.ch
|
||||
// route to show 'about' page
|
||||
app.get('/about', (req, res) => {
|
||||
// get and render the content
|
||||
res.status(200).render('about');
|
||||
|
@ -52,8 +53,9 @@ module.exports = (app) => {
|
|||
app.get('/embed/:claimId/:name', ({ params }, res) => {
|
||||
const claimId = params.claimId;
|
||||
const name = params.name;
|
||||
const host = site.host;
|
||||
// get and render the content
|
||||
res.status(200).render('embed', { layout: 'embed', claimId, name });
|
||||
res.status(200).render('embed', { layout: 'embed', host, claimId, name });
|
||||
});
|
||||
// route to display all free public claims at a given name
|
||||
app.get('/:name/all', (req, res) => {
|
||||
|
|
|
@ -129,7 +129,7 @@ function showOrServeAsset (responseType, claimId, claimName, res) {
|
|||
}
|
||||
|
||||
function flipClaimNameAndIdForBackwardsCompatibility (identifier, name) {
|
||||
// this is a patch for backwards compatability with 'spee.ch/name/claim_id' url format
|
||||
// this is a patch for backwards compatability with '/name/claim_id' url format
|
||||
if (isValidShortIdOrClaimId(name) && !isValidShortIdOrClaimId(identifier)) {
|
||||
const tempName = name;
|
||||
name = identifier;
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
</head>
|
||||
<body>
|
||||
<img src="https://dev1.spee.ch/zackmath"/>
|
||||
<!--<img src="https://staging.spee.ch/8/zackmath"/>-->
|
||||
<!--<img src="https://staging.spee.ch/zackmath.ext"/>-->
|
||||
<!--<img src="https://staging.spee.ch/8/zackmath.ext"/>-->
|
||||
<!--<img src="https://dev1.spee.ch/8/zackmath"/>-->
|
||||
<!--<img src="https://dev1.spee.ch/zackmath.ext"/>-->
|
||||
<!--<img src="https://dev1.spee.ch/8/zackmath.ext"/>-->
|
||||
<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://dev1.spee.ch/LBRY-Hype"></video>
|
||||
<!--<video width="50%" controls poster="https://spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype"></video>-->
|
||||
<!--<video width="50%" controls poster="https://spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/LBRY-Hype.test"></video>-->
|
||||
<!--<video width="50%" controls poster="https://spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype.test"></video>-->
|
||||
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype"></video>-->
|
||||
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/LBRY-Hype.test"></video>-->
|
||||
<!--<video width="50%" controls poster="https://dev1.spee.ch/assets/img/video_thumb_default.png" src="https://staging.spee.ch/a/LBRY-Hype.test"></video>-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<video width="100%" controls src="https://spee.ch/{{claimId}}/{{name}}.mp4" type="video/mp4"></video>
|
||||
<video width="100%" controls src="{{host}}/{{claimId}}/{{name}}.mp4" type="video/mp4"></video>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<div class="row row--short row--wide">
|
||||
<div class="column column--7">
|
||||
<div class="input-error" id="input-error-copy-short-link" hidden="true"></div>
|
||||
<input type="text" id="short-link" class="input-disabled input-text--full-width" readonly spellcheck="false" value="https://spee.ch/{{shortId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}" onclick="select()"/>
|
||||
<input type="text" id="short-link" class="input-disabled input-text--full-width" readonly spellcheck="false" value="{{claimInfo.host}}/{{shortId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}" onclick="select()"/>
|
||||
</div><div class="column column--1"></div><div class="column column--2">
|
||||
<button class="button--primary" data-elementtocopy="short-link" onclick="copyToClipboard(event)">copy</button>
|
||||
</div>
|
||||
|
@ -37,9 +37,9 @@
|
|||
<div class="column column--7">
|
||||
<div class="input-error" id="input-error-copy-embed-text" hidden="true"></div>
|
||||
{{#ifConditional claimInfo.contentType '===' 'video/mp4'}}
|
||||
<input type="text" id="embed-text" class="input-disabled input-text--full-width" readonly onclick="select()" spellcheck="false" value='<video width="100%" controls poster="{{claimInfo.thumbnail}}" src="https://spee.ch/{{claimInfo.claimId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}"/></video>'/>
|
||||
<input type="text" id="embed-text" class="input-disabled input-text--full-width" readonly onclick="select()" spellcheck="false" value='<video width="100%" controls poster="{{claimInfo.thumbnail}}" src="{{claimInfo.host}}/{{claimInfo.claimId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}"/></video>'/>
|
||||
{{else}}
|
||||
<input type="text" id="embed-text" class="input-disabled input-text--full-width" readonly onclick="select()" spellcheck="false" value='<img src="https://spee.ch/{{claimInfo.claimId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}"/>'/>
|
||||
<input type="text" id="embed-text" class="input-disabled input-text--full-width" readonly onclick="select()" spellcheck="false" value='<img src="{{claimInfo.host}}/{{claimInfo.claimId}}/{{claimInfo.name}}.{{claimInfo.fileExt}}"/>'/>
|
||||
{{/ifConditional}}
|
||||
</div><div class="column column--1"></div><div class="column column--2">
|
||||
<button class="button--primary" data-elementtocopy="embed-text" onclick="copyToClipboard(event)">copy</button>
|
||||
|
@ -55,10 +55,10 @@
|
|||
<span class="text">Share:</span>
|
||||
</div><div class="column column--7 column--med-10">
|
||||
<div class="row row--short row--wide flex-container--row flex-container--space-between-bottom flex-container--wrap">
|
||||
<a class="link--primary" target="_blank" href="https://twitter.com/intent/tweet?text=https://spee.ch/{{shortId}}/{{claimInfo.name}}">twitter</a>
|
||||
<a class="link--primary" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://spee.ch/{{shortId}}/{{claimInfo.name}}">facebook</a>
|
||||
<a class="link--primary" target="_blank" href="http://tumblr.com/widgets/share/tool?canonicalUrl=https://spee.ch/{{shortId}}/{{claimInfo.name}}">tumblr</a>
|
||||
<a class="link--primary" target="_blank" href="https://www.reddit.com/submit?url=https://spee.ch/{{shortId}}/{{claimInfo.name}}&title={{claimInfo.name}}">reddit</a>
|
||||
<a class="link--primary" target="_blank" href="https://twitter.com/intent/tweet?text={{claimInfo.host}}/{{shortId}}/{{claimInfo.name}}">twitter</a>
|
||||
<a class="link--primary" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u={{claimInfo.host}}/{{shortId}}/{{claimInfo.name}}">facebook</a>
|
||||
<a class="link--primary" target="_blank" href="http://tumblr.com/widgets/share/tool?canonicalUrl={{claimInfo.host}}/{{shortId}}/{{claimInfo.name}}">tumblr</a>
|
||||
<a class="link--primary" target="_blank" href="https://www.reddit.com/submit?url={{claimInfo.host}}/{{shortId}}/{{claimInfo.name}}&title={{claimInfo.name}}">reddit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue