initial project checkin

This commit is contained in:
Adam Brown 2016-11-23 16:58:48 -05:00
commit afce2f47a4
13 changed files with 9510 additions and 0 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
*~
node_modules
# have to add the bundle to version control so deployment with git subtree works
# browser-bundle.js
# skeleton.css
browser-bundle.js.map

13
README.md Normal file
View File

@ -0,0 +1,13 @@
## Math
http://www.geog.ucsb.edu/ideas/Insolation.html
## Libraries
https://www.npmjs.com/package/suncalc
## Tools
http://www.sunearthtools.com/dp/tools/pos_sun.php

2222
dist/browser-bundle.js vendored Normal file

File diff suppressed because one or more lines are too long

22
dist/index.html vendored Normal file
View File

@ -0,0 +1,22 @@
<html>
<head>
<title>Dubdiff 2</title>
</head>
<body>
<div class="table-container">
<div class="table-block footer-push">
<div id="root">If you see this then something is wrong.</div>
</div>
<div class="table-block">
<div class="container">
<footer id="footer" class="twelve columns">
<p><a href="http://adamarthurryan.com">Adam Brown</a> | This website is <a href="https://github.com/adamarthurryan/dubdiff-2">open source</a>.</p>
</footer>
</div>
</div>
</div>
<script src="browser-bundle.js"></script>
<link href="old-dubdiff.css" rel="stylesheet">
</body>
</html>

7002
dist/old-dubdiff.css vendored Normal file

File diff suppressed because it is too large Load Diff

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "dubdiff-2",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "npm run webpack --colors",
"start": "npm run webpack --progress --colors --watch",
"deploy": "git subtree push --prefix dist origin gh-pages",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "BSD-2-Clause",
"dependencies": {
"react": "^0.14.5",
"react-dom": "^0.14.5",
"react-redux": "^4.4.6",
"redux": "^3.5.1",
"reselect": "^2.5.1"
},
"devDependencies": {
"babel-core": "^6.3.26",
"babel-loader": "^6.2.0",
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"copyfiles": "^0.2.2",
"webpack": "^1.12.9"
}
}

3
src/actions.js Normal file
View File

@ -0,0 +1,3 @@
export const updateOriginalInput = (data) => ({ type: 'UPDATE_ORIGINAL_INPUT', data})
export const updateFinalInput = (data) => ({ type: 'UPDATE_FINAL_INPUT', data})

40
src/client.js Normal file
View File

@ -0,0 +1,40 @@
import React from 'react'
import ReactDOM from 'react-dom'
import * as Redux from 'redux'
import {Provider} from 'react-redux'
import * as localStore from './localStore'
import * as reducers from './reducers'
import Main from './components/Main'
//create the redux store
//initial state is retrieved from localStore
const store = Redux.createStore(
Redux.combineReducers(reducers),
localStore.get(),
window.devToolsExtension ? window.devToolsExtension() : undefined
)
//save the state whenever the state changes
function saveState() {
let state = store.getState()
//pass the elements of state that should be persisted to the local store as an array of element name strings
localStore.set(state, [])
}
store.subscribe(saveState)
function render() {
ReactDOM.render(
<Provider store={store}>
<Main/>
</Provider>
, document.getElementById('root'))
}
render()

90
src/components/Main.js Normal file
View File

@ -0,0 +1,90 @@
import React from 'react'
import {connect} from 'react-redux'
import * as Actions from '../actions'
import * as Selectors from '../selectors'
const mapStateToProps = (state) => ({
input: state.input,
safeInput: Selectors.safeInput(state),
})
const mapDispatchToProps = dispatch => ({
onChangeOriginal: (text) => dispatch(Actions.updateOriginalInput(text)),
onChangeFinal: (text) => dispatch(Actions.updateFinalInput(text))
})
class Main extends React.Component {
constructor() {
super()
}
render () {
return (
<div class="container">
<form class="row">
<div class="col-md-2 col-sm-12 form-group">
<div class="controls well col-lg-12">
<a type="button" ng-click="compare()" class="btn btn-block btn-primary">compare</a>
</div>
<div class="controls well btn-group col-lg-12">
<a ng-class="{&quot;active&quot;: isMarkdownFormat}" type="submit" ng-click="toggleMarkdownFormat()" class="btn btn-block btn-primary active">
<span ng-class="{&quot;glyphicon-ok&quot;: isMarkdownFormat}" class="glyphicon glyphicon-ok"></span>
&nbsp; As Markdown
</a>
</div>
</div>
<div class="col-lg-5 col-sm-12 form-group">
<label for="docA">Original</label>
<textarea id="docA" ng-model="docA" class="form-control"></textarea>
</div>
<div class="col-lg-5 col-sm-12 form-group">
<label for="docB">Final</label>
<textarea id="docB" ng-model="docB" class="form-control"></textarea>
</div>
</form>
</div>
)
}
}
function renderDate(props) {
return <div>
<DateInputForm/>
<div>
<p><strong>Data for {props.formattedDate}</strong></p>
<DateResultsSummary/>
<DateResultsChart/>
</div>
</div>
}
function renderMonthly(props) {
return <div>
<p><strong>Yearly Data</strong></p>
<MonthlyResultsSummary/>
<MonthlyResultsChart/>
</div>
}
export default connect(mapStateToProps, mapDispatchToProps)(Main)
/*
{this.props.view == "RESULTS" ?
(this.props.inputIsValid.valid ?
<div>
<p><strong>{this.props.formattedDate}</strong></p>
<DateResultsSummary/>
<DateResultsTable/>
</div> :
<InvalidResults/>
):
*/

7
src/localStore.js Normal file
View File

@ -0,0 +1,7 @@
export const get = () => JSON.parse(localStorage.getItem('state')) || undefined;
export function set (state, props) {
let toSave = {}
props.forEach(p => toSave[p] = state[p])
localStorage.setItem('state', JSON.stringify(toSave))
}

40
src/reducers.js Normal file
View File

@ -0,0 +1,40 @@
export function textInput (state, action ) {
switch (action.type) {
case 'UPDATE_ORIGINAL_INPUT':
return Object.assign({}, state, {original:action.data})
default:
return state || {original:"", final:""}
}
}
export function locationInput (state, action) {
switch (action.type) {
case 'UPDATE_LOCATION_INPUT':
return Object.assign({}, state, action.data)
default:
return state || {latitude:"0", longitude:"0"}
}
}
export function dateInput (state, action) {
switch (action.type) {
case 'UPDATE_DATE_INPUT':
return action.data
default:
return state || "Jun 21"
}
}
export function view (state, action) {
switch (action.type) {
case 'VIEW_DATE':
return 'DATE'
case 'VIEW_MONTHLY':
return 'MONTHLY'
default:
return state || 'MONTHLY'
}
}

13
src/selectors.js Normal file
View File

@ -0,0 +1,13 @@
//per http://redux.js.org/docs/recipes/ComputingDerivedData.html
import { createSelector } from 'reselect'
const input = (state) => state.input
export const safeInput = createSelector(
[input],
(input) => {
//!!! sanitize the input here and return
return input
}
)

21
webpack.config.js Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
cache: true,
entry: './src/client',
output: {
filename: './dist/browser-bundle.js'
},
target: 'web',
devtool: 'eval-cheap-module-source-map',
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react'],
compact: "false"
}
},
]
},
};