prettify all the files

This commit is contained in:
Alex Grintsvayg 2017-06-20 08:08:52 -04:00
parent 202570f286
commit aaec1f3a48
13 changed files with 368 additions and 353 deletions
ui/js
app.js
component
filePrice
userEmailVerify
welcomeModal
jsonrpc.jslbry.jslbryuri.jslighthouse.js
page
discover
publish
rewards

View file

@ -1,15 +1,15 @@
import store from 'store.js'; import store from "store.js";
import lbry from './lbry.js'; import lbry from "./lbry.js";
const env = ENV; const env = ENV;
const config = require(`./config/${env}`); const config = require(`./config/${env}`);
const language = lbry.getClientSetting('language') const language = lbry.getClientSetting("language")
? lbry.getClientSetting('language') ? lbry.getClientSetting("language")
: 'en'; : "en";
const i18n = require('y18n')({ const i18n = require("y18n")({
directory: 'app/locales', directory: "app/locales",
updateFiles: false, updateFiles: false,
locale: language locale: language,
}); });
const logs = []; const logs = [];
const app = { const app = {
@ -21,7 +21,7 @@ const app = {
log: function(message) { log: function(message) {
console.log(message); console.log(message);
logs.push(message); logs.push(message);
} },
}; };
window.__ = i18n.__; window.__ = i18n.__;

View file

@ -4,11 +4,9 @@ import { doFetchCostInfoForUri } from "actions/cost_info";
import { import {
makeSelectCostInfoForUri, makeSelectCostInfoForUri,
makeSelectFetchingCostInfoForUri, makeSelectFetchingCostInfoForUri,
} from 'selectors/cost_info' } from "selectors/cost_info";
import { import { makeSelectClaimForUri } from "selectors/claims";
makeSelectClaimForUri, import FilePrice from "./view";
} from 'selectors/claims'
import FilePrice from './view'
const makeSelect = () => { const makeSelect = () => {
const selectCostInfoForUri = makeSelectCostInfoForUri(); const selectCostInfoForUri = makeSelectCostInfoForUri();

View file

@ -46,7 +46,9 @@ class UserEmailVerify extends React.PureComponent {
{/* render help separately so it always shows */} {/* render help separately so it always shows */}
<div className="form-field__helper"> <div className="form-field__helper">
<p> <p>
{__("Email")} <Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("if you did not receive or are having trouble with your code.")} {__("Email")}{" "}
<Link href="mailto:help@lbry.io" label="help@lbry.io" />{" "}
{__("if you did not receive or are having trouble with your code.")}
</p> </p>
</div> </div>
<div className="form-row-submit form-row-submit--with-footer"> <div className="form-row-submit form-row-submit--with-footer">

View file

@ -13,12 +13,16 @@ class WelcomeModal extends React.PureComponent {
<section> <section>
<h3 className="modal__header">{__("Welcome to LBRY.")}</h3> <h3 className="modal__header">{__("Welcome to LBRY.")}</h3>
<p> <p>
{__("Using LBRY is like dating a centaur. Totally normal up top, and")} {__(
"Using LBRY is like dating a centaur. Totally normal up top, and"
)}
{" "}<em>{__("way different")}</em> {__("underneath.")} {" "}<em>{__("way different")}</em> {__("underneath.")}
</p> </p>
<p>{__("Up top, LBRY is similar to popular media sites.")}</p> <p>{__("Up top, LBRY is similar to popular media sites.")}</p>
<p> <p>
{__("Below, LBRY is controlled by users -- you -- via blockchain and decentralization.")} {__(
"Below, LBRY is controlled by users -- you -- via blockchain and decentralization."
)}
</p> </p>
<p> <p>
{__("Thank you for making content freedom possible!")} {__("Thank you for making content freedom possible!")}
@ -50,16 +54,24 @@ class WelcomeModal extends React.PureComponent {
{" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>. {" "}{__("LBRY credits, or")} <em>{__("LBC")}</em>.
</p> </p>
<p> <p>
{__("This reward will show in your Wallet momentarily, probably while you are reading this message.")} {__(
"This reward will show in your Wallet momentarily, probably while you are reading this message."
)}
</p> </p>
<p> <p>
{__("LBC is used to compensate creators, to publish, and to have say in how the network works.")} {__(
"LBC is used to compensate creators, to publish, and to have say in how the network works."
)}
</p> </p>
<p> <p>
{__("No need to understand it all just yet! Try watching or downloading something next.")} {__(
"No need to understand it all just yet! Try watching or downloading something next."
)}
</p> </p>
<p> <p>
{__("Finally, know that LBRY is an early beta and that it earns the name.")} {__(
"Finally, know that LBRY is an early beta and that it earns the name."
)}
</p> </p>
</section> </section>
</Modal>; </Modal>;

View file

@ -10,36 +10,36 @@ jsonrpc.call = function(
timeout timeout
) { ) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
if (typeof connectFailedCallback !== 'undefined') { if (typeof connectFailedCallback !== "undefined") {
if (timeout) { if (timeout) {
xhr.timeout = timeout; xhr.timeout = timeout;
} }
xhr.addEventListener('error', function(e) { xhr.addEventListener("error", function(e) {
connectFailedCallback(e); connectFailedCallback(e);
}); });
xhr.addEventListener('timeout', function() { xhr.addEventListener("timeout", function() {
connectFailedCallback( connectFailedCallback(
new Error(__('XMLHttpRequest connection timed out')) new Error(__("XMLHttpRequest connection timed out"))
); );
}); });
} }
xhr.addEventListener('load', function() { xhr.addEventListener("load", function() {
var response = JSON.parse(xhr.responseText); var response = JSON.parse(xhr.responseText);
if (response.error) { if (response.error) {
if (errorCallback) { if (errorCallback) {
errorCallback(response.error); errorCallback(response.error);
} else { } else {
var errorEvent = new CustomEvent('unhandledError', { var errorEvent = new CustomEvent("unhandledError", {
detail: { detail: {
connectionString: connectionString, connectionString: connectionString,
method: method, method: method,
params: params, params: params,
code: response.error.code, code: response.error.code,
message: response.error.message, message: response.error.message,
data: response.error.data data: response.error.data,
} },
}); });
document.dispatchEvent(errorEvent); document.dispatchEvent(errorEvent);
} }
@ -49,37 +49,37 @@ jsonrpc.call = function(
}); });
if (connectFailedCallback) { if (connectFailedCallback) {
xhr.addEventListener('error', function(event) { xhr.addEventListener("error", function(event) {
connectFailedCallback(event); connectFailedCallback(event);
}); });
} else { } else {
xhr.addEventListener('error', function(event) { xhr.addEventListener("error", function(event) {
var errorEvent = new CustomEvent('unhandledError', { var errorEvent = new CustomEvent("unhandledError", {
detail: { detail: {
connectionString: connectionString, connectionString: connectionString,
method: method, method: method,
params: params, params: params,
code: xhr.status, code: xhr.status,
message: __('Connection to API server failed') message: __("Connection to API server failed"),
} },
}); });
document.dispatchEvent(errorEvent); document.dispatchEvent(errorEvent);
}); });
} }
const counter = parseInt(sessionStorage.getItem('JSONRPCCounter') || 0); const counter = parseInt(sessionStorage.getItem("JSONRPCCounter") || 0);
xhr.open('POST', connectionString, true); xhr.open("POST", connectionString, true);
xhr.send( xhr.send(
JSON.stringify({ JSON.stringify({
jsonrpc: '2.0', jsonrpc: "2.0",
method: method, method: method,
params: params, params: params,
id: counter id: counter,
}) })
); );
sessionStorage.setItem('JSONRPCCounter', counter + 1); sessionStorage.setItem("JSONRPCCounter", counter + 1);
return xhr; return xhr;
}; };

View file

@ -458,7 +458,6 @@ lbry.claim_list_mine = function(params = {}) {
}); });
}; };
lbry._resolveXhrs = {}; lbry._resolveXhrs = {};
lbry.resolve = function(params = {}) { lbry.resolve = function(params = {}) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View file

@ -28,10 +28,10 @@ const lbryuri = {};
lbryuri.parse = function(uri, requireProto = false) { lbryuri.parse = function(uri, requireProto = false) {
// Break into components. Empty sub-matches are converted to null // Break into components. Empty sub-matches are converted to null
const componentsRegex = new RegExp( const componentsRegex = new RegExp(
'^((?:lbry://)?)' + // protocol "^((?:lbry://)?)" + // protocol
'([^:$#/]*)' + // name (stops at the first separator or end) "([^:$#/]*)" + // name (stops at the first separator or end)
'([:$#]?)([^/]*)' + // modifier separator, modifier (stops at the first path separator or end) "([:$#]?)([^/]*)" + // modifier separator, modifier (stops at the first path separator or end)
'(/?)(.*)' // path separator, path "(/?)(.*)" // path separator, path
); );
const [proto, name, modSep, modVal, pathSep, path] = componentsRegex const [proto, name, modSep, modVal, pathSep, path] = componentsRegex
.exec(uri) .exec(uri)
@ -42,20 +42,20 @@ lbryuri.parse = function(uri, requireProto = false) {
// Validate protocol // Validate protocol
if (requireProto && !proto) { if (requireProto && !proto) {
throw new Error(__('LBRY URIs must include a protocol prefix (lbry://).')); throw new Error(__("LBRY URIs must include a protocol prefix (lbry://)."));
} }
// Validate and process name // Validate and process name
if (!name) { if (!name) {
throw new Error(__('URI does not include name.')); throw new Error(__("URI does not include name."));
} }
const isChannel = name.startsWith('@'); const isChannel = name.startsWith("@");
const channelName = isChannel ? name.slice(1) : name; const channelName = isChannel ? name.slice(1) : name;
if (isChannel) { if (isChannel) {
if (!channelName) { if (!channelName) {
throw new Error(__('No channel name after @.')); throw new Error(__("No channel name after @."));
} }
if (channelName.length < CHANNEL_NAME_MIN_LEN) { if (channelName.length < CHANNEL_NAME_MIN_LEN) {
@ -75,8 +75,8 @@ lbryuri.parse = function(uri, requireProto = false) {
throw new Error( throw new Error(
__( __(
`Invalid character %s in name: %s.`, `Invalid character %s in name: %s.`,
nameBadChars.length == 1 ? '' : 's', nameBadChars.length == 1 ? "" : "s",
nameBadChars.join(', ') nameBadChars.join(", ")
) )
); );
} }
@ -88,11 +88,11 @@ lbryuri.parse = function(uri, requireProto = false) {
throw new Error(__(`No modifier provided after separator %s.`, modSep)); throw new Error(__(`No modifier provided after separator %s.`, modSep));
} }
if (modSep == '#') { if (modSep == "#") {
claimId = modVal; claimId = modVal;
} else if (modSep == ':') { } else if (modSep == ":") {
claimSequence = modVal; claimSequence = modVal;
} else if (modSep == '$') { } else if (modSep == "$") {
bidPosition = modVal; bidPosition = modVal;
} }
} }
@ -105,17 +105,17 @@ lbryuri.parse = function(uri, requireProto = false) {
} }
if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) { if (claimSequence && !claimSequence.match(/^-?[1-9][0-9]*$/)) {
throw new Error(__('Claim sequence must be a number.')); throw new Error(__("Claim sequence must be a number."));
} }
if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) { if (bidPosition && !bidPosition.match(/^-?[1-9][0-9]*$/)) {
throw new Error(__('Bid position must be a number.')); throw new Error(__("Bid position must be a number."));
} }
// Validate and process path // Validate and process path
if (path) { if (path) {
if (!isChannel) { if (!isChannel) {
throw new Error(__('Only channel URIs may have a path.')); throw new Error(__("Only channel URIs may have a path."));
} }
const pathBadChars = path.match(/[^A-Za-z0-9-]/g); const pathBadChars = path.match(/[^A-Za-z0-9-]/g);
@ -123,15 +123,15 @@ lbryuri.parse = function(uri, requireProto = false) {
throw new Error( throw new Error(
__( __(
`Invalid character %s in path: %s`, `Invalid character %s in path: %s`,
count == 1 ? '' : 's', count == 1 ? "" : "s",
nameBadChars.join(', ') nameBadChars.join(", ")
) )
); );
} }
contentName = path; contentName = path;
} else if (pathSep) { } else if (pathSep) {
throw new Error(__('No path provided after /')); throw new Error(__("No path provided after /"));
} }
return { return {
@ -143,7 +143,7 @@ lbryuri.parse = function(uri, requireProto = false) {
...(claimSequence ? { claimSequence: parseInt(claimSequence) } : {}), ...(claimSequence ? { claimSequence: parseInt(claimSequence) } : {}),
...(bidPosition ? { bidPosition: parseInt(bidPosition) } : {}), ...(bidPosition ? { bidPosition: parseInt(bidPosition) } : {}),
...(claimId ? { claimId } : {}), ...(claimId ? { claimId } : {}),
...(path ? { path } : {}) ...(path ? { path } : {}),
}; };
}; };
@ -160,13 +160,13 @@ lbryuri.build = function(uriObj, includeProto = true, allowExtraProps = false) {
bidPosition, bidPosition,
path, path,
contentName, contentName,
channelName channelName,
} = uriObj; } = uriObj;
if (channelName) { if (channelName) {
const channelNameFormatted = channelName.startsWith('@') const channelNameFormatted = channelName.startsWith("@")
? channelName ? channelName
: '@' + channelName; : "@" + channelName;
if (!name) { if (!name) {
name = channelNameFormatted; name = channelNameFormatted;
} else if (name !== channelNameFormatted) { } else if (name !== channelNameFormatted) {
@ -187,19 +187,19 @@ lbryuri.build = function(uriObj, includeProto = true, allowExtraProps = false) {
if (path && path !== contentName) { if (path && path !== contentName) {
throw new Error( throw new Error(
__( __(
'Path and contentName do not match. Only one is required; most likely you wanted contentName.' "Path and contentName do not match. Only one is required; most likely you wanted contentName."
) )
); );
} }
} }
return ( return (
(includeProto ? 'lbry://' : '') + (includeProto ? "lbry://" : "") +
name + name +
(claimId ? `#${claimId}` : '') + (claimId ? `#${claimId}` : "") +
(claimSequence ? `:${claimSequence}` : '') + (claimSequence ? `:${claimSequence}` : "") +
(bidPosition ? `\$${bidPosition}` : '') + (bidPosition ? `\$${bidPosition}` : "") +
(path ? `/${path}` : '') (path ? `/${path}` : "")
); );
}; };
@ -223,7 +223,7 @@ lbryuri.isValid = function(uri) {
}; };
lbryuri.isValidName = function(name, checkCase = true) { lbryuri.isValidName = function(name, checkCase = true) {
const regexp = new RegExp('^[a-z0-9-]+$', checkCase ? '' : 'i'); const regexp = new RegExp("^[a-z0-9-]+$", checkCase ? "" : "i");
return regexp.test(name); return regexp.test(name);
}; };

