1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00

improvements, icon bar for boards

This commit is contained in:
Enrico Fasoli 2015-12-17 16:18:07 +01:00
parent a4343f3555
commit 4081d5aa12
4 changed files with 41 additions and 22 deletions

View File

@ -66,8 +66,8 @@ var Homepage = React.createClass({
var NotFound = React.createClass({
render () {
return (<div className="text-center">
<h1><Icon name="ban"/></h1>
<p>Sorry, there's nothing here!</p>
<h1><Icon name="ban" className="light"/></h1>
<h3>Sorry, there's nothing here!</h3>
</div>)
}
})
@ -93,7 +93,10 @@ ReactDOM.render(
</Route>
<Route path="edit">
<Route path="profile" component={ProfileEditor} />
<Route path="board(/:boardname)" component={BoardEditor} />
<Route path="board" component={BoardEditor}>
<Route path=":boardname" component={BoardEditor}>
</Route>
</Route>
</Route>
<Route path="post/:posthash" component={PostPage} />
<Route path="board/:boardname" component={Board} />

View File

@ -97,7 +97,9 @@ module.exports = function (boardsAPI) {
} else {
return (
<div className="editor">
<h2><Icon name="inbox" className="light" /> Board Settings</h2>
<h2><Icon name="inbox" className="light" />
{this.props.params.boardname ? ' Board Settings' : ' New Board'}
</h2>
<p>This App uses IPFS to store your Boards. When you are offline,
other users or servers that viewed your content will serve it to
others.</p>

View File

@ -3,13 +3,16 @@ var Markdown = require('markdown.jsx')
var UserID = require('userID.jsx')
var PostList = require('postlist.jsx')
var GetIPFS = require('getipfs.jsx')
var Link = require('react-router').Link
var Icon = require('icon.jsx')
var {Loading} = require('status-components.jsx')
module.exports = function (boardsAPI) {
return React.createClass({
getInitialState: function () {
return { name: this.props.params.boardname, api: false, whitelist: [] }
getInitialState () {
return { loading: true, whitelist: [] }
},
componentDidMount: function () {
componentDidMount () {
boardsAPI.use(boards => {
/*
When a component inside the component being rendered by the router also needs
@ -33,17 +36,17 @@ module.exports = function (boardsAPI) {
})
ee.on('settings for ' + this.props.params.boardname + '@' + this.props.params.userid, (res) => {
if (!this.isMounted()) return true
if (res) this.setState({ name: res.fullname, description: res.description })
if (res) this.setState({ loading: false, name: res.fullname, description: res.description })
})
} else {
this.setState({ description: 'All the messages posted in __#' + this.props.params.boardname + '__' })
this.setState({ loading: false, description: 'All the messages posted in __#' + this.props.params.boardname + '__' })
}
if (boards.isInit || this.state.api) {
this.init(boards)
}
})
},
init: function (boards) {
init (boards) {
if (!this.state.init) {
if (this.props.params.userid) {
boards.getBoardSettings(this.props.params.userid, this.props.params.boardname)
@ -51,8 +54,17 @@ module.exports = function (boardsAPI) {
this.setState({ init: true, api: true, boards: boards })
}
},
render: function () {
toolbox () {
return <div className="iconbar text-center">
<Link to={'/edit/board/' + this.props.params.boardname} ><Icon name="edit" className="fa-2x light" /></Link>
<Link to={'/edit/board/' + this.props.params.boardname + '/post'} ><Icon name="plus" className="fa-2x light" /></Link>
</div>
},
render () {
if (this.state.api) {
if (this.state.loading) {
return <Loading title="Downloading Board data" />
} else {
return (<div className="board">
<h2>{this.state.name}</h2>
<Markdown source={this.state.description} skipHtml={true} />
@ -61,8 +73,10 @@ module.exports = function (boardsAPI) {
{this.state.whitelist.map(i => <UserID id={i} key={i} api={this.state.boards} />)}
</div>
<hr />
{this.toolbox()}
<PostList board={this.props.params.boardname} admin={this.props.params.userid} api={this.state.boards} />
</div>)
}
} else return <GetIPFS api={this.state.boards} />
}
})

View File

@ -142,7 +142,7 @@ a:hover {
margin-top: -5.2rem;
}
.navbar .iconbar .fa {
.iconbar .fa {
margin-left: .5rem;
}