From 46c2eb43095aa5173d1aebace386bb4df6933623 Mon Sep 17 00:00:00 2001 From: Enrico Fasoli Date: Sat, 14 Nov 2015 13:12:48 +0100 Subject: [PATCH] added routing and some css --- lib/boards-api.js | 2 +- package.json | 5 ++++- webapp/app.jsx | 35 ++++++++++++++++++++++++++++++----- webapp/style.css | 5 +++++ 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/lib/boards-api.js b/lib/boards-api.js index e25e8e2..e06720e 100644 --- a/lib/boards-api.js +++ b/lib/boards-api.js @@ -65,7 +65,7 @@ BoardsAPI.prototype.resolveIPNS = function(n,done){ done(null,cached) } this.ipfs.name.resolve(n,(err,r) => { - console.log('Resolved',n,'to',r) + if(!err) console.log('Resolved',n,'to',r.Path) if(err){ done(err) } else if(!cached){ diff --git a/package.json b/package.json index 4193655..89ed463 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,14 @@ "gulp-connect": "^2.2.0", "gulp-minify-css": "^1.2.1", "gulp-uglify": "^1.5.1", + "history": "^1.13.1", "ipfs-api": "^2.6.2", "moment": "^2.10.6", "react": "^0.14.2", "react-dom": "^0.14.2", + "react-router": "^1.0.0", "vinyl-buffer": "^1.0.0", - "vinyl-source-stream": "^1.1.0" + "vinyl-source-stream": "^1.1.0", + "wolfy87-eventemitter": "^4.3.0" } } diff --git a/webapp/app.jsx b/webapp/app.jsx index 9cf5de2..259c395 100644 --- a/webapp/app.jsx +++ b/webapp/app.jsx @@ -1,5 +1,10 @@ var React = require('react') var ReactDOM = require('react-dom') +var Router = require('react-router').Router +var Route = require('react-router').Route +var IndexRoute = require('react-router').IndexRoute +var Link = require('react-router').Link + var ipfs = require('ipfs-api')('localhost',5001) var BoardsAPI = require('../lib/boards-api.js') @@ -20,7 +25,11 @@ var App = React.createClass({ var Homepage = React.createClass({ render: function(){ return ( -

Hello

+
+

Hello

+

Not much is implemented...

+

You can try Opening a Profile though :)

+
) } }) @@ -30,7 +39,7 @@ var Navbar = React.createClass({ return (
-

Boards

+

Boards

) } @@ -41,7 +50,7 @@ var Profile = React.createClass({ return { name: '...' } }, componentDidMount: function(){ - boards.getProfile(this.props.id, (err,res) => { + boards.getProfile(this.props.params.userid, (err,res) => { if(err){ console.log(err) this.setState({ @@ -58,11 +67,27 @@ var Profile = React.createClass({ return (

{this.state.name}

{this.state.error}

-
@{this.props.id}
+
@{this.props.params.userid}
) } }) +var Board = React.createClass({ + getInitialState: function(){ + return { posts: [] } + }, + render: function(){ + return ( +
+ ) + } +}) + ReactDOM.render( - , document.getElementById('root') + + + + + + , document.getElementById('root') ) diff --git a/webapp/style.css b/webapp/style.css index 0480aaf..f171274 100644 --- a/webapp/style.css +++ b/webapp/style.css @@ -20,6 +20,11 @@ height: 4.5em } +.navbar a { + text-decoration: none; + color: inherit; +} + .navbar .container { padding-top: 1em }