Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: hiroeorz/hivespark
base: 147524a8e2
...
head fork: hiroeorz/hivespark
compare: de6fcff8b2
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
1  priv/views/team_index.html
@@ -48,6 +48,7 @@ <h1 id="title"></h1>
<div id="menu">
<ul>
<li><a href="#" class="on">トップ</a></li>
+ <li><a href="/usr/index" class="on">登録ユーザ</a></li>
</ul>
<ul style="display:block; float:right;">
View
94 priv/views/usr_list.html
@@ -0,0 +1,94 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
+<head>
+<style type="text/css">
+
+element {
+}
+
+</style>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
+<meta http-equiv="Content-style-Type" content="text/css" />
+<link rel="stylesheet" href="/shared/css/base.css" type="text/css" />
+<script type="text/javascript" src="/shared/js/jquery.js"></script>
+<script type="text/javascript" src="/shared/js/hs_util.js"></script>
+<script type="text/javascript" src="/shared/js/usr_list_view_controller.js"></script>
+
+<script type="text/javascript">
+//<![CDATA[
+ window.onload = function() {
+ new HS.UsrListViewController().view_did_load();
+ }
+//]]>
+</script>
+
+
+<title>HiveSpark</title>
+</head>
+<body>
+<div id="top">
+ <div id="header">
+ <h1 id="title"></h1>
+
+ <div id="navi">
+ <ul>
+ <li class="settings"><a href="">設定</a></li>
+ <li class="logout"><a href="/usr/logout?format=html">ログアウト</a></li>
+ </ul>
+ </div><!-- navi end -->
+ </div><!-- header end -->
+
+ <div id="menu">
+ <ul>
+ <li><a href="/team/index" class="on">トップ</a></li>
+ </ul>
+
+ <ul id="add-new-team-menu" style="display:block; float:right;">
+ </ul>
+
+ </div><!-- menu end -->
+
+ <div id="contents">
+
+
+ <div id="timeline_scroll" class="usr-list">
+ <ul id="timeline">
+ <li>
+ <img src="/usr/image?fname=17.jpg">
+ <b>シン</b>
+ <p>猫をこよなく愛すスーパー牛さんパワー使いのRubyプログラマ。iPhoneプログラムも組んでます。 音楽系</p>
+ </li>
+ <li>
+ <img src="/usr/image?fname=16.jpg">
+ <b>シン</b>
+ <p>猫をこよなく愛すスーパー牛さんパワー使いのRubyプログラマ。iPhoneプログラムも組んでます。 音楽系</p>
+ </li>
+ <li>
+ <img src="/usr/image?fname=20.jpg">
+ <b>シン</b>
+ <p>猫をこよなく愛すスーパー牛さんパワー使いのRubyプログラマ。iPhoneプログラムも組んでます。 音楽系</p>
+ </li>
+ </ul>
+ </div>
+
+ <div id="usr-show">
+ <div id="usr-description">
+ <img src="/usr/image?fname=17.jpg">
+ <b>シン</b><br />
+ <p>猫をこよなく愛すスーパー牛さんパワー使いのRubyプログラマ。iPhoneプログラムも組んでます。 音楽系</p>
+
+ </div>
+ <div style="clear:both;"></div>
+ </div>
+
+ </div><!-- contents end -->
+ <div id="totop">
+ <a href="#top">ページのトップへ戻る</a>
+ </div><!-- totop end -->
+ <div id="footer">
+ <address>Copyright &copy; 2009 YOUR SITE NAME All Rights Reserved.</address>
+ </div><!-- footer end -->
+</div><!-- top end -->
+</body>
+</html>
View
35 priv/www/css/base.css
@@ -913,4 +913,39 @@ a#new-ticket-link {
display: block;
float: right;
margin-top: -30px;
+}
+
+div#usr-show {
+ margin-left: 340px;
+}
+
+div#usr-show div#usr-description {
+ width: 600px;
+ min-height: 100px;
+ border: 1px solid #bababa;
+ padding: 5px;
+}
+
+div#usr-show div#usr-description img {
+ width: 100px;
+ height: 100px;
+ display: inline;
+ float: left;
+}
+
+div#usr-show div#usr-description b {
+ display: block;
+ float: left;
+ margin-left: 10px;
+}
+
+div#usr-show div#usr-description p {
+ font-size: 0.8em;
+ color: #777;
+ margin-left: 110px;
+}
+
+div#contents div.usr-list ul#timeline li {
+ border-right: 1px solid #bababa;
+ cursor: pointer;
}
View
29 priv/www/js/hs_notification.js
@@ -99,6 +99,9 @@ HS.Notification.prototype = (function () {
*
* @method handle_message
*/
+ var notification_change_flag = false;
+ var notification_title_change_timer = null;
+
var handle_message = function(msg) {
var view = create_notification_view(msg.message);
$("div.notification-message").remove();
@@ -110,6 +113,32 @@ HS.Notification.prototype = (function () {
setTimeout(function() {
$(view).animate({opacity:0.5}, 2000);
}, 10000)
+
+ var original_title = $("title").text();
+
+ /* 他のユーザのメッセージ投稿があった場合にウインドウのタイトルを反転させる */
+ if (notification_title_change_timer == undefined) {
+ notification_title_change_timer = setInterval(function() {
+ if (true == notification_change_flag) {
+ $("title").text("新規メッセージがあります");
+ notification_change_flag = false;
+ } else {
+ $("title").text(original_title);
+ notification_change_flag = true;
+ }
+ }, 1000);
+
+ var stop_fun = function() {
+ clearInterval(notification_title_change_timer);
+ $("title").text(original_title);
+ notification_title_change_timer = undefined;
+ window.onfocus = undefined;
+ document.onclick = undefined;
+ };
+
+ window.onfocus = stop_fun;
+ document.onclick = stop_fun;
+ };
};
/**
View
117 priv/www/js/usr_list_view_controller.js
@@ -0,0 +1,117 @@
+var HS = HS || {};
+
+/**
+ * チーム情報の表示
+ *
+ * @namespace HS
+ * @class TeamViewController
+*/
+
+HS.UsrListViewController = function () { 'use strict'; this.init(); };
+
+HS.UsrListViewController.prototype = (function () {
+ 'use strict';
+
+ /* private */
+
+ /**
+ * サーバからユーザ情報を取得してリスト表示します
+ *
+ * @method get_usr_list
+ */
+ var get_usr_list = function() {
+ $("ul#timeline").empty();
+
+ $.getJSON("/usr/all", {},
+ function(usrs) {
+ for (var i = 0; i < usrs.length; i++) {
+ var usr_li = create_list_of_usr_view(usrs[i]);
+ $("ul#timeline").append(usr_li);
+ }
+ });
+ };
+
+ /**
+ * ユーザ一人分のビューを作って返します
+ *
+ * @method create_list_of_usr_view
+ */
+ var create_list_of_usr_view = function(usr) {
+ var li = document.createElement("li");
+
+ var img = document.createElement("img")
+ img.src = usr.icon_url;
+ img.title = usr.name;
+ img.alt = usr.name;
+
+ var name_b = document.createElement("b");
+ var name_text = document.createTextNode(usr.longname);
+ name_b.appendChild(name_text);
+
+ var description_p = document.createElement("p");
+ var description_text = "";
+
+ if (usr.description.length < 40) {
+ description_text = document.createTextNode(usr.description);
+ } else {
+ description_text =
+ document.createTextNode(usr.description.substr(0, 40) + "..");
+ }
+
+ description_p.appendChild(description_text);
+
+ li.appendChild(img);
+ li.appendChild(name_b);
+ li.appendChild(description_p);
+
+ $(li).bind("click", function() {
+ show_usr_info(usr);
+ });
+
+ return li;
+ }
+
+ /**
+ * 選択されたユーザ情報を表示する
+ *
+ * @method show_usr_info
+ */
+ var show_usr_info = function(usr) {
+ $("div#usr-description img").attr("src", usr.icon_url);
+ $("div#usr-description b").text(usr.longname);
+ $("div#usr-description p").text(usr.description);
+ }
+
+ /**
+ * 各オブジェクトのイベントリスナを登録します
+ *
+ * @method set_default_event_lister
+ */
+ var set_default_event_lister = function(params) {
+ };
+
+ /* public */
+ return {
+ /**
+ * 初期化
+ *
+ * @method init
+ */
+ init: function () {
+ },
+
+ /**
+ * 画面表示直後に呼ばれる
+ *
+ * @method view_did_load
+ */
+ view_did_load: function () {
+ var self = this;
+ var params = new HS.Util().qs_vals();
+ set_default_event_lister(params);
+ get_usr_list();
+ }
+
+ };
+}());
+
View
6 src/hs_team.erl
@@ -214,7 +214,11 @@ to_tuple(TeamId) when is_integer(TeamId) ->
end;
to_tuple(Team) ->
- {ok, Owner} = hs_usr:lookup_id(Team#team.owner_id),
+ Owner = case hs_usr:lookup_id(Team#team.owner_id) of
+ {ok, Usr} -> Usr;
+ {error, not_found} -> null
+ end,
+
{ok, Members} = get_members(Team#team.id),
{[{id, Team#team.id}, {owner, hs_usr:to_tuple(Owner)},
View
13 src/hs_usr.erl
@@ -13,7 +13,7 @@
-include("hivespark.hrl").
%% API
--export([create/6, update/1, delete/1, lookup_id/1, lookup_name/1,
+-export([all/1, create/6, update/1, delete/1, lookup_id/1, lookup_name/1,
authenticate/2,
get_teams/1, add_team/2, delete_team/2,
to_tuple/1, add_message/2, get_messages/2, get_messages/3,
@@ -27,6 +27,17 @@
%%%===================================================================
%%--------------------------------------------------------------------
+%% @doc
+%% 登録が新しい順に指定個数のユーザリストを返す
+%% @end
+%%--------------------------------------------------------------------
+-spec all(Count) -> {ok, UsrList} when
+ Count :: integer() | binary(),
+ UsrList :: [#usr{}] | [].
+all(Count) when is_binary(Count)-> all(list_to_integer(binary_to_list(Count)));
+all(Count) when is_integer(Count)-> hs_usr_db:all(Count).
+
+%%--------------------------------------------------------------------
%% @doc create new user.
%% @end
%%--------------------------------------------------------------------
View
14 src/hs_usr_db.erl
@@ -14,7 +14,8 @@
%% API
-export([q/1, q/2,
- list/1, insert/6, lookup_id/1, lookup_name/1, update/1, delete/1,
+ all/1, list/1, insert/6, lookup_id/1, lookup_name/1,
+ update/1, delete/1,
authenticate/2,
add_team/2, delete_team/2, get_team_id_list/1]).
@@ -53,6 +54,17 @@ q(Sql, Params) ->
end.
%%--------------------------------------------------------------------
+%% @doc
+%% 登録が新しい順に指定個数のユーザリストを返す
+%% @end
+%%--------------------------------------------------------------------
+-spec all(Count) -> {ok, UsrList} when
+ Count :: integer(),
+ UsrList :: [#usr{}] | [].
+all(Count) ->
+ q("select * from usrs order by id desc limit $1", [Count]).
+
+%%--------------------------------------------------------------------
%% @doc get usr list from user id list.
%% @end
%%--------------------------------------------------------------------
View
10 src/usr_handler.erl
@@ -42,7 +42,9 @@ handle(Req, State) -> hs_router:handle(?MODULE, Req, State).
handle_route(Action, Args) ->
case Action of
+ <<"index">> -> index(Args);
<<"edit">> -> edit(Args);
+ <<"all">> -> all(Args);
<<"upload_icon">> -> upload_icon(Args);
<<"logout">> -> logout(Args);
<<"show_myself">> -> show_myself(Args);
@@ -56,12 +58,20 @@ handle_route(Action, Args) ->
%%% Request Handle Functions
%%%===================================================================
+index([_ParamList, _Req, State, _SessionKey]) ->
+ hs_util:view("usr_list.html", State).
+
edit([_ParamList, _Req, State, _SessionKey]) ->
hs_util:view("usr_edit.html", State).
upload_icon([_ParamList, _Req, State, _SessionKey]) ->
hs_util:view("usr_upload_icon.html", State).
+all([_ParamList, _Req, State, _SessionKey]) ->
+ {ok, UsrList} = hs_usr:all(50), %% とりあえず上限50
+ TUsrList = lists:map(fun(U) -> hs_usr:to_tuple(U) end, UsrList),
+ hs_util:ok(jiffy:encode(TUsrList), State).
+
logout([ParamList, _Req, State, SessionKey]) ->
Format = proplists:get_value(<<"format">>, ParamList),
ok = hs_session:abandon(SessionKey),

No commit comments for this range

Something went wrong with that request. Please try again.