Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh authored May 31, 2018
2 parents 5911f3e + 189d27c commit 01a0d0d
Show file tree
Hide file tree
Showing 251 changed files with 3,927 additions and 2,393 deletions.
3 changes: 2 additions & 1 deletion .nsprc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"https://nodesecurity.io/advisories/594",
"https://nodesecurity.io/advisories/603",
"https://nodesecurity.io/advisories/611",
"https://nodesecurity.io/advisories/612"
"https://nodesecurity.io/advisories/612",
"https://nodesecurity.io/advisories/654"
]
}
3 changes: 2 additions & 1 deletion Dockerfile.onbuild
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ONBUILD ARG TALK_REPLY_COMMENTS_LOAD_DEPTH=3
ONBUILD ARG TALK_THREADING_LEVEL=3
ONBUILD ARG TALK_DEFAULT_STREAM_TAB=all
ONBUILD ARG TALK_DEFAULT_LANG=en
ONBUILD ARG TALK_WHITELISTED_LANGUAGES
ONBUILD ARG TALK_PLUGINS_JSON
ONBUILD ARG TALK_WEBPACK_SOURCE_MAP

Expand All @@ -20,4 +21,4 @@ ONBUILD COPY . /usr/src/app
ONBUILD RUN cli plugins reconcile && \
yarn && \
yarn build && \
yarn cache clean
yarn cache clean
23 changes: 22 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const express = require('express');
const nunjucks = require('nunjucks');
const cons = require('consolidate');
const trace = require('./middleware/trace');
const logging = require('./middleware/logging');
const path = require('path');
Expand Down Expand Up @@ -72,7 +74,26 @@ app.use(
// VIEW CONFIGURATION
//==============================================================================

app.set('views', path.join(__dirname, 'views'));
// configure the default views directory.
const views = path.join(__dirname, 'views');
app.set('views', views);

// reconfigure nunjucks.
cons.requires.nunjucks = nunjucks.configure(views, {
autoescape: true,
trimBlocks: true,
lstripBlocks: true,
watch: process.env.NODE_ENV === 'development',
});

// assign the nunjucks engine to .njk files.
app.engine('njk', cons.nunjucks);

// assign the ejs engine to .ejs and .html files.
app.engine('ejs', cons.ejs);
app.engine('html', cons.ejs);

// set .ejs as the default extension.
app.set('view engine', 'ejs');

//==============================================================================
Expand Down
77 changes: 53 additions & 24 deletions bin/cli-assets
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const util = require('./util');
const program = require('commander');
const parseDuration = require('ms');
const Table = require('cli-table');
const Table = require('cli-table2');
const AssetModel = require('../models/asset');
const CommentModel = require('../models/comment');
const AssetsService = require('../services/assets');
Expand All @@ -23,23 +23,33 @@ util.onshutdown([() => mongoose.disconnect()]);
/**
* Lists all the assets registered in the database.
*/
async function listAssets() {
async function listAssets(opts) {
try {
let assets = await AssetModel.find({}).sort({ created_at: 1 });

let table = new Table({
head: ['ID', 'Title', 'URL'],
});
switch (opts.format) {
case 'json': {
console.log(JSON.stringify(assets, null, 2));
break;
}
default: {
let table = new Table({
head: ['ID', 'Title', 'URL'],
});

assets.forEach(asset => {
table.push([
asset.id,
asset.title ? asset.title : '',
asset.url ? asset.url : '',
]);
});
assets.forEach(asset => {
table.push([
asset.id,
asset.title ? asset.title : '',
asset.url ? asset.url : '',
]);
});

console.log(table.toString());
break;
}
}

console.log(table.toString());
util.shutdown();
} catch (e) {
console.error(e);
Expand All @@ -49,12 +59,13 @@ async function listAssets() {

async function refreshAssets(ageString) {
try {
const now = new Date().getTime();
const ageMs = parseDuration(ageString);
const age = new Date(now - ageMs);
const query = AssetModel.find({}, { id: 1 });
if (ageString) {
// An age was specified, so filter only those assets.
const ageMs = parseDuration(ageString);
const age = new Date(Date.now() - ageMs);

let assets = await AssetModel.find(
{
query.merge({
$or: [
{
scraped: {
Expand All @@ -65,16 +76,28 @@ async function refreshAssets(ageString) {
scraped: null,
},
],
},
{ id: 1 }
);
});
}

// Create a graph context.
const ctx = Context.forSystem();

// Load the assets.
const cursor = query.cursor();

// Queue all the assets for scraping.
await Promise.all(assets.map(({ id }) => scraper.create(ctx, id)));
console.log('Assets were queued to be scraped');
const promises = [];

let asset = await cursor.next();
while (asset) {
promises.push(scraper.create(ctx, asset.id));
asset = await cursor.next();
}

await Promise.all(promises);

console.log(`${promises.length} Assets were queued to be scraped.`);

util.shutdown();
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -202,11 +225,17 @@ async function rewrite(search, replace, options) {

program
.command('list')
.option(
'--format <type>',
'Specify the output format [table]',
/^(table|json)$/i,
'table'
)
.description('list all the assets in the database')
.action(listAssets);

program
.command('refresh <age>')
.command('refresh [age]')
.description('queues the assets that exceed the age requested')
.action(refreshAssets);

Expand Down
2 changes: 1 addition & 1 deletion bin/cli-settings
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function changeOrgName() {
await cache.init();

// Get the original settings.
const settings = await Settings.retrieve('organizationName');
const settings = await Settings.select('organizationName');

const { organizationName } = await inquirer.prompt([
{
Expand Down
2 changes: 1 addition & 1 deletion bin/cli-token
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const util = require('./util');
const program = require('commander');
const mongoose = require('../services/mongoose');
const TokensService = require('../services/tokens');
const Table = require('cli-table');
const Table = require('cli-table2');

// Register the shutdown criteria.
util.onshutdown([() => mongoose.disconnect()]);
Expand Down
4 changes: 2 additions & 2 deletions bin/cli-users
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const util = require('./util');
const program = require('commander');
const inquirer = require('inquirer');
const { stripIndent } = require('common-tags');
const Table = require('cli-table');
const Table = require('cli-table2');

// Make things colorful!
require('colors');
Expand Down Expand Up @@ -328,7 +328,7 @@ program
.action(searchUsers);

program
.command('set-role <userID> <role>')
.command('set-role <userID>')
.description('sets the role on a user')
.action(setUserRole);

Expand Down
11 changes: 11 additions & 0 deletions client/coral-admin/src/components/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
:global {
html, body, #root, #root > div {
min-height: 100%;
}

body {
margin: 0;
background-color: #FAFAFA;
font-family: 'Roboto', sans-serif;
}
}
1 change: 1 addition & 0 deletions client/coral-admin/src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import ToastContainer from './ToastContainer';
import './App.css';
import 'material-design-lite';

import AppRouter from '../AppRouter';
Expand Down
3 changes: 2 additions & 1 deletion client/coral-admin/src/components/ApproveButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const ApproveButton = ({ active, minimal, onClick, className, disabled }) => {
className={cn(
styles.root,
{ [styles.minimal]: minimal, [styles.active]: active },
className
className,
'talk-admin-approve-button'
)}
onClick={onClick}
disabled={disabled || active}
Expand Down
12 changes: 9 additions & 3 deletions client/coral-admin/src/components/BanUserDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class BanUserDialog extends React.Component {
}

handleMessageChange = e => {
const { value: message } = e;
const { target: { value: message } } = e;
this.setState({ message });
};

Expand All @@ -30,6 +30,12 @@ class BanUserDialog extends React.Component {
});
};

handlePerform = () => {
this.props.onPerform({
message: this.state.message,
});
};

renderStep0() {
const { onCancel, username, info } = this.props;

Expand Down Expand Up @@ -63,7 +69,7 @@ class BanUserDialog extends React.Component {
}

renderStep1() {
const { onCancel, onPerform } = this.props;
const { onCancel } = this.props;
const { message } = this.state;

return (
Expand Down Expand Up @@ -95,7 +101,7 @@ class BanUserDialog extends React.Component {
<Button
className={cn('talk-ban-user-dialog-button-confirm')}
cStyle="black"
onClick={onPerform}
onClick={this.handlePerform}
raised
>
{t('bandialog.send')}
Expand Down
2 changes: 1 addition & 1 deletion client/coral-admin/src/components/CommentAnimatedEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const CommentAnimatedEdit = ({ children, body }) => {

CommentAnimatedEdit.propTypes = {
children: PropTypes.node,
body: PropTypes.string,
body: PropTypes.string.isRequired,
};

export default CommentAnimatedEdit;
5 changes: 5 additions & 0 deletions client/coral-admin/src/components/CommentDeletedTombstone.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.tombstone {
background-color: #f0f0f0;
padding: 1em;
color: #1a212f;
}
9 changes: 9 additions & 0 deletions client/coral-admin/src/components/CommentDeletedTombstone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import styles from './CommentDeletedTombstone.css';
import t from 'coral-framework/services/i18n';

const CommentDeletedTombstone = () => (
<div className={styles.tombstone}>{t('framework.comment_is_deleted')}</div>
);

export default CommentDeletedTombstone;
9 changes: 7 additions & 2 deletions client/coral-admin/src/components/CommentLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import Label from 'coral-ui/components/Label';
import Slot from 'coral-framework/components/Slot';
import { t } from 'coral-framework/services/i18n';
import FlagLabel from 'coral-ui/components/FlagLabel';
import cn from 'classnames';
import styles from './CommentLabels.css';
Expand Down Expand Up @@ -63,10 +64,14 @@ const CommentLabels = ({
<FlagLabel iconName="person">{getUserFlaggedType(actions)}</FlagLabel>
)}
{hasSuspectedWords(actions) && (
<FlagLabel iconName="sms_failed">Suspect</FlagLabel>
<FlagLabel iconName="sms_failed">
{t('flags.reasons.comment.suspect_word')}
</FlagLabel>
)}
{hasHistoryFlag(actions) && (
<FlagLabel iconName="sentiment_very_dissatisfied">History</FlagLabel>
<FlagLabel iconName="sentiment_very_dissatisfied">
{t('flags.reasons.comment.trust')}
</FlagLabel>
)}
</div>
<Slot
Expand Down
16 changes: 16 additions & 0 deletions client/coral-admin/src/components/External.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.external {
margin-bottom: 20px;
}

.separator h5 {
text-align: center;
font-size: 1.2em;
}

.slot > * {
margin-bottom: 8px;

&:last-child {
margin-bottom: 0px;
}
}
24 changes: 24 additions & 0 deletions client/coral-admin/src/components/External.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import PropTypes from 'prop-types';
import styles from './External.css';
import Slot from 'coral-framework/components/Slot';
import IfSlotIsNotEmpty from 'coral-framework/components/IfSlotIsNotEmpty';

const External = ({ slot }) => (
<IfSlotIsNotEmpty slot={slot}>
<div>
<div className={styles.external}>
<Slot fill={slot} className={styles.slot} />
</div>
<div className={styles.separator}>
<h5>Or</h5>
</div>
</div>
</IfSlotIsNotEmpty>
);

External.propTypes = {
slot: PropTypes.string.isRequired,
};

export default External;
2 changes: 0 additions & 2 deletions client/coral-admin/src/components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import styles from './Header.css';
import t from 'coral-framework/services/i18n';
import { Logo } from './Logo';
import { can } from 'coral-framework/services/perms';
import ModerationIndicator from '../routes/Moderation/containers/Indicator';
import CommunityIndicator from '../routes/Community/containers/Indicator';

const CoralHeader = ({
Expand All @@ -32,7 +31,6 @@ const CoralHeader = ({
activeClassName={styles.active}
>
{t('configure.moderate')}
<ModerationIndicator root={root} data={data} />
</IndexLink>
)}
<Link
Expand Down
Loading

0 comments on commit 01a0d0d

Please sign in to comment.