Skip to content

Commit

Permalink
首页显示所有用户,提供gravatar支持
Browse files Browse the repository at this point in the history
  • Loading branch information
sumory committed Mar 28, 2012
1 parent 61742bb commit fade7b7
Show file tree
Hide file tree
Showing 22 changed files with 48 additions and 15 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ sumorio是用nodejs开发的社区系统,借鉴了[nodeclub][1]的一些通用

#### 0.1.2

* 首页显示所有用户(临时)
* 支持gravatar头像
* 添加全站导航,在nav表中添加数据

#### 0.1.1
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports.config = {
session_secret : 'sumorio_secret',
auth_cookie_name : 'sumorio_secret',
app_port : 8080,
version : '0.1.1 beta',
version : '0.1.2 beta',

//logfiles directory
logDirectory : __dirname + "/logs/",
Expand Down
2 changes: 1 addition & 1 deletion controller/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ exports.signup = function(req, res, next) {
// create gavatar
var avatar_url = 'http://www.gravatar.com/avatar/' + common.md5(email) + '?size=48';

mysql.insert('insert into user(loginname,email,pwd,create_at) values(?,?,?,?)', [ loginname, email, pass, new Date() ], function(err, info) {
mysql.insert('insert into user(loginname,email,pwd,create_at,avatar) values(?,?,?,?,?)', [ loginname, email, pass, new Date(), avatar_url ], function(err, info) {
if (err)
return next(err);
res.render('sign/signup', {
Expand Down
10 changes: 7 additions & 3 deletions controller/site.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
var config = require('../config').config;
var mysql = require('../lib/mysql.js');

exports.index = function(req, res, next) {

res.render('index', {
"welcome" : "welcome to sumorio"
mysql.query('select * from user', function(err,users){//得到所有的用户
res.render('index', {
users : users
});
return;
});

};
5 changes: 4 additions & 1 deletion controller/user.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
var log = require('../lib/log.js');
var config = require('../config.js').config;
var common = require('./common.js');
var mysql = require('../lib/mysql.js');

/**
* 到用户首页
* 到所选用户首页
*
* @param req
* @param res
Expand All @@ -21,3 +22,5 @@ exports.index = function(req, res, next) {
});
});
};


Empty file added logs/error.log.2012-03-20
Empty file.
Empty file added logs/error.log.2012-03-25
Empty file.
Empty file added logs/error.log.2012-03-26
Empty file.
Empty file added logs/error.log.2012-03-28
Empty file.
Empty file added logs/exception.log.2012-03-20
Empty file.
Empty file added logs/exception.log.2012-03-25
Empty file.
Empty file added logs/exception.log.2012-03-26
Empty file.
Empty file added logs/exception.log.2012-03-28
Empty file.
Empty file added logs/info.log.2012-03-20
Empty file.
Empty file added logs/info.log.2012-03-25
Empty file.
Empty file added logs/info.log.2012-03-26
Empty file.
Empty file added logs/info.log.2012-03-28
Empty file.
Binary file modified public/img/avatar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 26 additions & 4 deletions view/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@



<div class='panel' style="width: 600px; margin: auto; margin-top: 50px;height:300px;">
<div class='panel' style="width: 100%; margin: auto; margin-top: 50px;height:300px;">
<div class='inner'>
<div class='sep10'></div>
<div class='sep10'></div>

<!--
<div class='control-group'>
<%-welcome%>
<br>
sumorio(summary => input | ouput)<br/>
sumorio是基于nodejs开发的社区系统, 现已完成个人部分功能, 社区功能正在开发中...
Expand All @@ -27,6 +27,28 @@
}
%>
</div>

-->

<% for(var i =0;i< locals.users.length;i++){
var user = locals.users[i];
%>
<div class='user' style="background-color:#ffffff;">
<div>
<% if(user.avatar){ %>
<a href='/user/<%= user.loginname %>'><img class='user_avatar' src='<%= user.avatar %>' title='<%= user.loginname %>' /></a>
<% }else{ %>
<a href='/user/<%= user.loginname %>'><img class='user_avatar' src='/img/avatar.png' title='<%= user.loginname %>' /></a>
<% } %>
<span class='user_name'><a class='dark' href='/user/<%= user.id %>'><%= user.loginname %></a></span>
<div class='sep5'></div>
<span class='col_fade'></span>
<span class='sp5'></span>
<span class='col_fade'></span>
</div>
<div class='sep10'></div>
</div>
<%}%>


</div>
</div>
4 changes: 3 additions & 1 deletion view/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<a href="/user/<%=current_user.id %>" class="nav"><%=current_user.loginname %><span></span></a>
<ul>
<li><a href="/user/<%=current_user.id%>">我的主页</a></li>
<li><a href="/user/settings/">帐号设置</a></li>
<!-- <li><a href="/user/settings/">帐号设置</a></li> -->
<li class="divider"><a href="/signout">退出登录</a></li>
</ul>
</li>
Expand Down Expand Up @@ -61,13 +61,15 @@

</script>
<div id="search">
<!--
<form id="search_form" method="get" action="/" class="text">
<input id="query" type="text" size="27" name="q"
autocomplete="off" placeholder="搜索话题" value=""
class="default_value"><a style="width:16px;height:17px;" id="search_lens" href="#"
onclick="$(&#39;search_form&#39;).submit();return false;"
class="lg"><img src="/img/search.gif" alt="搜索"></a>
</form>
-->
</div>

</div>
Expand Down
2 changes: 1 addition & 1 deletion view/reply/reply.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class='cell reply_area reply_item' id='reply<%= indexInCollection+1 %>' reply_id='<%= reply.id %>'>
<% if(reply.author.avatar){ %>
<div class='user_avatar'><a href='/user/<%= reply.author.id %>'><img src='/img/<%= reply.author.avatar %>' title='<%= reply.author.loginname %>' /></a></div>
<div class='user_avatar'><a href='/user/<%= reply.author.id %>'><img src='<%= reply.author.avatar %>' title='<%= reply.author.loginname %>' /></a></div>
<% }else{ %>
<div class='user_avatar'><a href='/user/<%= reply.author.id %>'><img src='/img/avatar.png' title='<%= reply.author.loginname %>' /></a></div>
<% } %>
Expand Down
6 changes: 3 additions & 3 deletions view/user/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<div class='user_card'>
<div class='user_card_left'>
<h1><a href="/user/<%=user.id%>"><%= user.loginname%></a></h1>
<p><a href="/followers/">粉丝<span>0</span></a></p>
<p><a href="/following/">关注<span>2</span></a></p>
<!-- <p><a href="/followers/">粉丝<span>0</span>个</a></p>
<p><a href="/following/">关注<span>2</span>人</a></p>-->
</div>
<div class='user_card_right'>
<a href="/user/<%=user.id%>" title="echover" class="img x"><img src="/img/avatar.png"></a>
<a href="/user/<%=user.id%>" title="echover" class="img x"><img src="<%=user.avatar%>"></a>
</div>
</div>

Expand Down

0 comments on commit fade7b7

Please sign in to comment.