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
|
* start spee.ch
|
||||||
* clone this repo
|
* clone this repo
|
||||||
* run `npm install`
|
* run `npm install`
|
||||||
* to start the server, from your command line run `node speech.js` while passing three environmental variables:
|
* create your `speechConfig.js` file
|
||||||
* (1) your lbry wallet address (`LBRY_CLAIM_ADDRESS`),
|
* copy `speechConfig.js.example` and name it `speechConfig.js`
|
||||||
* (2) your mysql username (`MYSQL_USERNAME`),
|
* replace the `null` values in the config file with the appropriate values for your environement
|
||||||
* (2) your mysql password (`MYSQL_PASSWORD`),
|
* to start the server, from your command line run `node speech.js`
|
||||||
* (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`
|
|
||||||
* To run hot, use `nodemon` instead of `node`
|
* To run hot, use `nodemon` instead of `node`
|
||||||
* visit [localhost:3000](http://localhost:3000)
|
* 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
|
#### POST
|
||||||
* /api/publish
|
* /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:
|
* Parameters:
|
||||||
* name (string)
|
* `name`
|
||||||
* nsfw (boolean)
|
* `file` (.mp4, .jpeg, .jpg, .gif, or .png)
|
||||||
* file (.mp4, .jpeg, .jpg, .gif, or .png)
|
* `nsfw` (optional)
|
||||||
* license (string, optional)
|
* `license` (optional)
|
||||||
* title (string, optional)
|
* `title` (optional)
|
||||||
* description (string, optional)
|
* `description` (optional)
|
||||||
* thumbnail (string, optional) (for .mp4 uploads only)
|
* `thumbnail` url to thumbnail image, for .mp4 uploads only (optional)
|
||||||
* channelName(string, optional)
|
* `channelName`(optional)
|
||||||
* channelPassword (string, optional)
|
* `channelPassword` (optional,; required if `channelName` is provided)
|
||||||
|
|
||||||
## bugs
|
## bugs
|
||||||
If you find a bug or experience a problem, please report your issue here on github and find us in the lbry slack!
|
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 = {
|
module.exports = {
|
||||||
authenticateChannelCredentials (channelName, userPassword) {
|
authenticateChannelCredentials (channelName, userPassword) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!channelName) {
|
|
||||||
resolve(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const userName = channelName.substring(1);
|
const userName = channelName.substring(1);
|
||||||
logger.debug(`authenticateChannelCredentials > channelName: ${channelName} username: ${userName} pass: ${userPassword}`);
|
logger.debug(`authenticateChannelCredentials > channelName: ${channelName} username: ${userName} pass: ${userPassword}`);
|
||||||
db.User
|
db.User
|
||||||
|
@ -18,18 +14,32 @@ module.exports = {
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
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');
|
logger.debug('incorrect password');
|
||||||
resolve(false);
|
resolve(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.debug('user found:', user.dataValues);
|
logger.debug('...password was a match...');
|
||||||
resolve(true);
|
resolve(true);
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error(error);
|
reject(error);
|
||||||
reject();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
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 = {
|
module.exports = {
|
||||||
publish (publishParams, fileName, fileType) {
|
publish (publishParams, fileName, fileType) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let publishResults = {};
|
let publishResults, certificateId, channelName;
|
||||||
// 1. publish the file
|
// publish the file
|
||||||
return lbryApi.publishClaim(publishParams)
|
return lbryApi.publishClaim(publishParams)
|
||||||
// 2. upsert File record (update is in case the claim has been published before by this daemon)
|
|
||||||
.then(tx => {
|
.then(tx => {
|
||||||
logger.info(`Successfully published ${fileName}`, tx);
|
logger.info(`Successfully published ${fileName}`, tx);
|
||||||
publishResults = 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 => {
|
.then(channel => {
|
||||||
let certificateId;
|
// set channel information
|
||||||
|
certificateId = null;
|
||||||
|
channelName = null;
|
||||||
if (channel) {
|
if (channel) {
|
||||||
certificateId = channel.channelClaimId;
|
certificateId = channel.channelClaimId;
|
||||||
logger.debug('successfully found channel in Channel table');
|
channelName = channel.channelName;
|
||||||
} else {
|
}
|
||||||
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
|
|||||||
certificateId = null;
|
logger.debug(`certificateId: ${certificateId}`);
|
||||||
logger.debug('channel for publish not found in Channel table');
|
})
|
||||||
};
|
.then(() => {
|
||||||
|
// create the File record
|
||||||
const fileRecord = {
|
const fileRecord = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId : publishResults.claim_id,
|
claimId : publishResults.claim_id,
|
||||||
|
@ -37,6 +46,7 @@ module.exports = {
|
||||||
fileType,
|
fileType,
|
||||||
nsfw : publishParams.metadata.nsfw,
|
nsfw : publishParams.metadata.nsfw,
|
||||||
};
|
};
|
||||||
|
// create the Claim record
|
||||||
const claimRecord = {
|
const claimRecord = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId : publishResults.claim_id,
|
claimId : publishResults.claim_id,
|
||||||
|
@ -48,14 +58,16 @@ module.exports = {
|
||||||
height : 0,
|
height : 0,
|
||||||
contentType: fileType,
|
contentType: fileType,
|
||||||
nsfw : publishParams.metadata.nsfw,
|
nsfw : publishParams.metadata.nsfw,
|
||||||
certificateId,
|
|
||||||
amount : publishParams.bid,
|
amount : publishParams.bid,
|
||||||
|
certificateId,
|
||||||
|
channelName,
|
||||||
};
|
};
|
||||||
|
// upsert criteria
|
||||||
const upsertCriteria = {
|
const upsertCriteria = {
|
||||||
name : publishParams.name,
|
name : publishParams.name,
|
||||||
claimId: publishResults.claim_id,
|
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')]);
|
return Promise.all([db.upsert(db.File, fileRecord, upsertCriteria, 'File'), db.upsert(db.Claim, claimRecord, upsertCriteria, 'Claim')]);
|
||||||
})
|
})
|
||||||
.then(([file, claim]) => {
|
.then(([file, claim]) => {
|
||||||
|
@ -67,7 +79,6 @@ module.exports = {
|
||||||
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('publishController.publish, error', error);
|
|
||||||
publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file
|
publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const ua = require('universal-analytics');
|
const ua = require('universal-analytics');
|
||||||
const config = require('config');
|
const config = require('../config/speechConfig.js');
|
||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
const googleApiKey = config.analytics.googleId;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
postToStats (action, url, ipAddress, name, claimId, result) {
|
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 logger = require('winston');
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
module.exports = function () {
|
module.exports = function () {
|
||||||
// get the config file
|
// get the config file
|
||||||
const defaultConfigFile = JSON.parse(fs.readFileSync('./config/default.json'));
|
|
||||||
|
|
||||||
for (let configCategoryKey in defaultConfigFile) {
|
for (let configCategoryKey in config) {
|
||||||
if (defaultConfigFile.hasOwnProperty(configCategoryKey)) {
|
if (config.hasOwnProperty(configCategoryKey)) {
|
||||||
// get the final variables for each config category
|
// get the final variables for each config category
|
||||||
const configVariables = config.get(configCategoryKey);
|
const configVariables = config[configCategoryKey];
|
||||||
for (let configVarKey in configVariables) {
|
for (let configVarKey in configVariables) {
|
||||||
if (configVariables.hasOwnProperty(configVarKey)) {
|
if (configVariables.hasOwnProperty(configVarKey)) {
|
||||||
// print each variable
|
// print each variable
|
||||||
|
|
|
@ -2,38 +2,54 @@ const logger = require('winston');
|
||||||
const { postToStats } = require('../controllers/statsController.js');
|
const { postToStats } = require('../controllers/statsController.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
handleRequestError (action, originalUrl, ip, error, res) {
|
returnErrorMessageAndStatus: function (error) {
|
||||||
logger.error(`Request Error: ${originalUrl}`, module.exports.useObjectPropertiesIfNoKeys(error));
|
let status, message;
|
||||||
postToStats(action, originalUrl, ip, null, null, error);
|
// check for daemon being turned off
|
||||||
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));
|
|
||||||
if (error.code === 'ECONNREFUSED') {
|
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) {
|
} else if (error.response) {
|
||||||
|
status = error.response.status || 500;
|
||||||
if (error.response.data) {
|
if (error.response.data) {
|
||||||
if (error.response.data.message) {
|
if (error.response.data.message) {
|
||||||
return error.response.data.message;
|
message = error.response.data.message;
|
||||||
} else if (error.response.data.error) {
|
} else if (error.response.data.error) {
|
||||||
return error.response.data.error.message;
|
message = error.response.data.error.message;
|
||||||
}
|
|
||||||
return error.response.data;
|
|
||||||
}
|
|
||||||
return error.response;
|
|
||||||
} else {
|
} 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) {
|
if (Object.keys(err).length === 0) {
|
||||||
let newErrorObject = {};
|
let newErrorObject = {};
|
||||||
Object.getOwnPropertyNames(err).forEach((key) => {
|
Object.getOwnPropertyNames(err).forEach((key) => {
|
||||||
|
@ -43,4 +59,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return err;
|
return err;
|
||||||
},
|
},
|
||||||
|
createErrorResponsePayload (status, message) {
|
||||||
|
return {
|
||||||
|
status,
|
||||||
|
success: false,
|
||||||
|
message,
|
||||||
|
};
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
const Handlebars = require('handlebars');
|
const Handlebars = require('handlebars');
|
||||||
const config = require('config');
|
const config = require('../config/speechConfig.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// define any extra helpers you may need
|
// define any extra helpers you may need
|
||||||
googleAnalytics () {
|
googleAnalytics () {
|
||||||
const googleApiKey = config.get('AnalyticsConfig.GoogleId');
|
const googleApiKey = config.analytics.googleId;
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
`<script>
|
`<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(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 logger = require('winston');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
const config = require('config');
|
const config = require('../config/speechConfig.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
validateApiPublishRequest (body, files) {
|
validateApiPublishRequest (body, files) {
|
||||||
|
@ -11,9 +11,6 @@ module.exports = {
|
||||||
if (!body.name) {
|
if (!body.name) {
|
||||||
throw new Error('no name field found in request');
|
throw new Error('no name field found in request');
|
||||||
}
|
}
|
||||||
if (!body.nsfw) {
|
|
||||||
throw new Error('no nsfw field found in request');
|
|
||||||
}
|
|
||||||
if (!files) {
|
if (!files) {
|
||||||
throw new Error('no files found in request');
|
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');
|
throw new Error('no file with key of [file] found in request');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validatePublishSubmission (file, claimName, nsfw) {
|
validatePublishSubmission (file, claimName) {
|
||||||
try {
|
try {
|
||||||
module.exports.validateFile(file);
|
module.exports.validateFile(file);
|
||||||
module.exports.validateClaimName(claimName);
|
module.exports.validateClaimName(claimName);
|
||||||
module.exports.validateNSFW(nsfw);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw 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');
|
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) {
|
cleanseChannelName (channelName) {
|
||||||
if (channelName) {
|
if (channelName) {
|
||||||
if (channelName.indexOf('@') !== 0) {
|
if (channelName.indexOf('@') !== 0) {
|
||||||
|
@ -105,12 +83,6 @@ module.exports = {
|
||||||
}
|
}
|
||||||
return channelName;
|
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) {
|
createPublishParams (filePath, name, title, description, license, nsfw, thumbnail, channelName) {
|
||||||
logger.debug(`Creating Publish Parameters`);
|
logger.debug(`Creating Publish Parameters`);
|
||||||
// provide defaults for title
|
// provide defaults for title
|
||||||
|
@ -138,7 +110,7 @@ module.exports = {
|
||||||
license,
|
license,
|
||||||
nsfw,
|
nsfw,
|
||||||
},
|
},
|
||||||
claim_address: config.get('WalletConfig.LbryClaimAddress'),
|
claim_address: config.wallet.lbryClaimAddress,
|
||||||
};
|
};
|
||||||
// add thumbnail to channel if video
|
// add thumbnail to channel if video
|
||||||
if (thumbnail !== null) {
|
if (thumbnail !== null) {
|
||||||
|
@ -165,7 +137,7 @@ module.exports = {
|
||||||
db.File.findAll({ where: { name } })
|
db.File.findAll({ where: { name } })
|
||||||
.then(result => {
|
.then(result => {
|
||||||
if (result.length >= 1) {
|
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
|
// filter out any results that were not published from spee.ch's wallet address
|
||||||
const filteredResult = result.filter((claim) => {
|
const filteredResult = result.filter((claim) => {
|
||||||
return (claim.address === claimAddress);
|
return (claim.address === claimAddress);
|
||||||
|
|
|
@ -298,7 +298,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, ARRAY, DECIMAL, D
|
||||||
case 1:
|
case 1:
|
||||||
return resolve(result[0]);
|
return resolve(result[0]);
|
||||||
default:
|
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]);
|
return resolve(result[0]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,13 +2,13 @@ const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const Sequelize = require('sequelize');
|
const Sequelize = require('sequelize');
|
||||||
const basename = path.basename(module.filename);
|
const basename = path.basename(module.filename);
|
||||||
const config = require('config');
|
const config = require('../config/speechConfig.js');
|
||||||
const db = {};
|
const db = {};
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
|
|
||||||
const database = config.get('Database.Database');
|
const database = config.sql.database;
|
||||||
const username = config.get('Database.Username');
|
const username = config.sql.username;
|
||||||
const password = config.get('Database.Password');
|
const password = config.sql.password;
|
||||||
|
|
||||||
const sequelize = new Sequelize(database, username, password, {
|
const sequelize = new Sequelize(database, username, password, {
|
||||||
host : 'localhost',
|
host : 'localhost',
|
||||||
|
@ -66,7 +66,7 @@ db.upsert = (Model, values, condition, tableName) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.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) {
|
User.prototype.comparePassword = function (password, callback) {
|
||||||
logger.debug(`User.prototype.comparePassword ${password} ${this.password}`);
|
|
||||||
bcrypt.compare(password, this.password, callback);
|
bcrypt.compare(password, this.password, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
"cookie-session": "^2.0.0-beta.3",
|
"cookie-session": "^2.0.0-beta.3",
|
||||||
"express": "^4.15.2",
|
"express": "^4.15.2",
|
||||||
"express-handlebars": "^3.0.0",
|
"express-handlebars": "^3.0.0",
|
||||||
"express-session": "^1.15.5",
|
|
||||||
"form-data": "^2.3.1",
|
"form-data": "^2.3.1",
|
||||||
"helmet": "^3.8.1",
|
"helmet": "^3.8.1",
|
||||||
"mysql2": "^1.3.5",
|
"mysql2": "^1.3.5",
|
||||||
|
@ -44,8 +43,6 @@
|
||||||
"sequelize": "^4.1.0",
|
"sequelize": "^4.1.0",
|
||||||
"sequelize-cli": "^3.0.0-3",
|
"sequelize-cli": "^3.0.0-3",
|
||||||
"sleep": "^5.1.1",
|
"sleep": "^5.1.1",
|
||||||
"socket.io": "^2.0.1",
|
|
||||||
"socketio-file-upload": "^0.6.0",
|
|
||||||
"universal-analytics": "^0.4.13",
|
"universal-analytics": "^0.4.13",
|
||||||
"winston": "^2.3.1",
|
"winston": "^2.3.1",
|
||||||
"winston-slack-webhook": "billbitt/winston-slack-webhook"
|
"winston-slack-webhook": "billbitt/winston-slack-webhook"
|
||||||
|
|
|
@ -24,7 +24,7 @@ function publishNewChannel (event) {
|
||||||
// prevent default so this script can handle submission
|
// prevent default so this script can handle submission
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
// validate submission
|
// validate submission
|
||||||
validateNewChannelSubmission(userName, password)
|
validationFunctions.validateNewChannelSubmission(userName, password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
showChannelCreateInProgressDisplay();
|
showChannelCreateInProgressDisplay();
|
||||||
return sendAuthRequest(userName, password, '/signup') // post the request
|
return sendAuthRequest(userName, password, '/signup') // post the request
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
function triggerFileChooser(fileInputId, event) {
|
|
||||||
document.getElementById(fileInputId).click();
|
|
||||||
}
|
|
||||||
|
|
||||||
function drop_handler(event) {
|
function drop_handler(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -9,7 +6,7 @@ function drop_handler(event) {
|
||||||
if (dt.items) {
|
if (dt.items) {
|
||||||
if (dt.items[0].kind == 'file') {
|
if (dt.items[0].kind == 'file') {
|
||||||
var droppedFile = dt.items[0].getAsFile();
|
var droppedFile = dt.items[0].getAsFile();
|
||||||
previewAndStageFile(droppedFile);
|
publishFileFunctions.previewAndStageFile(droppedFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ function getRequest (url) {
|
||||||
if ( xhttp.status == 200) {
|
if ( xhttp.status == 200) {
|
||||||
resolve(xhttp.response);
|
resolve(xhttp.response);
|
||||||
} else if (xhttp.status == 401) {
|
} else if (xhttp.status == 401) {
|
||||||
reject('Wrong username or password');
|
reject('Wrong channel name or password');
|
||||||
} else {
|
} else {
|
||||||
reject('request failed with status:' + xhttp.status);
|
reject('request failed with status:' + xhttp.status);
|
||||||
};
|
};
|
||||||
|
@ -29,7 +29,7 @@ function postRequest (url, params) {
|
||||||
if ( xhttp.status == 200) {
|
if ( xhttp.status == 200) {
|
||||||
resolve(xhttp.response);
|
resolve(xhttp.response);
|
||||||
} else if (xhttp.status == 401) {
|
} else if (xhttp.status == 401) {
|
||||||
reject( new AuthenticationError('Wrong username or password'));
|
reject( new AuthenticationError('Wrong channel name or password'));
|
||||||
} else {
|
} else {
|
||||||
reject('request failed with status:' + xhttp.status);
|
reject('request failed with status:' + xhttp.status);
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ function loginToChannel (event) {
|
||||||
const password = document.getElementById('channel-login-password-input').value;
|
const password = document.getElementById('channel-login-password-input').value;
|
||||||
// prevent default
|
// prevent default
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
validateNewChannelLogin(userName, password)
|
validationFunctions.validateNewChannelLogin(userName, password)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// send request
|
// send request
|
||||||
return sendAuthRequest(userName, password, '/login')
|
return sendAuthRequest(userName, password, '/login')
|
||||||
|
@ -71,9 +71,9 @@ function loginToChannel (event) {
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
|
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
|
||||||
if (error.name){
|
if (error.name){
|
||||||
showError(loginErrorDisplayElement, error.message);
|
validationFunctions.showError(loginErrorDisplayElement, error.message);
|
||||||
} else {
|
} 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 */
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 () {
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 = '/';
|
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.
|
|||||||
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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.
|
|||||||
const fileSelectionInputError = document.getElementById('input-error-file-selection');
|
const fileSelectionInputError = document.getElementById('input-error-file-selection');
|
||||||
const thumbnailSelectionTool = document.getElementById('publish-thumbnail');
|
// 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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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');
|
// 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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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.
|
|||||||
try {
|
try {
|
||||||
validateFile(selectedFile);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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) {
|
} catch (error) {
|
||||||
showError(fileSelectionInputError, error.message);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
return;
|
||||||
}
|
}
|
||||||
// set the image preview, if an image was provided
|
// 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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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') {
|
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') {
|
if (selectedFile.type === 'image/gif') {
|
||||||
assetPreview.innerHTML = `<p>loading preview...</p>`
|
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"/>';
|
assetPreview.innerHTML = '<img id="asset-preview" src="' + previewReader.result + '" alt="image preview"/>';
|
||||||
};
|
};
|
||||||
// clear & hide the thumbnail selection input
|
// clear & hide the thumbnail selection input
|
||||||
thumbnailSelectionInput.value = '';
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 {
|
} else {
|
||||||
assetPreview.innerHTML = `<img id="asset-preview" src="/assets/img/video_thumb_default.png"/>`;
|
assetPreview.innerHTML = `<img id="asset-preview" src="/assets/img/video_thumb_default.png"/>`;
|
||||||
// clear & show the thumbnail selection input
|
// clear & show the thumbnail selection input
|
||||||
thumbnailSelectionInput.value = '';
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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');
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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')
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 === "") {
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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('.'))
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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.
|
|||||||
}
|
}
|
||||||
// store the selected file for upload
|
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.
|
|||||||
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.
|
|||||||
}
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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.
|
|||||||
|
|
||||||
// Validate the publish submission and then trigger upload
|
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.
|
|||||||
function publishStagedFile(event) {
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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();
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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
|
||||||
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 fileSelectionInputError = document.getElementById('input-error-file-selection');
|
||||||
const claimNameError = document.getElementById('input-error-claim-name');
|
const claimNameError = document.getElementById('input-error-claim-name');
|
||||||
const channelSelectError = document.getElementById('input-error-channel-select');
|
const channelSelectError = document.getElementById('input-error-channel-select');
|
||||||
const publishSubmitError = document.getElementById('input-error-publish-submit');
|
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
|
// validate, submit, and handle response
|
||||||
validateFilePublishSubmission(stagedFiles, claimName, channelName)
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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(() => {
|
.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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 => {
|
.catch(error => {
|
||||||
if (error.name === 'FileError') {
|
if (error.name === 'FileError') {
|
||||||
showError(fileSelectionInputError, error.message);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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') {
|
} else if (error.name === 'NameError') {
|
||||||
showError(claimNameError, error.message);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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'){
|
} else if (error.name === 'ChannelNameError'){
|
||||||
console.log(error);
|
console.log(error);
|
||||||
showError(channelSelectError, error.message);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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 {
|
} else {
|
||||||
showError(publishSubmitError, error.message);
|
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.
Presumably Presumably `const`
Late on catching this one, but this function name doesn't imply it is 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;
|
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
|
// validation function which checks the proposed file's type, size, and name
|
||||||
function validateFile(file) {
|
const validationFunctions = {
|
||||||
|
validateFile: function (file) {
|
||||||
if (!file) {
|
if (!file) {
|
||||||
console.log('no file found');
|
console.log('no file found');
|
||||||
throw new Error('no file provided');
|
throw new Error('no file provided');
|
||||||
|
@ -13,19 +14,19 @@ function validateFile(file) {
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
case 'image/jpg':
|
case 'image/jpg':
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
if (file.size > 10000000){
|
if (file.size > 10000000) {
|
||||||
console.log('file was too big');
|
console.log('file was too big');
|
||||||
throw new Error('Sorry, images are limited to 10 megabytes.');
|
throw new Error('Sorry, images are limited to 10 megabytes.');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'image/gif':
|
case 'image/gif':
|
||||||
if (file.size > 50000000){
|
if (file.size > 50000000) {
|
||||||
console.log('file was too big');
|
console.log('file was too big');
|
||||||
throw new Error('Sorry, .gifs are limited to 50 megabytes.');
|
throw new Error('Sorry, .gifs are limited to 50 megabytes.');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'video/mp4':
|
case 'video/mp4':
|
||||||
if (file.size > 50000000){
|
if (file.size > 50000000) {
|
||||||
console.log('file was too big');
|
console.log('file was too big');
|
||||||
throw new Error('Sorry, videos are limited to 50 megabytes.');
|
throw new Error('Sorry, videos are limited to 50 megabytes.');
|
||||||
}
|
}
|
||||||
|
@ -34,10 +35,10 @@ function validateFile(file) {
|
||||||
console.log('file type is not supported');
|
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.')
|
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
|
||||||
// validation function that checks to make sure the claim name is valid
|
validateClaimName: function (name) {
|
||||||
function validateClaimName (name) {
|
console.log('validating the claim name');
|
||||||
// ensure a name was entered
|
// ensure a name was entered
|
||||||
if (name.length < 1) {
|
if (name.length < 1) {
|
||||||
throw new NameError("You must enter a name for your url");
|
throw new NameError("You must enter a name for your url");
|
||||||
|
@ -47,9 +48,8 @@ function validateClaimName (name) {
|
||||||
if (invalidCharacters) {
|
if (invalidCharacters) {
|
||||||
throw new NameError('"' + invalidCharacters + '" characters are not allowed');
|
throw new NameError('"' + invalidCharacters + '" characters are not allowed');
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
validateChannelName: function (name) {
|
||||||
function validateChannelName (name) {
|
|
||||||
name = name.substring(name.indexOf('@') + 1);
|
name = name.substring(name.indexOf('@') + 1);
|
||||||
// ensure a name was entered
|
// ensure a name was entered
|
||||||
if (name.length < 1) {
|
if (name.length < 1) {
|
||||||
|
@ -60,87 +60,79 @@ function validateChannelName (name) {
|
||||||
if (invalidCharacters) {
|
if (invalidCharacters) {
|
||||||
throw new ChannelNameError('"' + invalidCharacters + '" characters are not allowed');
|
throw new ChannelNameError('"' + invalidCharacters + '" characters are not allowed');
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
validatePassword: function (password) {
|
||||||
function validatePassword (password) {
|
|
||||||
if (password.length < 1) {
|
if (password.length < 1) {
|
||||||
throw new ChannelPasswordError("You must enter a password for you channel");
|
throw new ChannelPasswordError("You must enter a password for you channel");
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
cleanseClaimName: function (name) {
|
||||||
function cleanseClaimName(name) {
|
|
||||||
name = name.replace(/\s+/g, '-'); // replace spaces with dashes
|
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 '-'
|
name = name.replace(/[^A-Za-z0-9-]/g, ''); // remove all characters that are not A-Z, a-z, 0-9, or '-'
|
||||||
return name;
|
return name;
|
||||||
}
|
},
|
||||||
|
// validation functions to check claim & channel name eligibility as the inputs change
|
||||||
// validation functions to check claim & channel name eligibility as the inputs change
|
isNameAvailable: function (name, apiUrl) {
|
||||||
|
|
||||||
function isNameAvailable (name, apiUrl) {
|
|
||||||
const url = apiUrl + name;
|
const url = apiUrl + name;
|
||||||
return getRequest(url)
|
return getRequest(url)
|
||||||
}
|
},
|
||||||
|
showError: function (errorDisplay, errorMsg) {
|
||||||
function showError(errorDisplay, errorMsg) {
|
|
||||||
errorDisplay.hidden = false;
|
errorDisplay.hidden = false;
|
||||||
errorDisplay.innerText = errorMsg;
|
errorDisplay.innerText = errorMsg;
|
||||||
}
|
},
|
||||||
|
hideError: function (errorDisplay) {
|
||||||
function hideError(errorDisplay) {
|
|
||||||
errorDisplay.hidden = true;
|
errorDisplay.hidden = true;
|
||||||
errorDisplay.innerText = '';
|
errorDisplay.innerText = '';
|
||||||
}
|
},
|
||||||
|
showSuccess: function (successElement) {
|
||||||
function showSuccess (successElement) {
|
|
||||||
successElement.hidden = false;
|
successElement.hidden = false;
|
||||||
successElement.innerHTML = "✔";
|
successElement.innerHTML = "✔";
|
||||||
}
|
},
|
||||||
|
hideSuccess: function (successElement) {
|
||||||
function hideSuccess (successElement) {
|
|
||||||
successElement.hidden = true;
|
successElement.hidden = true;
|
||||||
successElement.innerHTML = "";
|
successElement.innerHTML = "";
|
||||||
}
|
},
|
||||||
|
checkAvailability: function (name, successDisplayElement, errorDisplayElement, validateName, errorMessage, apiUrl) {
|
||||||
function checkAvailability(name, successDisplayElement, errorDisplayElement, validateName, isNameAvailable, errorMessage, apiUrl) {
|
var that = this;
|
||||||
try {
|
try {
|
||||||
// check to make sure the characters are valid
|
// check to make sure the characters are valid
|
||||||
validateName(name);
|
validateName(name);
|
||||||
// check to make sure it is available
|
// check to make sure it is available
|
||||||
isNameAvailable(name, apiUrl)
|
that.isNameAvailable(name, apiUrl)
|
||||||
.then(result => {
|
.then(function (result) {
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
hideError(errorDisplayElement);
|
that.hideError(errorDisplayElement);
|
||||||
showSuccess(successDisplayElement)
|
that.showSuccess(successDisplayElement)
|
||||||
} else {
|
} else {
|
||||||
hideSuccess(successDisplayElement);
|
that.hideSuccess(successDisplayElement);
|
||||||
showError(errorDisplayElement, errorMessage);
|
that.showError(errorDisplayElement, errorMessage);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
hideSuccess(successDisplayElement);
|
that.hideSuccess(successDisplayElement);
|
||||||
showError(errorDisplayElement, error.message);
|
that.showError(errorDisplayElement, error.message);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
hideSuccess(successDisplayElement);
|
that.hideSuccess(successDisplayElement);
|
||||||
showError(errorDisplayElement, error.message);
|
that.showError(errorDisplayElement, error.message);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
checkClaimName: function (name) {
|
||||||
function checkClaimName(name){
|
|
||||||
const successDisplayElement = document.getElementById('input-success-claim-name');
|
const successDisplayElement = document.getElementById('input-success-claim-name');
|
||||||
const errorDisplayElement = document.getElementById('input-error-claim-name');
|
const errorDisplayElement = document.getElementById('input-error-claim-name');
|
||||||
checkAvailability(name, successDisplayElement, errorDisplayElement, validateClaimName, isNameAvailable, 'Sorry, that ending is already taken', '/api/isClaimAvailable/');
|
this.checkAvailability(name, successDisplayElement, errorDisplayElement, this.validateClaimName, 'Sorry, that ending is already taken', '/api/isClaimAvailable/');
|
||||||
}
|
},
|
||||||
|
checkChannelName: function (name) {
|
||||||
function checkChannelName(name){
|
|
||||||
const successDisplayElement = document.getElementById('input-success-channel-name');
|
const successDisplayElement = document.getElementById('input-success-channel-name');
|
||||||
const errorDisplayElement = document.getElementById('input-error-channel-name');
|
const errorDisplayElement = document.getElementById('input-error-channel-name');
|
||||||
name = `@${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
|
||||||
// validation function which checks all aspects of the publish submission
|
validateFilePublishSubmission: function (stagedFiles, metadata) {
|
||||||
function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
const channelName = metadata.channelName;
|
||||||
|
const claimName = metadata.name;
|
||||||
|
var that = this;
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
// 1. make sure 1 file was staged
|
// 1. make sure 1 file was staged
|
||||||
if (!stagedFiles) {
|
if (!stagedFiles) {
|
||||||
|
@ -152,7 +144,7 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
||||||
}
|
}
|
||||||
// 2. validate the file's name, type, and size
|
// 2. validate the file's name, type, and size
|
||||||
try {
|
try {
|
||||||
validateFile(stagedFiles[0]);
|
that.validateFile(stagedFiles[0]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
return;
|
return;
|
||||||
|
@ -161,16 +153,17 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
||||||
if (channelName === 'new' || channelName === 'login') {
|
if (channelName === 'new' || channelName === 'login') {
|
||||||
reject(new ChannelNameError("Please log in to a channel"));
|
reject(new ChannelNameError("Please log in to a channel"));
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
// 4. validate the claim name
|
// 4. validate the claim name
|
||||||
try {
|
try {
|
||||||
validateClaimName(claimName);
|
that.validateClaimName(claimName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(error);
|
reject(error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if all validation passes, check availability of the name (note: do we need to re-validate channel name vs. credentials as well?)
|
// 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 => {
|
.then(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -182,55 +175,57 @@ function validateFilePublishSubmission(stagedFiles, claimName, channelName){
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
// validation function which checks all aspects of a new channel submission
|
||||||
// validation function which checks all aspects of a new channel submission
|
validateNewChannelSubmission: function (userName, password) {
|
||||||
function validateNewChannelSubmission(userName, password){
|
|
||||||
const channelName = `@${userName}`;
|
const channelName = `@${userName}`;
|
||||||
|
var that = this;
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
// 1. validate name
|
// 1. validate name
|
||||||
try {
|
try {
|
||||||
validateChannelName(channelName);
|
that.validateChannelName(channelName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
// 2. validate password
|
// 2. validate password
|
||||||
try {
|
try {
|
||||||
validatePassword(password);
|
that.validatePassword(password);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
// 3. if all validation passes, check availability of the name
|
// 3. if all validation passes, check availability of the name
|
||||||
isNameAvailable(channelName, '/api/isChannelAvailable/') // validate the availability
|
that.isNameAvailable(channelName, '/api/isChannelAvailable/') // validate the availability
|
||||||
.then(result => {
|
.then(function(result) {
|
||||||
if (result) {
|
if (result) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(new ChannelNameError('Sorry, that name is already taken'));
|
reject(new ChannelNameError('Sorry, that name is already taken'));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch( error => {
|
.catch(function(error) {
|
||||||
console.log('error evaluating channel name availability', error);
|
console.log('error evaluating channel name availability', error);
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
// validation function which checks all aspects of a new channel login
|
// validation function which checks all aspects of a new channel login
|
||||||
function validateNewChannelLogin(userName, password){
|
validateNewChannelLogin: function (userName, password) {
|
||||||
const channelName = `@${userName}`;
|
const channelName = `@${userName}`;
|
||||||
|
var that = this;
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
// 1. validate name
|
// 1. validate name
|
||||||
try {
|
try {
|
||||||
validateChannelName(channelName);
|
that.validateChannelName(channelName);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
// 2. validate password
|
// 2. validate password
|
||||||
try {
|
try {
|
||||||
validatePassword(password);
|
that.validatePassword(password);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
};
|
|
@ -1,13 +1,13 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const multipart = require('connect-multiparty');
|
const multipart = require('connect-multiparty');
|
||||||
const multipartMiddleware = multipart();
|
const multipartMiddleware = multipart({uploadDir: '/home/lbry/test/'});
|
||||||
const db = require('../models');
|
const db = require('../models');
|
||||||
const { publish } = require('../controllers/publishController.js');
|
const { publish } = require('../controllers/publishController.js');
|
||||||
const { getClaimList, resolveUri } = require('../helpers/lbryApi.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 errorHandlers = require('../helpers/errorHandlers.js');
|
||||||
const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
const { postToStats, sendGoogleAnalytics } = require('../controllers/statsController.js');
|
||||||
const { authenticateChannelCredentials } = require('../auth/authentication.js');
|
const { authenticateOrSkip } = require('../auth/authentication.js');
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// route to run a claim_list request on the daemon
|
// route to run a claim_list request on the daemon
|
||||||
|
@ -21,7 +21,7 @@ module.exports = (app) => {
|
||||||
res.status(200).json(claimsList);
|
res.status(200).json(claimsList);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.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
|
// route to check whether spee.ch has published to a claim
|
||||||
|
@ -67,15 +67,13 @@ module.exports = (app) => {
|
||||||
res.status(200).json(resolvedUri);
|
res.status(200).json(resolvedUri);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.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
|
// route to run a publish request on the daemon
|
||||||
app.post('/api/publish', multipartMiddleware, (req, res) => {
|
app.post('/api/publish', multipartMiddleware, ({ body, files, ip, originalUrl, user }, res) => {
|
||||||
logger.debug('req:', req);
|
let file, fileName, filePath, fileType, name, nsfw, license, title, description, thumbnail, anonymous, skipAuth, channelName, channelPassword;
|
||||||
// validate that mandatory parts of the request are present
|
// validate that mandatory parts of the request are present
|
||||||
const body = req.body;
|
|
||||||
const files = req.files;
|
|
||||||
try {
|
try {
|
||||||
validateApiPublishRequest(body, files);
|
validateApiPublishRequest(body, files);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -84,13 +82,12 @@ module.exports = (app) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// validate file, name, license, and nsfw
|
// validate file, name, license, and nsfw
|
||||||
const file = files.file;
|
file = files.file;
|
||||||
const fileName = file.name;
|
fileName = file.path.substring(file.path.lastIndexOf('/') + 1);
|
||||||
const filePath = file.path;
|
filePath = file.path;
|
||||||
const fileType = file.type;
|
fileType = file.type;
|
||||||
const name = body.name;
|
name = body.name;
|
||||||
let nsfw = body.nsfw;
|
nsfw = (body.nsfw === 'true');
|
||||||
nsfw = cleanseNSFW(nsfw); // cleanse nsfw
|
|
||||||
try {
|
try {
|
||||||
validatePublishSubmission(file, name, nsfw);
|
validatePublishSubmission(file, name, nsfw);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -98,20 +95,38 @@ module.exports = (app) => {
|
||||||
res.status(400).json({success: false, message: error.message});
|
res.status(400).json({success: false, message: error.message});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logger.debug(`name: ${name}, nsfw: ${nsfw}`);
|
|
||||||
// optional inputs
|
// optional inputs
|
||||||
const license = body.license || null;
|
license = body.license || null;
|
||||||
const title = body.title || null;
|
title = body.title || null;
|
||||||
const description = body.description || null;
|
description = body.description || null;
|
||||||
const thumbnail = body.thumbnail || null;
|
thumbnail = body.thumbnail || null;
|
||||||
let channelName = body.channelName || 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);
|
channelName = cleanseChannelName(channelName);
|
||||||
const channelPassword = body.channelPassword || null;
|
logger.debug(`/api/publish > name: ${name}, license: ${license} title: "${title}" description: "${description}" channelName: "${channelName}" channelPassword: "${channelPassword}" nsfw: "${nsfw}"`);
|
||||||
logger.debug(`license: ${license} title: "${title}" description: "${description}" channelName: "${channelName}" channelPassword: "${channelPassword}"`);
|
|
||||||
// check channel authorization
|
// check channel authorization
|
||||||
authenticateChannelCredentials(channelName, channelPassword)
|
authenticateOrSkip(skipAuth, channelName, channelPassword)
|
||||||
.then(result => {
|
.then(authenticated => {
|
||||||
if (!result) {
|
if (!authenticated) {
|
||||||
throw new Error('Authentication failed, you do not have access to that channel');
|
throw new Error('Authentication failed, you do not have access to that channel');
|
||||||
}
|
}
|
||||||
// make sure the claim name is available
|
// make sure the claim name is available
|
||||||
|
@ -133,14 +148,14 @@ module.exports = (app) => {
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
success: true,
|
success: true,
|
||||||
message: {
|
message: {
|
||||||
|
name,
|
||||||
url : `spee.ch/${result.claim_id}/${name}`,
|
url : `spee.ch/${result.claim_id}/${name}`,
|
||||||
lbryTx: result,
|
lbryTx: result,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('publish api error', error);
|
errorHandlers.handleApiError('publish', originalUrl, ip, error, res);
|
||||||
res.status(400).json({success: false, message: error.message});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -157,7 +172,7 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// route to get a short channel id from long channel Id
|
// 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
|
// serve content
|
||||||
db.Certificate.getShortChannelIdFromLongChannelId(params.longId, params.name)
|
db.Certificate.getShortChannelIdFromLongChannelId(params.longId, params.name)
|
||||||
.then(shortId => {
|
.then(shortId => {
|
||||||
|
@ -166,7 +181,7 @@ module.exports = (app) => {
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('api error getting short channel id', 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) => {
|
app.get('/trending', (req, res) => {
|
||||||
res.status(301).redirect('/popular');
|
res.status(301).redirect('/popular');
|
||||||
});
|
});
|
||||||
app.get('/popular', (req, res) => {
|
app.get('/popular', ({ ip, originalUrl }, res) => {
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
startDate.setDate(startDate.getDate() - 1);
|
||||||
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
const dateTime = startDate.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
@ -36,20 +36,18 @@ module.exports = (app) => {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.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
|
// route to display a list of the trending images
|
||||||
app.get('/new', (req, res) => {
|
app.get('/new', ({ ip, originalUrl }, res) => {
|
||||||
getRecentClaims()
|
getRecentClaims()
|
||||||
.then(result => {
|
.then(result => {
|
||||||
// logger.debug(result);
|
// logger.debug(result);
|
||||||
res.status(200).render('new', {
|
res.status(200).render('new', { newClaims: result });
|
||||||
newClaims: result,
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
errorHandlers.handleRequestError(null, null, null, error, res);
|
errorHandlers.handleRequestError('new', originalUrl, ip, error, res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// route to send embedable video player (for twitter)
|
// route to send embedable video player (for twitter)
|
||||||
|
|
|
@ -49,7 +49,6 @@ function extractPageFromClaims (claims, pageNumber) {
|
||||||
const claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;
|
const claimStartIndex = (pageNumber - 1) * CLAIMS_PER_PAGE;
|
||||||
const claimEndIndex = claimStartIndex + 10;
|
const claimEndIndex = claimStartIndex + 10;
|
||||||
const pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);
|
const pageOfClaims = claims.slice(claimStartIndex, claimEndIndex);
|
||||||
logger.debug('page of claims:', pageOfClaims);
|
|
||||||
return 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 Handlebars = require('handlebars');
|
||||||
const handlebarsHelpers = require('./helpers/handlebarsHelpers.js');
|
const handlebarsHelpers = require('./helpers/handlebarsHelpers.js');
|
||||||
const { populateLocalsDotUser, serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
|
const { populateLocalsDotUser, serializeSpeechUser, deserializeSpeechUser } = require('./helpers/authHelpers.js');
|
||||||
const config = require('config');
|
const config = require('./config/speechConfig.js');
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { getDownloadDirectory } = require('./helpers/lbryApi');
|
const { getDownloadDirectory } = require('./helpers/lbryApi');
|
||||||
const helmet = require('helmet');
|
const helmet = require('helmet');
|
||||||
|
@ -17,9 +17,9 @@ const passport = require('passport');
|
||||||
const cookieSession = require('cookie-session');
|
const cookieSession = require('cookie-session');
|
||||||
|
|
||||||
// configure logging
|
// configure logging
|
||||||
const logLevel = config.get('Logging.LogLevel');
|
const logLevel = config.logging.logLevel;
|
||||||
require('./config/loggerConfig.js')(logger, logLevel);
|
require('./config/loggerConfig.js')(logger, logLevel);
|
||||||
require('./config/slackLoggerConfig.js')(logger);
|
require('./config/slackConfig.js')(logger);
|
||||||
|
|
||||||
// check for global config variables
|
// check for global config variables
|
||||||
require('./helpers/configVarCheck.js')();
|
require('./helpers/configVarCheck.js')();
|
||||||
|
@ -42,7 +42,7 @@ app.use((req, res, next) => { // custom logging middleware to log all incoming
|
||||||
// initialize passport
|
// initialize passport
|
||||||
app.use(cookieSession({
|
app.use(cookieSession({
|
||||||
name : 'session',
|
name : 'session',
|
||||||
keys : [config.get('Session.SessionKey')],
|
keys : [config.session.sessionKey],
|
||||||
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
maxAge: 24 * 60 * 60 * 1000, // 24 hours
|
||||||
}));
|
}));
|
||||||
app.use(passport.initialize());
|
app.use(passport.initialize());
|
||||||
|
@ -82,7 +82,8 @@ db.sequelize
|
||||||
require('./routes/page-routes.js')(app);
|
require('./routes/page-routes.js')(app);
|
||||||
require('./routes/serve-routes.js')(app);
|
require('./routes/serve-routes.js')(app);
|
||||||
require('./routes/home-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
|
.then(server => { // start the server
|
||||||
server.listen(PORT, () => {
|
server.listen(PORT, () => {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="row">
|
<div class="row row--padded">
|
||||||
<h3>404: Not Found</h3>
|
<h3>404: Not Found</h3>
|
||||||
<p>That page does not exist. Return <a class="link--primary" href="/">home</a>.</p>
|
<p>That page does not exist. Return <a class="link--primary" href="/">home</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<div class="row row--tall flex-container--column">
|
<div class="row row--tall flex-container--column">
|
||||||
<form>
|
<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>
|
</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">
|
<div id="primary-dropzone-instructions">
|
||||||
<p class="info-message-placeholder info-message--failure" id="input-error-file-selection" hidden="true"></p>
|
<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>
|
<p>Drag & drop image or video here to publish</p>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<div class="column column--5 column--sml-10" >
|
<div class="column column--5 column--sml-10" >
|
||||||
<!-- preview -->
|
<!-- preview -->
|
||||||
<div class="row row--padded">
|
<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">
|
<div id="asset-preview-dropzone-instructions" class="hidden">
|
||||||
<p>Drag & drop image or video here</p>
|
<p>Drag & drop image or video here</p>
|
||||||
<p class="fine-print">OR</p>
|
<p class="fine-print">OR</p>
|
||||||
|
@ -50,105 +50,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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><div class="column column--6 column--sml-10">
|
||||||
<div class="input-text--primary flex-container--row flex-container--left-bottom">
|
<div class="input-text--primary flex-container--row flex-container--left-bottom">
|
||||||
<span>@</span>
|
<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>
|
<span id="input-success-channel-name" class="info-message--success"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
<div class="column column--10">
|
<div class="column column--10">
|
||||||
<form>
|
<form>
|
||||||
<div class="column column--3 column--med-10">
|
<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)"/>
|
<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-select">Anonymous</label>
|
<label class="label label--pointer" for="anonymous-radio">Anonymous</label>
|
||||||
</div><div class="column column--7 column--med-10">
|
</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)"/>
|
<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="in-a-channel-select">In a channel</label>
|
<label class="label label--pointer" for="channel-radio">In a channel</label>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<div class="row row--padded row--wide">
|
<div class="row row--padded row--wide">
|
||||||
<div class="input-error" id="input-error-publish-submit" hidden="true"></div>
|
<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>
|
||||||
<div class="row row--short align-content-center">
|
<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>
|
||||||
<div class="row row--short align-content-center">
|
<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>
|
<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-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-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> /
|
<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>
|
<span id="input-success-claim-name" class="info-message--success span--absolute"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Missing
let
?