diff --git a/app.js b/app.js index 838819e35..76dba1c1a 100644 --- a/app.js +++ b/app.js @@ -8,6 +8,8 @@ const app = express(); // Middleware declarations. app.use(morgan('dev')); app.use(bodyParser.json()); +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'ejs'); // API Routes. app.use('/api/v1', require('./routes/api')); @@ -15,4 +17,8 @@ app.use('/api/v1', require('./routes/api')); // Static Routes. app.use('/client/', express.static(path.join(__dirname, 'dist'))); +app.get('/admin/*', (req, res) => { + res.render('admin', {basePath: '/client/coral-admin'}); +}); + module.exports = app; diff --git a/client/coral-admin/.gitignore b/client/coral-admin/.gitignore index c9c7cb580..707c890e5 100644 --- a/client/coral-admin/.gitignore +++ b/client/coral-admin/.gitignore @@ -3,5 +3,4 @@ public/bundle.js public/embed/comment-stream .DS_Store npm-debug.log -config.json yarn.lock diff --git a/client/coral-admin/config.json b/client/coral-admin/config.json new file mode 100644 index 000000000..c8f318cfc --- /dev/null +++ b/client/coral-admin/config.json @@ -0,0 +1,5 @@ +{ + "basePath": "admin", + "talkHost": "http://localhost:16180", + "xeniaHost": "http://localhost:16180" +} diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index 4b7c01e84..81eea850f 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -8,17 +8,16 @@ import store from 'services/store' import CommentStream from 'containers/CommentStream' import EmbedLink from 'components/EmbedLink' import Configure from 'containers/Configure' -import config from 'services/config' export default class App extends React.Component { render (props) { return ( - - - - + + + + ) diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js index 0e52686d8..ea268108e 100644 --- a/client/coral-admin/src/components/Header.js +++ b/client/coral-admin/src/components/Header.js @@ -9,14 +9,14 @@ export default (props) => (
- Moderate - Configure + Moderate + Configure
- Moderate - Configure + Moderate + Configure {props.children} diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js index bd5913b5a..1eba29d66 100644 --- a/client/coral-admin/webpack.config.dev.js +++ b/client/coral-admin/webpack.config.dev.js @@ -1,16 +1,6 @@ - const path = require('path') -const fs = require('fs') const autoprefixer = require('autoprefixer') const precss = require('precss') -const config = require('./config.json') - -// doing a string replace here because I spent a day trying to do it the "webpack" way -// ond nothing works. just trying to replace a string in an index.html file is -// apparently something no one has ever done in the js community. -let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString() -templateString = templateString.replace('<%= basePath %>', config.basePath) -fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString) module.exports = { entry: { diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 2c81bf4fc..10768b6e5 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -1,17 +1,8 @@ const path = require('path') -const fs = require('fs') const devConfig = require('./webpack.config.dev') const autoprefixer = require('autoprefixer') const precss = require('precss') const Copy = require('copy-webpack-plugin') -const config = require('./config.json') - -// doing a string replace here because I spent a day trying to do it the "webpack" way -// ond nothing works. just trying to replace a string in an index.html file is -// apparently something no one has ever done in the js community. -let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString() -templateString = templateString.replace('<%= basePath %>', config.basePath) -fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString) module.exports = Object.assign({}, devConfig, { module: { diff --git a/package.json b/package.json index 45470f3c8..bb62d4ca3 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "app.js", "scripts": { "start": "./bin/www", - "build": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.js && cd client/coral-admin && npm run build", + "build": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.js && cd client/coral-admin && npm install && npm run build", "lint": "eslint .", "pretest": "npm install", "test": "mocha tests --recursive", @@ -45,6 +45,7 @@ "autoprefixer": "^6.5.2", "body-parser": "^1.15.2", "debug": "^2.2.0", + "ejs": "^2.5.2", "express": "^4.14.0", "mongoose": "^4.6.5", "morgan": "^1.7.0", diff --git a/client/coral-admin/index.ejs b/views/admin.ejs similarity index 100% rename from client/coral-admin/index.ejs rename to views/admin.ejs