2015-11-14 01:34:03 +01:00
|
|
|
var React = require('react')
|
|
|
|
var ReactDOM = require('react-dom')
|
2015-11-14 13:12:48 +01:00
|
|
|
var Router = require('react-router').Router
|
|
|
|
var Route = require('react-router').Route
|
|
|
|
var IndexRoute = require('react-router').IndexRoute
|
2015-11-20 14:20:06 +01:00
|
|
|
|
|
|
|
// Load CSS
|
|
|
|
require('normalize.css')
|
|
|
|
require('skeleton.css')
|
|
|
|
require('style.css')
|
2015-11-20 17:24:06 +01:00
|
|
|
require('raleway.css')
|
2015-11-14 12:06:37 +01:00
|
|
|
|
2015-11-22 00:10:46 +01:00
|
|
|
// Load Components
|
2015-11-14 12:06:37 +01:00
|
|
|
|
2015-12-14 00:29:25 +01:00
|
|
|
var BoardsWrapper = require('boardsapiwrapper.js')
|
|
|
|
var boards = new BoardsWrapper()
|
2015-11-22 00:10:46 +01:00
|
|
|
var Icon = require('icon.jsx')
|
|
|
|
|
|
|
|
// Load pages
|
|
|
|
|
|
|
|
var Navbar = require('navbar.jsx')(boards)
|
|
|
|
var Users = require('users.jsx')(boards)
|
|
|
|
var Settings = require('settings.jsx')(boards)
|
|
|
|
var Profile = require('profile.jsx')(boards)
|
|
|
|
var Board = require('board.jsx')(boards)
|
|
|
|
var PostPage = require('postpage.jsx')(boards)
|
2015-11-26 19:04:47 +01:00
|
|
|
var CommentPage = require('commentpage.jsx')(boards)
|
2015-12-15 21:47:26 +01:00
|
|
|
var ProfileEditor = require('profile-editor.jsx')(boards)
|
2015-12-16 23:05:48 +01:00
|
|
|
var BoardEditor = require('board-editor.jsx')(boards)
|
2015-11-22 00:10:46 +01:00
|
|
|
|
|
|
|
// Define Main Components
|
2015-11-17 20:32:52 +01:00
|
|
|
|
|
|
|
var Container = React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
render () {
|
|
|
|
return (<div className="container app">{this.props.children}</div>)
|
2015-11-17 20:32:52 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var App = React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
render () {
|
|
|
|
return (<div><Navbar /><Container>{this.props.children}</Container></div>)
|
2015-11-14 12:06:37 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2015-11-17 20:32:52 +01:00
|
|
|
// Static pages
|
|
|
|
|
2015-11-21 16:29:54 +01:00
|
|
|
var Static = React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
html () {
|
2015-11-21 16:29:54 +01:00
|
|
|
return { __html: this.props.content }
|
|
|
|
},
|
2015-12-14 00:29:25 +01:00
|
|
|
render () {
|
|
|
|
if (this.props.content) {
|
2015-11-21 16:29:54 +01:00
|
|
|
return <div className={this.props.className} dangerouslySetInnerHTML={this.html()} />
|
|
|
|
} else {
|
|
|
|
return <NotFound />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
var Homepage = React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
render () {
|
2015-11-21 16:29:54 +01:00
|
|
|
return <Static className="homepage" content={require('landing.md')} />
|
|
|
|
}
|
2015-11-14 15:03:38 +01:00
|
|
|
})
|
|
|
|
|
2015-11-17 20:32:52 +01:00
|
|
|
var NotFound = React.createClass({
|
2015-12-14 00:29:25 +01:00
|
|
|
render () {
|
2015-11-17 20:32:52 +01:00
|
|
|
return (<div className="text-center">
|
|
|
|
<h1><Icon name="ban"/></h1>
|
|
|
|
<p>Sorry, there's nothing here!</p>
|
|
|
|
</div>)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// Start
|
|
|
|
|
2015-11-22 00:10:46 +01:00
|
|
|
ReactDOM.render(
|
|
|
|
<Router>
|
|
|
|
<Route path="/" component={App}>
|
|
|
|
<IndexRoute component={Homepage} />
|
|
|
|
<Route path="/@:userid">
|
|
|
|
<IndexRoute component={Profile} />
|
2015-11-26 19:04:47 +01:00
|
|
|
<Route path="post/:posthash" >
|
|
|
|
<IndexRoute component={PostPage} />
|
2015-11-23 13:00:49 +01:00
|
|
|
</Route>
|
2015-11-22 00:10:46 +01:00
|
|
|
<Route path=":boardname">
|
|
|
|
<IndexRoute component={Board} />
|
2015-11-26 19:04:47 +01:00
|
|
|
<Route path=":posthash">
|
|
|
|
<IndexRoute component={PostPage} />
|
|
|
|
<Route path=":commenthash" component={CommentPage} />
|
|
|
|
</Route>
|
2015-11-14 23:33:50 +01:00
|
|
|
</Route>
|
2015-11-22 00:10:46 +01:00
|
|
|
</Route>
|
2015-12-16 23:05:48 +01:00
|
|
|
<Route path="edit">
|
|
|
|
<Route path="profile" component={ProfileEditor} />
|
|
|
|
<Route path="board(/:boardname)" component={BoardEditor} />
|
|
|
|
</Route>
|
|
|
|
<Route path="post/:posthash" component={PostPage} />
|
|
|
|
<Route path="board/:boardname" component={Board} />
|
|
|
|
<Route path="users" component={Users} />
|
|
|
|
<Route path="settings" component={Settings} />
|
2015-11-22 00:10:46 +01:00
|
|
|
<Route path="*" component={NotFound} />
|
|
|
|
</Route>
|
|
|
|
</Router>, document.getElementById('root')
|
|
|
|
)
|