Merge pull request #33 from coralproject/admin-routes

add ejs templating and serve coral-admin from /admin
This commit is contained in:
David Erwin
2016-11-08 14:15:56 -05:00
committed by GitHub
9 changed files with 21 additions and 30 deletions
+6
View File
@@ -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;
-1
View File
@@ -3,5 +3,4 @@ public/bundle.js
public/embed/comment-stream
.DS_Store
npm-debug.log
config.json
yarn.lock
+5
View File
@@ -0,0 +1,5 @@
{
"basePath": "admin",
"talkHost": "http://localhost:16180",
"xeniaHost": "http://localhost:16180"
}
+4 -5
View File
@@ -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 (
<Provider store={store}>
<Router history={browserHistory}>
<Route path={config.basePath} component={ModerationQueue} />
<Route path={`${config.basePath}/embed`} component={CommentStream} />
<Route path={`${config.basePath}/embedlink`} component={EmbedLink} />
<Route path={`${config.basePath}/configure`} component={Configure} />
<Route path='admin' component={ModerationQueue} />
<Route path='admin/embed' component={CommentStream} />
<Route path='admin/embedlink' component={EmbedLink} />
<Route path='admin/configure' component={Configure} />
</Router>
</Provider>
)
+4 -4
View File
@@ -9,14 +9,14 @@ export default (props) => (
<Layout fixedDrawer>
<Header title='Talk'>
<Navigation>
<Link className={styles.navLink} to={`/${config.basePath}/`}>Moderate</Link>
<Link className={styles.navLink} to={`/${config.basePath}/configure`}>Configure</Link>
<Link className={styles.navLink} to={`/admin/`}>Moderate</Link>
<Link className={styles.navLink} to={`/admin/configure`}>Configure</Link>
</Navigation>
</Header>
<Drawer>
<Navigation>
<Link className={styles.navLink} to={`/${config.basePath}/`}>Moderate</Link>
<Link className={styles.navLink} to={`/${config.basePath}/configure`}>Configure</Link>
<Link className={styles.navLink} to={`/admin/`}>Moderate</Link>
<Link className={styles.navLink} to={`/admin/configure`}>Configure</Link>
</Navigation>
</Drawer>
{props.children}
-10
View File
@@ -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: {
-9
View File
@@ -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: {
+2 -1
View File
@@ -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",