Merge branch 'master' into rte-rework

This commit is contained in:
Kim Gardner
2018-03-21 17:14:02 -04:00
committed by GitHub
29 changed files with 371 additions and 8 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"presets": [
["es2015", {modules: false}]
["es2015", {"modules": false}]
],
"plugins": [
"transform-class-properties",
+4
View File
@@ -30,6 +30,7 @@ plugins/*
!plugins/talk-plugin-author-menu
!plugins/talk-plugin-comment-content
!plugins/talk-plugin-deep-reply-count
!plugins/talk-plugin-downvote
!plugins/talk-plugin-facebook-auth
!plugins/talk-plugin-featured-comments
!plugins/talk-plugin-flag-details
@@ -52,14 +53,17 @@ plugins/*
!plugins/talk-plugin-remember-sort
!plugins/talk-plugin-respect
!plugins/talk-plugin-slack-notifications
!plugins/talk-plugin-sort-most-downvoted
!plugins/talk-plugin-sort-most-liked
!plugins/talk-plugin-sort-most-loved
!plugins/talk-plugin-sort-most-replied
!plugins/talk-plugin-sort-most-respected
!plugins/talk-plugin-sort-most-upvoted
!plugins/talk-plugin-sort-newest
!plugins/talk-plugin-sort-oldest
!plugins/talk-plugin-subscriber
!plugins/talk-plugin-toxic-comments
!plugins/talk-plugin-upvote
!plugins/talk-plugin-viewing-options
!plugins/talk-plugin-rich-text
+3 -3
View File
@@ -126,6 +126,7 @@
"inquirer": "^3.2.2",
"inquirer-autocomplete-prompt": "^0.12.1",
"ioredis": "3.1.4",
"ip": "^1.1.5",
"joi": "^13.0.0",
"jsonwebtoken": "^8.0.0",
"jwt-decode": "^2.2.0",
@@ -143,6 +144,7 @@
"morgan": "^1.9.0",
"ms": "^2.0.0",
"murmurhash-js": "^1.0.0",
"name-all-modules-plugin": "^1.0.1",
"node-emoji": "^1.8.1",
"node-fetch": "^1.7.2",
"nodemailer": "^2.6.4",
@@ -195,6 +197,7 @@
"url-search-params": "^0.9.0",
"uuid": "^3.1.0",
"webpack": "^3.10.0",
"webpack-manifest-plugin": "^2.0.0-rc.2",
"webpack-sources": "^1.0.1",
"yaml-loader": "^0.4.0",
"yamljs": "^0.2.10"
@@ -216,19 +219,16 @@
"eslint-plugin-mocha": "^4.11.0",
"husky": "^0.14.3",
"identity-obj-proxy": "^3.0.0",
"ip": "^1.1.5",
"jest": "^21.2.1",
"jest-junit": "^3.6.0",
"lint-staged": "^7.0.0",
"mocha": "^3.1.2",
"mocha-junit-reporter": "^1.12.1",
"name-all-modules-plugin": "^1.0.1",
"nightwatch": "^0.9.16",
"nodemon": "^1.11.0",
"selenium-standalone": "^6.11.0",
"sinon": "^3.2.1",
"sinon-chai": "^2.13.0",
"webpack-manifest-plugin": "^2.0.0-rc.2",
"yaml-lint": "^1.0.0"
},
"engines": {
@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es6": true,
"mocha": true
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }]
}
}
@@ -0,0 +1,39 @@
.container {
display: inline-block;
}
.button {
color: #2a2a2a;
margin: 5px 10px 5px 0px;
background: none;
padding: 0px;
border: none;
font-size: inherit;
vertical-align: middle;
&:hover {
color: #767676;
cursor: pointer;
}
&.downvoted {
color: #cc0000;
&:hover {
color: #ff3232;
cursor: pointer;
}
}
}
.icon {
font-size: 12px;
padding: 0 3px;
}
@media (max-width: 425px) {
.label {
display: none;
}
}
@@ -0,0 +1,56 @@
import React from 'react';
import Icon from './Icon';
import styles from './DownvoteButton.css';
import { withReaction } from 'plugin-api/beta/client/hocs';
import cn from 'classnames';
const plugin = 'talk-plugin-downvote';
class DownvoteButton extends React.Component {
handleClick = () => {
const {
postReaction,
deleteReaction,
showSignInDialog,
alreadyReacted,
user,
} = this.props;
// If the current user does not exist, trigger sign in dialog.
if (!user) {
showSignInDialog();
return;
}
if (alreadyReacted) {
deleteReaction();
} else {
postReaction();
}
};
render() {
const { count, alreadyReacted } = this.props;
return (
<div className={cn(styles.container, `${plugin}-container`)}>
<button
className={cn(
styles.button,
{
[`${
styles.downvoted
} talk-plugin-downvote-downvoted`]: alreadyReacted,
},
`${plugin}-button`
)}
onClick={this.handleClick}
>
<Icon className={cn(styles.icon, `${plugin}-icon`)} />
<span className={cn(`${plugin}-count`)}>{count > 0 && count}</span>
</button>
</div>
);
}
}
export default withReaction('downvote')(DownvoteButton);
@@ -0,0 +1,10 @@
import React from 'react';
import cn from 'classnames';
// @TODO change icon when we deprecate FA
export default ({ className }) => (
<i
className={cn('fa', 'fa-arrow-circle-down', className)}
aria-hidden="true"
/>
);
@@ -0,0 +1,7 @@
import DownvoteButton from './components/DownvoteButton';
export default {
slots: {
commentReactions: [DownvoteButton],
},
};
+2
View File
@@ -0,0 +1,2 @@
const { getReactionConfig } = require('../../plugin-api/beta/server');
module.exports = getReactionConfig('downvote');
@@ -0,0 +1,9 @@
{
"name": "@coralproject/talk-plugin-downvote",
"pluginName": "talk-plugin-downvote",
"version": "0.0.1",
"description": "Downvote comments",
"main": "index.js",
"author": "The Coral Project Team <coral@mozillafoundation.org>",
"license": "Apache-2.0"
}
@@ -1,6 +1,7 @@
import React from 'react';
import cn from 'classnames';
// @TODO change icon when we deprecate FA
export default ({ className }) => (
<i className={cn('fa', 'fa-handshake-o', className)} aria-hidden="true" />
);
@@ -0,0 +1,3 @@
{
"extends": "@coralproject/eslint-config-talk/client"
}
@@ -0,0 +1,19 @@
import translations from './translations.yml';
import { createSortOption } from 'talk-plugin-viewing-options/client/api/factories';
import { t } from 'plugin-api/beta/client/services';
const SortOption = createSortOption(
() => t('talk-plugin-sort-most-downvoted.label'),
{ sortBy: 'DOWNVOTES', sortOrder: 'DESC' }
);
/**
* This plugin depends on talk-plugin-viewing-options.
*/
export default {
translations,
slots: {
viewingOptionsSort: [SortOption],
},
};
@@ -0,0 +1,3 @@
en:
talk-plugin-sort-most-downvoted:
label: Most downvoted first
@@ -0,0 +1 @@
module.exports = {};
@@ -0,0 +1,9 @@
{
"name": "@coralproject/talk-plugin-sort-most-downvoted",
"pluginName": "talk-plugin-sort-most-downvoted",
"version": "0.0.1",
"description": "Sort by most downvotes",
"main": "index.js",
"author": "The Coral Project Team <coral@mozillafoundation.org>",
"license": "Apache-2.0"
}
@@ -0,0 +1,3 @@
{
"extends": "@coralproject/eslint-config-talk/client"
}
@@ -0,0 +1,19 @@
import translations from './translations.yml';
import { createSortOption } from 'talk-plugin-viewing-options/client/api/factories';
import { t } from 'plugin-api/beta/client/services';
const SortOption = createSortOption(
() => t('talk-plugin-sort-most-upvoted.label'),
{ sortBy: 'UPVOTES', sortOrder: 'DESC' }
);
/**
* This plugin depends on talk-plugin-viewing-options.
*/
export default {
translations,
slots: {
viewingOptionsSort: [SortOption],
},
};
@@ -0,0 +1,3 @@
en:
talk-plugin-sort-most-upvoted:
label: Most upvoted first
@@ -0,0 +1 @@
module.exports = {};
@@ -0,0 +1,9 @@
{
"name": "@coralproject/talk-plugin-sort-most-upvoted",
"pluginName": "talk-plugin-sort-most-upvoted",
"version": "0.0.1",
"description": "Sort by most upvotes",
"main": "index.js",
"author": "The Coral Project Team <coral@mozillafoundation.org>",
"license": "Apache-2.0"
}
@@ -0,0 +1,23 @@
{
"env": {
"browser": true,
"es6": true,
"mocha": true
},
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error",
"no-console": ["warn", { "allow": ["warn", "error"] }]
}
}
@@ -0,0 +1,7 @@
import React from 'react';
import cn from 'classnames';
// @TODO change icon when we deprecate FA
export default ({ className }) => (
<i className={cn('fa', 'fa-arrow-circle-up', className)} aria-hidden="true" />
);
@@ -0,0 +1,39 @@
.container {
display: inline-block;
}
.button {
color: #2a2a2a;
margin: 5px 10px 5px 0px;
background: none;
padding: 0px;
border: none;
font-size: inherit;
vertical-align: middle;
&:hover {
color: #767676;
cursor: pointer;
}
&.upvoted {
color: #008000;
&:hover {
color: #66b266;
cursor: pointer;
}
}
}
.icon {
font-size: 12px;
padding: 0 3px;
}
@media (max-width: 425px) {
.label {
display: none;
}
}
@@ -0,0 +1,54 @@
import React from 'react';
import Icon from './Icon';
import styles from './UpvoteButton.css';
import { withReaction } from 'plugin-api/beta/client/hocs';
import cn from 'classnames';
const plugin = 'talk-plugin-upvote';
class UpvoteButton extends React.Component {
handleClick = () => {
const {
postReaction,
deleteReaction,
showSignInDialog,
alreadyReacted,
user,
} = this.props;
// If the current user does not exist, trigger sign in dialog.
if (!user) {
showSignInDialog();
return;
}
if (alreadyReacted) {
deleteReaction();
} else {
postReaction();
}
};
render() {
const { count, alreadyReacted } = this.props;
return (
<div className={cn(styles.container, `${plugin}-container`)}>
<button
className={cn(
styles.button,
{
[`${styles.upvoted} talk-plugin-upvote-upvoted`]: alreadyReacted,
},
`${plugin}-button`
)}
onClick={this.handleClick}
>
<Icon className={cn(styles.icon, `${plugin}-icon`)} />
<span className={cn(`${plugin}-count`)}>{count > 0 && count}</span>
</button>
</div>
);
}
}
export default withReaction('upvote')(UpvoteButton);
@@ -0,0 +1,7 @@
import UpvoteButton from './components/UpvoteButton';
export default {
slots: {
commentReactions: [UpvoteButton],
},
};
+2
View File
@@ -0,0 +1,2 @@
const { getReactionConfig } = require('../../plugin-api/beta/server');
module.exports = getReactionConfig('upvote');
+9
View File
@@ -0,0 +1,9 @@
{
"name": "@coralproject/talk-plugin-upvote",
"pluginName": "talk-plugin-upvote",
"version": "0.0.1",
"description": "Upvote comments",
"main": "index.js",
"author": "The Coral Project Team <coral@mozillafoundation.org>",
"license": "Apache-2.0"
}
+5 -4
View File
@@ -13,6 +13,7 @@ const staticMiddleware = require('express-static-gzip');
const { DISABLE_STATIC_SERVER } = require('../config');
const { passport } = require('../services/passport');
const { MOUNT_PATH } = require('../url');
const url = require('url');
const context = require('../middleware/context');
const router = express.Router();
@@ -31,8 +32,8 @@ if (!DISABLE_STATIC_SERVER) {
/**
* Redirect old embed calls.
*/
const oldEmbed = path.resolve(MOUNT_PATH, 'embed.js');
const newEmbed = path.resolve(MOUNT_PATH, 'static/embed.js');
const oldEmbed = url.resolve(MOUNT_PATH, 'embed.js');
const newEmbed = url.resolve(MOUNT_PATH, 'static/embed.js');
router.get('/embed.js', (req, res) => {
console.warn(
`deprecation warning: ${oldEmbed} will be phased out soon, please replace calls from ${oldEmbed} to ${newEmbed}`
@@ -132,9 +133,9 @@ if (process.env.NODE_ENV !== 'production') {
router.get('/', async (req, res, next) => {
try {
await SetupService.isAvailable();
return res.redirect('/admin/install');
return res.redirect(url.resolve(MOUNT_PATH, 'admin/install'));
} catch (e) {
return res.redirect('/admin');
return res.redirect(url.resolve(MOUNT_PATH, 'admin'));
}
});
}