• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Node.js sample application with Socket.IO


Commit MetaInfo

Revisão697ad4f1a1cf226025fe58fb5874fc5fa05905dd (tree)
Hora2012-10-23 23:28:54
Autorhylom <hylom@hylo...>
Commiterhylom

Mensagem de Log

implement initial html & css

Mudança Sumário

Diff

--- a/app.js
+++ b/app.js
@@ -5,7 +5,6 @@
55
66 var express = require('express')
77 , routes = require('./routes')
8- , user = require('./routes/user')
98 , http = require('http')
109 , path = require('path');
1110
@@ -28,7 +27,7 @@ app.configure('development', function(){
2827 });
2928
3029 app.get('/', routes.index);
31-app.get('/users', user.list);
30+app.post('/room', routes.room);
3231
3332 http.createServer(app).listen(app.get('port'), function(){
3433 console.log("Express server listening on port " + app.get('port'));
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -1,8 +1,28 @@
11 body {
22 padding: 50px;
33 font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4+ color: #333;
45 }
56
67 a {
78 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;
828 }
\ No newline at end of file
--- /dev/null
+++ b/public/js/minichat.js
@@ -0,0 +1,5 @@
1+// minichat.js
2+
3+(function () {
4+
5+}).apply(this);
--- a/routes/index.js
+++ b/routes/index.js
@@ -4,5 +4,21 @@
44 */
55
66 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+};
--- a/routes/user.js
+++ /dev/null
@@ -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
--- a/views/index.jade
+++ b/views/index.jade
@@ -1,5 +1,50 @@
11 extends layout
2-
32 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
--- a/views/layout.jade
+++ b/views/layout.jade
@@ -2,8 +2,10 @@ doctype 5
22 html
33 head
44 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')
79 script(src='/js/bootstrap.min.js')
810 body
911 block content
\ No newline at end of file
--- /dev/null
+++ b/views/room.jade
@@ -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