Skip to content

Commit

Permalink
init static
Browse files Browse the repository at this point in the history
  • Loading branch information
soyking committed Oct 22, 2016
1 parent 0003aef commit 2198925
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 0 deletions.
5 changes: 5 additions & 0 deletions routers/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import (
)

func InitRouters(g *gin.Engine, client *client.EtcdHRCHYClient) {
g.GET("/", func(c *gin.Context) {
c.File("./static/dist/index.html")
})
g.Static("public","./static")

g.GET("/kv/*key", resp(getKeyHandler(client)))
g.PUT("/kv/*key", resp(putKeyHandler(client)))
g.DELETE("/kv/*key", resp(delKeyHandler(client)))
Expand Down
3 changes: 3 additions & 0 deletions static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
*.log
24 changes: 24 additions & 0 deletions static/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"devDependencies": {
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-plugin-antd": "^0.5.1",
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"css-loader": "^0.25.0",
"html-webpack-plugin": "^2.22.0",
"style-loader": "^0.13.1",
"webpack": "^1.13.2"
},
"dependencies": {
"antd": "^1.11.0",
"react": "15.1.0",
"react-dom": "15.1.0",
"react-polymer-layout": "^0.2.17",
"react-router": "^2.8.1"
},
"scripts": {
"watch": "./node_modules/webpack/bin/webpack.js --watch",
"build": "./node_modules/webpack/bin/webpack.js"
}
}
11 changes: 11 additions & 0 deletions static/src/components/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const App = React.createClass({
render() {
return (
<div>app</div>
)
}
})

module.exports = App
11 changes: 11 additions & 0 deletions static/src/components/KeyValue.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'

const KeyValue = React.createClass({
render() {
return (
<div>key value</div>
)
}
})

module.exports = KeyValue
14 changes: 14 additions & 0 deletions static/src/entry.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import ReactDOM from 'react-dom'
import { hashHistory, Router, Route, IndexRedirect } from 'react-router'
import App from './components/App.jsx'
import KeyValue from './components/KeyValue.jsx'

ReactDOM.render((
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRedirect to="kv" />
<Route path="kv" component={KeyValue} />
</Route>
</Router>
), document.querySelector(".root"))
5 changes: 5 additions & 0 deletions static/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>ETCD V3 WEB UI</title>
<section class="root"></section>
<script src="public/dist/bundle.js"></script>
35 changes: 35 additions & 0 deletions static/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
devtool: "inline-source-map",
entry: './src/entry.jsx',
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [{
test: /.jsx$/,
loader: 'babel',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015'],
plugins: ['antd']
}
}, {
test: /\.css$/,
loader: 'style-loader!css-loader'
}]
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
inject: false,
}),
]
}

0 comments on commit 2198925

Please sign in to comment.