diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-11-12 19:03:31 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-11-12 19:03:31 +0100 |
| commit | e9a5a0eb4b122ab83fd48f7a0f34cd56ee63bd7e (patch) | |
| tree | 4c67d72ec4979c0afcffd651e7b8732dd4c6b91f /animism-align/frontend/site | |
| parent | d5924e554701a5d7cdee52c7fd264a164e880a84 (diff) | |
stub in site frontend spot
Diffstat (limited to 'animism-align/frontend/site')
| -rw-r--r-- | animism-align/frontend/site/actions.js | 19 | ||||
| -rw-r--r-- | animism-align/frontend/site/app.js | 35 | ||||
| -rw-r--r-- | animism-align/frontend/site/index.js | 17 | ||||
| -rw-r--r-- | animism-align/frontend/site/store.js | 37 | ||||
| -rw-r--r-- | animism-align/frontend/site/types.js | 11 |
5 files changed, 119 insertions, 0 deletions
diff --git a/animism-align/frontend/site/actions.js b/animism-align/frontend/site/actions.js new file mode 100644 index 0000000..16297ce --- /dev/null +++ b/animism-align/frontend/site/actions.js @@ -0,0 +1,19 @@ +import { bindActionCreators } from 'redux' +// import { actions as crudActions } from './api' + +// import * as siteActions from './site/site.actions' + +import { store } from './store' + +export default + // Object.keys(crudActions) + // .map(a => [a, crudActions[a]]) + // .concat( + [ + ['site', siteActions], + ] //) + .map(p => [p[0], bindActionCreators(p[1], store.dispatch)]) + .concat([ + // ['socket', socketActions], + ]) + .reduce((a,b) => (a[b[0]] = b[1])&&a,{})
\ No newline at end of file diff --git a/animism-align/frontend/site/app.js b/animism-align/frontend/site/app.js new file mode 100644 index 0000000..4f8a6cf --- /dev/null +++ b/animism-align/frontend/site/app.js @@ -0,0 +1,35 @@ +import React, { Component } from 'react' +import { ConnectedRouter } from 'connected-react-router' +import { Route } from 'react-router' + +// import ViewerContainer from './viewer/viewer.container' +import actions from './actions' + +export default class App extends Component { + componentDidMount() { + const path_partz = window.location.pathname.split('/') + const graph_name = path_partz[1] + let path_name = null + if (path_partz.length > 2) { + path_name = path_partz[2] + } + // console.log('loading', graph_name, path_name) + actions.site.loadSite(graph_name, path_name) + } + + render() { + return ( + <ConnectedRouter history={this.props.history}> + <div className='app'> + <Route exact key='root' path='/' render={() => { + // setTimeout(() => this.props.history.push('/'), 10) + return null + }} /> + </div> + </ConnectedRouter> + ) + } +} +/* + <Route path={'/:graph_name/:page_name'} component={ViewerContainer} exact /> +*/ diff --git a/animism-align/frontend/site/index.js b/animism-align/frontend/site/index.js new file mode 100644 index 0000000..6f1a0a5 --- /dev/null +++ b/animism-align/frontend/site/index.js @@ -0,0 +1,17 @@ +import React from 'react' +import ReactDOM from 'react-dom' +import { Provider } from 'react-redux' + +import App from './app' + +import { store, history } from './store' + +const container = document.createElement('div') +container.classList.add('container') +document.body.appendChild(container) + +ReactDOM.render( + <Provider store={store}> + <App history={history} /> + </Provider>, container +) diff --git a/animism-align/frontend/site/store.js b/animism-align/frontend/site/store.js new file mode 100644 index 0000000..a687a69 --- /dev/null +++ b/animism-align/frontend/site/store.js @@ -0,0 +1,37 @@ +import { applyMiddleware, compose, combineReducers, createStore } from 'redux' +import { connectRouter, routerMiddleware } from 'connected-react-router' +import { createBrowserHistory } from 'history' +import thunk from 'redux-thunk' + +// import siteReducer from './site/site.reducer' + +const createRootReducer = history => ( + combineReducers({ + auth: (state = {}) => state, + router: connectRouter(history), + // site: siteReducer, + }) +) + +const configureStore = (initialState = {}, history) => { + const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose + + const store = createStore( + createRootReducer(history), + initialState, + composeEnhancers( + applyMiddleware( + thunk, + routerMiddleware(history) + ), + ), + ) + + return store +} + +const history = createBrowserHistory() +const store = configureStore({}, history) +const { dispatch } = store + +export { store, history, dispatch } diff --git a/animism-align/frontend/site/types.js b/animism-align/frontend/site/types.js new file mode 100644 index 0000000..23bed98 --- /dev/null +++ b/animism-align/frontend/site/types.js @@ -0,0 +1,11 @@ +import { with_type, crud_type } from 'app/api/crud.types' + +export const site = with_type('site', [ + 'set_site_title', 'loading', 'loaded', 'error', +]) + +export const system = with_type('system', [ + 'load_site', +]) + +export const init = '@@INIT' |
