diff --git a/.gitignore b/.gitignore index 36170a7..17e43c0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules public +db.json diff --git a/db.json b/db.json index f08c31c..78e8ee5 100644 --- a/db.json +++ b/db.json @@ -1,16 +1,34 @@ { - "posts": [ - { - "id": 1, - "title": "json-server", - "author": "typicode" - } - ], "comments": [ { - "id": 1, - "body": "some comment", - "postId": 1 + "author": "Maki Nishikino", + "text": "imi wakannai", + "postdate": 1427032542268, + "id": "c9fd1ac6-b2f7-4a6c-b63e-099c851a0f31" + }, + { + "author": "Nico Yazawa", + "text": "Nico nico nii~", + "postdate": 1427034542268, + "id": "e8686677-41da-4bef-b033-cc678e08e814" + }, + { + "author": "Aoba Suzukaze", + "text": "zoi", + "postdate": 1427038542268, + "id": "a5a3e078-8033-44dc-8f3b-43e443415b5a" + }, + { + "author": "Kou Yagami", + "text": "Shigoto bakka sitettoyo-", + "postdate": 1427040542268, + "id": "cb550e14-8063-4113-9948-48d996e29d26" + }, + { + "author": "Yuiko Kuroki", + "text": "Tomoya!", + "postdate": 1427041542268, + "id": "66c06445-8de5-4f0d-83bf-6e00c45bbb8b" } ], "favicon.ico": [] diff --git a/gulpfile.js b/gulpfile.js index 66a1fd6..81f0469 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,7 +14,7 @@ gulp.task('build.copy', function() { gulp.task('build.react', function(){ var b = browserify({ - entries: ['./src/javascripts/hello.jsx'], + entries: ['./src/javascripts/main.js'], transform: [reactify] }); return b.bundle() @@ -24,8 +24,16 @@ gulp.task('build.react', function(){ gulp.task('build', ['build.copy','build.react']); -gulp.task('run', ['build'], function() { - var exec = require("child_process").exec - exec('json-server db.json') - console.log('db ok') -}); +gulp.task('json-server', function() { + var jsonServer = require('json-server') + var object = require('./db.json'); + + var router = jsonServer.router('./db.json'); // Express router + var server = jsonServer.create() // Express server + var port = 3000; + server.use(router) + server.listen(port) + console.log('json-server is ready at port:' + port) +}) + +gulp.task('run', ['build', 'json-server']); diff --git a/package.json b/package.json index a203de8..ea58b9b 100644 --- a/package.json +++ b/package.json @@ -31,5 +31,10 @@ "json-server": "0.6.4" }, "favicon.ico": [], - "javascripts": [] -} \ No newline at end of file + "javascripts": [], + "dependencies": { + "dateformat": "^1.0.11", + "glob": "^5.0.3", + "superagent": "^1.1.0" + } +} diff --git a/src/index.html b/src/index.html index 5fd21db..95c6577 100644 --- a/src/index.html +++ b/src/index.html @@ -1,9 +1,12 @@
+ + - + + diff --git a/src/javascripts/main.js b/src/javascripts/main.js new file mode 100644 index 0000000..27c13dc --- /dev/null +++ b/src/javascripts/main.js @@ -0,0 +1,148 @@ +var React = require('react'); +var converter = new Showdown.converter(); +var dateFormat = require('dateformat'); +var request = require('superagent'); + +var CommentHeader = React.createClass({ + render: function() { + return ( +