Upload refactor #242
31
README.md
|
@ -14,13 +14,10 @@ spee.ch is a single-serving site that reads and publishes images and videos to a
|
|||
* start spee.ch
|
||||
* clone this repo
|
||||
* run `npm install`
|
||||
* to start the server, from your command line run `node speech.js` while passing three environmental variables:
|
||||
* (1) your lbry wallet address (`LBRY_CLAIM_ADDRESS`),
|
||||
* (2) your mysql username (`MYSQL_USERNAME`),
|
||||
* (2) your mysql password (`MYSQL_PASSWORD`),
|
||||
* (3) the environment to run (`NODE_ENV`).
|
||||
* i.e. `LBRY_CLAIM_ADDRESS=<your wallet address here> MYSQL_USERNAME=<username here> MYSQL_PASSWORD=<password here> NODE_ENV=development node speech.js`
|
||||
* e.g. `LBRY_CLAIM_ADDRESS=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX MYSQL_USERNAME="lbry" MYSQL_PASSWORD="xxxxxx" NODE_ENV=development node speech.js`
|
||||
* create your `speechConfig.js` file
|
||||
* copy `speechConfig.js.example` and name it `speechConfig.js`
|
||||
* replace the `null` values in the config file with the appropriate values for your environement
|
||||
* to start the server, from your command line run `node speech.js`
|
||||
* To run hot, use `nodemon` instead of `node`
|
||||
* visit [localhost:3000](http://localhost:3000)
|
||||
|
||||
|
@ -36,17 +33,17 @@ spee.ch is a single-serving site that reads and publishes images and videos to a
|
|||
|
||||
#### POST
|
||||
* /api/publish
|
||||
* example: `curl -X POST -F 'name=MyPictureName' -F 'nsfw=false' -F 'file=@/path/to/my/picture.jpeg' https://spee.ch/api/publish`
|
||||
* example: `curl -X POST -F 'name=MyPictureName' -F 'file=@/path/to/myPicture.jpeg' https://spee.ch/api/publish`
|
||||
* Parameters:
|
||||
* name (string)
|
||||
* nsfw (boolean)
|
||||
* file (.mp4, .jpeg, .jpg, .gif, or .png)
|
||||
* license (string, optional)
|
||||
* title (string, optional)
|
||||
* description (string, optional)
|
||||
* thumbnail (string, optional) (for .mp4 uploads only)
|
||||
* channelName(string, optional)
|
||||
* channelPassword (string, optional)
|
||||
* `name`
|
||||
* `file` (.mp4, .jpeg, .jpg, .gif, or .png)
|
||||
* `nsfw` (optional)
|
||||
* `license` (optional)
|
||||
* `title` (optional)
|
||||
* `description` (optional)
|
||||
* `thumbnail` url to thumbnail image, for .mp4 uploads only (optional)
|
||||
* `channelName`(optional)
|
||||
* `channelPassword` (optional,; required if `channelName` is provided)
|
||||
|
||||
## bugs
|
||||
If you find a bug or experience a problem, please report your issue here on github and find us in the lbry slack!
|
||||
|
|
|
@ -4,10 +4,6 @@ const logger = require('winston');
|
|||
module.exports = {
|
||||
authenticateChannelCredentials (channelName, userPassword) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!channelName) {
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
const userName = channelName.substring(1);
|
||||
logger.debug(`authenticateChannelCredentials > channelName: ${channelName} username: ${userName} pass: ${userPassword}`);
|
||||
db.User
|
||||
|
@ -18,18 +14,32 @@ module.exports = {
|
|||
resolve(false);
|
||||
return;
|
||||
}
|
||||
if (!user.validPassword(userPassword, user.password)) {
|
||||
return user.comparePassword(userPassword, (passwordErr, isMatch) => {
|
||||
if (passwordErr) {
|
||||
logger.error('comparePassword error:', passwordErr);
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
if (!isMatch) {
|
||||
logger.debug('incorrect password');
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
logger.debug('user found:', user.dataValues);
|
||||
logger.debug('...password was a match...');
|
||||
resolve(true);
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error(error);
|
||||
reject();
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
},
|
||||
authenticateOrSkip (skipAuth, channelName, channelPassword) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (skipAuth) {
|
||||
return resolve(true);
|
||||
}
|
||||
return resolve(module.exports.authenticateChannelCredentials(channelName, channelPassword));
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"LbryClaimAddress": "LBRY_CLAIM_ADDRESS"
|
||||
},
|
||||
"Database": {
|
||||
"Username": "MYSQL_USERNAME",
|
||||
"Password": "MYSQL_PASSWORD"
|
||||
},
|
||||
"Logging": {
|
||||
"SlackWebHook": "SLACK_WEB_HOOK"
|
||||
},
|
||||
"Session": {
|
||||
"SessionKey": "SESSION_KEY"
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
{}
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"LbryClaimAddress": null,
|
||||
"DefaultChannel": null
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"GoogleId": null
|
||||
},
|
||||
"Database": {
|
||||
"Database": "lbry",
|
||||
"Username": null,
|
||||
"Password": null
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": null,
|
||||
"SlackWebHook": null,
|
||||
"SlackErrorChannel": null,
|
||||
"SlackInfoChannel": null
|
||||
},
|
||||
"Session": {
|
||||
"SessionKey": null
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"DefaultChannel": "@speechDev"
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"GoogleId": "UA-100747990-1"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": "silly",
|
||||
"SlackErrorChannel": "#staging_speech-errors",
|
||||
"SlackInfoChannel": "none"
|
||||
}
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"WalletConfig": {
|
||||
"DefaultChannel": "@speech"
|
||||
},
|
||||
"AnalyticsConfig":{
|
||||
"GoogleId": "UA-60403362-3"
|
||||
},
|
||||
"Logging": {
|
||||
"LogLevel": "verbose",
|
||||
"SlackErrorChannel": "#speech-errors",
|
||||
"SlackInfoChannel": "#speech-logs"
|
||||
}
|
||||
}
|
30
config/slackConfig.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
const config = require('./speechConfig.js');
|
||||
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
||||
|
||||
module.exports = (winston) => {
|
||||
if (config.logging.slackWebHook) {
|
||||
// add a transport for errors to slack
|
||||
winston.add(winstonSlackWebHook, {
|
||||
name : 'slack-errors-transport',
|
||||
level : 'warn',
|
||||
webhookUrl: config.logging.slackWebHook,
|
||||
channel : config.logging.slackErrorChannel,
|
||||
username : 'spee.ch',
|
||||
iconEmoji : ':face_with_head_bandage:',
|
||||
});
|
||||
winston.add(winstonSlackWebHook, {
|
||||
name : 'slack-info-transport',
|
||||
level : 'info',
|
||||
webhookUrl: config.logging.slackWebHook,
|
||||
channel : config.logging.slackInfoChannel,
|
||||
username : 'spee.ch',
|
||||
iconEmoji : ':nerd_face:',
|
||||
});
|
||||
// send test message
|
||||
winston.error('Slack "error" logging is online.');
|
||||
winston.warn('Slack "warning" logging is online.');
|
||||
winston.info('Slack "info" logging is online.');
|
||||
} else {
|
||||
winston.warn('Slack logging is not enabled because no SLACK_WEB_HOOK env var provided.');
|
||||
}
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
const config = require('config');
|
||||
const SLACK_WEB_HOOK = config.get('Logging.SlackWebHook');
|
||||
const SLACK_ERROR_CHANNEL = config.get('Logging.SlackErrorChannel');
|
||||
const SLACK_INFO_CHANNEL = config.get('Logging.SlackInfoChannel');
|
||||
const winstonSlackWebHook = require('winston-slack-webhook').SlackWebHook;
|
||||
|
||||
module.exports = (winston) => {
|
||||
if (SLACK_WEB_HOOK) {
|
||||
// add a transport for errors to slack
|
||||
winston.add(winstonSlackWebHook, {
|
||||
name : 'slack-errors-transport',
|
||||
level : 'error',
|
||||
webhookUrl: SLACK_WEB_HOOK,
|
||||
channel : SLACK_ERROR_CHANNEL,
|
||||
username : 'spee.ch',
|
||||
iconEmoji : ':face_with_head_bandage:',
|
||||
});
|
||||
winston.add(winstonSlackWebHook, {
|
||||
name : 'slack-info-transport',
|
||||
level : 'info',
|
||||
webhookUrl: SLACK_WEB_HOOK,
|
||||
channel : SLACK_INFO_CHANNEL,
|
||||
username : 'spee.ch',
|
||||
iconEmoji : ':nerd_face:',
|
||||
});
|
||||
// send test message
|
||||
winston.error('Slack error logging is online.');
|
||||
winston.info('Slack info logging is online.');
|
||||
} else {
|
||||
winston.error('Slack logging is not enabled because no SLACK_WEB_HOOK env var provided.');
|
||||
}
|
||||
};
|
22
config/speechConfig.js.example
Normal file
|
@ -0,0 +1,22 @@
|
|||
module.exports = {
|
||||
wallet: {
|
||||
lbryClaimAddress: null, // choose an address from your lbry wallet
|
||||
},
|
||||
analytics: {
|
||||
googleId: null, // google id for analytics tracking; leave `null` if not applicable
|
||||
},
|
||||
sql: {
|
||||
database: null, // name of mysql database
|
||||
username: null, // username for mysql
|
||||
password: null, // password for mysql
|
||||
},
|
||||
logging: {
|
||||
logLevel : null, // options: silly, debug, verbose, info
|
||||
slackWebHook : null, // enter a webhook if you wish to push logs to slack; otherwise leave as `null`
|
||||
slackErrorChannel: null, // enter a slack channel (#example) for errors to be sent to; otherwise leave null
|
||||
slackInfoChannel : null, // enter a slack channel (#info) for info level logs to be sent to otherwise leave null
|
||||
},
|
||||
session: {
|
||||
sessionKey: null, // enter a secret key to be used for session encryption
|
||||
},
|
||||
};
|
|
@ -6,24 +6,33 @@ const publishHelpers = require('../helpers/publishHelpers.js');
|
|||
module.exports = {
|
||||
publish (publishParams, fileName, fileType) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let publishResults = {};
|
||||
// 1. publish the file
|
||||
let publishResults, certificateId, channelName;
|
||||
// publish the file
|
||||
return lbryApi.publishClaim(publishParams)
|
||||
// 2. upsert File record (update is in case the claim has been published before by this daemon)
|
||||
.then(tx => {
|
||||
logger.info(`Successfully published ${fileName}`, tx);
|
||||
publishResults = tx;
|
||||
return db.Channel.findOne({where: {channelName: publishParams.channel_name}}); // note: should this be db.User ??
|
||||
// get the channel information
|
||||
if (publishParams.channel_name) {
|
||||
logger.debug(`this claim was published in channel: ${publishParams.channel_name}`);
|
||||
return db.Channel.findOne({where: {channelName: publishParams.channel_name}});
|
||||
} else {
|
||||
logger.debug('this claim was published in channel: n/a');
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.then(channel => {
|
||||
let certificateId;
|
||||
// set channel information
|
||||
certificateId = null;
|
||||
channelName = null;
|
||||
if (channel) {
|
||||
certificateId = channel.channelClaimId;
|
||||
logger.debug('successfully found channel in Channel table');
|
||||
} else {
|
||||
certificateId = null;
|
||||
logger.debug('channel for publish not found in Channel table');
|
||||
};
|
||||
channelName = channel.channelName;
|
||||
}
|
||||
defined on line 9 to hoist and make available further down promise chain defined on line 9 to hoist and make available further down promise chain
|
||||
logger.debug(`certificateId: ${certificateId}`);
|
||||
})
|
||||
.then(() => {
|
||||
// create the File record
|
||||
const fileRecord = {
|
||||
name : publishParams.name,
|
||||
claimId : publishResults.claim_id,
|
||||
|
@ -37,6 +46,7 @@ module.exports = {
|
|||
fileType,
|
||||
nsfw : publishParams.metadata.nsfw,
|
||||
};
|
||||
// create the Claim record
|
||||
const claimRecord = {
|
||||
name : publishParams.name,
|
||||
claimId : publishResults.claim_id,
|
||||
|
@ -48,14 +58,16 @@ module.exports = {
|
|||
height : 0,
|
||||
contentType: fileType,
|
||||
nsfw : publishParams.metadata.nsfw,
|
||||
certificateId,
|
||||
amount : publishParams.bid,
|
||||
certificateId,
|
||||
channelName,
|
||||
};
|
||||
// upsert criteria
|
||||
const upsertCriteria = {
|
||||
name : publishParams.name,
|
||||
claimId: publishResults.claim_id,
|
||||
};
|
||||
// create the records
|
||||
// upsert the records
|
||||
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);
|
||||
})
|
||||
.then(([file, claim]) => {
|
||||
|
@ -67,7 +79,6 @@ module.exports = {
|
|||
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('publishController.publish, error', error);
|
||||
publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file
|
||||
reject(error);
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const logger = require('winston');
|
||||
const ua = require('universal-analytics');
|
||||
const config = require('config');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const db = require('../models');
|
||||
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
||||
const googleApiKey = config.analytics.googleId;
|
||||
|
||||
module.exports = {
|
||||
postToStats (action, url, ipAddress, name, claimId, result) {
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
const config = require('config');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const logger = require('winston');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = function () {
|
||||
// get the config file
|
||||
const defaultConfigFile = JSON.parse(fs.readFileSync('./config/default.json'));
|
||||
|
||||
for (let configCategoryKey in defaultConfigFile) {
|
||||
if (defaultConfigFile.hasOwnProperty(configCategoryKey)) {
|
||||
for (let configCategoryKey in config) {
|
||||
if (config.hasOwnProperty(configCategoryKey)) {
|
||||
// get the final variables for each config category
|
||||
const configVariables = config.get(configCategoryKey);
|
||||
const configVariables = config[configCategoryKey];
|
||||
for (let configVarKey in configVariables) {
|
||||
if (configVariables.hasOwnProperty(configVarKey)) {
|
||||
// print each variable
|
||||
|
|
|
@ -2,38 +2,54 @@ const logger = require('winston');
|
|||
const { postToStats } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = {
|
||||
handleRequestError (action, originalUrl, ip, error, res) {
|
||||
logger.error(`Request Error: ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
||||
postToStats(action, originalUrl, ip, null, null, error);
|
||||
if (error.response) {
|
||||
res.status(error.response.status).render('requestError', {message: error.response.data.error.message, status: error.response.status});
|
||||
} else if (error.code === 'ECONNREFUSED') {
|
||||
res.status(503).render('requestError', {message: 'Connection refused. The daemon may not be running.', status: 503});
|
||||
} else if (error.message) {
|
||||
res.status(500).render('requestError', {message: error.message, status: 500});
|
||||
} else {
|
||||
res.status(400).render('requestError', {message: error, status: 400});
|
||||
}
|
||||
},
|
||||
handlePublishError (error) {
|
||||
logger.error('Publish Error:', module.exports.useObjectPropertiesIfNoKeys(error));
|
||||
returnErrorMessageAndStatus: function (error) {
|
||||
let status, message;
|
||||
// check for daemon being turned off
|
||||
if (error.code === 'ECONNREFUSED') {
|
||||
return 'Connection refused. The daemon may not be running.';
|
||||
status = 503;
|
||||
message = 'Connection refused. The daemon may not be running.';
|
||||
// check for errors from the deamon
|
||||
} else if (error.response) {
|
||||
status = error.response.status || 500;
|
||||
if (error.response.data) {
|
||||
if (error.response.data.message) {
|
||||
return error.response.data.message;
|
||||
message = error.response.data.message;
|
||||
} else if (error.response.data.error) {
|
||||
return error.response.data.error.message;
|
||||
}
|
||||
return error.response.data;
|
||||
}
|
||||
return error.response;
|
||||
message = error.response.data.error.message;
|
||||
} else {
|
||||
return error;
|
||||
message = error.response.data;
|
||||
}
|
||||
} else {
|
||||
message = error.response;
|
||||
}
|
||||
// check for spee.ch thrown errors
|
||||
} else if (error.message) {
|
||||
status = 400;
|
||||
message = error.message;
|
||||
// fallback for everything else
|
||||
} else {
|
||||
status = 400;
|
||||
message = error;
|
||||
}
|
||||
return [status, message];
|
||||
},
|
||||
useObjectPropertiesIfNoKeys (err) {
|
||||
handleRequestError: function (action, originalUrl, ip, error, res) {
|
||||
logger.error(`Request Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
||||
postToStats(action, originalUrl, ip, null, null, error);
|
||||
const [status, message] = this.returnErrorMessageAndStatus(error);
|
||||
res
|
||||
.status(status)
|
||||
.render('requestError', this.createErrorResponsePayload(status, message));
|
||||
},
|
||||
handleApiError: function (action, originalUrl, ip, error, res) {
|
||||
logger.error(`Api ${action} Error on ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
||||
postToStats(action, originalUrl, ip, null, null, error);
|
||||
const [status, message] = this.returnErrorMessageAndStatus(error);
|
||||
res
|
||||
.status(status)
|
||||
.json(this.createErrorResponsePayload(status, message));
|
||||
},
|
||||
useObjectPropertiesIfNoKeys: function (err) {
|
||||
if (Object.keys(err).length === 0) {
|
||||
let newErrorObject = {};
|
||||
Object.getOwnPropertyNames(err).forEach((key) => {
|
||||
|
@ -43,4 +59,11 @@ module.exports = {
|
|||
}
|
||||
return err;
|
||||
},
|
||||
createErrorResponsePayload (status, message) {
|
||||
return {
|
||||
status,
|
||||
success: false,
|
||||
message,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const Handlebars = require('handlebars');
|
||||
const config = require('config');
|
||||
const config = require('../config/speechConfig.js');
|
||||
|
||||
module.exports = {
|
||||
// define any extra helpers you may need
|
||||
googleAnalytics () {
|
||||
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
||||
const googleApiKey = config.analytics.googleId;
|
||||
return new Handlebars.SafeString(
|
||||
`<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const logger = require('winston');
|
||||
const fs = require('fs');
|
||||
const db = require('../models');
|
||||
const config = require('config');
|
||||
const config = require('../config/speechConfig.js');
|
||||
|
||||
module.exports = {
|
||||
validateApiPublishRequest (body, files) {
|
||||
|
@ -11,9 +11,6 @@ module.exports = {
|
|||
if (!body.name) {
|
||||
throw new Error('no name field found in request');
|
||||
}
|
||||
if (!body.nsfw) {
|
||||
throw new Error('no nsfw field found in request');
|
||||
}
|
||||
if (!files) {
|
||||
throw new Error('no files found in request');
|
||||
}
|
||||
|
@ -21,11 +18,10 @@ module.exports = {
|
|||
throw new Error('no file with key of [file] found in request');
|
||||
}
|
||||
},
|
||||
validatePublishSubmission (file, claimName, nsfw) {
|
||||
validatePublishSubmission (file, claimName) {
|
||||
try {
|
||||
module.exports.validateFile(file);
|
||||
module.exports.validateClaimName(claimName);
|
||||
module.exports.validateNSFW(nsfw);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
|
@ -79,24 +75,6 @@ module.exports = {
|
|||
throw new Error('Only posts with a "Public Domain" or "Creative Commons" license are eligible for publishing through spee.ch');
|
||||
}
|
||||
},
|
||||
cleanseNSFW (nsfw) {
|
||||
switch (nsfw) {
|
||||
case true:
|
||||
case 'on':
|
||||
case 'true':
|
||||
case 1:
|
||||
case '1':
|
||||
return true;
|
||||
case false:
|
||||
case 'false':
|
||||
case 'off':
|
||||
case 0:
|
||||
case '0':
|
||||
return false;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
cleanseChannelName (channelName) {
|
||||
if (channelName) {
|
||||
if (channelName.indexOf('@') !== 0) {
|
||||
|
@ -105,12 +83,6 @@ module.exports = {
|
|||
}
|
||||
return channelName;
|
||||
},
|
||||
validateNSFW (nsfw) {
|
||||
if (nsfw === true || nsfw === false) {
|
||||
return;
|
||||
}
|
||||
throw new Error('NSFW must be set to either true or false');
|
||||
},
|
||||
createPublishParams (filePath, name, title, description, license, nsfw, thumbnail, channelName) {
|
||||
logger.debug(`Creating Publish Parameters`);
|
||||
// provide defaults for title
|
||||
|
@ -138,7 +110,7 @@ module.exports = {
|
|||
license,
|
||||
nsfw,
|
||||
},
|
||||
claim_address: config.get('WalletConfig.LbryClaimAddress'),
|
||||
claim_address: config.wallet.lbryClaimAddress,
|
||||
};
|
||||
// add thumbnail to channel if video
|
||||
if (thumbnail !== null) {
|
||||
|
@ -165,7 +137,7 @@ module.exports = {
|
|||
db.File.findAll({ where: { name } })
|
||||
.then(result => {
|
||||
if (result.length >= 1) {
|
||||
const claimAddress = config.get('WalletConfig.LbryClaimAddress');
|
||||
const claimAddress = config.wallet.lbryClaimAddress;
|
||||
// filter out any results that were not published from spee.ch's wallet address
|
||||
const filteredResult = result.filter((claim) => {
|
||||
return (claim.address === claimAddress);
|
||||
|
|
|
@ -298,7 +298,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
|
|||
case 1:
|
||||
return resolve(result[0]);
|
||||
default:
|
||||
logger.error('more than one entry matches that name and claimID');
|
||||
logger.warn(`more than one entry matches that name (${name}) and claimID (${claimId})`);
|
||||
return resolve(result[0]);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -2,13 +2,13 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
const Sequelize = require('sequelize');
|
||||
const basename = path.basename(module.filename);
|
||||
const config = require('config');
|
||||
const config = require('../config/speechConfig.js');
|
||||
const db = {};
|
||||
const logger = require('winston');
|
||||
|
||||
const database = config.get('Database.Database');
|
||||
const username = config.get('Database.Username');
|
||||
const password = config.get('Database.Password');
|
||||
const database = config.sql.database;
|
||||
const username = config.sql.username;
|
||||
const password = config.sql.password;
|
||||
|
||||
const sequelize = new Sequelize(database, username, password, {
|
||||
host : 'localhost',
|
||||
|
@ -66,7 +66,7 @@ db.upsert = (Model, values, condition, tableName) => {
|
|||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
logger.error('Sequelize findOne error', error);
|
||||
logger.error(`${tableName}.upsert error`, error);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ module.exports = (sequelize, { STRING }) => {
|
|||
};
|
||||
|
||||
User.prototype.comparePassword = function (password, callback) {
|
||||
logger.debug(`User.prototype.comparePassword ${password} ${this.password}`);
|
||||
bcrypt.compare(password, this.password, callback);
|
||||
};
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
"cookie-session": "^2.0.0-beta.3",
|
||||
"express": "^4.15.2",
|
||||
"express-handlebars": "^3.0.0",
|
||||
"express-session": "^1.15.5",
|
||||
"form-data": "^2.3.1",
|
||||
"helmet": "^3.8.1",
|
||||
"mysql2": "^1.3.5",
|
||||
|
@ -44,8 +43,6 @@
|
|||
"sequelize": "^4.1.0",
|
||||
"sequelize-cli": "^3.0.0-3",
|
||||
"sleep": "^5.1.1",
|
||||
"socket.io": "^2.0.1",
|
||||
"socketio-file-upload": "^0.6.0",
|
||||
"universal-analytics": "^0.4.13",
|
||||
"winston": "^2.3.1",
|
||||
"winston-slack-webhook": "billbitt/winston-slack-webhook"
|
||||
|
|
|
@ -24,7 +24,7 @@ function publishNewChannel (event) {
|
|||
// prevent default so this script can handle submission
|
||||
event.preventDefault();
|
||||
// validate submission
|
||||
validateNewChannelSubmission(userName, password)
|
||||
validationFunctions.validateNewChannelSubmission(userName, password)
|
||||
.then(() => {
|
||||
showChannelCreateInProgressDisplay();
|
||||
return sendAuthRequest(userName, password, '/signup') // post the request
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
function triggerFileChooser(fileInputId, event) {
|
||||
document.getElementById(fileInputId).click();
|
||||
}
|
||||
|
||||
function drop_handler(event) {
|
||||
event.preventDefault();
|
||||
|
@ -9,7 +6,7 @@ function drop_handler(event) {
|
|||
if (dt.items) {
|
||||
if (dt.items[0].kind == 'file') {
|
||||
var droppedFile = dt.items[0].getAsFile();
|
||||
previewAndStageFile(droppedFile);
|
||||
publishFileFunctions.previewAndStageFile(droppedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ function getRequest (url) {
|
|||
if ( xhttp.status == 200) {
|
||||
resolve(xhttp.response);
|
||||
} else if (xhttp.status == 401) {
|
||||
reject('Wrong username or password');
|
||||
reject('Wrong channel name or password');
|
||||
} else {
|
||||
reject('request failed with status:' + xhttp.status);
|
||||
};
|
||||
|
@ -29,7 +29,7 @@ function postRequest (url, params) {
|
|||
if ( xhttp.status == 200) {
|
||||
resolve(xhttp.response);
|
||||
} else if (xhttp.status == 401) {
|
||||
reject( new AuthenticationError('Wrong username or password'));
|
||||
reject( new AuthenticationError('Wrong channel name or password'));
|
||||
} else {
|
||||
reject('request failed with status:' + xhttp.status);
|
||||
};
|
||||
|
|
|
@ -47,7 +47,7 @@ function loginToChannel (event) {
|
|||
const password = document.getElementById('channel-login-password-input').value;
|
||||
// prevent default
|
||||
event.preventDefault()
|
||||
validateNewChannelLogin(userName, password)
|
||||
validationFunctions.validateNewChannelLogin(userName, password)
|
||||
.then(() => {
|
||||
// send request
|
||||
return sendAuthRequest(userName, password, '/login')
|
||||
|
@ -71,9 +71,9 @@ function loginToChannel (event) {
|
|||
.catch(error => {
|
||||
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
|
||||
if (error.name){
|
||||
showError(loginErrorDisplayElement, error.message);
|
||||
validationFunctions.showError(loginErrorDisplayElement, error.message);
|
||||
} else {
|
||||
showError(loginErrorDisplayElement, 'There was an error logging into your channel');
|
||||
validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,29 +1,51 @@
|
|||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
/* publish functions */
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var stagedFiles = null;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
||||
function cancelPublish () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishFileFunctions = {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
triggerFileChooser: function (fileInputId) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
document.getElementById(fileInputId).click();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
cancelPublish: function () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
window.location.href = '/';
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// When a file is selected for publish, validate that file and
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// stage it so it will be ready when the publish button is clicked.
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
function previewAndStageFile(selectedFile){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishForm = document.getElementById('publish-form');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const assetPreview = document.getElementById('asset-preview-target');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const primaryDropzone = document.getElementById('primary-dropzone');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const previewReader = new FileReader();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const nameInput = document.getElementById('claim-name-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
previewAndStageFile: function (selectedFile) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const fileSelectionInputError = document.getElementById('input-error-file-selection');
|
||||
const thumbnailSelectionTool = document.getElementById('publish-thumbnail');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const thumbnailSelectionInput = document.getElementById('claim-thumbnail-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// validate the file's name, type, and size
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// When a file is selected for publish, validate that file and
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// stage it so it will be ready when the publish button is clicked
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
try {
|
||||
validateFile(selectedFile);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.validateFile(selectedFile); // validate the file's name, type, and size
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} catch (error) {
|
||||
showError(fileSelectionInputError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.showError(fileSelectionInputError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
return;
|
||||
}
|
||||
// set the image preview, if an image was provided
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// set image preview, if an image was provided
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.setImagePreview(selectedFile);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// hide the primary drop zone
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.hidePrimaryDropzone();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// set the name input value to the image name if none is set yet
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updateClaimNameInputWithFileName(selectedFile);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// store the selected file for upload
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
stagedFiles = [selectedFile];
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
hidePrimaryDropzone: function () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const primaryDropzone = document.getElementById('primary-dropzone');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishForm = document.getElementById('publish-form');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
primaryDropzone.setAttribute('class', 'hidden');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishForm.setAttribute('class', 'row')
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
updateClaimNameInputWithFileName: function (selectedFile) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const nameInput = document.getElementById('claim-name-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (nameInput.value === "") {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var filename = selectedFile.name.substring(0, selectedFile.name.indexOf('.'))
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
nameInput.value = validationFunctions.cleanseClaimName(filename);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.checkClaimName(nameInput.value);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
setImagePreview: function (selectedFile) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const assetPreview = document.getElementById('asset-preview-target');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const thumbnailInput = document.getElementById('claim-thumbnail-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const thumbnailInputTool = document.getElementById('publish-thumbnail');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (selectedFile.type !== 'video/mp4') {
|
||||
const previewReader = new FileReader();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (selectedFile.type === 'image/gif') {
|
||||
assetPreview.innerHTML = `<p>loading preview...</p>`
|
||||
}
|
||||
|
@ -32,68 +54,178 @@ function previewAndStageFile(selectedFile){
|
|||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
assetPreview.innerHTML = '<img id="asset-preview" src="' + previewReader.result + '" alt="image preview"/>';
|
||||
};
|
||||
// clear & hide the thumbnail selection input
|
||||
thumbnailSelectionInput.value = '';
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailSelectionTool.hidden = true;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailInput.value = '';
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailInputTool.hidden = true;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else {
|
||||
assetPreview.innerHTML = `<img id="asset-preview" src="/assets/img/video_thumb_default.png"/>`;
|
||||
// clear & show the thumbnail selection input
|
||||
thumbnailSelectionInput.value = '';
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailSelectionTool.hidden = false;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailInput.value = '';
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnailInputTool.hidden = false;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
// hide the drop zone
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
primaryDropzone.setAttribute('class', 'hidden');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishForm.setAttribute('class', 'row')
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// set the name input value to the image name if none is set yet
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (nameInput.value === "") {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var filename = selectedFile.name.substring(0, selectedFile.name.indexOf('.'))
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
nameInput.value = cleanseClaimName(filename);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
checkClaimName(nameInput.value);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// store the selected file for upload
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
stagedFiles = [selectedFile];
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
returnNullOrChannel: function () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const channelRadio = document.getElementById('channel-radio');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (channelRadio.checked) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const channelInput = document.getElementById('channel-name-select');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
return channelInput.value.trim();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
return null;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
createMetadata: function() {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const nameInput = document.getElementById('claim-name-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const titleInput = document.getElementById('publish-title');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const descriptionInput = document.getElementById('publish-description');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const licenseInput = document.getElementById('publish-license');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const nsfwInput = document.getElementById('publish-nsfw');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const thumbnailInput = document.getElementById('claim-thumbnail-input');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
||||
return {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
name: nameInput.value.trim(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
channelName: this.returnNullOrChannel(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
title: titleInput.value.trim(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
description: descriptionInput.value.trim(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
license: licenseInput.value.trim(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
nsfw: nsfwInput.checked,
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
type: stagedFiles[0].type,
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
thumbnail: thumbnailInput.value.trim(),
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
appendDataToFormData: function (file, metadata) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var fd = new FormData();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
fd.append('file', file)
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
for (var key in metadata) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (metadata.hasOwnProperty(key)) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log(key, metadata[key]);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
fd.append(key, metadata[key]);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
return fd;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishFile: function (file, metadata) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var uri = "/api/publish";
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var xhr = new XMLHttpRequest();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var fd = this.appendDataToFormData(file, metadata);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var that = this;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.upload.addEventListener("loadstart", function(e) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.showUploadStartedMessage();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
})
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.upload.addEventListener("progress", function(e) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (e.lengthComputable) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
var percentage = Math.round((e.loaded * 100) / e.total);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('progress:', percentage);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.showUploadProgressMessage(percentage);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}, false);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.upload.addEventListener("load", function(e){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('loaded 100%');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.showFilePublishUpdate("Your file has been loaded, and is now being published to the blockchain. Sit tight...")
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}, false);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.open("POST", uri, true);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.onreadystatechange = function() {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (xhr.readyState == 4) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (xhr.status == 200) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('publish complete!');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.showFilePublishComplete(JSON.parse(xhr.response).message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log(xhr.response);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.showFilePublishFailure(JSON.parse(xhr.response).message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('xhr.readyState', xhr.readyState, 'xhr.status', xhr.status);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
};
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// Initiate a multipart/form-data upload
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
xhr.send(fd);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// Validate the publish submission and then trigger upload
|
||||
function publishStagedFile(event) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// prevent default so this script can handle submission
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
event.preventDefault();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// declare variables
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const claimName = document.getElementById('claim-name-input').value;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
let channelName = document.getElementById('channel-name-select').value;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishStagedFile: function (event) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
event.preventDefault(); // prevent default so this script can handle submission
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const metadata = this.createMetadata();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const that = this; // note: necessary ?
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const fileSelectionInputError = document.getElementById('input-error-file-selection');
|
||||
const claimNameError = document.getElementById('input-error-claim-name');
|
||||
const channelSelectError = document.getElementById('input-error-channel-select');
|
||||
const publishSubmitError = document.getElementById('input-error-publish-submit');
|
||||
let anonymousOrInChannel;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// replace channelName with 'anonymous' if appropriate
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const radios = document.getElementsByName('anonymous-or-channel');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
for (let i = 0; i < radios.length; i++) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (radios[i].checked) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// do whatever you want with the checked radio
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
anonymousOrInChannel = radios[i].value;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// only one radio can be logically checked, don't check the rest
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
break;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
if (anonymousOrInChannel === 'anonymous') {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
channelName = null;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
};
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// validate, submit, and handle response
|
||||
validateFilePublishSubmission(stagedFiles, claimName, channelName)
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
.then(() => {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
uploader.submitFiles(stagedFiles);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.validateFilePublishSubmission(stagedFiles, metadata)
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
.then( function() {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
that.publishFile(stagedFiles[0], metadata);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.name === 'FileError') {
|
||||
showError(fileSelectionInputError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.showError(fileSelectionInputError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else if (error.name === 'NameError') {
|
||||
showError(claimNameError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.showError(claimNameError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else if (error.name === 'ChannelNameError'){
|
||||
console.log(error);
|
||||
showError(channelSelectError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.showError(channelSelectError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
} else {
|
||||
showError(publishSubmitError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
validationFunctions.showError(publishSubmitError, error.message);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
return;
|
||||
})
|
||||
};
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showUploadStartedMessage: function (){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('starting upload');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// hide the publish tool
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.hidePublishTools();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// show the progress status and animation
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.showPublishStatus();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.showPublishProgressBar();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showUploadProgressMessage: function (percentage){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updatePublishStatus('<p>File is loading to server</p>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updateUploadPercent('<p class="blue">' + percentage + '% </p>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showFilePublishUpdate: function (msg) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updatePublishStatus('<p>' + msg + '</p>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updateUploadPercent('<p>Curious what magic is happening here? <a class="link--primary" target="blank" href="https://lbry.io/faq/what-is-lbry">Learn more.</a></p>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showFilePublishFailure: function (msg){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updatePublishStatus('<p>Something went wrong...</p><p><strong>' + msg + '</strong></p><p>For help, post the above error text in the #speech channel on the <a class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">lbry discord</a>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.hidePublishProgressBar();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.hideUploadPercent();
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showFilePublishComplete: function (msg) {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
console.log('Publish complete!');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const showUrl = msg.lbryTx.claim_id + "/" + msg.name;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// update status
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updatePublishStatus('<p>Your publish is complete! You are being redirected to it now.</p>');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
this.updateUploadPercent('<p><a class="link--primary" target="_blank" href="' + showUrl + '">If you do not get redirected, click here.</a></p>')
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// redirect the user
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
window.location.href = showUrl;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
hidePublishTools: function () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishFormWrapper = document.getElementById('publish-form');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishFormWrapper.setAttribute('class', 'hidden');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// publish status functions
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showPublishStatus: function () {
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishStatus = document.getElementById('publish-status');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishStatus.setAttribute('class', 'row row--tall flex-container--column flex-container--center-center');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
updatePublishStatus: function (msg){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishUpdate = document.getElementById('publish-update');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishUpdate.innerHTML = msg;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// progress bar functions
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
showPublishProgressBar: function (){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishProgressBar = document.getElementById('publish-progress-bar');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
createProgressBar(publishProgressBar, 12);
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
hidePublishProgressBar: function (){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const publishProgressBar = document.getElementById('publish-progress-bar');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
publishProgressBar.hidden = true;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
// upload percent functions
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
updateUploadPercent: function (msg){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const uploadPercent = document.getElementById('upload-percent');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
uploadPercent.innerHTML = msg;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
hideUploadPercent: function (){
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
const uploadPercent = document.getElementById('upload-percent');
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
uploadPercent.hidden = true;
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
},
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
}
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
||||
|
|
|||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage. Late on catching this one, but this function name doesn't imply it is redirecting me to the homepage.
|
|
@ -1,5 +1,6 @@
|
|||
// validation function which checks the proposed file's type, size, and name
|
||||
function validateFile(file) {
|
||||
const validationFunctions = {
|
||||
validateFile: function (file) {
|
||||
if (!file) {
|
||||
console.log('no file found');
|
||||
throw new Error('no file provided');
|
||||
|
@ -34,10 +35,10 @@ function validateFile(file) {
|
|||
console.log('file type is not supported');
|
||||
throw new Error(file.type + ' is not a supported file type. Only, .jpeg, .png, .gif, and .mp4 files are currently supported.')
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
// validation function that checks to make sure the claim name is valid
|
||||
function validateClaimName (name) {
|
||||
validateClaimName: function (name) {
|
||||
console.log('validating the claim name');
|
||||
// ensure a name was entered
|
||||
if (name.length < 1) {
|
||||
throw new NameError("You must enter a name for your url");
|
||||
|
@ -47,9 +48,8 @@ function validateClaimName (name) {
|
|||
if (invalidCharacters) {
|
||||
throw new NameError('"' + invalidCharacters + '" characters are not allowed');
|
||||
}
|
||||
}
|
||||
|
||||
function validateChannelName (name) {
|
||||
},
|
||||
validateChannelName: function (name) {
|
||||
name = name.substring(name.indexOf('@') + 1);
|
||||
// ensure a name was entered
|
||||
if (name.length < 1) {
|
||||
|
@ -60,87 +60,79 @@ function validateChannelName (name) {
|
|||
if (invalidCharacters) {
|
||||
throw new ChannelNameError('"' + invalidCharacters + '" characters are not allowed');
|
||||
}
|
||||
}
|
||||
|
||||
function validatePassword (password) {
|
||||
},
|
||||
validatePassword: function (password) {
|
||||
if (password.length < 1) {
|
||||
throw new ChannelPasswordError("You must enter a password for you channel");
|
||||
}
|
||||
}
|
||||
|
||||
function cleanseClaimName(name) {
|
||||
},
|
||||
cleanseClaimName: function (name) {
|
||||
name = name.replace(/\s+/g, '-'); // replace spaces with dashes
|
||||
name = name.replace(/[^A-Za-z0-9-]/g, ''); // remove all characters that are not A-Z, a-z, 0-9, or '-'
|
||||
return name;
|
||||
}
|
||||
|
||||
},
|
||||
// validation functions to check claim & channel name eligibility as the inputs change
|
||||
|
||||
function isNameAvailable (name, apiUrl) {
|
||||
isNameAvailable: function (name, apiUrl) {
|
||||
const url = apiUrl + name;
|
||||
return getRequest(url)
|
||||
}
|
||||
|
||||
function showError(errorDisplay, errorMsg) {
|
||||
},
|
||||
showError: function (errorDisplay, errorMsg) {
|
||||
errorDisplay.hidden = false;
|
||||
errorDisplay.innerText = errorMsg;
|
||||
}
|
||||
|
||||
function hideError(errorDisplay) {
|
||||
},
|
||||
hideError: function (errorDisplay) {
|
||||
errorDisplay.hidden = true;
|
||||
errorDisplay.innerText = '';
|
||||
}
|
||||
|
||||
function showSuccess (successElement) {
|
||||
},
|
||||
showSuccess: function (successElement) {
|
||||
successElement.hidden = false;
|
||||
successElement.innerHTML = "✔";
|
||||
}
|
||||
|
||||
function hideSuccess (successElement) {
|
||||
},
|
||||
hideSuccess: function (successElement) {
|
||||
successElement.hidden = true;
|
||||
successElement.innerHTML = "";
|
||||
}
|
||||
|
||||
function checkAvailability(name, successDisplayElement, errorDisplayElement, validateName, isNameAvailable, errorMessage, apiUrl) {
|
||||
},
|
||||
checkAvailability: function (name, successDisplayElement, errorDisplayElement, validateName, errorMessage, apiUrl) {
|
||||
var that = this;
|
||||
try {
|
||||
// check to make sure the characters are valid
|
||||
validateName(name);
|
||||
// check to make sure it is available
|
||||
isNameAvailable(name, apiUrl)
|
||||
.then(result => {
|
||||
that.isNameAvailable(name, apiUrl)
|
||||
.then(function (result) {
|
||||
if (result === true) {
|
||||
hideError(errorDisplayElement);
|
||||
showSuccess(successDisplayElement)
|
||||
that.hideError(errorDisplayElement);
|
||||
that.showSuccess(successDisplayElement)
|
||||
} else {
|
||||
hideSuccess(successDisplayElement);
|
||||
showError(errorDisplayElement, errorMessage);
|
||||
that.hideSuccess(successDisplayElement);
|
||||
that.showError(errorDisplayElement, errorMessage);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
hideSuccess(successDisplayElement);
|
||||
showError(errorDisplayElement, error.message);
|
||||
that.hideSuccess(successDisplayElement);
|
||||
that.showError(errorDisplayElement, error.message);
|
||||
});
|
||||
} catch (error) {
|
||||
hideSuccess(successDisplayElement);
|
||||
showError(errorDisplayElement, error.message);
|
||||
that.hideSuccess(successDisplayElement);
|
||||
that.showError(errorDisplayElement, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function checkClaimName(name){
|
||||
},
|
||||
checkClaimName: function (name) {
|
||||
const successDisplayElement = document.getElementById('input-success-claim-name');
|
||||
const errorDisplayElement = document.getElementById('input-error-claim-name');
|
||||
checkAvailability(name, successDisplayElement, errorDisplayElement, validateClaimName, isNameAvailable, 'Sorry, that ending is already taken', '/api/isClaimAvailable/');
|
||||
}
|
||||
|
||||
function checkChannelName(name){
|
||||
this.checkAvailability(name, successDisplayElement, errorDisplayElement, this.validateClaimName, 'Sorry, that ending is already taken', '/api/isClaimAvailable/');
|
||||
},
|
||||
checkChannelName: function (name) {
|
||||
const successDisplayElement = document.getElementById('input-success-channel-name');
|
||||
const errorDisplayElement = document.getElementById('input-error-channel-name');
|
||||
name = `@${name}`;
|
||||
checkAvailability(name, successDisplayElement, errorDisplayElement, validateChannelName, isNameAvailable, 'Sorry, that name is already taken', '/api/isChannelAvailable/');
|
||||
}
|
||||
|
||||
this.checkAvailability(name, successDisplayElement, errorDisplayElement, this.validateChannelName, 'Sorry, that name is already taken', '/api/isChannelAvailable/');
|
||||
},
|
||||
// validation function which checks all aspects of the publish submission
|
||||
function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
||||
validateFilePublishSubmission: function (stagedFiles, metadata) {
|
||||
const channelName = metadata.channelName;
|
||||
const claimName = metadata.name;
|
||||
var that = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
// 1. make sure 1 file was staged
|
||||
if (!stagedFiles) {
|
||||
|
@ -152,7 +144,7 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
|||
}
|
||||
// 2. validate the file's name, type, and size
|
||||
try {
|
||||
validateFile(stagedFiles[0]);
|
||||
that.validateFile(stagedFiles[0]);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
|
@ -161,16 +153,17 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
|||
if (channelName === 'new' || channelName === 'login') {
|
||||
reject(new ChannelNameError("Please log in to a channel"));
|
||||
return;
|
||||
};
|
||||
}
|
||||
;
|
||||
// 4. validate the claim name
|
||||
try {
|
||||
validateClaimName(claimName);
|
||||
that.validateClaimName(claimName);
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
// if all validation passes, check availability of the name (note: do we need to re-validate channel name vs. credentials as well?)
|
||||
return isNameAvailable(claimName, '/api/isClaimAvailable/')
|
||||
return that.isNameAvailable(claimName, '/api/isClaimAvailable/')
|
||||
.then(result => {
|
||||
if (result) {
|
||||
resolve();
|
||||
|
@ -182,55 +175,57 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
|||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
// validation function which checks all aspects of a new channel submission
|
||||
function validateNewChannelSubmission(userName, password){
|
||||
validateNewChannelSubmission: function (userName, password) {
|
||||
const channelName = `@${userName}`;
|
||||
var that = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
// 1. validate name
|
||||
try {
|
||||
validateChannelName(channelName);
|
||||
that.validateChannelName(channelName);
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
// 2. validate password
|
||||
try {
|
||||
validatePassword(password);
|
||||
that.validatePassword(password);
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
// 3. if all validation passes, check availability of the name
|
||||
isNameAvailable(channelName, '/api/isChannelAvailable/') // validate the availability
|
||||
.then(result => {
|
||||
that.isNameAvailable(channelName, '/api/isChannelAvailable/') // validate the availability
|
||||
.then(function(result) {
|
||||
if (result) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new ChannelNameError('Sorry, that name is already taken'));
|
||||
}
|
||||
})
|
||||
.catch( error => {
|
||||
.catch(function(error) {
|
||||
console.log('error evaluating channel name availability', error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
// validation function which checks all aspects of a new channel login
|
||||
function validateNewChannelLogin(userName, password){
|
||||
validateNewChannelLogin: function (userName, password) {
|
||||
const channelName = `@${userName}`;
|
||||
var that = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
// 1. validate name
|
||||
try {
|
||||
validateChannelName(channelName);
|
||||
that.validateChannelName(channelName);
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
// 2. validate password
|
||||
try {
|
||||
validatePassword(password);
|
||||
that.validatePassword(password);
|
||||
} catch (error) {
|
||||
return reject(error);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
};
|
|
@ -1,13 +1,13 @@
|
|||
const logger = require('winston');
|
||||
const multipart = require('connect-multiparty');
|
||||
const multipartMiddleware = multipart();
|
||||
const multipartMiddleware = multipart({uploadDir: '/home/lbry/test/'});
|
||||
const db = require('../models');
|
||||
const { publish } = require('../controllers/publishController.js');
|
||||
const { getClaimList, resolveUri } = require('../helpers/lbryApi.js');
|
||||
const { createPublishParams, validateApiPublishRequest, validatePublishSubmission, cleanseNSFW, cleanseChannelName, checkClaimNameAvailability, checkChannelAvailability } = require('../helpers/publishHelpers.js');
|
||||
const { createPublishParams, validateApiPublishRequest, validatePublishSubmission, cleanseChannelName, checkClaimNameAvailability, checkChannelAvailability } = require('../helpers/publishHelpers.js');
|
||||
const errorHandlers = require('../helpers/errorHandlers.js');
|
||||
const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||
const { authenticateChannelCredentials } = require('../auth/authentication.js');
|
||||
const { authenticateOrSkip } = require('../auth/authentication.js');
|
||||
|
||||
module.exports = (app) => {
|
||||
// route to run a claim_list request on the daemon
|
||||
|
@ -21,7 +21,7 @@ module.exports = (app) => {
|
|||
res.status(200).json(claimsList);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('publish', originalUrl, ip, error, res);
|
||||
errorHandlers.handleApiError('claim_list', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
// route to check whether spee.ch has published to a claim
|
||||
|
@ -67,15 +67,13 @@ module.exports = (app) => {
|
|||
res.status(200).json(resolvedUri);
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError('publish', originalUrl, ip, error, res);
|
||||
errorHandlers.handleApiError('resolve', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
// route to run a publish request on the daemon
|
||||
app.post('/api/publish', multipartMiddleware, (req, res) => {
|
||||
logger.debug('req:', req);
|
||||
app.post('/api/publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
||||
let file, fileName, filePath, fileType, name, nsfw, license, title, description, thumbnail, anonymous, skipAuth, channelName, channelPassword;
|
||||
// validate that mandatory parts of the request are present
|
||||
const body = req.body;
|
||||
const files = req.files;
|
||||
try {
|
||||
validateApiPublishRequest(body, files);
|
||||
} catch (error) {
|
||||
|
@ -84,13 +82,12 @@ module.exports = (app) => {
|
|||
return;
|
||||
}
|
||||
// validate file, name, license, and nsfw
|
||||
const file = files.file;
|
||||
const fileName = file.name;
|
||||
const filePath = file.path;
|
||||
const fileType = file.type;
|
||||
const name = body.name;
|
||||
let nsfw = body.nsfw;
|
||||
nsfw = cleanseNSFW(nsfw); // cleanse nsfw
|
||||
file = files.file;
|
||||
fileName = file.path.substring(file.path.lastIndexOf('/') + 1);
|
||||
filePath = file.path;
|
||||
fileType = file.type;
|
||||
name = body.name;
|
||||
nsfw = (body.nsfw === 'true');
|
||||
try {
|
||||
validatePublishSubmission(file, name, nsfw);
|
||||
} catch (error) {
|
||||
|
@ -98,20 +95,38 @@ module.exports = (app) => {
|
|||
res.status(400).json({success: false, message: error.message});
|
||||
return;
|
||||
}
|
||||
logger.debug(`name: ${name}, nsfw: ${nsfw}`);
|
||||
// optional inputs
|
||||
const license = body.license || null;
|
||||
const title = body.title || null;
|
||||
const description = body.description || null;
|
||||
const thumbnail = body.thumbnail || null;
|
||||
let channelName = body.channelName || null;
|
||||
license = body.license || null;
|
||||
title = body.title || null;
|
||||
description = body.description || null;
|
||||
thumbnail = body.thumbnail || null;
|
||||
anonymous = (body.channelName === 'null') || (body.channelName === undefined);
|
||||
if (user) {
|
||||
channelName = user.channelName || null;
|
||||
} else {
|
||||
channelName = body.channelName || null;
|
||||
}
|
||||
channelPassword = body.channelPassword || null;
|
||||
skipAuth = false;
|
||||
// case 1: publish from spee.ch, client logged in
|
||||
if (user) {
|
||||
skipAuth = true;
|
||||
if (anonymous) {
|
||||
channelName = null;
|
||||
}
|
||||
// case 2: publish from api or spee.ch, client not logged in
|
||||
} else {
|
||||
if (anonymous) {
|
||||
skipAuth = true;
|
||||
channelName = null;
|
||||
}
|
||||
}
|
||||
channelName = cleanseChannelName(channelName);
|
||||
const channelPassword = body.channelPassword || null;
|
||||
logger.debug(`license: ${license} title: "${title}" description: "${description}" channelName: "${channelName}" channelPassword: "${channelPassword}"`);
|
||||
logger.debug(`/api/publish > name: ${name}, license: ${license} title: "${title}" description: "${description}" channelName: "${channelName}" channelPassword: "${channelPassword}" nsfw: "${nsfw}"`);
|
||||
// check channel authorization
|
||||
authenticateChannelCredentials(channelName, channelPassword)
|
||||
.then(result => {
|
||||
if (!result) {
|
||||
authenticateOrSkip(skipAuth, channelName, channelPassword)
|
||||
.then(authenticated => {
|
||||
if (!authenticated) {
|
||||
throw new Error('Authentication failed, you do not have access to that channel');
|
||||
}
|
||||
// make sure the claim name is available
|
||||
|
@ -133,14 +148,14 @@ module.exports = (app) => {
|
|||
res.status(200).json({
|
||||
success: true,
|
||||
message: {
|
||||
name,
|
||||
url : `spee.ch/${result.claim_id}/${name}`,
|
||||
lbryTx: result,
|
||||
},
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('publish api error', error);
|
||||
res.status(400).json({success: false, message: error.message});
|
||||
errorHandlers.handleApiError('publish', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -157,7 +172,7 @@ module.exports = (app) => {
|
|||
});
|
||||
});
|
||||
// route to get a short channel id from long channel Id
|
||||
app.get('/api/shortChannelId/:longId/:name', ({ params }, res) => {
|
||||
app.get('/api/shortChannelId/:longId/:name', ({ ip, originalUrl, params }, res) => {
|
||||
// serve content
|
||||
db.Certificate.getShortChannelIdFromLongChannelId(params.longId, params.name)
|
||||
.then(shortId => {
|
||||
|
@ -166,7 +181,7 @@ module.exports = (app) => {
|
|||
})
|
||||
.catch(error => {
|
||||
logger.error('api error getting short channel id', error);
|
||||
res.status(400).json(error.message);
|
||||
errorHandlers.handleApiError('short channel id', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -24,7 +24,7 @@ module.exports = (app) => {
|
|||
app.get('/trending', (req, res) => {
|
||||
res.status(301).redirect('/popular');
|
||||
});
|
||||
app.get('/popular', (req, res) => {
|
||||
app.get('/popular', ({ ip, originalUrl }, res) => {
|
||||
const startDate = new Date();
|
||||
startDate.setDate(startDate.getDate() - 1);
|
||||
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
||||
|
@ -36,20 +36,18 @@ module.exports = (app) => {
|
|||
});
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError(null, null, null, error, res);
|
||||
errorHandlers.handleRequestError('popular', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
// route to display a list of the trending images
|
||||
app.get('/new', (req, res) => {
|
||||
app.get('/new', ({ ip, originalUrl }, res) => {
|
||||
getRecentClaims()
|
||||
.then(result => {
|
||||
// logger.debug(result);
|
||||
res.status(200).render('new', {
|
||||
newClaims: result,
|
||||
});
|
||||
res.status(200).render('new', { newClaims: result });
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandlers.handleRequestError(null, null, null, error, res);
|
||||
errorHandlers.handleRequestError('new', originalUrl, ip, error, res);
|
||||
});
|
||||
});
|
||||
// route to send embedable video player (for twitter)
|
||||
|
|
|
@ -49,7 +49,6 @@ function extractPageFromClaims (claims, pageNumber) {
|
|||
const claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;
|
||||
const claimEndIndex = claimStartIndex + 10;
|
||||
const pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);
|
||||
logger.debug('page of claims:', pageOfClaims);
|
||||
return pageOfClaims;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
const logger = require('winston');
|
||||
const { publish } = require('../controllers/publishController.js');
|
||||
const { createPublishParams } = require('../helpers/publishHelpers.js');
|
||||
const { useObjectPropertiesIfNoKeys } = require('../helpers/errorHandlers.js');
|
||||
const { postToStats } = require('../controllers/statsController.js');
|
||||
|
||||
module.exports = (app, siofu, hostedContentPath) => {
|
||||
const http = require('http');
|
||||
const server = http.Server(app);
|
||||
const io = require('socket.io')(server);
|
||||
|
||||
io.on('connection', socket => {
|
||||
logger.silly('a user connected via sockets');
|
||||
// attach upload listeners
|
||||
const uploader = new siofu();
|
||||
uploader.dir = hostedContentPath;
|
||||
uploader.listen(socket);
|
||||
// listener for when file upload starts
|
||||
uploader.on('start', ({ file }) => {
|
||||
// log
|
||||
logger.info('client started an upload:', file.name);
|
||||
// server side test to make sure file is not a bad file type
|
||||
if (/\.exe$/.test(file.name)) {
|
||||
uploader.abort(file.id, socket);
|
||||
}
|
||||
});
|
||||
// listener for when file upload encounters an error
|
||||
uploader.on('error', ({ error }) => {
|
||||
logger.error('an error occured while uploading', error);
|
||||
postToStats('PUBLISH', '/', null, null, null, error);
|
||||
socket.emit('publish-status', error);
|
||||
});
|
||||
// listener for when file has been uploaded
|
||||
uploader.on('saved', ({ file }) => {
|
||||
if (file.success) {
|
||||
logger.debug(`Client successfully uploaded ${file.name}`);
|
||||
socket.emit('publish-update', 'File upload successfully completed. Your image is being published to LBRY (this might take a second)...');
|
||||
// /*
|
||||
// NOTE: need to validate that client has the credentials to the channel they chose
|
||||
// otherwise they could circumvent security.
|
||||
// */
|
||||
let thumbnail;
|
||||
if (file.meta.thumbnail) {
|
||||
thumbnail = file.meta.thumbnail;
|
||||
} else {
|
||||
thumbnail = null;
|
||||
}
|
||||
let channelName;
|
||||
if (file.meta.channel) {
|
||||
channelName = file.meta.channel;
|
||||
} else {
|
||||
channelName = null;
|
||||
}
|
||||
// prepare the publish parameters
|
||||
const publishParams = createPublishParams(file.pathName, file.meta.name, file.meta.title, file.meta.description, file.meta.license, file.meta.nsfw, thumbnail, channelName);
|
||||
logger.debug('publish parameters:', publishParams);
|
||||
// publish the file
|
||||
publish(publishParams, file.name, file.meta.type)
|
||||
.then(result => {
|
||||
socket.emit('publish-complete', { name: publishParams.name, result });
|
||||
})
|
||||
.catch(error => {
|
||||
logger.error('Publish Error:', useObjectPropertiesIfNoKeys(error));
|
||||
socket.emit('publish-failure', error.message);
|
||||
});
|
||||
} else {
|
||||
socket.emit('publish-failure', 'File uploaded, but with errors');
|
||||
logger.error(`An error occurred in uploading the client's file`);
|
||||
// to-do: remove the file, if not done automatically
|
||||
}
|
||||
});
|
||||
// handle disconnect
|
||||
socket.on('disconnect', () => {
|
||||
logger.silly('a user disconnected via sockets');
|
||||
});
|
||||
});
|
||||
|
||||
return server;
|
||||
};
|
11
speech.js
|
@ -6,7 +6,7 @@ const expressHandlebars = require('express-handlebars');
|
|||
const Handlebars = require('handlebars');
|
||||
const handlebarsHelpers = require('./helpers/handlebarsHelpers.js');
|
||||
const { populateLocalsDotUser, serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
|
||||
const config = require('config');
|
||||
const config = require('./config/speechConfig.js');
|
||||
const logger = require('winston');
|
||||
const { getDownloadDirectory } = require('./helpers/lbryApi');
|
||||
const helmet = require('helmet');
|
||||
|
@ -17,9 +17,9 @@ const passport = require('passport');
|
|||
const cookieSession = require('cookie-session');
|
||||
|
||||
// configure logging
|
||||
const logLevel = config.get('Logging.LogLevel');
|
||||
const logLevel = config.logging.logLevel;
|
||||
require('./config/loggerConfig.js')(logger, logLevel);
|
||||
require('./config/slackLoggerConfig.js')(logger);
|
||||
require('./config/slackConfig.js')(logger);
|
||||
|
||||
// check for global config variables
|
||||
require('./helpers/configVarCheck.js')();
|
||||
|
@ -42,7 +42,7 @@ app.use((req, res, next) => { // custom logging middleware to log all incoming
|
|||
// initialize passport
|
||||
app.use(cookieSession({
|
||||
name : 'session',
|
||||
keys : [config.get('Session.SessionKey')],
|
||||
keys : [config.session.sessionKey],
|
||||
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
||||
}));
|
||||
app.use(passport.initialize());
|
||||
|
@ -82,7 +82,8 @@ db.sequelize
|
|||
require('./routes/page-routes.js')(app);
|
||||
require('./routes/serve-routes.js')(app);
|
||||
require('./routes/home-routes.js')(app);
|
||||
return require('./routes/sockets-routes.js')(app, siofu, hostedContentPath);
|
||||
const http = require('http');
|
||||
return http.Server(app);
|
||||
})
|
||||
.then(server => { // start the server
|
||||
server.listen(PORT, () => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="row">
|
||||
<div class="row row--padded">
|
||||
<h3>404: Not Found</h3>
|
||||
<p>That page does not exist. Return <a class="link--primary" href="/">home</a>.</p>
|
||||
</div>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="row row--tall flex-container--column">
|
||||
<form>
|
||||
<input class="input-file" type="file" id="siofu_input" name="siofu_input" accept="video/*,image/*" onchange="previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
|
||||
<input class="input-file" type="file" id="siofu_input" name="siofu_input" accept="video/*,image/*" onchange="publishFileFunctions.previewAndStageFile(event.target.files[0])" enctype="multipart/form-data"/>
|
||||
</form>
|
||||
<div id="primary-dropzone" class="dropzone row row--margined row--padded row--tall flex-container--column flex-container--center-center" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="dragenter_handler(event)" ondragleave="dragexit_handler(event)" onclick="triggerFileChooser('siofu_input', event)">
|
||||
<div id="primary-dropzone" class="dropzone row row--margined row--padded row--tall flex-container--column flex-container--center-center" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="dragenter_handler(event)" ondragleave="dragexit_handler(event)" onclick="publishFileFunctions.triggerFileChooser('siofu_input', event)">
|
||||
<div id="primary-dropzone-instructions">
|
||||
<p class="info-message-placeholder info-message--failure" id="input-error-file-selection" hidden="true"></p>
|
||||
<p>Drag & drop image or video here to publish</p>
|
||||
|
@ -22,7 +22,7 @@
|
|||
<div class="column column--5 column--sml-10" >
|
||||
<!-- preview -->
|
||||
<div class="row row--padded">
|
||||
<div id="asset-preview-holder" class="dropzone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="preview_onmouseenter_handler()" ondragleave="preview_onmouseleave_handler()" onmouseenter="preview_onmouseenter_handler()" onmouseleave="preview_onmouseleave_handler()" onclick="triggerFileChooser('siofu_input', event)">
|
||||
<div id="asset-preview-holder" class="dropzone" ondrop="drop_handler(event);" ondragover="dragover_handler(event);" ondragend="dragend_handler(event)" ondragenter="preview_onmouseenter_handler()" ondragleave="preview_onmouseleave_handler()" onmouseenter="preview_onmouseenter_handler()" onmouseleave="preview_onmouseleave_handler()" onclick="publishFileFunctions.triggerFileChooser('siofu_input', event)">
|
||||
<div id="asset-preview-dropzone-instructions" class="hidden">
|
||||
<p>Drag & drop image or video here</p>
|
||||
<p class="fine-print">OR</p>
|
||||
|
@ -50,105 +50,3 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="/socket.io/socket.io.js"></script>
|
||||
<script src="/siofu/client.js"></script>
|
||||
<script typ="text/javascript">
|
||||
|
||||
checkCookie();
|
||||
|
||||
const socket = io();
|
||||
const uploader = new SocketIOFileUpload(socket);
|
||||
let stagedFiles = null;
|
||||
|
||||
const publishFormWrapper = document.getElementById('publish-form');
|
||||
const publishStatus = document.getElementById('publish-status');
|
||||
const publishUpdate = document.getElementById('publish-update');
|
||||
const publishProgressBar = document.getElementById('publish-progress-bar');
|
||||
const uploadPercent = document.getElementById('upload-percent');
|
||||
|
||||
/* socketio-file-upload listeners */
|
||||
uploader.addEventListener('start', function(event){
|
||||
console.log('starting upload');
|
||||
addInputValuesToFileMetaData(event)
|
||||
// hide the publish tool
|
||||
hidePublishTools();
|
||||
// show the progress status and animation
|
||||
showPublishStatus();
|
||||
showPublishProgressBar();
|
||||
});
|
||||
uploader.addEventListener('progress', function(event){
|
||||
var percent = event.bytesLoaded / event.file.size * 100;
|
||||
updatePublishStatus('<p>File is loading to server</p>')
|
||||
updateUploadPercent(`<p class="blue">${percent.toFixed(2)}%</p>`)
|
||||
});
|
||||
/* socket.io message listeners */
|
||||
socket.on('publish-update', function(msg){
|
||||
updatePublishStatus(`<p>${msg}</p>`);
|
||||
updateUploadPercent(`<p>Curious what magic is happening here? <a class="link--primary" target="blank" href="https://lbry.io/faq/what-is-lbry">Learn more.</a></p>`);
|
||||
});
|
||||
socket.on('publish-failure', function(msg){
|
||||
updatePublishStatus('<p> --(✖╭╮✖)→ </p><p>' + JSON.stringify(msg) + '</p><strong>For help, post the above error text in the #speech channel on the <a class="link--primary" href="https://discord.gg/YjYbwhS" target="_blank">lbry discord</a></strong>');
|
||||
hidePublishProgressBar();
|
||||
hideUploadPercent();
|
||||
});
|
||||
socket.on('publish-complete', function(msg){
|
||||
const showUrl = msg.result.claim_id + "/" + msg.name;
|
||||
// update status
|
||||
updatePublishStatus('<p>Your publish is complete! You are being redirected to it now.</p>');
|
||||
updateUploadPercent('<p><a class="link--primary" target="_blank" href="\' + showUrl + \'">If you do not get redirected, click here.</a></p>')
|
||||
// redirect the user
|
||||
window.location.href = showUrl;
|
||||
});
|
||||
|
||||
function hidePublishTools() {
|
||||
publishFormWrapper.setAttribute('class', 'hidden');
|
||||
}
|
||||
// publish status functions
|
||||
function showPublishStatus() {
|
||||
publishStatus.setAttribute('class', 'row row--tall flex-container--column flex-container--center-center');
|
||||
}
|
||||
function updatePublishStatus(msg){
|
||||
publishUpdate.innerHTML = msg;
|
||||
}
|
||||
// progress bar functions
|
||||
function showPublishProgressBar(){
|
||||
createProgressBar(publishProgressBar, 12);
|
||||
}
|
||||
function hidePublishProgressBar(){
|
||||
publishProgressBar.hidden = true;
|
||||
}
|
||||
// upload percent functions
|
||||
function updateUploadPercent(msg){
|
||||
uploadPercent.innerHTML = msg;
|
||||
}
|
||||
function hideUploadPercent(){
|
||||
uploadPercent.hidden = true;
|
||||
}
|
||||
|
||||
function addInputValuesToFileMetaData(event) {
|
||||
// get values from inputs
|
||||
const name = document.getElementById('claim-name-input').value.trim();
|
||||
const title = document.getElementById('publish-title').value.trim();
|
||||
const description = document.getElementById('publish-description').value.trim();
|
||||
const license = document.getElementById('publish-license').value.trim();
|
||||
const nsfw = document.getElementById('publish-nsfw').checked;
|
||||
const anonymous = document.getElementById('anonymous-select').checked;
|
||||
const channel = document.getElementById('channel-name-select').value.trim();
|
||||
const thumbnail = document.getElementById('claim-thumbnail-input').value.trim();
|
||||
// set values on file meta data
|
||||
event.file.meta.name = name;
|
||||
event.file.meta.title = title;
|
||||
event.file.meta.description = description;
|
||||
event.file.meta.license = license;
|
||||
event.file.meta.nsfw = nsfw;
|
||||
event.file.meta.type = stagedFiles[0].type;
|
||||
if (!anonymous) {
|
||||
event.file.meta.channel = channel;
|
||||
}
|
||||
if (thumbnail && (thumbnail.trim !== '')){
|
||||
event.file.meta.thumbnail = thumbnail;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
</div><div class="column column--6 column--sml-10">
|
||||
<div class="input-text--primary flex-container--row flex-container--left-bottom">
|
||||
<span>@</span>
|
||||
<input type="text" name="new-channel-name" id="new-channel-name" class="input-text" placeholder="exampleChannelName" value="" oninput="checkChannelName(event.target.value)">
|
||||
<input type="text" name="new-channel-name" id="new-channel-name" class="input-text" placeholder="exampleChannelName" value="" oninput="validationFunctions.checkChannelName(event.target.value)">
|
||||
<span id="input-success-channel-name" class="info-message--success"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<div class="column column--10">
|
||||
<form>
|
||||
<div class="column column--3 column--med-10">
|
||||
<input type="radio" name="anonymous-or-channel" id="anonymous-select" class="input-radio" value="anonymous" {{#unless user}}checked {{/unless}} onchange="toggleChannel(event.target.value)"/>
|
||||
<label class="label label--pointer" for="anonymous-select">Anonymous</label>
|
||||
<input type="radio" name="anonymous-or-channel" id="anonymous-radio" class="input-radio" value="anonymous" {{#unless user}}checked {{/unless}} onchange="toggleChannel(event.target.value)"/>
|
||||
<label class="label label--pointer" for="anonymous-radio">Anonymous</label>
|
||||
</div><div class="column column--7 column--med-10">
|
||||
<input type="radio" name="anonymous-or-channel" id="in-a-channel-select" class="input-radio" value="in a channel" {{#if user}}checked {{/if}} onchange="toggleChannel(event.target.value)"/>
|
||||
<label class="label label--pointer" for="in-a-channel-select">In a channel</label>
|
||||
<input type="radio" name="anonymous-or-channel" id="channel-radio" class="input-radio" value="in a channel" {{#if user}}checked {{/if}} onchange="toggleChannel(event.target.value)"/>
|
||||
<label class="label label--pointer" for="channel-radio">In a channel</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="row row--padded row--wide">
|
||||
<div class="input-error" id="input-error-publish-submit" hidden="true"></div>
|
||||
<button id="publish-submit" class="button--primary button--large" onclick="publishStagedFile(event)">Upload</button>
|
||||
<button id="publish-submit" class="button--primary button--large" onclick="publishFileFunctions.publishStagedFile(event)">Upload</button>
|
||||
</div>
|
||||
<div class="row row--short align-content-center">
|
||||
<button class="button--cancel" onclick="cancelPublish()">Cancel</button>
|
||||
<button class="button--cancel" onclick="publishFileFunctions.cancelPublish()">Cancel</button>
|
||||
</div>
|
||||
<div class="row row--short align-content-center">
|
||||
<p class="fine-print">By clicking 'Upload', you affirm that you have the rights to publish this content to the LBRY network, and that you understand the properties of publishing it to a decentralized, user-controlled network. <a class="link--primary" target="_blank" href="https://lbry.io/learn">Read more.</a></p>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<span id="url-channel" class="url-text--secondary" {{#if user}}{{else}}hidden="true"{{/if}}>{{user.channelName}}:{{user.shortChannelId}}</span>
|
||||
<span id="url-no-channel-placeholder" class="url-text--secondary tooltip" {{#if user}}hidden="true"{{else}}{{/if}}>xyz<span class="tooltip-text">This will be a random id</span></span>
|
||||
<span id="url-channel-placeholder" class="url-text--secondary tooltip" hidden="true">@channel<span class="tooltip-text">Select a channel above</span></span> /
|
||||
<input type="text" id="claim-name-input" class="input-text" placeholder="your-url-here" oninput="checkClaimName(event.target.value)">
|
||||
<input type="text" id="claim-name-input" class="input-text" placeholder="your-url-here" oninput="validationFunctions.checkClaimName(event.target.value)">
|
||||
<span id="input-success-claim-name" class="info-message--success span--absolute"></span>
|
||||
</div>
|
||||
|
||||
|
|
Missing
let
?