mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-11 21:38:38 +01:00
looks like everything works.. needs moar testing
This commit is contained in:
parent
bae52734af
commit
7608757891
@ -41,7 +41,7 @@ var Comment = React.createClass({
|
||||
{this.getParentlink()}
|
||||
</div>
|
||||
<Markdown source={this.props.comment.text} />
|
||||
<hr/></div>
|
||||
<hr/>{this.getComments()}</div>
|
||||
} else {
|
||||
return <div><hr/>Invalid Comment<hr/></div>
|
||||
}
|
||||
|
@ -3,41 +3,39 @@ var Markdown = require('markdown.jsx')
|
||||
var Icon = require('icon.jsx')
|
||||
var Link = require('react-router').Link
|
||||
var Clock = require('clock.jsx')
|
||||
var UserID = require('userID.jsx')
|
||||
|
||||
module.exports = function(){
|
||||
var UserID = require('userID.jsx')()
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { moment: false }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
require.ensure(['moment'],_ => {
|
||||
if(this.isMounted()) this.setState({ moment: require('moment') })
|
||||
})
|
||||
},
|
||||
postLink: function(){
|
||||
if(this.props.post.op){
|
||||
if(this.props.board){
|
||||
return '/@'+this.props.post.op+'/'+this.props.board+'/'+this.props.post.hash
|
||||
} else {
|
||||
return '/@'+this.props.post.op+'/post/'+this.props.post.hash
|
||||
}
|
||||
module.exports = React.createClass({
|
||||
getInitialState: function(){
|
||||
return { moment: false }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
require.ensure(['moment'],_ => {
|
||||
if(this.isMounted()) this.setState({ moment: require('moment') })
|
||||
})
|
||||
},
|
||||
postLink: function(){
|
||||
if(this.props.post.op){
|
||||
if(this.props.board){
|
||||
return '/@'+this.props.post.op+'/'+this.props.board+'/'+this.props.post.hash
|
||||
} else {
|
||||
return '/post/'+this.props.post.hash
|
||||
return '/@'+this.props.post.op+'/post/'+this.props.post.hash
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
return <div key={this.props.post.title} className="post">
|
||||
<div className="content">
|
||||
<h5>{this.props.post.title}</h5><hr/>
|
||||
<Markdown source={this.props.post.text} /><hr/>
|
||||
<div className="icons">
|
||||
<UserID id={this.props.post.op} api={this.props.api} ></UserID>
|
||||
<Clock className="not-first" date={this.props.post.date} />
|
||||
<Icon name="comments" className="not-first" /> <Link className="nounderline" to={this.postLink()}>View</Link>
|
||||
</div>
|
||||
} else {
|
||||
return '/post/'+this.props.post.hash
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
return <div key={this.props.post.title} className="post">
|
||||
<div className="content">
|
||||
<h5>{this.props.post.title}</h5><hr/>
|
||||
<Markdown source={this.props.post.text} /><hr/>
|
||||
<div className="icons">
|
||||
<UserID id={this.props.post.op} api={this.props.api} ></UserID>
|
||||
<Clock className="not-first" date={this.props.post.date} />
|
||||
<Icon name="comments" className="not-first" /> <Link className="nounderline" to={this.postLink()}>View</Link>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
})
|
||||
}
|
||||
</div>
|
||||
}
|
||||
})
|
||||
|
@ -1,58 +1,56 @@
|
||||
var React = require('react')
|
||||
var sortedIndex = require('lodash.sortedindex')
|
||||
var Icon = require('icon.jsx')
|
||||
var Post = require('post.jsx')
|
||||
|
||||
module.exports = function(){
|
||||
var Post = require('post.jsx')()
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { posts: [], api: false }
|
||||
},
|
||||
sortFn: function(a,b){
|
||||
return (b.date || 0) - (a.date || 0)
|
||||
},
|
||||
init: function(boards){
|
||||
this.setState({ api: true })
|
||||
boards.getPostsInBoard(this.props.admin,this.props.board)
|
||||
.on('post in '+this.props.board+(this.props.admin?'@'+this.props.admin:''),(post,hash) => {
|
||||
if(!this.isMounted()) return true
|
||||
var now = (new Date()).getTime()
|
||||
var posts = this.state.posts
|
||||
if(post.date === undefined || post.date <= 0){
|
||||
posts.push(post)
|
||||
} else if(post.date <= now){
|
||||
var i = sortedIndex(posts,post,(p) => now-p.date || now)
|
||||
posts.splice(i,0,post)
|
||||
} else {
|
||||
console.log('Post discarded cause date in the future:',post)
|
||||
}
|
||||
this.setState({ posts })
|
||||
})
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(boards.isInit) this.init(boards)
|
||||
else boards.getEventEmitter().on('init',err => {
|
||||
if(!err && this.isMounted()) this.init(boards)
|
||||
})
|
||||
module.exports = React.createClass({
|
||||
getInitialState: function(){
|
||||
return { posts: [], api: false }
|
||||
},
|
||||
sortFn: function(a,b){
|
||||
return (b.date || 0) - (a.date || 0)
|
||||
},
|
||||
init: function(boards){
|
||||
this.setState({ api: true })
|
||||
boards.getPostsInBoard(this.props.admin,this.props.board)
|
||||
.on('post in '+this.props.board+(this.props.admin?'@'+this.props.admin:''),(post,hash) => {
|
||||
if(!this.isMounted()) return true
|
||||
var now = (new Date()).getTime()
|
||||
var posts = this.state.posts
|
||||
if(post.date === undefined || post.date <= 0){
|
||||
posts.push(post)
|
||||
} else if(post.date <= now){
|
||||
var i = sortedIndex(posts,post,(p) => now-p.date || now)
|
||||
posts.splice(i,0,post)
|
||||
} else {
|
||||
console.log('Post discarded cause date in the future:',post)
|
||||
}
|
||||
},
|
||||
getPosts: function(){
|
||||
if(this.state.posts.length > 0 || this.state.api){
|
||||
return this.state.posts.map(post => {
|
||||
return <Post key={post.hash} board={this.props.board} admin={this.props.admin} post={post} api={this.props.api} />
|
||||
})
|
||||
} else return <div className="center-block text-center">
|
||||
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
|
||||
</div>
|
||||
},
|
||||
render: function(){
|
||||
return (
|
||||
<div className="postList">
|
||||
{this.getPosts()}
|
||||
</div>
|
||||
)
|
||||
this.setState({ posts })
|
||||
})
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(boards.isInit) this.init(boards)
|
||||
else boards.getEventEmitter().on('init',err => {
|
||||
if(!err && this.isMounted()) this.init(boards)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getPosts: function(){
|
||||
if(this.state.posts.length > 0 || this.state.api){
|
||||
return this.state.posts.map(post => {
|
||||
return <Post key={post.hash} board={this.props.board} admin={this.props.admin} post={post} api={this.props.api} />
|
||||
})
|
||||
} else return <div className="center-block text-center">
|
||||
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
|
||||
</div>
|
||||
},
|
||||
render: function(){
|
||||
return (
|
||||
<div className="postList">
|
||||
{this.getPosts()}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
})
|
||||
|
@ -2,52 +2,50 @@ var React = require('react')
|
||||
var Icon = require('icon.jsx')
|
||||
var Link = require('react-router').Link
|
||||
|
||||
module.exports = function(){
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(boards.isInit){
|
||||
this.getProfile(boards)
|
||||
}
|
||||
boards.getEventEmitter().on('init',err => {
|
||||
if(!err && this.isMounted()) this.getProfile(boards)
|
||||
else console.log('ERR INIT',err)
|
||||
})
|
||||
module.exports = React.createClass({
|
||||
getInitialState: function(){
|
||||
return { }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(boards.isInit){
|
||||
this.getProfile(boards)
|
||||
}
|
||||
},
|
||||
getProfile: function(boards){
|
||||
if(this.props.id === undefined) return
|
||||
boards.getProfile(this.props.id, (err,res) => {
|
||||
if(!this.isMounted()) return true
|
||||
if(err){
|
||||
console.log('Error while resolving user badge:',err)
|
||||
} else {
|
||||
this.setState({ name: res.name || 'Unknown Name' })
|
||||
}
|
||||
boards.getEventEmitter().on('init',err => {
|
||||
if(!err && this.isMounted()) this.getProfile(boards)
|
||||
else console.log('ERR INIT',err)
|
||||
})
|
||||
},
|
||||
getContent: function(){
|
||||
if(this.state.name){
|
||||
return (<Icon name="user" />)
|
||||
} else {
|
||||
return '@'
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
if(this.props.id === undefined || this.props.id === 'undefined')
|
||||
return <div className="user-id">
|
||||
<Icon name="ban" /> Unknown User
|
||||
</div>
|
||||
else
|
||||
return (<div className="user-id">
|
||||
<Link className="light nounderline" to={'/@'+this.props.id}>
|
||||
{this.getContent()}{this.state.name || this.props.id}
|
||||
</Link>
|
||||
</div>)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
getProfile: function(boards){
|
||||
if(this.props.id === undefined) return
|
||||
boards.getProfile(this.props.id, (err,res) => {
|
||||
if(!this.isMounted()) return true
|
||||
if(err){
|
||||
console.log('Error while resolving user badge:',err)
|
||||
} else {
|
||||
this.setState({ name: res.name || 'Unknown Name' })
|
||||
}
|
||||
})
|
||||
},
|
||||
getContent: function(){
|
||||
if(this.state.name){
|
||||
return (<Icon name="user" />)
|
||||
} else {
|
||||
return '@'
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
if(this.props.id === undefined || this.props.id === 'undefined')
|
||||
return <div className="user-id">
|
||||
<Icon name="ban" /> Unknown User
|
||||
</div>
|
||||
else
|
||||
return (<div className="user-id">
|
||||
<Link className="light nounderline" to={'/@'+this.props.id}>
|
||||
{this.getContent()}{this.state.name || this.props.id}
|
||||
</Link>
|
||||
</div>)
|
||||
}
|
||||
})
|
||||
|
@ -2,11 +2,11 @@ var React = require('react')
|
||||
var Markdown = require('markdown.jsx')
|
||||
var Link = require('react-router').Link
|
||||
var Icon = require('icon.jsx')
|
||||
var UserID = require('userID.jsx')
|
||||
var PostList = require('postlist.jsx')
|
||||
var GetIPFS = require('getipfs.jsx')
|
||||
|
||||
module.exports = function(boardsAPI){
|
||||
var UserID = require('userID.jsx')()
|
||||
var PostList = require('postlist.jsx')()
|
||||
var GetIPFS = require('getipfs.jsx')()
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { name: this.props.params.boardname, api: false }
|
||||
|
@ -1,13 +1,12 @@
|
||||
var React = require('react')
|
||||
var Link = require('react-router').Link
|
||||
var Icon = require('icon.jsx')
|
||||
var UserID = require('userID.jsx')
|
||||
var GetIPFS = require('getipfs.jsx')
|
||||
var Post = require('post.jsx')
|
||||
var Comment = require('comment.jsx').Comment
|
||||
|
||||
module.exports = function(boardsAPI){
|
||||
var UserID = require('userID.jsx')()
|
||||
var GetIPFS = require('getipfs.jsx')()
|
||||
var Post = require('post.jsx')()
|
||||
var Comment = require('comment.jsx').Comment
|
||||
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { parent: false, api: false }
|
||||
@ -25,6 +24,11 @@ module.exports = function(boardsAPI){
|
||||
}
|
||||
})
|
||||
},
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
if(nextProps.params.commenthash !== this.props.params.commenthash){
|
||||
location.reload() // cheap hack, should swap with something more efficient
|
||||
}
|
||||
},
|
||||
init: function(boards){
|
||||
if(this.state.init) return
|
||||
this.setState({ api: true, boards: boards })
|
||||
|
@ -2,65 +2,63 @@ var React = require('react')
|
||||
var Link = require('react-router').Link
|
||||
var Icon = require('icon.jsx')
|
||||
|
||||
module.exports = function(){
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { connected: false, error: false, long: false }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(!this.isMounted()) return
|
||||
if(boards.isInit){
|
||||
this.setState({ connected: true })
|
||||
} else {
|
||||
setTimeout(_ => {
|
||||
if(this.isMounted()) this.setState({ long: true })
|
||||
}, 5000)
|
||||
boards.getEventEmitter().on('init', err => {
|
||||
if(!this.isMounted()) return
|
||||
if(err){
|
||||
this.setState({ error: true })
|
||||
} else {
|
||||
this.setState({ connected: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
var opt = require('options.jsx').get()
|
||||
if(this.state.error){
|
||||
return (
|
||||
<div className="">
|
||||
<h1><Icon name="ban"/> Connection to IPFS not available</h1>
|
||||
<h4 className="light">Sorry, but at the moment an external application is needed to try the Prototype</h4>
|
||||
<p>You don't have an IPFS node running at <code>{opt.addr}:{opt.port}</code> or it is not reachable.
|
||||
The IPFS Boards prototype requires a full IPFS node. Please start one by following the
|
||||
<a href="https://github.com/ipfs/go-ipfs"><code>go-ipfs</code> documentation.</a></p>
|
||||
<h5>Do you have a running node but the app won't work?</h5>
|
||||
<p>It's probably one of these issues:</p>
|
||||
<ul>
|
||||
<li>Your node is not located at <code>{opt.addr}:{opt.port}</code>. Go to the <Link to="/settings">Settings Page</Link> to configure the connection.</li>
|
||||
<li>You edited your settings and saved them but didn't reload the page</li>
|
||||
<li>Your IPFS node doesn't allow requests from the domain you're running the app from (CORS issue). See <a href="https://github.com/fazo96/ipfs-board/blob/master/ipfs_daemon_set_cors.sh">here</a> for the fix.</li>
|
||||
<li>You're downloading the app via `https`: at the moment, connecting to IPFS only works if you donwload the app via plain HTTP. If you're using `ipfs.io` please consider accessing the app via a local gateway like `localhost:8080`</li>
|
||||
<li>Some other networking or browser security issue is preventing the App from talking to your node.</li>
|
||||
</ul>
|
||||
<p>Still can't fix it? <a href="https://github.com/fazo96/ipfs-board/issues">File a issue on GitHub</a>, we'll be happy to help!</p>
|
||||
</div>
|
||||
)} else if(this.state.connected){
|
||||
return <div class="text-center">
|
||||
<h1><Icon name="check" /></h1>
|
||||
<h5 class="light">You're connected!</h5>
|
||||
</div>
|
||||
module.exports = React.createClass({
|
||||
getInitialState: function(){
|
||||
return { connected: false, error: false, long: false }
|
||||
},
|
||||
componentDidMount: function(){
|
||||
var boards = this.props.api
|
||||
if(boards){
|
||||
if(!this.isMounted()) return
|
||||
if(boards.isInit){
|
||||
this.setState({ connected: true })
|
||||
} else {
|
||||
return <div className="center-block text-center">
|
||||
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
|
||||
<h4>Connecting to IPFS</h4>
|
||||
{this.state.long?(<p>It's taking long... there's probably something wrong</p>):<p></p>}
|
||||
</div>
|
||||
setTimeout(_ => {
|
||||
if(this.isMounted()) this.setState({ long: true })
|
||||
}, 5000)
|
||||
boards.getEventEmitter().on('init', err => {
|
||||
if(!this.isMounted()) return
|
||||
if(err){
|
||||
this.setState({ error: true })
|
||||
} else {
|
||||
this.setState({ connected: true })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
render: function(){
|
||||
var opt = require('options.jsx').get()
|
||||
if(this.state.error){
|
||||
return (
|
||||
<div className="">
|
||||
<h1><Icon name="ban"/> Connection to IPFS not available</h1>
|
||||
<h4 className="light">Sorry, but at the moment an external application is needed to try the Prototype</h4>
|
||||
<p>You don't have an IPFS node running at <code>{opt.addr}:{opt.port}</code> or it is not reachable.
|
||||
The IPFS Boards prototype requires a full IPFS node. Please start one by following the
|
||||
<a href="https://github.com/ipfs/go-ipfs"><code>go-ipfs</code> documentation.</a></p>
|
||||
<h5>Do you have a running node but the app won't work?</h5>
|
||||
<p>It's probably one of these issues:</p>
|
||||
<ul>
|
||||
<li>Your node is not located at <code>{opt.addr}:{opt.port}</code>. Go to the <Link to="/settings">Settings Page</Link> to configure the connection.</li>
|
||||
<li>You edited your settings and saved them but didn't reload the page</li>
|
||||
<li>Your IPFS node doesn't allow requests from the domain you're running the app from (CORS issue). See <a href="https://github.com/fazo96/ipfs-board/blob/master/ipfs_daemon_set_cors.sh">here</a> for the fix.</li>
|
||||
<li>You're downloading the app via `https`: at the moment, connecting to IPFS only works if you donwload the app via plain HTTP. If you're using `ipfs.io` please consider accessing the app via a local gateway like `localhost:8080`</li>
|
||||
<li>Some other networking or browser security issue is preventing the App from talking to your node.</li>
|
||||
</ul>
|
||||
<p>Still can't fix it? <a href="https://github.com/fazo96/ipfs-board/issues">File a issue on GitHub</a>, we'll be happy to help!</p>
|
||||
</div>
|
||||
)} else if(this.state.connected){
|
||||
return <div class="text-center">
|
||||
<h1><Icon name="check" /></h1>
|
||||
<h5 class="light">You're connected!</h5>
|
||||
</div>
|
||||
} else {
|
||||
return <div className="center-block text-center">
|
||||
<Icon name="refresh" className="fa-3x center-block light fa-spin" />
|
||||
<h4>Connecting to IPFS</h4>
|
||||
{this.state.long?(<p>It's taking long... there's probably something wrong</p>):<p></p>}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -1,12 +1,11 @@
|
||||
var React = require('react')
|
||||
var Link = require('react-router').Link
|
||||
var UserID = require('userID.jsx')
|
||||
var GetIPFS = require('getipfs.jsx')
|
||||
var Post = require('post.jsx')
|
||||
var Comments = require('comment.jsx').Comments
|
||||
|
||||
module.exports = function(boardsAPI){
|
||||
var UserID = require('userID.jsx')()
|
||||
var GetIPFS = require('getipfs.jsx')()
|
||||
var Post = require('post.jsx')()
|
||||
var Comments = require('comment.jsx').Comments
|
||||
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { post: { title: '...', text: '...' }, api: false }
|
||||
|
@ -2,9 +2,9 @@ var React = require('react')
|
||||
var Markdown = require('markdown.jsx')
|
||||
var Link = require('react-router').Link
|
||||
var Icon = require('icon.jsx')
|
||||
var GetIPFS = require('getipfs.jsx')
|
||||
|
||||
module.exports = function(boardsAPI){
|
||||
var GetIPFS = require('getipfs.jsx')(boardsAPI)
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { name: '...', boards: [], api: false }
|
||||
|
@ -1,9 +1,9 @@
|
||||
var React = require('react')
|
||||
var Icon = require('icon.jsx')
|
||||
var GetIPFS = require('getipfs.jsx')
|
||||
var UserID = require('userID.jsx')
|
||||
|
||||
module.exports = function(boardsAPI){
|
||||
var GetIPFS = require('getipfs.jsx')()
|
||||
var UserID = require('userID.jsx')()
|
||||
return React.createClass({
|
||||
getInitialState: function(){
|
||||
return { users: [], api: false }
|
||||
|
Loading…
Reference in New Issue
Block a user