forked from AlexanderWingard/umts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/AlexanderWingard/umts
Conflicts: site/include/umts_db.hrl site/src/index.erl site/src/umts_db.erl and fixed cookie login redirect
- Loading branch information
Showing
11 changed files
with
187 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "nitrogen"] | ||
path = nitrogen | ||
url = git://github.com/rklophaus/nitrogen.git | ||
url = http://github.com/rklophaus/nitrogen.git | ||
[submodule "esmtp"] | ||
path = esmtp | ||
url = git://github.com/AlexanderWingard/esmtp.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{esmtp, [{smarthost, {"mailout.comhem.se", 25}}]}]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
-record(users, {id, name, password, display, lastlogin}). | ||
-record(users, {id, name, password, display, email, lastlogin}). | ||
-record(wtts, {id, timestamp, wanters = ordsets:new(), havers = ordsets:new()}). | ||
-record(auto_increment, {table, key}). | ||
-record(cards, {id, name, color=[]}). | ||
-record(events, {time, event}). | ||
-record(login_event, {user}). | ||
-record(register_event, {user}). | ||
-record(wtt_event, {user, card, kind}). | ||
|
||
%% mnesia:transform_table(users, fun({users, Id, Name, Password, Display}) -> {users, Id, Name, Password, Display, ""} end, [id, name, password, display, email]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-module(eventlog). | ||
-compile(export_all). | ||
-include_lib("nitrogen/include/wf.hrl"). | ||
|
||
-include("umts_db.hrl"). | ||
|
||
main() -> | ||
#template{file = "./templates/bare.html"}. | ||
|
||
title() -> | ||
"Recent events". | ||
|
||
body() -> | ||
#container_12{body = [#grid_8{ | ||
alpha=true, | ||
prefix=2, | ||
suffix=2, | ||
omega=true, | ||
body=umts_eventlog:get_events() | ||
}]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
-module(umts_eventlog). | ||
-compile(export_all). | ||
-include_lib("nitrogen/include/wf.hrl"). | ||
|
||
-include("umts_db.hrl"). | ||
|
||
log_login(User) -> | ||
log_event(#login_event{user = User}). | ||
|
||
log_register(User) -> | ||
log_event(#register_event{user = User}). | ||
|
||
log_wtt(User, Card, Kind) -> | ||
log_event(#wtt_event{user = User, card = Card, kind = Kind}). | ||
|
||
log_event(Event) -> | ||
T = fun() -> | ||
mnesia:write(#events{time = now(), event = Event}) | ||
end, | ||
{atomic, ok} = mnesia:transaction(T). | ||
|
||
get_events() -> | ||
Items = lists:flatmap(fun format_event/1, lists:reverse(lists:keysort(#events.time, umts_db:all(events)))), | ||
#list{body = Items}. | ||
|
||
format_event(Event) -> | ||
case format_event_event(Event#events.event) of | ||
not_ok -> | ||
[]; | ||
Formated -> | ||
[#listitem{text = wf:f("~w: ~s", [calendar:now_to_local_time(Event#events.time), | ||
Formated])}] | ||
end. | ||
|
||
format_event_event(#wtt_event{user = UserID, card = CardID, kind = Kind}) -> | ||
User = umts_db:get_user(UserID), | ||
Card = umts_db:get_card(CardID), | ||
Action = case Kind of | ||
add_wanter -> | ||
"now wants"; | ||
del_wanter -> | ||
"no longer wants"; | ||
add_haver -> | ||
"now haves"; | ||
del_haver -> | ||
"no longer haves" | ||
end, | ||
wf:f("~s ~s ~s", [User#users.display, Action, Card#cards.name]); | ||
format_event_event(#login_event{user = UserID}) -> | ||
User = umts_db:get_user(UserID), | ||
wf:f("~s logged in", [User#users.display]); | ||
format_event_event(Event) -> | ||
not_ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"c:\Program Files\erl5.8.1\bin\werl.exe" -sname umts -pa "./site/ebin" -pa "../nitrogen/apps/nitrogen/ebin" -pa "../nitrogen/apps/simple_bridge/ebin" -pa "../nitrogen/apps/nprocreg/ebin" -pa "./ebin" | ||
"c:\Program Files\erl5.8.1\bin\werl.exe" -config apps -sname umts -pa "./site/ebin" -pa "../nitrogen/apps/nitrogen/ebin" -pa "../nitrogen/apps/simple_bridge/ebin" -pa "../nitrogen/apps/nprocreg/ebin" -pa "../esmtp/ebin" -pa "./ebin" -eval "lists:foreach(fun application:start/1, [sasl, nprocreg, esmtp, umts])." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters