Commit 6dfeb5fe authored by Benjamin Chodoroff's avatar Benjamin Chodoroff
Browse files

yarn run fmt

parent b3e67d4c
import 'babel-core/register';
import 'babel-polyfill';
import 'whatwg-fetch';
import {VIEW_MODE_WHISTLE, PARAM_VIEW_MODE} from 'shared/constants';
import { VIEW_MODE_WHISTLE, PARAM_VIEW_MODE } from 'shared/constants';
import './assets/stylesheets/app.scss';
import plugins from 'app/utils/JsPlugins';
import Iso from 'iso';
import universalRender from 'shared/UniversalRender';
import ConsoleExports from './utils/ConsoleExports';
import {serverApiRecordEvent} from 'app/utils/ServerApiClient';
import { serverApiRecordEvent } from 'app/utils/ServerApiClient';
import * as steem from '@steemit/steem-js';
import {determineViewMode} from "app/utils/Links";
import { determineViewMode } from 'app/utils/Links';
window.onerror = error => {
if (window.$STM_csrf) serverApiRecordEvent('client_error', error);
......@@ -20,86 +20,92 @@ const CMD_LOG_TOGGLE = 'log-toggle';
const CMD_LOG_O = 'log-on';
try {
if(process.env.NODE_ENV === 'development') {
if (process.env.NODE_ENV === 'development') {
// Adds some object refs to the global window object
ConsoleExports.init(window)
ConsoleExports.init(window);
}
} catch (e) {
console.error(e)
console.error(e);
}
let offchain // loaded by main()
let offchain; // loaded by main()
// iso default selector that injects offchain state
const isoSelector = () => {
const all = document.querySelectorAll('[data-iso-key]')
return Array.prototype.reduce.call(all, (cache, node) => {
const key = node.getAttribute('data-iso-key')
if (!cache[key]) cache[key] = {}
if (node.nodeName === 'SCRIPT') {
try {
const state = JSON.parse(node.innerHTML)
state.offchain = offchain
cache[key].state = state
} catch (e) {
cache[key].state = {}
}
} else {
cache[key].node = node
}
return cache
}, {})
}
const all = document.querySelectorAll('[data-iso-key]');
return Array.prototype.reduce.call(
all,
(cache, node) => {
const key = node.getAttribute('data-iso-key');
if (!cache[key]) cache[key] = {};
if (node.nodeName === 'SCRIPT') {
try {
const state = JSON.parse(node.innerHTML);
state.offchain = offchain;
cache[key].state = state;
} catch (e) {
cache[key].state = {};
}
} else {
cache[key].node = node;
}
return cache;
},
{}
);
};
async function runApp(initial_state) {
console.log('Initial state', initial_state);
const konami = {
code: 'xyzzy',
enabled: false
enabled: false,
};
const buff = konami.code.split('');
const cmd = (command) => {
const cmd = command => {
console.log('got command:' + command);
switch (command) {
case CMD_LOG_O :
case CMD_LOG_O:
konami.enabled = false;
case CMD_LOG_TOGGLE :
case CMD_LOG_T :
case CMD_LOG_TOGGLE:
case CMD_LOG_T:
konami.enabled = !konami.enabled;
if(konami.enabled) {
steem.api.setOptions({logger: console});
if (konami.enabled) {
steem.api.setOptions({ logger: console });
} else {
steem.api.setOptions({logger: false});
steem.api.setOptions({ logger: false });
}
return 'api logging ' + konami.enabled;
default :
default:
return 'That command is not supported.';
}
//return 'done';
}
};
const enableKonami = () => {
if(!window.s) {
if (!window.s) {
console.log('The cupie doll is yours.');
window.s = (command) => { return cmd.call(this, command) };
window.s = command => {
return cmd.call(this, command);
};
}
}
};
window.document.body.onkeypress = (e) => {
buff.shift()
buff.push(e.key)
if(buff.join('') === konami.code) {
window.document.body.onkeypress = e => {
buff.shift();
buff.push(e.key);
if (buff.join('') === konami.code) {
enableKonami();
cmd(CMD_LOG_T)
cmd(CMD_LOG_T);
}
};
if(window.location.hash.indexOf('#'+konami.code) === 0) {
enableKonami()
cmd(CMD_LOG_O)
if (window.location.hash.indexOf('#' + konami.code) === 0) {
enableKonami();
cmd(CMD_LOG_O);
}
const config = initial_state.offchain.config
const config = initial_state.offchain.config;
steem.api.setOptions({ url: config.steemd_connection_client });
steem.config.set('address_prefix', config.address_prefix);
steem.config.set('chain_id', config.chain_id);
......@@ -115,41 +121,47 @@ async function runApp(initial_state) {
initial_state.app.viewMode = determineViewMode(window.location.search);
const location = `${window.location.pathname}${window.location.search}${window.location.hash}`;
universalRender({history, location, initial_state})
.catch(error => {
const location = `${window.location.pathname}${window.location.search}${
window.location.hash
}`;
universalRender({ history, location, initial_state }).catch(error => {
console.error(error);
serverApiRecordEvent('client_error', error);
});
}
async function getOffchainState() {
const state = await (await fetch('/api/v1/state', {credentials: 'same-origin'})).json()
const now = Date.now() / 1000
const lastVisit = localStorage.getItem('lastVisit') || -Infinity
const loginData = localStorage.getItem('autopost2')
state.new_visit = (loginData == null && now - lastVisit > 1800)
return state
const state = await (await fetch('/api/v1/state', {
credentials: 'same-origin',
})).json();
const now = Date.now() / 1000;
const lastVisit = localStorage.getItem('lastVisit') || -Infinity;
const loginData = localStorage.getItem('autopost2');
state.new_visit = loginData == null && now - lastVisit > 1800;
return state;
}
async function main() {
offchain = await getOffchainState()
localStorage.setItem('lastVisit', Date.now() / 1000)
offchain = await getOffchainState();
localStorage.setItem('lastVisit', Date.now() / 1000);
if (!window.Intl) {
require.ensure(['intl/dist/Intl'], (require) => {
window.IntlPolyfill = window.Intl = require('intl/dist/Intl')
require('intl/locale-data/jsonp/en-US.js')
require('intl/locale-data/jsonp/ru.js');
require('intl/locale-data/jsonp/fr.js');
require('intl/locale-data/jsonp/it.js');
require('intl/locale-data/jsonp/ko.js');
require('intl/locale-data/jsonp/es.js')
Iso.bootstrap(runApp, isoSelector);
}, "IntlBundle");
}
else {
require.ensure(
['intl/dist/Intl'],
require => {
window.IntlPolyfill = window.Intl = require('intl/dist/Intl');
require('intl/locale-data/jsonp/en-US.js');
require('intl/locale-data/jsonp/ru.js');
require('intl/locale-data/jsonp/fr.js');
require('intl/locale-data/jsonp/it.js');
require('intl/locale-data/jsonp/ko.js');
require('intl/locale-data/jsonp/es.js');
Iso.bootstrap(runApp, isoSelector);
},
'IntlBundle'
);
} else {
Iso.bootstrap(runApp, isoSelector);
}
}
main()
main();
......@@ -4,7 +4,7 @@ export const routeRegex = {
UserProfile2: /^\/(@[\w\.\d-]+)\/(blog|posts|comments|recommended|transfers|curation-rewards|author-rewards|permissions|created|recent-replies|feed|password|followed|followers|settings)\/?$/,
UserProfile3: /^\/(@[\w\.\d-]+)\/[\w\.\d-]+/,
UserEndPoints: /^(blog|posts|comments|recommended|transfers|curation-rewards|author-rewards|permissions|created|recent-replies|feed|password|followed|followers|settings)$/,
CategoryFilters: /^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/ig,
CategoryFilters: /^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/gi,
PostNoCategory: /^\/(@[\w\.\d-]+)\/([\w\d-]+)/,
Post: /^\/([\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)\/?($|\?)/,
PostJson: /^\/([\w\d\-\/]+)\/(\@[\w\d\.-]+)\/([\w\d-]+)(\.json)$/,
......@@ -12,90 +12,95 @@ export const routeRegex = {
UserNameJson: /^.*(?=(\.json))/,
};
export default function resolveRoute(path)
{
export default function resolveRoute(path) {
if (path === '/') {
return {page: 'PostsIndex', params: ['trending']};
return { page: 'PostsIndex', params: ['trending'] };
}
if (path === '/about.html') {
return {page: 'About'};
return { page: 'About' };
}
if (path === '/welcome') {
return {page: 'Welcome'};
return { page: 'Welcome' };
}
if (path === '/faq.html') {
return {page: 'Faq'};
return { page: 'Faq' };
}
if (path === '/login.html') {
return {page: 'Login'};
return { page: 'Login' };
}
if (path === '/privacy.html') {
return {page: 'Privacy'};
return { page: 'Privacy' };
}
if (path === '/support.html') {
return {page: 'Support'};
return { page: 'Support' };
}
if (path === '/xss/test' && process.env.NODE_ENV === 'development') {
return {page: 'XSSTest'};
return { page: 'XSSTest' };
}
if (path.match(/^\/tags\/?/)) {
return {page: 'Tags'};
return { page: 'Tags' };
}
if (path === '/tos.html') {
return {page: 'Tos'};
return { page: 'Tos' };
}
if (path === '/change_password') {
return {page: 'ChangePassword'};
return { page: 'ChangePassword' };
}
if (path === '/create_account') {
return {page: 'CreateAccount'};
return { page: 'CreateAccount' };
}
if (path === '/approval') {
return {page: 'Approval'};
return { page: 'Approval' };
}
if (path === '/pick_account') {
return {page: 'PickAccount'};
return { page: 'PickAccount' };
}
if (path === '/recover_account_step_1') {
return {page: 'RecoverAccountStep1'};
return { page: 'RecoverAccountStep1' };
}
if (path === '/recover_account_step_2') {
return {page: 'RecoverAccountStep2'};
return { page: 'RecoverAccountStep2' };
}
if (path === '/waiting_list.html') {
return {page: 'WaitingList'};
return { page: 'WaitingList' };
}
if (path === '/market') {
return {page: 'Market'};
return { page: 'Market' };
}
if (path === '/~witnesses') {
return {page: 'Witnesses'};
return { page: 'Witnesses' };
}
if (path === '/submit.html') {
return {page: 'SubmitPost'};
return { page: 'SubmitPost' };
}
let match = path.match(routeRegex.PostsIndex);
if (match) {
return {page: 'PostsIndex', params: ['home', match[1]]};
return { page: 'PostsIndex', params: ['home', match[1]] };
}
match = path.match(routeRegex.UserProfile1) ||
match =
path.match(routeRegex.UserProfile1) ||
// @user/"posts" is deprecated in favor of "comments" as of oct-2016 (#443)
path.match(routeRegex.UserProfile2);
if (match) {
return {page: 'UserProfile', params: match.slice(1)};
return { page: 'UserProfile', params: match.slice(1) };
}
match = path.match(routeRegex.PostNoCategory);
if (match) {
return {page: 'PostNoCategory', params: match.slice(1)};
return { page: 'PostNoCategory', params: match.slice(1) };
}
match = path.match(routeRegex.Post);
if (match) {
return {page: 'Post', params: match.slice(1)};
}
match = path.match(/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/)
|| path.match(/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/([\w\d-]+)\/?$/);
return { page: 'Post', params: match.slice(1) };
}
match =
path.match(
/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/?$/
) ||
path.match(
/^\/(hot|votes|responses|trending|trending30|promoted|cashout|payout|payout_comments|created|active)\/([\w\d-]+)\/?$/
);
if (match) {
return {page: 'PostsIndex', params: match.slice(1)};
return { page: 'PostsIndex', params: match.slice(1) };
}
return {page: 'NotFound'};
return { page: 'NotFound' };
}
......@@ -34,7 +34,10 @@ export default {
//require.ensure([], (require) => {
cb(null, [require('app/components/pages/Support')]);
//});
} else if (route.page === 'XSSTest' && process.env.NODE_ENV === 'development') {
} else if (
route.page === 'XSSTest' &&
process.env.NODE_ENV === 'development'
) {
//require.ensure([], (require) => {
cb(null, [require('app/components/pages/XSS')]);
//});
......@@ -81,17 +84,19 @@ export default {
} else if (route.page === 'SubmitPost') {
if (process.env.BROWSER) {
// require.ensure([], (require) => {
cb(null, [require('app/components/pages/SubmitPost')]);
cb(null, [require('app/components/pages/SubmitPost')]);
// });
} else {
cb(null, [require('app/components/pages/SubmitPostServerRender')]);
cb(null, [
require('app/components/pages/SubmitPostServerRender'),
]);
}
} else if (route.page === 'UserProfile') {
//require.ensure([], (require) => {
cb(null, [require('app/components/pages/UserProfile')]);
//});
} else if (route.page === 'Market') {
require.ensure([], (require) => {
require.ensure([], require => {
cb(null, [require('app/components/pages/Market')]);
});
} else if (route.page === 'Post') {
......@@ -107,11 +112,13 @@ export default {
//});
} else {
//require.ensure([], (require) => {
cb(process.env.BROWSER ? null : Error(404), [require('app/components/pages/NotFound')]);
cb(process.env.BROWSER ? null : Error(404), [
require('app/components/pages/NotFound'),
]);
//});
}
},
indexRoute: {
component: PostsIndex.component
}
component: PostsIndex.component,
},
};
import React from 'react';
import {connect} from 'react-redux'
import {IntlProvider, addLocaleData} from 'react-intl';
import { connect } from 'react-redux';
import { IntlProvider, addLocaleData } from 'react-intl';
import en from 'react-intl/locale-data/en';
import es from 'react-intl/locale-data/es';
import ru from 'react-intl/locale-data/ru';
import fr from 'react-intl/locale-data/fr';
import it from 'react-intl/locale-data/it';
import ko from 'react-intl/locale-data/ko';
import {DEFAULT_LANGUAGE} from 'app/client_config';
import { DEFAULT_LANGUAGE } from 'app/client_config';
import tt from 'counterpart';
addLocaleData([...en, ...es, ...ru, ...fr, ...it, ...ko]);
......@@ -31,32 +31,35 @@ tt.registerTranslations('ko', require('app/locales/counterpart/ko'));
tt.registerTranslations('ko', require('app/locales/ko.json'));
if (process.env.NODE_ENV === 'production') {
tt.setFallbackLocale('en');
tt.setFallbackLocale('en');
}
class Translator extends React.Component {
render() {
const language = this.props.locale;
tt.setLocale(language);
return <IntlProvider
// to ensure dynamic language change, "key" property with same "locale" info must be added
// see: https://github.com/yahoo/react-intl/wiki/Components#multiple-intl-contexts
key={language}
locale={language}
defaultLocale={DEFAULT_LANGUAGE}
>
{this.props.children}
</IntlProvider>
return (
<IntlProvider
// to ensure dynamic language change, "key" property with same "locale" info must be added
// see: https://github.com/yahoo/react-intl/wiki/Components#multiple-intl-contexts
key={language}
locale={language}
defaultLocale={DEFAULT_LANGUAGE}
>
{this.props.children}
</IntlProvider>
);
}
}
export default connect(
(state, ownProps) => {
const locale = state.app.getIn(['user_preferences', 'locale']);
return {...ownProps, locale};
}
)(Translator);
export default connect((state, ownProps) => {
const locale = state.app.getIn(['user_preferences', 'locale']);
return { ...ownProps, locale };
})(Translator);
export const FormattedHTMLMessage = ({id, params, className}) => (
<div className={'FormattedHTMLMessage' + (className ? ` ${className}` : '')} dangerouslySetInnerHTML={ { __html: tt(id, params) } }></div>
export const FormattedHTMLMessage = ({ id, params, className }) => (
<div
className={'FormattedHTMLMessage' + (className ? ` ${className}` : '')}
dangerouslySetInnerHTML={{ __html: tt(id, params) }}
/>
);
{
"name": "Golos",
"icons": [
{
"src": "\/images\/favicons\/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image\/png"
},
{
"src": "\/images\/favicons\/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image\/png"
}
],
"theme_color": "#ffffff",
"display": "standalone"
"name": "Golos",
"icons": [
{
"src": "/images/favicons/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/images/favicons/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"display": "standalone"
}
{
"name": "Steemit",
"short_name": "Steemit",
"start_url": "/",
"display": "standalone",
"gcm_sender_id": "724829305784",
"gcm_user_visible_only": true
"name": "Steemit",
"short_name": "Steemit",
"start_url": "/",
"display": "standalone",
"gcm_sender_id": "724829305784",
"gcm_user_visible_only": true
}
......@@ -38,13 +38,12 @@ export const FRACTION_DIGITS_MARKET = 3; // accurate amount of deciaml digits (e
// meta info
export const TWITTER_HANDLE = '@steemit';
export const SHARE_IMAGE = 'https://' +
APP_DOMAIN +
'/images/steemit-share.png';
export const TWITTER_SHARE_IMAGE = 'https://' +
APP_DOMAIN +
'/images/steemit-twshare.png';
export const SITE_DESCRIPTION = 'Steemit is a social media platform where everyone gets paid for ' +
export const SHARE_IMAGE =
'https://' + APP_DOMAIN + '/images/steemit-share.png';
export const TWITTER_SHARE_IMAGE =
'https://' + APP_DOMAIN + '/images/steemit-twshare.png';
export const SITE_DESCRIPTION =
'Steemit is a social media platform where everyone gets paid for ' +
'creating and curating content. It leverages a robust digital points system, called Steem, that ' +
'supports real value for digital rewards through market price discovery and liquidity';
......
This diff is collapsed.
import React from 'react';
import {connect} from 'react-redux'
import Link from 'app/components/elements/Link'
import { connect } from 'react-redux';
import Link from 'app/components/elements/Link';
import * as globalActions from 'app/redux/GlobalReducer';
import links from 'app/utils/Links'
import links from 'app/utils/Links';
import tt from 'counterpart';
/** @deprecated */
......@@ -17,57 +17,76 @@ class CardView extends React.Component {
// redux
clearMetaElement: React.PropTypes.func,
}
};
static defaultProps = {
canEdit: false
}
canEdit: false,
};
constructor() {
super()
this.onCloseImage = (e) => {
e.preventDefault()
const {formId, clearMetaElement} = this.props
clearMetaElement(formId, 'image')
}
this.onCloseDescription = (e) => {
e.preventDefault()
const {formId, clearMetaElement} = this.props
clearMetaElement(formId, 'description')
}
super();
this.onCloseImage = e => {