Merge branch 'reject-username' of ssh://github.com/coralproject/talk into reject-username

This commit is contained in:
Chi Vinh Le
2018-06-04 22:38:21 +02:00
12 changed files with 72 additions and 27 deletions
@@ -1,20 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from './CountBadge.css';
import t from 'coral-framework/services/i18n';
import { humanizeNumber } from 'coral-framework/helpers/numbers';
const CountBadge = ({ count }) => {
let number = count;
// shorten large counts to abbreviations
if (number / 1e9 > 1) {
number = `${(number / 1e9).toFixed(1)}${t('modqueue.billion')}`;
} else if (number / 1e6 > 1) {
number = `${(number / 1e6).toFixed(1)}${t('modqueue.million')}`;
} else if (number / 1e3 > 1) {
number = `${(number / 1e3).toFixed(1)}${t('modqueue.thousand')}`;
}
number = humanizeNumber(number);
return <span className={styles.count}>{number}</span>;
};
@@ -31,6 +31,7 @@ import ActionsMenuItem from 'coral-admin/src/components/ActionsMenuItem';
import UserInfoTooltip from './UserInfoTooltip';
import KarmaTooltip from './KarmaTooltip';
import t from 'coral-framework/services/i18n';
import { humanizeNumber } from 'coral-framework/helpers/numbers';
/**
* getUserStatusArray
@@ -324,7 +325,7 @@ class UserDetail extends React.Component {
styles[getKarma(user.reliable.commenter)]
)}
>
{user.reliable.commenterKarma}
{humanizeNumber(user.reliable.commenterKarma)}
</span>
</div>
<KarmaTooltip thresholds={karmaThresholds.comment} />
@@ -3,7 +3,7 @@ import { SelectField, Option } from 'react-mdl-selectfield';
import t from 'coral-framework/services/i18n';
import styles from './StreamSettings.css';
import { Textfield } from 'react-mdl';
import { Icon, TextArea } from 'coral-ui';
import { Icon } from 'coral-ui';
import PropTypes from 'prop-types';
import Slot from 'coral-framework/components/Slot';
import MarkdownEditor from 'coral-framework/components/MarkdownEditor';
@@ -66,8 +66,8 @@ class StreamSettings extends React.Component {
this.props.updatePending({ updater });
};
updateClosedMessage = event => {
const updater = { closedMessage: { $set: event.target.value } };
updateClosedMessage = value => {
const updater = { closedMessage: { $set: value } };
this.props.updatePending({ updater });
};
@@ -178,7 +178,7 @@ class StreamSettings extends React.Component {
>
<p>{t('configure.closed_comments_desc')}</p>
<div>
<TextArea
<MarkdownEditor
className={styles.descriptionBox}
onChange={this.updateClosedMessage}
value={settings.closedMessage}
@@ -4,11 +4,11 @@ import StreamError from './StreamError';
import Comment from '../containers/Comment';
import BannedAccount from '../../../components/BannedAccount';
import ChangeUsername from '../containers/ChangeUsername';
import Markdown from 'coral-framework/components/Markdown';
import Slot from 'coral-framework/components/Slot';
import InfoBox from './InfoBox';
import { can } from 'coral-framework/services/perms';
import ModerationLink from './ModerationLink';
import Markdown from 'coral-framework/components/Markdown';
import RestrictedMessageBox from 'coral-framework/components/RestrictedMessageBox';
import t, { timeago } from 'coral-framework/services/i18n';
import CommentBox from '../containers/CommentBox';
@@ -298,7 +298,7 @@ class Stream extends React.Component {
) : (
<div>
{asset.isClosed ? (
<p>{asset.settings.closedMessage}</p>
<Markdown content={asset.settings.closedMessage} />
) : (
<Markdown content={asset.settings.disableCommentingMessage} />
)}
+22
View File
@@ -0,0 +1,22 @@
import t from 'coral-framework/services/i18n';
const DECIMAL_AMOUNT = 1;
export function humanizeNumber(number) {
const abs = Math.abs(number);
if (abs >= 1e9) {
number = `${(number / 1e9).toFixed(DECIMAL_AMOUNT)}${t(
'modqueue.billion'
)}`;
} else if (abs >= 1e6) {
number = `${(number / 1e6).toFixed(DECIMAL_AMOUNT)}${t(
'modqueue.million'
)}`;
} else if (abs >= 1e3) {
number = `${(number / 1e3).toFixed(DECIMAL_AMOUNT)}${t(
'modqueue.thousand'
)}`;
}
return number;
}
+3
View File
@@ -204,6 +204,9 @@ const CONFIG = {
// STATIC_URI is the base uri where static files are hosted.
STATIC_URI: process.env.TALK_STATIC_URI || process.env.TALK_ROOT_URL,
// SCRAPER_PROXY_URL is the url to be used as a proxy by the scraper
SCRAPER_PROXY_URL: process.env.TALK_SCRAPER_PROXY_URL || null,
// The keepalive timeout (in ms) that should be used to send keep alive
// messages through the websocket to keep the socket alive.
KEEP_ALIVE: process.env.TALK_KEEP_ALIVE || '30s',
@@ -568,3 +568,7 @@ A JSON string representing the configuration passed to the
[fetch](https://www.npmjs.com/package/node-fetch) call for the scraper. It
can be used to set an authorization header, or change the user agent. (Default
`{}`)
## TALK_SCRAPER_PROXY_URL
Sets a specific HTTP/S proxy to be used by the Asset Scraper using [https-proxy-agent](https://www.npmjs.com/package/https-proxy-agent). (Default `null`)
@@ -10,18 +10,13 @@ Using plugins and configuration variables, you can modify the way the Talk comme
To enable our default rich text editor plugin, you'll need to:
1. Enable `talk-plugin-rich-text` as a server-side plugin
2. Enable `talk-plugin-rich-text-pell` as a client-side plugin
3. If you have `talk-plugin-comment-content` enabled, you will need to disable this (this supports hyperlinks in the comment body)
1. Enable `talk-plugin-rich-text` as a server-side and client-side plugin
2. If you have `talk-plugin-comment-content` enabled, you will need to disable this (this supports hyperlinks in the comment body)
Out of the box, our Talk Editor supports Bold, Italic, and Blockquote.
If you want to support another editor, you can create a plugin and replace the client-side one with the editor of your choice.
For more information on our implementation, see https://github.com/coralproject/talk/pull/1391
For more information on Pell, check out https://jaredreich.com/pell
### Sorting/Filtering the Stream
To enable sorting and filtering plugins, you will first need to enable the viewing options plugin:
@@ -1 +0,0 @@
../../../plugins/talk-plugin-rich-text-pell/README.md
+6 -2
View File
@@ -6,7 +6,8 @@ const logger = createLogger('jobs:scraper');
const fetch = require('node-fetch');
const { merge } = require('lodash');
const { version } = require('../../package.json');
const { SCRAPER_HEADERS } = require('../../config');
const { SCRAPER_HEADERS, SCRAPER_PROXY_URL } = require('../../config');
const HttpsProxyAgent = require('https-proxy-agent');
// Load the scraper with the rules.
const metascraper = require('metascraper').load([
@@ -35,12 +36,16 @@ const headers = merge(
customHeaders
);
// Add proxy configuration if exists.
const agent = SCRAPER_PROXY_URL ? new HttpsProxyAgent(SCRAPER_PROXY_URL) : null;
/**
* Scrapes the given asset for metadata.
*/
async function scrape({ url }) {
const res = await fetch(url, {
headers,
agent,
});
const html = await res.text();
@@ -49,7 +54,6 @@ async function scrape({ url }) {
html,
url,
});
return metadata;
}
+2 -1
View File
@@ -1,6 +1,6 @@
{
"name": "talk",
"version": "4.4.2",
"version": "4.5.0",
"description": "A better commenting experience from Mozilla, The New York Times, and the Washington Post. https://coralproject.net",
"main": "app.js",
"private": true,
@@ -125,6 +125,7 @@
"history": "^3.0.0",
"hjson": "^3.1.1",
"hjson-loader": "^1.0.0",
"https-proxy-agent": "^2.2.0",
"immutability-helper": "^2.2.0",
"imports-loader": "^0.7.1",
"inquirer": "^3.2.2",
+23
View File
@@ -239,6 +239,12 @@ agent-base@2:
extend "~3.0.0"
semver "~5.0.1"
agent-base@^4.1.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce"
dependencies:
es6-promisify "^5.0.0"
ajv-keywords@^2.0.0, ajv-keywords@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"
@@ -3420,10 +3426,20 @@ es6-map@^0.1.3:
es6-symbol "~3.1.1"
event-emitter "~0.3.5"
es6-promise@^4.0.3:
version "4.2.4"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
es6-promise@^4.0.5:
version "4.1.1"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.1.tgz#8811e90915d9a0dba36274f0b242dbda78f9c92a"
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
dependencies:
es6-promise "^4.0.3"
es6-set@~0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1"
@@ -5077,6 +5093,13 @@ https-proxy-agent@1, https-proxy-agent@^1.0.0:
debug "2"
extend "3"
https-proxy-agent@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
dependencies:
agent-base "^4.1.0"
debug "^3.1.0"
husky@^0.14.3:
version "0.14.3"
resolved "https://registry.yarnpkg.com/husky/-/husky-0.14.3.tgz#c69ed74e2d2779769a17ba8399b54ce0b63c12c3"