Node.js sample application with Socket.IO
リビジョン | 697ad4f1a1cf226025fe58fb5874fc5fa05905dd (tree) |
---|---|
日時 | 2012-10-23 23:28:54 |
作者 | hylom <hylom@hylo...> |
コミッター | hylom |
implement initial html & css
@@ -5,7 +5,6 @@ | ||
5 | 5 | |
6 | 6 | var express = require('express') |
7 | 7 | , routes = require('./routes') |
8 | - , user = require('./routes/user') | |
9 | 8 | , http = require('http') |
10 | 9 | , path = require('path'); |
11 | 10 |
@@ -28,7 +27,7 @@ app.configure('development', function(){ | ||
28 | 27 | }); |
29 | 28 | |
30 | 29 | app.get('/', routes.index); |
31 | -app.get('/users', user.list); | |
30 | +app.post('/room', routes.room); | |
32 | 31 | |
33 | 32 | http.createServer(app).listen(app.get('port'), function(){ |
34 | 33 | console.log("Express server listening on port " + app.get('port')); |
@@ -1,8 +1,28 @@ | ||
1 | 1 | body { |
2 | 2 | padding: 50px; |
3 | 3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif; |
4 | + color: #333; | |
4 | 5 | } |
5 | 6 | |
6 | 7 | a { |
7 | 8 | color: #00B7FF; |
9 | +} | |
10 | + | |
11 | +#messages { | |
12 | + margin-top: 60px; | |
13 | + background: white; | |
14 | + border: 1px solid #bbb; | |
15 | +} | |
16 | + | |
17 | +.message { | |
18 | + border-bottom: 1px solid #ddd; | |
19 | + line-height: 120%; | |
20 | +} | |
21 | + | |
22 | +.message .postdate { | |
23 | + color: #aaa; | |
24 | +} | |
25 | + | |
26 | +.message .author { | |
27 | + font-weight: bold; | |
8 | 28 | } |
\ No newline at end of file |
@@ -0,0 +1,5 @@ | ||
1 | +// minichat.js | |
2 | + | |
3 | +(function () { | |
4 | + | |
5 | +}).apply(this); |
@@ -4,5 +4,21 @@ | ||
4 | 4 | */ |
5 | 5 | |
6 | 6 | exports.index = function(req, res){ |
7 | - res.render('index', { title: 'Express' }); | |
8 | -}; | |
\ No newline at end of file | ||
7 | + res.render('index', { title: 'minichat' }); | |
8 | +}; | |
9 | + | |
10 | +exports.room = function(req, res){ | |
11 | + var roomName = req.body.roomName || ''; | |
12 | + var yourName = req.body.yourName || ''; | |
13 | + var password = req.body.password || ''; | |
14 | + | |
15 | + var params = { | |
16 | + title: 'チャットルーム:' + roomName, | |
17 | + room: { | |
18 | + name: roomName, | |
19 | + password: password | |
20 | + }, | |
21 | + user: {name: yourName} | |
22 | + }; | |
23 | + res.render('room', params); | |
24 | +}; |
@@ -1,8 +0,0 @@ | ||
1 | - | |
2 | -/* | |
3 | - * GET users listing. | |
4 | - */ | |
5 | - | |
6 | -exports.list = function(req, res){ | |
7 | - res.send("respond with a resource"); | |
8 | -}; | |
\ No newline at end of file |
@@ -1,5 +1,50 @@ | ||
1 | 1 | extends layout |
2 | - | |
3 | 2 | block content |
4 | - h1= title | |
5 | - p Welcome to #{title} | |
\ No newline at end of file | ||
3 | + | |
4 | + .container | |
5 | + .hero-unit | |
6 | + h1= title | |
7 | + p node.jsによるシンプルなチャットWebアプリケーション | |
8 | + | |
9 | + .row | |
10 | + .span6 | |
11 | + h2 Create: | |
12 | + p チャットルームを新しく作成する | |
13 | + form#new.form-horizontal(action='/room/', method='post') | |
14 | + .control-group | |
15 | + label.control-label(for='new-room-name') 作成するルーム名 | |
16 | + .controls | |
17 | + input#new-room(type='text', name='roomName', placeholder='ルーム名を入力...') | |
18 | + .control-group | |
19 | + label.control-label(for='new-name') 表示するあなたの名前 | |
20 | + .controls | |
21 | + input#new-name(type='text', name='yourName', placeholder='表示名を入力...') | |
22 | + .control-group | |
23 | + label.control-label(for='new-password') 認証用パスワード | |
24 | + .controls | |
25 | + label | |
26 | + input#new-password(type='password', name='password', placeholder='パスワードを入力...') | |
27 | + button#create(type='submit', class='btn', name='create') チャットルームを作成 | |
28 | + | |
29 | + .span6 | |
30 | + h2 Enter: | |
31 | + p 既存のチャットルームに入る | |
32 | + form#enter.form-horizontal(action='/enter/', method='post') | |
33 | + .control-group | |
34 | + label.control-label(for='enter-room') ルーム名 | |
35 | + .controls | |
36 | + input#enter-room(type='text', name='roomName', placeholder='ルーム名を入力...') | |
37 | + .control-group | |
38 | + label.control-label(for='enter-name') 表示するあなたの名前 | |
39 | + .controls | |
40 | + input#enter-name(type='text', name='yourName', placeholder='表示名を入力...') | |
41 | + .control-group | |
42 | + label.control-label(for='enter-password') 認証用パスワード | |
43 | + .controls | |
44 | + label | |
45 | + input#enter-password(type='password', name='password', placeholder='パスワードを入力...') | |
46 | + button(type='submit', name='enter', class='btn') チャットルームへ入る | |
47 | + | |
48 | + hr | |
49 | + footer | |
50 | + p minichat 0.0.1 | |
\ No newline at end of file |
@@ -2,8 +2,10 @@ doctype 5 | ||
2 | 2 | html |
3 | 3 | head |
4 | 4 | title= title |
5 | - link(rel='stylesheet', href='/stylesheets/style.css') | |
6 | - script(src='js/jquery-1.8.2.min.js') | |
5 | + link(rel='stylesheet', href='/css/style.css') | |
6 | + link(rel='stylesheet', href='/css/bootstrap.css') | |
7 | + script(src='/js/jquery-1.8.2.min.js') | |
8 | + script(src='/js/minichat.js') | |
7 | 9 | script(src='/js/bootstrap.min.js') |
8 | 10 | body |
9 | 11 | block content |
\ No newline at end of file |
@@ -0,0 +1,30 @@ | ||
1 | +extends layout | |
2 | +block content | |
3 | + | |
4 | + .navbar.navbar-inverse.navbar-fixed-top | |
5 | + .navbar-inner | |
6 | + .container | |
7 | + a.brand(href='/') minichat | |
8 | + ul.nav | |
9 | + li | |
10 | + a ルーム名:#{room.name} | |
11 | + li | |
12 | + a(href='/') 退出する | |
13 | + .container | |
14 | + .row | |
15 | + .span4 | |
16 | + h3 | |
17 | + span#yourname #{user.name} | |
18 | + form(action='#') | |
19 | + label | |
20 | + textarea#new-message.span4(rows='5', placeholder='メッセージを入力...') | |
21 | + button(type='submit', class='btn') メッセージを投稿 | |
22 | + .span8 | |
23 | + #messages.well | |
24 | + .message | |
25 | + p.postdate.pull-right 10/23 12:34 | |
26 | + p.author システムメッセージ: | |
27 | + p.comment チャットルーム「hogehoge」が作成されました。 | |
28 | + hr | |
29 | + footer | |
30 | + p minichat 0.0.1 | |
\ No newline at end of file |