View file

@ -1,21 +1,21 @@
import lbry from './lbry.js'; import lbry from "./lbry.js";
import jsonrpc from './jsonrpc.js'; import jsonrpc from "./jsonrpc.js";
const queryTimeout = 3000; const queryTimeout = 3000;
const maxQueryTries = 2; const maxQueryTries = 2;
const defaultServers = [ const defaultServers = [
'http://lighthouse7.lbry.io:50005', "http://lighthouse7.lbry.io:50005",
'http://lighthouse8.lbry.io:50005', "http://lighthouse8.lbry.io:50005",
'http://lighthouse9.lbry.io:50005' "http://lighthouse9.lbry.io:50005",
]; ];
const path = '/'; const path = "/";
let server = null; let server = null;
let connectTryNum = 0; let connectTryNum = 0;
function getServers() { function getServers() {
return lbry.getClientSetting('useCustomLighthouseServers') return lbry.getClientSetting("useCustomLighthouseServers")
? lbry.getClientSetting('customLighthouseServers') ? lbry.getClientSetting("customLighthouseServers")
: defaultServers; : defaultServers;
} }
@ -77,7 +77,7 @@ const lighthouse = new Proxy(
call(name, params, resolve, reject); call(name, params, resolve, reject);
}); });
}; };
} },
} }
); );

