Skip to content

Commit 7447069

Browse files
committed
优化
1 parent 077bfd5 commit 7447069

File tree

7 files changed

+290
-34
lines changed

7 files changed

+290
-34
lines changed

access.log

+250
Large diffs are not rendered by default.

app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ app.use(function(req,res,next){
4848
next();
4949
});
5050

51-
http.createServer(app).listen(app.get('port'), function(err){
51+
app.listen(app.get('port'), function(err){
5252
console.log("Express server listening on port " + app.get('port'));
5353
});
5454

models/db.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ var mysql = require('mysql'),
33
settings = require('../settings');
44
var connection = mysql.createConnection({
55
host : settings.host,
6-
database : 'blog_mysql',
7-
user : 'root',
8-
password : ''
6+
port : settings.port,
7+
database : settings.db_name,
8+
user : settings.username,
9+
password : settings.password
910
});
1011
connection.connect();
1112
module.exports = connection;
13+

public/stylesheets/style.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* inspired by http://yihui.name/cn/ */
22
*{padding:0;margin:0;}
3-
body{width:600px;margin:2em auto;padding:0 2em;font-size:14px;font-family:"Microsoft YaHei";}
4-
p{line-height:24px;margin:1em 0;}
3+
.wrapper{width:600px;margin:2em auto;padding:0 2em;font-size:14px;
4+
font-family:"Microsoft YaHei";word-break:break-all;word-wrap:break-word;}
5+
p{line-height:24px;margin:1em 0;text-indent:2em;}
56
header{padding:.5em 0;border-bottom:1px solid #cccccc;}
67
nav{float:left;font-family:"Microsoft YaHei";font-size:1.1em;text-transform:uppercase;margin-left:-12em;width:9em;text-align:right;}
78
nav a{display:block;text-decoration:none;padding:.7em 1em;color:#000000;}

settings.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module.exports = {
22
cookieSecret: 'myblog_mysql',
3-
db: 'blog_mysql',
4-
host: 'localhost'
3+
db_name: 'blog_mysql',
4+
host: 'localhost',
5+
username: 'root',
6+
password: ''
57
};

views/footer.ejs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
</article>
1+
</article>
2+
</div>
23
</body>
34
</html>

views/header.ejs

+25-25
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@
1010
<% } %>
1111
</head>
1212
<body>
13+
<div class="wrapper">
14+
<header>
15+
<h1><%= title %></h1>
16+
</header>
1317

14-
<header>
15-
<h1><%= title %></h1>
16-
</header>
18+
<nav>
19+
<span><a title="主页" href="/">home</a></span>
20+
<% if(locals.user){ %>
21+
<span><a title="发表" href="/post">post</a></span>
22+
<span><a title="登出" href="/logout">logout</a></span>
23+
<% } else { %>
24+
<span><a title="登录" href="/login">login</a></span>
25+
<span><a title="注册" href="/reg">register</a></span>
26+
<% } %>
27+
</nav>
1728

18-
<nav>
19-
<span><a title="主页" href="/">home</a></span>
20-
<% if(locals.user){ %>
21-
<span><a title="发表" href="/post">post</a></span>
22-
<span><a title="登出" href="/logout">logout</a></span>
23-
<% } else { %>
24-
<span><a title="登录" href="/login">login</a></span>
25-
<span><a title="注册" href="/reg">register</a></span>
26-
<% } %>
27-
</nav>
28-
29-
<article>
30-
<% if (locals.success) { %>
31-
<div >
32-
<%= locals.success %>
33-
</div>
34-
<% } %>
35-
<% if (locals.error) { %>
36-
<div>
37-
<%= locals.error %>
38-
</div>
39-
<% } %>
29+
<article>
30+
<% if (locals.success) { %>
31+
<div >
32+
<%= locals.success %>
33+
</div>
34+
<% } %>
35+
<% if (locals.error) { %>
36+
<div>
37+
<%= locals.error %>
38+
</div>
39+
<% } %>

0 commit comments

Comments
 (0)