diff --git a/.eslintignore b/.eslintignore index 1521c8b76..53c37a166 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1 @@ -dist +dist \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 23bdea410..6ac5a08e6 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -59,6 +59,7 @@ "no-multiple-empty-lines": [ "error", {"max": 1} - ] + ], + "newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }] } } diff --git a/app.js b/app.js index 04e4222cd..22f343221 100644 --- a/app.js +++ b/app.js @@ -17,9 +17,8 @@ app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); // Routes. -app.use('/api/v1', require('./routes/api')); app.use('/client', express.static(path.join(__dirname, 'dist'))); -app.use('/admin', require('./routes/admin')); +app.use('/', require('./routes')); //============================================================================== // ERROR HANDLING diff --git a/bin/cli-settings b/bin/cli-settings index 0920473da..cff6c04ed 100755 --- a/bin/cli-settings +++ b/bin/cli-settings @@ -24,11 +24,13 @@ program const Setting = require('../models/setting'); const defaults = {id: '1', moderation: 'pre'}; - Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}) + Setting + .update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}) .then(() => { console.log('Created settings object.'); mongoose.disconnect(); - }).catch((err) => { + }) + .catch((err) => { console.error(`failed to create the settings object ${JSON.stringify(err)}`); throw new Error(err); // just to be safe }); diff --git a/bin/cli-users b/bin/cli-users index 74aa902eb..b27c41e14 100755 --- a/bin/cli-users +++ b/bin/cli-users @@ -71,10 +71,12 @@ function createUser(options) { }) .then((result) => { return User.createLocalUser(result.email.trim(), result.password.trim(), result.displayName.trim()); - }).then((user) => { + }) + .then((user) => { console.log(`Created user ${user.id}.`); mongoose.disconnect(); - }).catch((err) => { + }) + .catch((err) => { console.error(err); mongoose.disconnect(); }); @@ -249,7 +251,8 @@ function mergeUsers(dstUserID, srcUserID) { .then(() => { console.log(`User ${srcUserID} was merged into user ${dstUserID}.`); mongoose.disconnect(); - }).catch((err) => { + }) + .catch((err) => { console.error(err); mongoose.disconnect(); }); diff --git a/bin/www b/bin/www index af91c2c40..792a6b98a 100755 --- a/bin/www +++ b/bin/www @@ -13,27 +13,33 @@ process.env.DEBUG = process.env.TALK_DEBUG; const app = require('../app'); const debug = require('debug')('talk:server'); const http = require('http'); - -/** - * Get port from environment and store in Express. - */ - +const initPromise = require('../init'); const port = normalizePort(process.env.TALK_PORT || '3000'); -app.set('port', port); -/** - * Create HTTP server. - */ +let server; -const server = http.createServer(app); +initPromise + .then(() => { + /** + * Get port from environment and store in Express. + */ -/** - * Listen on provided port, on all network interfaces. - */ + app.set('port', port); -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); + /** + * Create HTTP server. + */ + + server = http.createServer(app); + + /** + * Listen on provided port, on all network interfaces. + */ + + server.listen(port); + server.on('error', onError); + server.on('listening', onListening); + }); /** * Normalize a port into a number, string, or false. diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index d00caa6c5..5d21fc819 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -3,16 +3,14 @@ import {Router, Route, IndexRoute, browserHistory} from 'react-router'; import ModerationQueue from 'containers/ModerationQueue'; import CommentStream from 'containers/CommentStream'; -import EmbedLink from 'components/EmbedLink'; import Configure from 'containers/Configure'; -import CommunityContainer from 'containers/CommunityContainer'; +import CommunityContainer from 'containers/Community/CommunityContainer'; import LayoutContainer from 'containers/LayoutContainer'; const routes = ( - diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js new file mode 100644 index 000000000..06c8ab0f6 --- /dev/null +++ b/client/coral-admin/src/actions/community.js @@ -0,0 +1,42 @@ +import qs from 'qs'; + +import { + FETCH_COMMENTERS_REQUEST, + FETCH_COMMENTERS_SUCCESS, + FETCH_COMMENTERS_FAILURE, + SORT_UPDATE, + COMMENTERS_NEW_PAGE +} from '../constants/community'; + +import {base, getInit, handleResp} from '../helpers/response'; + +export const fetchCommenters = (query = {}) => dispatch => { + dispatch(requestFetchCommenters()); + fetch(`${base}/user?${qs.stringify(query)}`, getInit('GET')) + .then(handleResp) + .then(({result, page, count, limit, totalPages}) => + dispatch({ + type: FETCH_COMMENTERS_SUCCESS, + commenters: result, + page, + count, + limit, + totalPages + }) + ) + .catch(error => dispatch({type: FETCH_COMMENTERS_FAILURE, error})); +}; + +const requestFetchCommenters = () => ({ + type: FETCH_COMMENTERS_REQUEST +}); + +export const updateSorting = sort => ({ + type: SORT_UPDATE, + sort +}); + +export const newPage = () => ({ + type: COMMENTERS_NEW_PAGE +}); + diff --git a/client/coral-admin/src/components/EmbedLink.css b/client/coral-admin/src/components/EmbedLink.css deleted file mode 100644 index 15583414a..000000000 --- a/client/coral-admin/src/components/EmbedLink.css +++ /dev/null @@ -1,13 +0,0 @@ -#embedLink { - width:400px; - margin-left: auto; - margin-right: auto; -} - -.embedTextarea { - width: 100%; -} - -.copyButton { - margin-top: 20px; -} diff --git a/client/coral-admin/src/components/EmbedLink.js b/client/coral-admin/src/components/EmbedLink.js deleted file mode 100644 index 41cbdf170..000000000 --- a/client/coral-admin/src/components/EmbedLink.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import styles from './EmbedLink.css'; -import I18n from 'coral-framework/i18n/i18n'; -import translations from '../translations'; -import {Button} from 'react-mdl'; - -const embedText = -`
`; - -const copyToClipBoard = () => { - const copyTextarea = document.querySelector(`.${ styles.embedTextarea}`); - copyTextarea.select(); - - try { - document.execCommand('copy'); - } catch (err) { - console.error('Unable to copy'); - } -}; - -const EmbedLink = () =>
-

Embed Comment Stream

-