From d9dc198d463a5bb97558e44b5ce6312769a853b8 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 14:52:05 -0500 Subject: [PATCH 01/11] Moved chained funcitons to multiple lines --- .eslintrc.json | 3 +- bin/cli-settings | 6 +- bin/cli-users | 9 +- .../src/containers/ModerationQueue.js | 17 ++- client/coral-framework/store/actions/items.js | 3 +- client/coral-plugin-commentbox/CommentBox.js | 3 +- models/user.js | 3 +- routes/api/comments/index.js | 137 +++++++++++------- routes/api/settings/index.js | 10 +- routes/api/stream/index.js | 3 +- tests/routes/api/settings/index.js | 6 +- 11 files changed, 131 insertions(+), 69 deletions(-) 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/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/client/coral-admin/src/containers/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue.js index 6cd9f46fc..9178bda57 100644 --- a/client/coral-admin/src/containers/ModerationQueue.js +++ b/client/coral-admin/src/containers/ModerationQueue.js @@ -73,7 +73,12 @@ class ModerationQueue extends React.Component { !comments.get('byId').get(id).get('status'))} + commentIds={ + comments.get('ids') + .filter(id => !comments.get('byId') + .get(id) + .get('status')) + } comments={comments.get('byId')} onClickAction={(action, id) => this.onCommentAction(action, id)} actions={['reject', 'approve']} @@ -83,7 +88,15 @@ class ModerationQueue extends React.Component { comments.get('byId').get(id).get('status') === 'rejected')} + commentIds={ + comments + .get('ids') + .filter(id => + comments + .get('byId') + .get(id) + .get('status') === 'rejected') + } comments={comments.get('byId')} onClickAction={(action, id) => this.onCommentAction(action, id)} actions={['approve']} diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index b690c6f0a..173413d66 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -241,7 +241,8 @@ export function postAction (item_id, action_type, user_id, item_type) { return response.ok ? response.json() : Promise.reject(`${response.status} ${response.statusText}`); } - ).then((json)=>{ + ) + .then((json)=>{ return json; }); }; diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index a4e32d73b..dbcd9dd97 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -40,7 +40,8 @@ class CommentBox extends Component { .then((comment_id) => { appendItemArray(parent_id || id, related, comment_id, !parent_id, parent_type); addNotification('success', 'Your comment has been posted.'); - }).catch((err) => console.error(err)); + }) + .catch((err) => console.error(err)); this.setState({body: ''}); } diff --git a/models/user.js b/models/user.js index 6800b59ef..0370a7e33 100644 --- a/models/user.js +++ b/models/user.js @@ -112,7 +112,8 @@ UserSchema.statics.mergeUsers = function(dstUserID, srcUserID) { }); return srcUser.remove(); - }).then(() => dstUser.save()); + }) + .then(() => dstUser.save()); }; /** diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index a2e77b417..3a0129ff4 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -12,17 +12,21 @@ const router = express.Router(); router.get('/', (req, res, next) => { Comment.find({}).then((comments) => { res.status(200).json(comments); - }).catch(error => { + }) + .catch(error => { next(error); }); }); router.get('/:comment_id', (req, res, next) => { - Comment.findById(req.params.comment_id).then((comment) => { - res.status(200).json(comment); - }).catch(error => { - next(error); - }); + Comment + .findById(req.params.comment_id) + .then(comment => { + res.status(200).json(comment); + }) + .catch(error => { + next(error); + }); }); //============================================================================== @@ -31,20 +35,26 @@ router.get('/:comment_id', (req, res, next) => { // Get all the comments that have that action_type over them. router.get('/action/:action_type', (req, res, next) => { - Comment.findByActionType(req.params.action_type).then((comments) => { - res.status(200).json(comments); - }).catch(error => { - next(error); - }); + Comment + .findByActionType(req.params.action_type) + .then((comments) => { + res.status(200).json(comments); + }) + .catch(error => { + next(error); + }); }); // Get all the comments that were rejected. router.get('/status/rejected', (req, res, next) => { - Comment.findByStatus('rejected').then((comments) => { - res.status(200).json(comments); - }).catch(error => { - next(error); - }); + Comment + .findByStatus('rejected') + .then(comments => { + res.status(200).json(comments); + }) + .catch(error => { + next(error); + }); }); // Returns back all the comments that are in the moderation queue. The moderation queue is pre or post moderated, @@ -52,17 +62,23 @@ router.get('/status/rejected', (req, res, next) => { // Pre-moderation: New comments are shown in the moderator queues immediately. // Post-moderation: New comments do not appear in moderation queues unless they are flagged by other users. router.get('/status/pending', (req, res, next) => { - Setting.getModerationSetting().then(function({moderation}){ - let moderationValue = req.query.moderation; - if (typeof moderationValue === 'undefined' || moderationValue === undefined) { - moderationValue = moderation; - } - Comment.moderationQueue(moderationValue).then((comments) => { - res.status(200).json(comments); + + Setting + .getModerationSetting() + .then(function({moderation}){ + let moderationValue = req.query.moderation; + if (typeof moderationValue === 'undefined' || moderationValue === undefined) { + moderationValue = moderation; + } + Comment + .moderationQueue(moderationValue) + .then((comments) => { + res.status(200).json(comments); + }); + }) + .catch(error => { + next(error); }); - }).catch(error => { - next(error); - }); }); //============================================================================== @@ -70,27 +86,36 @@ router.get('/status/pending', (req, res, next) => { //============================================================================== router.post('/', (req, res, next) => { + const {body, author_id, asset_id, parent_id, status, username} = req.body; - Comment.new(body, author_id, asset_id, parent_id, status, username).then((comment) => { - res.status(200).send({'id': comment.id}); - }).catch(error => { - next(error); - }); + + Comment + .new(body, author_id, asset_id, parent_id, status, username) + .then((comment) => { + res.status(200).send({'id': comment.id}); + }) + .catch(error => { + next(error); + }); }); router.post('/:comment_id', (req, res, next) => { - Comment.findById(req.params.comment_id).then((comment) => { - comment.body = req.body.body; - comment.author_id = req.body.author_id; - comment.asset_id = req.body.asset_id; - comment.parent_id = req.body.parent_id; - comment.status = req.body.status; - return comment.save(); - }).then((comment) => { - res.status(200).send(comment); - }).catch(error => { - next(error); - }); + Comment + .findById(req.params.comment_id) + .then((comment) => { + comment.body = req.body.body; + comment.author_id = req.body.author_id; + comment.asset_id = req.body.asset_id; + comment.parent_id = req.body.parent_id; + comment.status = req.body.status; + return comment.save(); + }) + .then((comment) => { + res.status(200).send(comment); + }) + .catch(error => { + next(error); + }); }); router.post('/:comment_id/status', (req, res, next) => { @@ -103,11 +128,14 @@ router.post('/:comment_id/status', (req, res, next) => { }); router.post('/:comment_id/actions', (req, res, next) => { - Comment.addAction(req.params.comment_id, req.body.user_id, req.body.action_type).then((action) => { - res.status(200).send(action); - }).catch(error => { - next(error); - }); + Comment + .addAction(req.params.comment_id, req.body.user_id, req.body.action_type) + .then((action) => { + res.status(200).send(action); + }) + .catch(error => { + next(error); + }); }); //============================================================================== @@ -115,11 +143,14 @@ router.post('/:comment_id/actions', (req, res, next) => { //============================================================================== router.delete('/:comment_id', (req, res, next) => { - Comment.removeById(req.params.comment_id).then(() => { - res.status(201).send('OK. Removed'); - }).catch(error => { - next(error); - }); + Comment + .removeById(req.params.comment_id) + .then(() => { + res.status(201).send('OK. Removed'); + }) + .catch(error => { + next(error); + }); }); module.exports = router; diff --git a/routes/api/settings/index.js b/routes/api/settings/index.js index 53bf53f3c..585bf083a 100644 --- a/routes/api/settings/index.js +++ b/routes/api/settings/index.js @@ -3,11 +3,17 @@ const router = express.Router(); const Setting = require('../../../models/setting'); router.get('/', (req, res, next) => { - Setting.getSettings().then(settings => res.json(settings)).catch(next); + Setting + .getSettings() + .then(settings => res.json(settings)) + .catch(next); }); router.put('/', (req, res, next) => { - Setting.updateSettings(req.body).then(() => res.status(204).end()).catch(next); + Setting + .updateSettings(req.body) + .then(() => res.status(204).end()) + .catch(next); }); module.exports = router; diff --git a/routes/api/stream/index.js b/routes/api/stream/index.js index 1e3e39d81..3f49d48fc 100644 --- a/routes/api/stream/index.js +++ b/routes/api/stream/index.js @@ -36,7 +36,8 @@ router.get('/', (req, res, next) => { users, actions }); - }).catch(error => { + }) + .catch(error => { next(error); }); }); diff --git a/tests/routes/api/settings/index.js b/tests/routes/api/settings/index.js index 5bcf9de28..41c37828e 100644 --- a/tests/routes/api/settings/index.js +++ b/tests/routes/api/settings/index.js @@ -43,11 +43,13 @@ describe('update settings', () => { return Setting.getSettings(); - }).then(settings => { + }) + .then(settings => { // confirm updated settings in db expect(settings).to.have.property('moderation'); expect(settings.moderation).to.equal('post'); - }).catch(err => { + }) + .catch(err => { throw err; }); }); From 89398120d5ca770d08654d90346a6d31f1da3314 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 14:57:57 -0500 Subject: [PATCH 02/11] Remove function keyword --- routes/api/comments/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index 3a0129ff4..e8a995089 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -65,7 +65,7 @@ router.get('/status/pending', (req, res, next) => { Setting .getModerationSetting() - .then(function({moderation}){ + .then(({moderation}) => { let moderationValue = req.query.moderation; if (typeof moderationValue === 'undefined' || moderationValue === undefined) { moderationValue = moderation; From c698ae78a7aae2ea980a7b00df98435cb5e41dcb Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 10 Nov 2016 13:02:52 -0700 Subject: [PATCH 03/11] initialize settings in an init file before app accepts requests --- bin/www | 34 +++++++++++++++++++--------------- init.js | 6 ++++++ models/setting.js | 8 ++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 init.js diff --git a/bin/www b/bin/www index af91c2c40..6ebfc6944 100755 --- a/bin/www +++ b/bin/www @@ -13,27 +13,31 @@ process.env.DEBUG = process.env.TALK_DEBUG; const app = require('../app'); const debug = require('debug')('talk:server'); const http = require('http'); +const initPromise = require('../init'); +let server; -/** - * Get port from environment and store in Express. - */ +initPromise.then(() => { + /** + * Get port from environment and store in Express. + */ -const port = normalizePort(process.env.TALK_PORT || '3000'); -app.set('port', port); + const port = normalizePort(process.env.TALK_PORT || '3000'); + app.set('port', port); -/** - * Create HTTP server. - */ + /** + * Create HTTP server. + */ -const server = http.createServer(app); + server = http.createServer(app); -/** - * Listen on provided port, on all network interfaces. - */ + /** + * Listen on provided port, on all network interfaces. + */ -server.listen(port); -server.on('error', onError); -server.on('listening', onListening); + server.listen(port); + server.on('error', onError); + server.on('listening', onListening); +}); /** * Normalize a port into a number, string, or false. diff --git a/init.js b/init.js new file mode 100644 index 000000000..9c3c2bda5 --- /dev/null +++ b/init.js @@ -0,0 +1,6 @@ +const Setting = require('./models/setting'); + +const defaults = {id: '1', moderation: 'pre'}; +module.exports = Setting.init(defaults); + +// presumably this file will grow, which is why I've broken it out. diff --git a/models/setting.js b/models/setting.js index 15c457307..a9b60abb8 100644 --- a/models/setting.js +++ b/models/setting.js @@ -11,6 +11,14 @@ const SettingSchema = new Schema({ } }); +/** + * this is run once when the app starts to ensure settings are populated + * @return {Promise} null initialize the global settings object + */ +SettingSchema.statics.init = function (defaults) { + return this.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}); +}; + /** * gets the entire settings record and sends it back * @return {Promise} settings the whole settings record From 677faebf7685551a456d4203e0bc003be0f958f1 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 10 Nov 2016 13:09:23 -0700 Subject: [PATCH 04/11] adhere to new linting rules --- bin/www | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/www b/bin/www index 6ebfc6944..639852a93 100755 --- a/bin/www +++ b/bin/www @@ -16,7 +16,8 @@ const http = require('http'); const initPromise = require('../init'); let server; -initPromise.then(() => { +initPromise +.then(() => { /** * Get port from environment and store in Express. */ From f7249c4016e7b5c802771ffbabde7f98aebd0558 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 15:12:56 -0500 Subject: [PATCH 05/11] More linting and commenting --- models/comment.js | 25 +++++++++--- models/setting.js | 9 +++-- models/user.js | 73 +++++++++++++++++++----------------- routes/api/comments/index.js | 20 +++------- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/models/comment.js b/models/comment.js index 3f99bcb6a..a80e353f0 100644 --- a/models/comment.js +++ b/models/comment.js @@ -86,9 +86,13 @@ CommentSchema.statics.findAcceptedAndNewByAssetId = function(asset_id) { * @param {String} action_type the type of action that was performed on the comment */ CommentSchema.statics.findByActionType = function(action_type) { - return Action.findCommentsIdByActionType(action_type, 'comment').then((actions) => { - return Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}); - }); + return Action + .findCommentsIdByActionType(action_type, 'comment') + .then((actions) => { + return Comment.find({'id': {'$in': actions.map(function(a){ + return a.item_id;})} + }); + }); }; /** @@ -97,9 +101,18 @@ CommentSchema.statics.findByActionType = function(action_type) { * @param {String} status the status of the comment to search for */ CommentSchema.statics.findByStatusByActionType = function(status, action_type) { - return Action.findCommentsIdByActionType(action_type, 'comment').then((actions) => { - return Comment.find({'status': status, 'id': {'$in': actions.map(function(a){return a.item_id;})}}); - }); + return Action + .findCommentsIdByActionType(action_type, 'comment') + .then((actions) => { + + return Comment.find({ + 'status': status, + 'id': {'$in': actions.map(a => { + return a.item_id;} + )} + }); + + }); }; /** diff --git a/models/setting.js b/models/setting.js index 15c457307..7d1f4b367 100644 --- a/models/setting.js +++ b/models/setting.js @@ -12,7 +12,7 @@ const SettingSchema = new Schema({ }); /** - * gets the entire settings record and sends it back + * Gets the entire settings record and sends it back * @return {Promise} settings the whole settings record */ SettingSchema.statics.getSettings = function () { @@ -20,7 +20,7 @@ SettingSchema.statics.getSettings = function () { }; /** - * gets the moderation settings and sends it back + * Gets the moderation settings and sends it back * @return {Promise} moderation the settings for how to moderate comments */ SettingSchema.statics.getModerationSetting = function () { @@ -28,12 +28,13 @@ SettingSchema.statics.getModerationSetting = function () { }; /** - * this will update the settings object with whatever you pass in + * This will update the settings object with whatever you pass in * @param {object} setting a hash of whatever settings you want to update * @return {Promise} settings Promise that resolves to the entire (updated) settings object. */ SettingSchema.statics.updateSettings = function (setting) { - // there should only ever be one record unless something has gone wrong. + // There should only ever be one record unless something has gone wrong. + // In the future we may have multiple records for custom settings for objects/users. return this.findOneAndUpdate({id: '1'}, {$set: setting}, {new: true}); }; diff --git a/models/user.js b/models/user.js index 0370a7e33..ac642c910 100644 --- a/models/user.js +++ b/models/user.js @@ -100,20 +100,22 @@ UserSchema.statics.findLocalUser = function(email, password) { UserSchema.statics.mergeUsers = function(dstUserID, srcUserID) { let srcUser, dstUser; - return Promise.all([ - User.findOne({id: dstUserID}).exec(), - User.findOne({id: srcUserID}).exec() - ]).then((users) => { - dstUser = users[0]; - srcUser = users[1]; + return Promise + .all([ + User.findOne({id: dstUserID}).exec(), + User.findOne({id: srcUserID}).exec() + ]) + .then((users) => { + dstUser = users[0]; + srcUser = users[1]; - srcUser.profiles.forEach((profile) => { - dstUser.profiles.push(profile); - }); + srcUser.profiles.forEach((profile) => { + dstUser.profiles.push(profile); + }); - return srcUser.remove(); - }) - .then(() => dstUser.save()); + return srcUser.remove(); + }) + .then(() => dstUser.save()); }; /** @@ -123,33 +125,34 @@ UserSchema.statics.mergeUsers = function(dstUserID, srcUserID) { * @param {Function} done [description] */ UserSchema.statics.findOrCreateExternalUser = function(profile) { - return User.findOne({ - profiles: { - $elemMatch: { - id: profile.id, - provider: profile.provider - } - } - }) - .then((user) => { - if (user) { - return user; - } - - // The user was not found, lets create them! - user = new User({ - displayName: profile.displayName, - roles: [], - profiles: [ - { + return User + .findOne({ + profiles: { + $elemMatch: { id: profile.id, provider: profile.provider } - ] - }); + } + }) + .then((user) => { + if (user) { + return user; + } - return user.save(); - }); + // The user was not found, lets create them! + user = new User({ + displayName: profile.displayName, + roles: [], + profiles: [ + { + id: profile.id, + provider: profile.provider + } + ] + }); + + return user.save(); + }); }; UserSchema.statics.changePassword = function(id, password) { diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index e8a995089..5126bf93c 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -13,9 +13,7 @@ router.get('/', (req, res, next) => { Comment.find({}).then((comments) => { res.status(200).json(comments); }) - .catch(error => { - next(error); - }); + .catch(next); }); router.get('/:comment_id', (req, res, next) => { @@ -24,9 +22,7 @@ router.get('/:comment_id', (req, res, next) => { .then(comment => { res.status(200).json(comment); }) - .catch(error => { - next(error); - }); + .catch(next); }); //============================================================================== @@ -40,9 +36,7 @@ router.get('/action/:action_type', (req, res, next) => { .then((comments) => { res.status(200).json(comments); }) - .catch(error => { - next(error); - }); + .catch(next); }); // Get all the comments that were rejected. @@ -52,9 +46,7 @@ router.get('/status/rejected', (req, res, next) => { .then(comments => { res.status(200).json(comments); }) - .catch(error => { - next(error); - }); + .catch(next); }); // Returns back all the comments that are in the moderation queue. The moderation queue is pre or post moderated, @@ -76,9 +68,7 @@ router.get('/status/pending', (req, res, next) => { res.status(200).json(comments); }); }) - .catch(error => { - next(error); - }); + .catch(next); }); //============================================================================== From 95f3b86f3b02fdcfad56f0aa66fbba9f6ae8a90f Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 15:24:34 -0500 Subject: [PATCH 06/11] cleaning up nested objects --- models/comment.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/models/comment.js b/models/comment.js index a80e353f0..8eab6aff4 100644 --- a/models/comment.js +++ b/models/comment.js @@ -107,9 +107,11 @@ CommentSchema.statics.findByStatusByActionType = function(status, action_type) { return Comment.find({ 'status': status, - 'id': {'$in': actions.map(a => { - return a.item_id;} - )} + 'id': { + '$in': actions.map(a => { + return a.item_id; + }) + } }); }); From 7a8cb90ebd7ab741b0a9e5a5794087c1d4f03a62 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 15:28:14 -0500 Subject: [PATCH 07/11] Fix port scope bug --- bin/www | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/bin/www b/bin/www index 639852a93..792a6b98a 100755 --- a/bin/www +++ b/bin/www @@ -14,31 +14,32 @@ const app = require('../app'); const debug = require('debug')('talk:server'); const http = require('http'); const initPromise = require('../init'); +const port = normalizePort(process.env.TALK_PORT || '3000'); + let server; initPromise -.then(() => { - /** - * Get port from environment and store in Express. - */ + .then(() => { + /** + * Get port from environment and store in Express. + */ - const port = normalizePort(process.env.TALK_PORT || '3000'); - app.set('port', port); + app.set('port', port); - /** - * Create HTTP server. - */ + /** + * Create HTTP server. + */ - server = http.createServer(app); + server = http.createServer(app); - /** - * Listen on provided port, on all network interfaces. - */ + /** + * Listen on provided port, on all network interfaces. + */ - server.listen(port); - server.on('error', onError); - server.on('listening', onListening); -}); + server.listen(port); + server.on('error', onError); + server.on('listening', onListening); + }); /** * Normalize a port into a number, string, or false. From 6f7fe6ace7c6373c0f22d246c17adbd4bf18816f Mon Sep 17 00:00:00 2001 From: David Erwin Date: Thu, 10 Nov 2016 17:12:32 -0500 Subject: [PATCH 08/11] Add embedding routes and homepage --- app.js | 3 +- client/coral-admin/src/AppRouter.js | 2 - .../coral-admin/src/components/EmbedLink.css | 13 ------- .../coral-admin/src/components/EmbedLink.js | 37 ------------------- .../coral-admin/src/containers/Configure.js | 3 +- routes/index.js | 22 +++++++++++ views/embed/stream.ejs | 13 +++++++ views/home.ejs | 16 ++++++++ 8 files changed, 53 insertions(+), 56 deletions(-) delete mode 100644 client/coral-admin/src/components/EmbedLink.css delete mode 100644 client/coral-admin/src/components/EmbedLink.js create mode 100644 routes/index.js create mode 100644 views/embed/stream.ejs create mode 100644 views/home.ejs 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/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index d00caa6c5..d1b25d0f1 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -3,7 +3,6 @@ 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 LayoutContainer from 'containers/LayoutContainer'; @@ -12,7 +11,6 @@ const routes = ( - 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

-