View file

@ -5,9 +5,6 @@ import FileCard from "component/fileCard";
import { BusyMessage } from "component/common.js"; import { BusyMessage } from "component/common.js";
import ToolTip from "component/tooltip.js"; import ToolTip from "component/tooltip.js";
const FeaturedCategory = props => { const FeaturedCategory = props => {
const { category, names } = props; const { category, names } = props;
@ -19,7 +16,9 @@ const FeaturedCategory = props => {
category.match(/^community/i) && category.match(/^community/i) &&
<ToolTip <ToolTip
label={__("What's this?")} label={__("What's this?")}
body={__("Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names \"one,\" \"two,\" \"three,\" \"four\" and \"five\" to put your content here!")} body={__(
'Community Content is a public space where anyone can share content with the rest of the LBRY community. Bid on the names "one," "two," "three," "four" and "five" to put your content here!'
)}
className="tooltip--header" className="tooltip--header"
/>} />}
</h3> </h3>

View file

@ -15,7 +15,8 @@ const perform = dispatch => ({
back: () => dispatch(doHistoryBack()), back: () => dispatch(doHistoryBack()),
navigate: path => dispatch(doNavigate(path)), navigate: path => dispatch(doNavigate(path)),
fetchClaimListMine: () => dispatch(doFetchClaimListMine()), fetchClaimListMine: () => dispatch(doFetchClaimListMine()),
claimFirstChannelReward: () => dispatch(doClaimRewardType(rewards.TYPE_FIRST_CHANNEL)), claimFirstChannelReward: () =>
dispatch(doClaimRewardType(rewards.TYPE_FIRST_CHANNEL)),
}); });
export default connect(select, perform)(PublishPage); export default connect(select, perform)(PublishPage);

View file

@ -437,7 +437,8 @@ class PublishPage extends React.PureComponent {
return ( return (
<span> <span>
{__( {__(
'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.name 'A deposit of at least one credit is required to win "%s". However, you can still get a permanent URL for any amount.',
this.state.name
)} )}
</span> </span>
); );
@ -445,7 +446,9 @@ class PublishPage extends React.PureComponent {
return ( return (
<span> <span>
{__( {__(
'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.', this.state.topClaimValue, this.state.name 'A deposit of at least "%s" credits is required to win "%s". However, you can still get a permanent URL for any amount.',
this.state.topClaimValue,
this.state.name
)} )}
</span> </span>
); );

View file

@ -60,7 +60,8 @@ const RewardsPage = props => {
<p>{__("You are not eligible to claim rewards.")}</p> <p>{__("You are not eligible to claim rewards.")}</p>
<p> <p>
{__("To become eligible, email")} {__("To become eligible, email")}
{" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" /> {__("with a link to a public social media profile.")} {" "}<Link href="mailto:help@lbry.io" label="help@lbry.io" />{" "}
{__("with a link to a public social media profile.")}
</p> </p>
</div> </div>
); );