mirror of
https://github.com/wassname/talk.git
synced 2026-08-19 12:40:16 +08:00
Merge pull request #33 from coralproject/admin-routes
add ejs templating and serve coral-admin from /admin
This commit is contained in:
@@ -8,6 +8,8 @@ const app = express();
|
|||||||
// Middleware declarations.
|
// Middleware declarations.
|
||||||
app.use(morgan('dev'));
|
app.use(morgan('dev'));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
app.set('views', path.join(__dirname, 'views'));
|
||||||
|
app.set('view engine', 'ejs');
|
||||||
|
|
||||||
// API Routes.
|
// API Routes.
|
||||||
app.use('/api/v1', require('./routes/api'));
|
app.use('/api/v1', require('./routes/api'));
|
||||||
@@ -15,4 +17,8 @@ app.use('/api/v1', require('./routes/api'));
|
|||||||
// Static Routes.
|
// Static Routes.
|
||||||
app.use('/client/', express.static(path.join(__dirname, 'dist')));
|
app.use('/client/', express.static(path.join(__dirname, 'dist')));
|
||||||
|
|
||||||
|
app.get('/admin/*', (req, res) => {
|
||||||
|
res.render('admin', {basePath: '/client/coral-admin'});
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ public/bundle.js
|
|||||||
public/embed/comment-stream
|
public/embed/comment-stream
|
||||||
.DS_Store
|
.DS_Store
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
config.json
|
|
||||||
yarn.lock
|
yarn.lock
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"basePath": "admin",
|
||||||
|
"talkHost": "http://localhost:16180",
|
||||||
|
"xeniaHost": "http://localhost:16180"
|
||||||
|
}
|
||||||
@@ -8,17 +8,16 @@ import store from 'services/store'
|
|||||||
import CommentStream from 'containers/CommentStream'
|
import CommentStream from 'containers/CommentStream'
|
||||||
import EmbedLink from 'components/EmbedLink'
|
import EmbedLink from 'components/EmbedLink'
|
||||||
import Configure from 'containers/Configure'
|
import Configure from 'containers/Configure'
|
||||||
import config from 'services/config'
|
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
render (props) {
|
render (props) {
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Router history={browserHistory}>
|
<Router history={browserHistory}>
|
||||||
<Route path={config.basePath} component={ModerationQueue} />
|
<Route path='admin' component={ModerationQueue} />
|
||||||
<Route path={`${config.basePath}/embed`} component={CommentStream} />
|
<Route path='admin/embed' component={CommentStream} />
|
||||||
<Route path={`${config.basePath}/embedlink`} component={EmbedLink} />
|
<Route path='admin/embedlink' component={EmbedLink} />
|
||||||
<Route path={`${config.basePath}/configure`} component={Configure} />
|
<Route path='admin/configure' component={Configure} />
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ export default (props) => (
|
|||||||
<Layout fixedDrawer>
|
<Layout fixedDrawer>
|
||||||
<Header title='Talk'>
|
<Header title='Talk'>
|
||||||
<Navigation>
|
<Navigation>
|
||||||
<Link className={styles.navLink} to={`/${config.basePath}/`}>Moderate</Link>
|
<Link className={styles.navLink} to={`/admin/`}>Moderate</Link>
|
||||||
<Link className={styles.navLink} to={`/${config.basePath}/configure`}>Configure</Link>
|
<Link className={styles.navLink} to={`/admin/configure`}>Configure</Link>
|
||||||
</Navigation>
|
</Navigation>
|
||||||
</Header>
|
</Header>
|
||||||
<Drawer>
|
<Drawer>
|
||||||
<Navigation>
|
<Navigation>
|
||||||
<Link className={styles.navLink} to={`/${config.basePath}/`}>Moderate</Link>
|
<Link className={styles.navLink} to={`/admin/`}>Moderate</Link>
|
||||||
<Link className={styles.navLink} to={`/${config.basePath}/configure`}>Configure</Link>
|
<Link className={styles.navLink} to={`/admin/configure`}>Configure</Link>
|
||||||
</Navigation>
|
</Navigation>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
|
||||||
const autoprefixer = require('autoprefixer')
|
const autoprefixer = require('autoprefixer')
|
||||||
const precss = require('precss')
|
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 = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const fs = require('fs')
|
|
||||||
const devConfig = require('./webpack.config.dev')
|
const devConfig = require('./webpack.config.dev')
|
||||||
const autoprefixer = require('autoprefixer')
|
const autoprefixer = require('autoprefixer')
|
||||||
const precss = require('precss')
|
const precss = require('precss')
|
||||||
const Copy = require('copy-webpack-plugin')
|
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.exports = Object.assign({}, devConfig, {
|
||||||
module: {
|
module: {
|
||||||
|
|||||||
+2
-1
@@ -5,7 +5,7 @@
|
|||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "./bin/www",
|
"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 .",
|
"lint": "eslint .",
|
||||||
"pretest": "npm install",
|
"pretest": "npm install",
|
||||||
"test": "mocha tests --recursive",
|
"test": "mocha tests --recursive",
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
"autoprefixer": "^6.5.2",
|
"autoprefixer": "^6.5.2",
|
||||||
"body-parser": "^1.15.2",
|
"body-parser": "^1.15.2",
|
||||||
"debug": "^2.2.0",
|
"debug": "^2.2.0",
|
||||||
|
"ejs": "^2.5.2",
|
||||||
"express": "^4.14.0",
|
"express": "^4.14.0",
|
||||||
"mongoose": "^4.6.5",
|
"mongoose": "^4.6.5",
|
||||||
"morgan": "^1.7.0",
|
"morgan": "^1.7.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user