Skip to content
Browse files

untabified all of yaws

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@1217 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
1 parent c9cd304 commit 0be3c7e838bbe6c7d50b6b124bf3720526af1bf3 @klacke committed
Showing with 8,634 additions and 8,601 deletions.
  1. +41 −41 applications/chat/chat/chat.js
  2. +6 −6 applications/chat/chat/chat.yaws
  3. +1 −1 applications/chat/chat/chat_read.yaws
  4. +5 −5 applications/chat/chat/chat_write.yaws
  5. +1 −1 applications/chat/chat/index.yaws
  6. +16 −16 applications/chat/chat/login.yaws
  7. +166 −166 applications/chat/src/chat.erl
  8. +4 −4 applications/mail/mail/compose.yaws
  9. +5 −5 applications/mail/mail/headers.yaws
  10. +7 −7 applications/mail/mail/listop.yaws
  11. +11 −11 applications/mail/mail/login.yaws
  12. +4 −4 applications/mail/mail/logout.yaws
  13. +3 −3 applications/mail/mail/mail.js
  14. +15 −15 applications/mail/mail/mail.yaws
  15. +26 −26 applications/mail/mail/reply.yaws
  16. +5 −5 applications/mail/mail/send.yaws
  17. +6 −6 applications/mail/mail/showmail.yaws
  18. +11 −11 applications/mail/src/attachment.erl
  19. +7 −7 applications/mail/src/defs.hrl
  20. +1,474 −1,474 applications/mail/src/mail.erl
  21. +57 −57 applications/mail/src/mail_html.erl
  22. +77 −77 applications/mail/src/smtp.erl
  23. +16 −16 applications/wiki/src/utils.erl
  24. +1,228 −1,228 applications/wiki/src/wiki.erl
  25. +16 −16 applications/wiki/src/wiki_diff.erl
  26. +117 −117 applications/wiki/src/wiki_format_txt.erl
  27. +2 −2 applications/wiki/src/wiki_plugin_backlinks.erl
  28. +6 −6 applications/wiki/src/wiki_plugin_menu.erl
  29. +9 −9 applications/wiki/src/wiki_split.erl
  30. +20 −20 applications/wiki/src/wiki_templates.erl
  31. +14 −14 applications/wiki/src/wiki_to_html.erl
  32. +33 −33 applications/wiki/src/wiki_utils.erl
  33. +36 −36 applications/wiki/src/wiki_yaws.erl
  34. +2 −2 applications/wiki/wiki/WikiPreferences.files/template_info2.html
  35. +8 −8 applications/wiki/wiki/searchPage.yaws
  36. +10 −10 applications/yapp/priv/docroot/add_post.yaws
  37. +8 −8 applications/yapp/priv/docroot/remove_post.yaws
  38. +92 −92 applications/yapp/src/yapp.erl
  39. +4 −4 applications/yapp/src/yapp_app.erl
  40. +1 −1 applications/yapp/src/yapp_event_handler.erl
  41. +3 −3 applications/yapp/src/yapp_handler.erl
  42. +45 −45 applications/yapp/src/yapp_mnesia_server.erl
  43. +5 −5 applications/yapp/src/yapp_server.erl
  44. +2 −2 applications/yapp/src/yapp_sup.erl
  45. +152 −152 c_src/epam.c
  46. +51 −51 c_src/setuid_drv.c
  47. +76 −76 configure.in
  48. +4 −4 include.mk.in
  49. +3 −3 include/yaws_dav.hrl
  50. +5 −5 man/yaws.conf.5
  51. +16 −16 man/yaws_api.5
  52. +8 −8 scripts/netbsd/yaws.sh
  53. +24 −24 scripts/yaws.conf.template
  54. +67 −67 scripts/yaws.template
  55. +42 −42 src/authmod_gssapi.erl
  56. +12 −12 src/benchmarks/all.erl
  57. +177 −177 src/benchmarks/bench.erl
  58. +24 −24 src/benchmarks/conc_path_bm.erl
  59. +282 −282 src/haxe.erl
  60. +30 −18 src/jsonrpc.erl
  61. +59 −59 src/mime_type_c.erl
  62. +3 −3 src/yaws.conf
  63. +810 −810 src/yaws.erl
  64. +14 −14 src/yaws_404.erl
  65. +610 −611 src/yaws_api.erl
  66. +230 −223 src/yaws_cgi.erl
  67. +260 −256 src/yaws_compile.erl
  68. +1,058 −1,059 src/yaws_config.erl
  69. +124 −113 src/yaws_content_negotiation.erl
  70. +247 −247 src/yaws_ctl.erl
  71. +218 −218 src/yaws_dav.erl
  72. +115 −115 src/yaws_debug.erl
  73. +12 −12 src/yaws_debug.hrl
  74. +1 −1 src/yaws_generated.template
  75. +83 −83 src/yaws_html.erl
  76. +192 −191 src/yaws_log.erl
Sorry, we could not display the entire diff because it was too big.
View
82 applications/chat/chat/chat.js
@@ -75,7 +75,7 @@ function smilies_toolbar() {
for (smile in smilies) {
tool += ("<img src='"+smilies[smile]+"' onmousedown='return addText(\""+
- smile+"\")'></img> ");
+ smile+"\")'></img> ");
}
return tool;
@@ -89,7 +89,7 @@ function expandSmilies(message) {
i = message.indexOf(smile,i);
while(i >= 0) {
message = message.substring(0,i)+"<img src='"+smilies[smile]+"'>"+
- message.substring(i+smile.length);
+ message.substring(i+smile.length);
i = message.indexOf(smile,i);
}
}
@@ -140,49 +140,49 @@ function reader_init() {
debug("reader_init(): something");
if (reply.substring(0,2) == "ok") {
- var msg = reply.substring(2);
- var messages = "";
- var members = "";
-
- while(msg.length > 0) {
- var op = msg.substring(0,1);
- var i = msg.indexOf(":");
- var len = parseInt(msg.substring(1,i));
- var body = msg.substring(i+1, i+len+1);
-
- msg = msg.substring(i+len+1);
-
- debug("msg = " + msg);
- debug("i = " + i);
- debug("len = " + len);
- debug("body = " + body);
- debug("op = " + op);
-
- switch(op) {
- case "m":
- messages += body.replace(/\n/g,"<br>")+"<br>";
- break;
- case "e":
- members = body;
- break;
- default:
- }
- }
-
- if (messages.length > 0)
- msgs.innerHTML = msgs.innerHTML + messages;
-
- if (members.length > 0)
- memb.innerHTML = members;
-
- move_to_end(msgs);
- setTimeout("reader_init()", 0);
+ var msg = reply.substring(2);
+ var messages = "";
+ var members = "";
+
+ while(msg.length > 0) {
+ var op = msg.substring(0,1);
+ var i = msg.indexOf(":");
+ var len = parseInt(msg.substring(1,i));
+ var body = msg.substring(i+1, i+len+1);
+
+ msg = msg.substring(i+len+1);
+
+ debug("msg = " + msg);
+ debug("i = " + i);
+ debug("len = " + len);
+ debug("body = " + body);
+ debug("op = " + op);
+
+ switch(op) {
+ case "m":
+ messages += body.replace(/\n/g,"<br>")+"<br>";
+ break;
+ case "e":
+ members = body;
+ break;
+ default:
+ }
+ }
+
+ if (messages.length > 0)
+ msgs.innerHTML = msgs.innerHTML + messages;
+
+ if (members.length > 0)
+ memb.innerHTML = members;
+
+ move_to_end(msgs);
+ setTimeout("reader_init()", 0);
}
else if (reply.substring(0,7) == "timeout") {
- setTimeout("reader_init()", 0);
+ setTimeout("reader_init()", 0);
}
else {
- // alert("Chat server got unsupported reply.'" + reply+"'");
+ // alert("Chat server got unsupported reply.'" + reply+"'");
}
}
}
View
12 applications/chat/chat/chat.yaws
@@ -3,9 +3,9 @@
out(A) ->
case chat:check_session(A) of
{ok, Session} ->
- chat:dynamic_headers();
- Error ->
- Error++[break]
+ chat:dynamic_headers();
+ Error ->
+ Error++[break]
end.
</erl>
@@ -16,7 +16,7 @@ function handleEnter(event) {
event = window.event;
var keyCode = event.keyCode ? event.keyCode : event.which ?
- event.which : event.charCode;
+ event.which : event.charCode;
if (keyCode == 13) {
sendmsg();
@@ -78,8 +78,8 @@ h1 {
}
#msg {
- width: 614px;
- clear: both;
+ width: 614px;
+ clear: both;
}
</style>
View
2 applications/chat/chat/chat_read.yaws
@@ -1,4 +1,4 @@
<erl>
out(A) ->
- chat:chat_read(A).
+ chat:chat_read(A).
</erl>
View
10 applications/chat/chat/chat_write.yaws
@@ -1,10 +1,10 @@
<erl>
out(A) ->
- case chat:check_session(A) of
- Session ->
- chat:chat_write(A);
- Error ->
- Error
+ case chat:check_session(A) of
+ Session ->
+ chat:chat_write(A);
+ Error ->
+ Error
end.
</erl>
View
2 applications/chat/chat/index.yaws
@@ -1,4 +1,4 @@
<erl>
out(A) ->
- {redirect_local, {rel_path, "chat.yaws"}}.
+ {redirect_local, {rel_path, "chat.yaws"}}.
</erl>
View
32 applications/chat/chat/login.yaws
@@ -2,23 +2,23 @@
out(A) ->
L = case (A#arg.req)#http_request.method of
- 'GET' ->
- yaws_api:parse_query(A);
- 'POST' ->
- yaws_api:parse_post(A)
- end,
+ 'GET' ->
+ yaws_api:parse_query(A);
+ 'POST' ->
+ yaws_api:parse_post(A)
+ end,
case {lists:keysearch("user", 1, L),
- lists:keysearch("password", 1, L)} of
- {{value, {_, User}}, {value, {_,Passwd}}} ->
- case chat:login(User, Passwd) of
- {ok, Cookie} ->
- [yaws_api:setcookie("sessionid", Cookie),
- {redirect_local, {rel_path,"chat.yaws"}}];
- {error, Reason} ->
- chat:display_login(A, Reason)
- end;
- _ ->
- chat:display_login(A, "badly formated POST/GET")
+ lists:keysearch("password", 1, L)} of
+ {{value, {_, User}}, {value, {_,Passwd}}} ->
+ case chat:login(User, Passwd) of
+ {ok, Cookie} ->
+ [yaws_api:setcookie("sessionid", Cookie),
+ {redirect_local, {rel_path,"chat.yaws"}}];
+ {error, Reason} ->
+ chat:display_login(A, Reason)
+ end;
+ _ ->
+ chat:display_login(A, "badly formated POST/GET")
end.
</erl>
View
332 applications/chat/src/chat.erl
@@ -1,7 +1,7 @@
% -*- Erlang -*-
-% File: chat.erl (chat.erl)
-% Author: Johan Bevemyr
-% Created: Thu Nov 18 21:27:41 2004
+% File: chat.erl (chat.erl)
+% Author: Johan Bevemyr
+% Created: Thu Nov 18 21:27:41 2004
% Purpose:
-module('chat').
@@ -21,29 +21,29 @@
-define(ERL_BUG, true).
-export([check_session/1, get_user/1, login/2, chat_server_init/0,
- session_server/0,dynamic_headers/0, display_login/2]).
+ session_server/0,dynamic_headers/0, display_login/2]).
-export([chat_read/1, chat_write/1]).
-include("../../../include/yaws_api.hrl").
-record(user, {last_read,
- buffer=[],
- user,
- pid,
- color,
- cookie}).
+ buffer=[],
+ user,
+ pid,
+ color,
+ cookie}).
login(User, Password) ->
session_server(),
erlang:send(chat_server, {new_session, User, self()}),
receive
- {session_manager, Cookie, Session} ->
- chat_server ! {join_message, User},
- {ok, Cookie};
- _ ->
- error
+ {session_manager, Cookie, Session} ->
+ chat_server ! {join_message, User},
+ {ok, Cookie};
+ _ ->
+ error
end.
%% FIXME: way to simple session handling. The system will behave
@@ -52,25 +52,25 @@ login(User, Password) ->
check_session(A) ->
H = A#arg.headers,
case yaws_api:find_cookie_val("sessionid", H#headers.cookie) of
- [] ->
- display_login(A, "not logged in");
- CVal ->
- case check_cookie(CVal) of
- error ->
- display_login(A, "not logged in");
- Session ->
- {ok, Session}
- end
+ [] ->
+ display_login(A, "not logged in");
+ CVal ->
+ case check_cookie(CVal) of
+ error ->
+ display_login(A, "not logged in");
+ Session ->
+ {ok, Session}
+ end
end.
check_cookie(Cookie) ->
session_server(),
chat_server ! {get_session, Cookie, self()},
receive
- {session_manager, {ok, Session}} ->
- Session;
- {session_manager, error} ->
- error
+ {session_manager, {ok, Session}} ->
+ Session;
+ {session_manager, error} ->
+ error
end.
get_user(Session) ->
@@ -80,48 +80,48 @@ display_login(A, Status) ->
(dynamic_headers() ++
[{ehtml,
[{body, [{onload,"document.f.user.focus();"},{bgcolor,?COLOR3}],
- [{table, [{border,0},{bgcolor,?COLOR2},{cellspacing,1},
- {width,"100%"}],
- {tr,[{bgcolor,?COLOR1},{height,30}],
- {td,[{nowrap,true},{align,left},{valign,middle}],
- {b,[],
- {font, [{size,4},{color,black}],
- ["Chat at ", ?LOCATION]}}}}},
- {pre_html, io_lib:format("<p>Your login status is: ~s</p>",
- [Status])},
- {form,
- [{method,post},
- {name,f},
- {action, "login.yaws"},
- {autocomplete,"off"}],
- {table,[{cellspacing, "5"}],
- [{tr, [],
- [{td, [], {p, [], "Username:"}},
- {td, [], {input, [{name, user},
- {type, text},
- {size, "20"}]}}
- ]},
- {tr, [],
- [{td, [], {p, [], "Password:"}},
- {td, [], {input, [{name, password},
- {type, password},
- {size, "20"}]}}]},
- {tr, [],
- {td, [{align, "right"}, {colspan, "2"}],
- {input, [{type, submit},
- {value, "Login"}]}}}
- ]}}]
- }]
+ [{table, [{border,0},{bgcolor,?COLOR2},{cellspacing,1},
+ {width,"100%"}],
+ {tr,[{bgcolor,?COLOR1},{height,30}],
+ {td,[{nowrap,true},{align,left},{valign,middle}],
+ {b,[],
+ {font, [{size,4},{color,black}],
+ ["Chat at ", ?LOCATION]}}}}},
+ {pre_html, io_lib:format("<p>Your login status is: ~s</p>",
+ [Status])},
+ {form,
+ [{method,post},
+ {name,f},
+ {action, "login.yaws"},
+ {autocomplete,"off"}],
+ {table,[{cellspacing, "5"}],
+ [{tr, [],
+ [{td, [], {p, [], "Username:"}},
+ {td, [], {input, [{name, user},
+ {type, text},
+ {size, "20"}]}}
+ ]},
+ {tr, [],
+ [{td, [], {p, [], "Password:"}},
+ {td, [], {input, [{name, password},
+ {type, password},
+ {size, "20"}]}}]},
+ {tr, [],
+ {td, [{align, "right"}, {colspan, "2"}],
+ {input, [{type, submit},
+ {value, "Login"}]}}}
+ ]}}]
+ }]
}]).
session_server() ->
case whereis(chat_server) of
- undefined ->
- Pid = proc_lib:spawn(?MODULE, chat_server_init, []),
- register(chat_server, Pid);
- _ ->
- done
+ undefined ->
+ Pid = proc_lib:spawn(?MODULE, chat_server_init, []),
+ register(chat_server, Pid);
+ _ ->
+ done
end.
%%
@@ -138,56 +138,56 @@ chat_server(Users0) ->
Users = gc_users(Users0),
%% io:format("Users = ~p\n", [Users]),
receive
- {get_session, Cookie, From} ->
- %% io:format("get_session ~p\n", [Cookie]),
- case lists:keysearch(Cookie, #user.cookie, Users) of
- {value, Session} ->
- From ! {session_manager, {ok, Session}};
- false ->
- From ! {session_manager, error}
- end,
- chat_server(Users);
- {new_session, User, From} ->
- Cookie = integer_to_list(random:uniform(1 bsl 50)),
- Session = #user{cookie=Cookie, user=User, color=pick_color()},
- From ! {session_manager, Cookie, Session},
- chat_server([Session|Users]);
- {write, Session, Msg} ->
- NewUsers = send_to_all(msg,
- fmt_msg(Session#user.user, Msg,
- Session#user.color),
- Users),
- chat_server(NewUsers);
- {send_to, User, Msg} ->
- NewUsers = send_to_one(msg, Msg, Users, User),
- chat_server(NewUsers);
- {join_message, User} ->
- NewUsers0 = send_to_all(msg,fmt_join(User), Users),
- NewUsers1 = send_to_all(members,
- fmt_members(NewUsers0), NewUsers0),
- chat_server(NewUsers1);
- {members, User} ->
- NewUsers1 = send_to_one(members,
- fmt_members(Users),
- Users, User),
- chat_server(NewUsers1);
- {left_message, User} ->
- NewUsers0 = send_to_all(msg,fmt_left(User), Users),
- NewUsers1 = send_to_all(members,
- fmt_members(NewUsers0), NewUsers0),
- chat_server(NewUsers1);
- {read, Session, Pid} ->
- %% io:format("~p want read ~p\n", [Session#user.user, Pid]),
- NewUsers = user_read(Users, Session, Pid),
- chat_server(NewUsers);
- {cancel_read, Pid} ->
- NewUsers = cancel_read(Users, Pid),
- chat_server(NewUsers)
+ {get_session, Cookie, From} ->
+ %% io:format("get_session ~p\n", [Cookie]),
+ case lists:keysearch(Cookie, #user.cookie, Users) of
+ {value, Session} ->
+ From ! {session_manager, {ok, Session}};
+ false ->
+ From ! {session_manager, error}
+ end,
+ chat_server(Users);
+ {new_session, User, From} ->
+ Cookie = integer_to_list(random:uniform(1 bsl 50)),
+ Session = #user{cookie=Cookie, user=User, color=pick_color()},
+ From ! {session_manager, Cookie, Session},
+ chat_server([Session|Users]);
+ {write, Session, Msg} ->
+ NewUsers = send_to_all(msg,
+ fmt_msg(Session#user.user, Msg,
+ Session#user.color),
+ Users),
+ chat_server(NewUsers);
+ {send_to, User, Msg} ->
+ NewUsers = send_to_one(msg, Msg, Users, User),
+ chat_server(NewUsers);
+ {join_message, User} ->
+ NewUsers0 = send_to_all(msg,fmt_join(User), Users),
+ NewUsers1 = send_to_all(members,
+ fmt_members(NewUsers0), NewUsers0),
+ chat_server(NewUsers1);
+ {members, User} ->
+ NewUsers1 = send_to_one(members,
+ fmt_members(Users),
+ Users, User),
+ chat_server(NewUsers1);
+ {left_message, User} ->
+ NewUsers0 = send_to_all(msg,fmt_left(User), Users),
+ NewUsers1 = send_to_all(members,
+ fmt_members(NewUsers0), NewUsers0),
+ chat_server(NewUsers1);
+ {read, Session, Pid} ->
+ %% io:format("~p want read ~p\n", [Session#user.user, Pid]),
+ NewUsers = user_read(Users, Session, Pid),
+ chat_server(NewUsers);
+ {cancel_read, Pid} ->
+ NewUsers = cancel_read(Users, Pid),
+ chat_server(NewUsers)
after
- 5000 ->
- chat_server(Users)
+ 5000 ->
+ chat_server(Users)
end.
-
+
%%
@@ -209,10 +209,10 @@ user_read([], User, Pid, All) ->
user_read([U|Users], User, Pid, All) when U#user.cookie == User#user.cookie ->
if U#user.buffer /= [] ->
- Pid ! {msgs,lists:reverse(U#user.buffer)},
- [U#user{buffer=[]}|Users];
+ Pid ! {msgs,lists:reverse(U#user.buffer)},
+ [U#user{buffer=[]}|Users];
true ->
- [U#user{pid=Pid}|Users]
+ [U#user{pid=Pid}|Users]
end;
user_read([U|Users], User, Pid, All) ->
@@ -223,14 +223,14 @@ user_read([U|Users], User, Pid, All) ->
send_to_all(Type, Msg, Users) ->
Now = inow(now()),
F = fun(U) ->
- if U#user.pid /= undefined ->
- %% io:format("Sending ~p to ~p\n", [Msg, U#user.user]),
- U#user.pid ! {msgs, [{Type, Msg}]},
- U#user{pid=undefined, last_read = Now};
- true ->
- U#user{buffer=[{Type,Msg}|U#user.buffer]}
- end
- end,
+ if U#user.pid /= undefined ->
+ %% io:format("Sending ~p to ~p\n", [Msg, U#user.user]),
+ U#user.pid ! {msgs, [{Type, Msg}]},
+ U#user{pid=undefined, last_read = Now};
+ true ->
+ U#user{buffer=[{Type,Msg}|U#user.buffer]}
+ end
+ end,
lists:map(F, Users).
%%
@@ -238,16 +238,16 @@ send_to_all(Type, Msg, Users) ->
send_to_one(Type, Msg, Users, User) ->
Now = inow(now()),
F = fun(U) when U#user.cookie == User#user.cookie ->
- if U#user.pid /= undefined ->
- %% io:format("Sending ~p to ~p\n", [Msg, U#user.user]),
- U#user.pid ! {msgs, [{Type, Msg}]},
- U#user{pid=undefined, last_read = Now};
- true ->
- U#user{buffer=[{Type,Msg}|U#user.buffer]}
- end;
- (U) ->
- U
- end,
+ if U#user.pid /= undefined ->
+ %% io:format("Sending ~p to ~p\n", [Msg, U#user.user]),
+ U#user.pid ! {msgs, [{Type, Msg}]},
+ U#user{pid=undefined, last_read = Now};
+ true ->
+ U#user{buffer=[{Type,Msg}|U#user.buffer]}
+ end;
+ (U) ->
+ U
+ end,
lists:map(F, Users).
%%
@@ -261,10 +261,10 @@ gc_users([], _Now) ->
[];
gc_users([U|Us], Now) ->
if U#user.pid == undefined, (Now-U#user.last_read > 10) ->
- self() ! {left_message, U#user.user},
- gc_users(Us, Now);
+ self() ! {left_message, U#user.user},
+ gc_users(Us, Now);
true ->
- [U|gc_users(Us, Now)]
+ [U|gc_users(Us, Now)]
end.
%
@@ -285,24 +285,24 @@ dynamic_headers() ->
chat_read(A) ->
session_server(),
case check_session(A) of
- {ok, Session} ->
- chat_server ! {read, Session, self()},
- if length(A#arg.querydata) > 0 ->
- chat_server ! {members, Session};
- true ->
- ok
- end,
- receive
- {msgs, Messages} ->
- M = [fmt_type(Type,L) || {Type, L} <- Messages],
- dynamic_headers()++[{html, ["ok",M]}, break]
- after
- 20000 ->
- catch erlang:send(chat_server, {cancel_read, self()}),
- dynamic_headers()++[{html, "timeout"}, break]
- end;
- Error ->
- dynamic_headers()++[{html, "error"}, break]
+ {ok, Session} ->
+ chat_server ! {read, Session, self()},
+ if length(A#arg.querydata) > 0 ->
+ chat_server ! {members, Session};
+ true ->
+ ok
+ end,
+ receive
+ {msgs, Messages} ->
+ M = [fmt_type(Type,L) || {Type, L} <- Messages],
+ dynamic_headers()++[{html, ["ok",M]}, break]
+ after
+ 20000 ->
+ catch erlang:send(chat_server, {cancel_read, self()}),
+ dynamic_headers()++[{html, "timeout"}, break]
+ end;
+ Error ->
+ dynamic_headers()++[{html, "error"}, break]
end.
type2tag(msg) -> $m;
@@ -320,24 +320,24 @@ fmt_type(Type, L) ->
chat_write(A) ->
session_server(),
case check_session(A) of
- {ok, Session} ->
- chat_server ! {write, Session, A#arg.clidata},
+ {ok, Session} ->
+ chat_server ! {write, Session, A#arg.clidata},
[{html, "ok"},
- break];
- Error ->
- Error
+ break];
+ Error ->
+ Error
end.
-else.
chat_write(A) ->
session_server(),
case check_session(A) of
- {ok, Session} ->
- chat_server ! {write, Session,A#arg.clidata},
- [{header, {connection,"close"}},
- {html, "ok"},
- break];
- Error ->
- Error
+ {ok, Session} ->
+ chat_server ! {write, Session,A#arg.clidata},
+ [{header, {connection,"close"}},
+ {html, "ok"},
+ break];
+ Error ->
+ Error
end.
-endif.
View
8 applications/mail/mail/compose.yaws
@@ -2,10 +2,10 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- mail:compose(Session);
- Error ->
- Error
+ {ok, Session} ->
+ mail:compose(Session);
+ Error ->
+ Error
end.
</erl>
View
10 applications/mail/mail/headers.yaws
@@ -2,11 +2,11 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- {ok, Nr} = queryvar(A, "nr"),
- mail:showheaders(Session, list_to_integer(Nr));
- Error ->
- Error
+ {ok, Session} ->
+ {ok, Nr} = queryvar(A, "nr"),
+ mail:showheaders(Session, list_to_integer(Nr));
+ Error ->
+ Error
end.
</erl>
View
14 applications/mail/mail/listop.yaws
@@ -2,13 +2,13 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- L = yaws_api:parse_post(A),
- Op = mail:get_val("cmd", L, ""),
- ToDelete = [M || {M,Op} <- L, Op=="yes"],
- mail:delete(Session, ToDelete);
- Error ->
- Error
+ {ok, Session} ->
+ L = yaws_api:parse_post(A),
+ Op = mail:get_val("cmd", L, ""),
+ ToDelete = [M || {M,Op} <- L, Op=="yes"],
+ mail:delete(Session, ToDelete);
+ Error ->
+ Error
end.
</erl>
View
22 applications/mail/mail/login.yaws
@@ -2,19 +2,19 @@
out(A) ->
L = case (A#arg.req)#http_request.method of
- 'GET' ->
- yaws_api:parse_query(A);
- 'POST' ->
- yaws_api:parse_post(A)
- end,
+ 'GET' ->
+ yaws_api:parse_query(A);
+ 'POST' ->
+ yaws_api:parse_post(A)
+ end,
User = mail:getopt("user", L, ""),
Passwd = mail:getopt("password", L, ""),
case mail:login(User, Passwd) of
- {ok, Cookie} ->
- [yaws_api:setcookie("mailsession", Cookie),
- {redirect_local, {rel_path,"mail.yaws"}}];
- {error, Reason} ->
- mail:display_login(A, Reason)
+ {ok, Cookie} ->
+ [yaws_api:setcookie("mailsession", Cookie),
+ {redirect_local, {rel_path,"mail.yaws"}}];
+ {error, Reason} ->
+ mail:display_login(A, Reason)
end.
-</erl>
+</erl>
View
8 applications/mail/mail/logout.yaws
@@ -2,10 +2,10 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- mail:logout(Session);
- Error ->
- Error
+ {ok, Session} ->
+ mail:logout(Session);
+ Error ->
+ Error
end.
</erl>
View
6 applications/mail/mail/mail.js
@@ -1,8 +1,8 @@
/* -*- Java -*-
*
- * File: mail.js
- * Author: Johan Bevemyr
- * Created: Sun Feb 15 23:40:56 2004
+ * File: mail.js
+ * Author: Johan Bevemyr
+ * Created: Sun Feb 15 23:40:56 2004
* Purpose: support functions for webmail
*/
View
30 applications/mail/mail/mail.yaws
@@ -2,21 +2,21 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- L = yaws_api:parse_query(A),
- Refresh =
- case lists:keysearch("refresh",1,L) of
- {value, _} -> true;
- _ -> false
- end,
- Sort =
- case lists:keysearch("sort",1,L) of
- {value, {_,SortStr}} -> list_to_atom(SortStr);
- _ -> undefined
- end,
- mail:list(Session, {Refresh, Sort});
- Error ->
- Error
+ {ok, Session} ->
+ L = yaws_api:parse_query(A),
+ Refresh =
+ case lists:keysearch("refresh",1,L) of
+ {value, _} -> true;
+ _ -> false
+ end,
+ Sort =
+ case lists:keysearch("sort",1,L) of
+ {value, {_,SortStr}} -> list_to_atom(SortStr);
+ _ -> undefined
+ end,
+ mail:list(Session, {Refresh, Sort});
+ Error ->
+ Error
end.
</erl>
View
52 applications/mail/mail/reply.yaws
@@ -2,34 +2,34 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- L = yaws_api:parse_post(A),
- Cmd = mail:get_val("cmd", L, reply),
- case Cmd of
- "reply" ->
- From = yaws_api:url_decode(mail:get_val("from", L, "")),
- Subject = yaws_api:url_decode(mail:get_val("subject", L, "")),
- To = yaws_api:url_decode(mail:get_val("to", L, "")),
- Cc = yaws_api:url_decode(mail:get_val("cc", L, "")),
- Bcc = yaws_api:url_decode(mail:get_val("bcc", L, "")),
- Quote = yaws_api:url_decode(mail:get_val("quote", L, "")),
- NewCc =
- if To == [] -> Cc;
- Cc == [] -> To;
- true -> To ++ ", " ++ Cc
- end,
- mail:compose(Session,"",From,NewCc,Bcc,"RE: "++Subject,
- Quote);
- "delete" ->
- Nr = mail:get_val("nr", L, ""),
- mail:delete(Session, [Nr])
- end;
- Error ->
- Error
+ {ok, Session} ->
+ L = yaws_api:parse_post(A),
+ Cmd = mail:get_val("cmd", L, reply),
+ case Cmd of
+ "reply" ->
+ From = yaws_api:url_decode(mail:get_val("from", L, "")),
+ Subject = yaws_api:url_decode(mail:get_val("subject", L, "")),
+ To = yaws_api:url_decode(mail:get_val("to", L, "")),
+ Cc = yaws_api:url_decode(mail:get_val("cc", L, "")),
+ Bcc = yaws_api:url_decode(mail:get_val("bcc", L, "")),
+ Quote = yaws_api:url_decode(mail:get_val("quote", L, "")),
+ NewCc =
+ if To == [] -> Cc;
+ Cc == [] -> To;
+ true -> To ++ ", " ++ Cc
+ end,
+ mail:compose(Session,"",From,NewCc,Bcc,"RE: "++Subject,
+ Quote);
+ "delete" ->
+ Nr = mail:get_val("nr", L, ""),
+ mail:delete(Session, [Nr])
+ end;
+ Error ->
+ Error
end.
-</erl>
-
+</erl>
+
View
10 applications/mail/mail/send.yaws
@@ -2,10 +2,10 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- mail:send(Session,A);
- Error ->
- Error
+ {ok, Session} ->
+ mail:send(Session,A);
+ Error ->
+ Error
end.
-</erl>
+</erl>
View
12 applications/mail/mail/showmail.yaws
@@ -2,12 +2,12 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- L = yaws_api:parse_query(A),
- {value, {_,Nr}} = lists:keysearch("nr",1,L),
- mail:showmail(Session, list_to_integer(Nr));
- Error ->
- Error
+ {ok, Session} ->
+ L = yaws_api:parse_query(A),
+ {value, {_,Nr}} = lists:keysearch("nr",1,L),
+ mail:showmail(Session, list_to_integer(Nr));
+ Error ->
+ Error
end.
</erl>
View
22 applications/mail/src/attachment.erl
@@ -10,17 +10,17 @@
out(A) ->
case mail:check_session(A) of
- {ok, Session} ->
- case {yaws_api:queryvar(A, "nr"),yaws_api:queryvar(A,"form")} of
- {{ok, Nr},{ok,"text"}} ->
- mail:send_attachment_plain(Session, yaws:to_integer(Nr));
- {{ok, Nr},_} ->
- mail:send_attachment(Session, yaws:to_integer(Nr));
- _ ->
- err()
- end;
- Error ->
- err()
+ {ok, Session} ->
+ case {yaws_api:queryvar(A, "nr"),yaws_api:queryvar(A,"form")} of
+ {{ok, Nr},{ok,"text"}} ->
+ mail:send_attachment_plain(Session, yaws:to_integer(Nr));
+ {{ok, Nr},_} ->
+ mail:send_attachment(Session, yaws:to_integer(Nr));
+ _ ->
+ err()
+ end;
+ Error ->
+ err()
end.
View
14 applications/mail/src/defs.hrl
@@ -1,7 +1,7 @@
% -*- Erlang -*-
-% File: defs.hrl (/mnt/disk2/jb/work/yaws/yaws/applications/mail/src/defs.hrl)
-% Author: Johan Bevemyr
-% Created: Wed Oct 29 23:39:30 2003
+% File: defs.hrl (/mnt/disk2/jb/work/yaws/yaws/applications/mail/src/defs.hrl)
+% Author: Johan Bevemyr
+% Created: Wed Oct 29 23:39:30 2003
% Purpose:
-ifndef(DEFS_HRL).
@@ -11,10 +11,10 @@
%% Create config file in /etc/mail/yaws-webmail.conf
-record(cfg, {ttl = 1800, % 30 minuter TTL
- popserver = "localhost",
- maildomain = "foo.bar",
- smtpserver = "localhost",
- sendtimeout = 3000}).
+ popserver = "localhost",
+ maildomain = "foo.bar",
+ smtpserver = "localhost",
+ sendtimeout = 3000}).
-endif.
View
2,948 applications/mail/src/mail.erl
1,474 additions, 1,474 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
114 applications/mail/src/mail_html.erl
@@ -1,7 +1,7 @@
% -*- Erlang -*-
-% File: mail_html.erl
-% Author: Johan Bevemyr
-% Created: Sat Jun 19 15:13:49 2004
+% File: mail_html.erl
+% Author: Johan Bevemyr
+% Created: Sat Jun 19 15:13:49 2004
% Purpose: Transform HTML to text
-module('mail_html').
@@ -62,18 +62,18 @@ parse([], Acc) -> lists:reverse(Acc);
parse([{begin_tag, T, A, L}|Rest], Acc) ->
case tag_type(T) of
- leaf ->
- parse(Rest, [{T,A}|Acc]);
- node ->
- case find_body(T, Rest, []) of
- {error, Reason} ->
- %% no body found, assume leaf
- %% io:format("Error: ~s on line ~p\n", [Reason, L]),
- parse(Rest, [{T,A}|Acc]);
- {Body,Rest2} ->
- ParsedBody = parse(Body),
- parse(Rest2, [{T,A,ParsedBody}|Acc])
- end
+ leaf ->
+ parse(Rest, [{T,A}|Acc]);
+ node ->
+ case find_body(T, Rest, []) of
+ {error, Reason} ->
+ %% no body found, assume leaf
+ %% io:format("Error: ~s on line ~p\n", [Reason, L]),
+ parse(Rest, [{T,A}|Acc]);
+ {Body,Rest2} ->
+ ParsedBody = parse(Body),
+ parse(Rest2, [{T,A,ParsedBody}|Acc])
+ end
end;
parse([{end_tag, T, A, L}|Rest], Acc) ->
%% errounous end tag, ignore
@@ -87,13 +87,13 @@ find_body(Tag, [{end_tag,Tag,_,_}|Rest], Acc) ->
{lists:reverse(Acc),Rest};
find_body(Tag, [{begin_tag, Tag, A, L}|Rest], Acc) ->
case find_body(Tag, Rest, []) of
- {error, Reason} ->
- %% no body found
- {error, Reason};
- {Body, Rest1} ->
- find_body(Tag, Rest1,
- [{end_tag, Tag, [], -1}|lists:reverse(Body)++
- [{begin_tag, Tag, A, L}|Acc]])
+ {error, Reason} ->
+ %% no body found
+ {error, Reason};
+ {Body, Rest1} ->
+ find_body(Tag, Rest1,
+ [{end_tag, Tag, [], -1}|lists:reverse(Body)++
+ [{begin_tag, Tag, A, L}|Acc]])
end;
find_body(Tag, [X|Rest], Acc) ->
find_body(Tag, Rest, [X|Acc]).
@@ -128,11 +128,11 @@ tokenize([$<,$!,$-,$-|R0], Acc, Tokens, L0) ->
tokenize([$<|R0], Acc, Tokens, L0) ->
{Tag,R1,L1} = scan_tag(R0,L0),
if
- Acc == [] ->
- next_token(Tag, R1, [Tag|Tokens], L1);
- true ->
- Data = {data,lists:reverse(Acc),L0},
- next_token(Tag, R1, [Tag,Data|Tokens], L1)
+ Acc == [] ->
+ next_token(Tag, R1, [Tag|Tokens], L1);
+ true ->
+ Data = {data,lists:reverse(Acc),L0},
+ next_token(Tag, R1, [Tag,Data|Tokens], L1)
end;
tokenize([C=$\n|R0], Acc, Tokens, L) ->
tokenize(R0, [C|Acc], Tokens, L+1);
@@ -187,14 +187,14 @@ scan_tag_args(R0, Acc, L0) ->
{Name,R1,L1} = scan_value(R0, L0),
{R2, L2} = skip_space(R1, L1),
case R2 of
- [$=|R3] ->
- {R4,L4} = skip_space(R3, L2),
- {Value,R5,L5} = scan_value(R4, L4),
- {R6,L6} = skip_space(R5, L5),
- OptName = list_to_atom(lowercase(Name)),
- scan_tag_args(R6, [{OptName,Value}|Acc], L6);
- _ ->
- scan_tag_args(R2, [Name|Acc], L2)
+ [$=|R3] ->
+ {R4,L4} = skip_space(R3, L2),
+ {Value,R5,L5} = scan_value(R4, L4),
+ {R6,L6} = skip_space(R5, L5),
+ OptName = list_to_atom(lowercase(Name)),
+ scan_tag_args(R6, [{OptName,Value}|Acc], L6);
+ _ ->
+ scan_tag_args(R2, [Name|Acc], L2)
end.
%
@@ -218,12 +218,12 @@ scan_token(R=[$=|_], Acc, L) -> %% bad html
{lists:reverse(Acc), R, L};
scan_token([C|R], Acc, L0) ->
case char_class(C) of
- space ->
- {lists:reverse(Acc), R, L0};
- nl ->
- {lists:reverse(Acc), R, L0+1};
- _ ->
- scan_token(R, [C|Acc], L0)
+ space ->
+ {lists:reverse(Acc), R, L0};
+ nl ->
+ {lists:reverse(Acc), R, L0+1};
+ _ ->
+ scan_token(R, [C|Acc], L0)
end.
%
@@ -238,7 +238,7 @@ scan_quote([C=$\r|R], Acc, Q, L) ->
scan_quote(R, [C|Acc], Q, L+1);
scan_quote([C|R], Acc, Q, L) ->
scan_quote(R, [C|Acc], Q, L).
-
+
%
scan_endtag(R, Tag, L) ->
@@ -248,15 +248,15 @@ scan_endtag([], _Tag, Acc, L) ->
{lists:reverse(Acc), [], L};
scan_endtag(R=[$<,$/|R0], Tag, Acc, L0) ->
case casecmp(Tag, R0) of
- {true, R1} ->
- {R2,_} = skip_space(R1,L0),
- if hd(R2) == $> ->
- {lists:reverse(Acc), R, L0};
- true ->
- scan_endtag(R0, Tag, Acc, L0)
- end;
- false ->
- scan_endtag(R0, Tag, Acc, L0)
+ {true, R1} ->
+ {R2,_} = skip_space(R1,L0),
+ if hd(R2) == $> ->
+ {lists:reverse(Acc), R, L0};
+ true ->
+ scan_endtag(R0, Tag, Acc, L0)
+ end;
+ false ->
+ scan_endtag(R0, Tag, Acc, L0)
end;
scan_endtag([C=$\n|R], Tag, Acc, L) ->
scan_endtag(R, Tag, [C|Acc], L+1);
@@ -291,12 +291,12 @@ skip_space([], L) ->
{[], L};
skip_space(R = [C|R0], L) ->
case char_class(C) of
- nl ->
- skip_space(R0, L+1);
- space ->
- skip_space(R0, L);
- _ ->
- {R, L}
+ nl ->
+ skip_space(R0, L+1);
+ space ->
+ skip_space(R0, L);
+ _ ->
+ {R, L}
end.
%
View
154 applications/mail/src/smtp.erl
@@ -1,7 +1,7 @@
% -*- Erlang -*-
-% File: smtp.erl (~jb/work/yaws/applications/mail/src/smtp.erl)
-% Author: Johan Bevemyr
-% Created: Tue Feb 24 23:15:59 2004
+% File: smtp.erl (~jb/work/yaws/applications/mail/src/smtp.erl)
+% Author: Johan Bevemyr
+% Created: Tue Feb 24 23:15:59 2004
% Purpose:
-module('smtp').
@@ -13,9 +13,9 @@
%
% smtp:send("mail.bevemyr.com", "jb@bevemyr.com",
-% ["katrin@bevemyr.com","jb@bevemyr.com"],
-% "Test Subject",
-% "My Message", [{"file1.txt","text/plain","hej hopp igen"}]).
+% ["katrin@bevemyr.com","jb@bevemyr.com"],
+% "Test Subject",
+% "My Message", [{"file1.txt","text/plain","hej hopp igen"}]).
%
@@ -23,41 +23,41 @@ send(Server, From, To, Subject, Message, Attached) ->
{ok, Port} = smtp_init(Server, From, To),
Boundary="--Next_Part("++boundary_date()++")--",
CommonHeaders =
- [mail_header("To: ", To),
- mail_header("From: ", From),
- mail_header("Subject: ", Subject)],
+ [mail_header("To: ", To),
+ mail_header("From: ", From),
+ mail_header("Subject: ", Subject)],
Headers = case Attached of
- [] ->
- [mail_header("Content-Type: ", "text/plain"),
- mail_header("Content-Transfer-Encoding: ", "8bit")];
- _ ->
- [mail_header("Mime-Version: ", "1.0"),
- mail_header("Content-Type: ",
- "Multipart/Mixed;\r\n boundary=\""++
- Boundary++"\""),
- mail_header("Content-Transfer-Encoding: ", "8bit")]
- end,
+ [] ->
+ [mail_header("Content-Type: ", "text/plain"),
+ mail_header("Content-Transfer-Encoding: ", "8bit")];
+ _ ->
+ [mail_header("Mime-Version: ", "1.0"),
+ mail_header("Content-Type: ",
+ "Multipart/Mixed;\r\n boundary=\""++
+ Boundary++"\""),
+ mail_header("Content-Transfer-Encoding: ", "8bit")]
+ end,
smtp_send_part(Port, [CommonHeaders, Headers, "\r\n"]),
case Attached of
- [] ->
- ok;
- _ ->
- smtp_send_part(Port, ["--",Boundary,"\r\n",
- mail_header("Content-Type: ",
- "Text/Plain; charset=us-ascii"),
- mail_header("Content-Transfer-Encoding: ",
- "8bit"),
- "\r\n"])
+ [] ->
+ ok;
+ _ ->
+ smtp_send_part(Port, ["--",Boundary,"\r\n",
+ mail_header("Content-Type: ",
+ "Text/Plain; charset=us-ascii"),
+ mail_header("Content-Transfer-Encoding: ",
+ "8bit"),
+ "\r\n"])
end,
smtp_send_message(Port, Message),
case Attached of
- [] ->
- smtp_send_part(Port, ["\r\n.\r\n"]),
- smtp_close(Port);
- Files ->
- smtp_send_attachments(Port, Boundary, Files),
- smtp_send_part(Port, ["\r\n.\r\n"]),
- smtp_close(Port)
+ [] ->
+ smtp_send_part(Port, ["\r\n.\r\n"]),
+ smtp_close(Port);
+ Files ->
+ smtp_send_attachments(Port, Boundary, Files),
+ smtp_send_part(Port, ["\r\n.\r\n"]),
+ smtp_close(Port)
end.
@@ -65,14 +65,14 @@ smtp_send_attachments(Port, Boundary, []) ->
smtp_send_part(Port, ["\r\n--",Boundary,"--\r\n"]);
smtp_send_attachments(Port, Boundary, [{FileName,ContentType,Data}|Rest]) ->
smtp_send_part(Port, ["\r\n--",Boundary,"\r\n",
- mail_header("Content-Type: ", ContentType),
- mail_header("Content-Transfer-Encoding: ",
- "base64"),
- mail_header("Content-Disposition: ",
- "attachment; filename=\""++
- FileName++"\""),
- "\r\n"
- ]),
+ mail_header("Content-Type: ", ContentType),
+ mail_header("Content-Transfer-Encoding: ",
+ "base64"),
+ mail_header("Content-Disposition: ",
+ "attachment; filename=\""++
+ FileName++"\""),
+ "\r\n"
+ ]),
smtp_send_b64(Port, Data),
smtp_send_attachments(Port, Boundary, Rest).
@@ -87,14 +87,14 @@ boundary_date() ->
dat2str_boundary({{Y, Mo, D}, {H, M, S}}) ->
lists:flatten(
io_lib:format("~s_~2.2.0w_~s_~w_~2.2.0w:~2.2.0w:~2.2.0w_~w",
- [weekday(Y,Mo,D), D, int_to_mt(Mo),
- Y,H,M,S,random:uniform(5000)])).
+ [weekday(Y,Mo,D), D, int_to_mt(Mo),
+ Y,H,M,S,random:uniform(5000)])).
smtp_init(Server, From, Recipients) ->
{ok, Port} = gen_tcp:connect(Server, 25, [{active, false},
- {reuseaddr,true},
- binary]),
+ {reuseaddr,true},
+ binary]),
smtp_expect(220, Port, "SMTP server does not respond"),
smtp_put( smtp_from(From), Port ),
smtp_expect(250, Port, "Sender not accepted by mail server"),
@@ -118,11 +118,11 @@ smtp_send_message(Port, Data) ->
gen_tcp:send(Port, Escaped).
send_recipients( Recipients, Port ) ->
- Fun = fun (R) ->
- smtp_put( smtp_recipient(R), Port),
- smtp_expect(250, Port, io_lib:format("Recipient ~s not accepted.",[R]))
- end,
- lists:foreach( Fun, Recipients ).
+ Fun = fun (R) ->
+ smtp_put( smtp_recipient(R), Port),
+ smtp_expect(250, Port, io_lib:format("Recipient ~s not accepted.",[R]))
+ end,
+ lists:foreach( Fun, Recipients ).
smtp_put(Message, Port) ->
gen_tcp:send(Port, [Message,"\r\n"]).
@@ -133,43 +133,43 @@ smtp_expect(Code, Port, ErrorMsg) ->
smtp_expect(Code, Port, Acc, ErrorMsg) ->
Res = gen_tcp:recv(Port, 0, 15000),
case Res of
- {ok, Bin} ->
- NAcc = Acc++binary_to_list(Bin),
- case string:chr(NAcc, $\n) of
- 0 ->
- smtp_expect(Code, Port, NAcc, ErrorMsg);
- _N ->
- ResponseCode = to_int(NAcc),
- if
- ResponseCode == Code -> ok;
- true -> throw({error, ErrorMsg})
- end
- end;
- Err ->
- throw({error, Err})
+ {ok, Bin} ->
+ NAcc = Acc++binary_to_list(Bin),
+ case string:chr(NAcc, $\n) of
+ 0 ->
+ smtp_expect(Code, Port, NAcc, ErrorMsg);
+ _N ->
+ ResponseCode = to_int(NAcc),
+ if
+ ResponseCode == Code -> ok;
+ true -> throw({error, ErrorMsg})
+ end
+ end;
+ Err ->
+ throw({error, Err})
end.
%% add smtp from prelude. add <> around address (if needed)
smtp_from( Address ) ->
- lists:append( "MAIL FROM: ", add_angle_brackets( Address ) ).
+ lists:append( "MAIL FROM: ", add_angle_brackets( Address ) ).
%% add smtp recipients prelude. add <> around address (if needed)
smtp_recipient( Address ) ->
- lists:append( "RCPT TO: ", add_angle_brackets( Address ) ).
+ lists:append( "RCPT TO: ", add_angle_brackets( Address ) ).
%% make sure the address has <> around itself
add_angle_brackets( Address ) ->
- add_angle_bracket_start( add_angle_bracket_close(Address) ).
+ add_angle_bracket_start( add_angle_bracket_close(Address) ).
add_angle_bracket_start( [$<|T] ) -> [$<|T];
add_angle_bracket_start( Address ) -> [$<|Address].
%% add > at the end of address, if it is not present
add_angle_bracket_close( Address ) ->
- case lists:reverse( Address ) of
- [$>|_T] -> Address;
- Reversed -> lists:reverse( [$>|Reversed] )
- end.
+ case lists:reverse( Address ) of
+ [$>|_T] -> Address;
+ Reversed -> lists:reverse( [$>|Reversed] )
+ end.
%% Add an . at all lines starting with a dot.
@@ -214,10 +214,10 @@ str2b64_final([], Acc) ->
lists:reverse(Acc);
str2b64_final(String, Acc) ->
case str2b64_line(String, []) of
- {ok, Line, Rest} ->
- str2b64_final(Rest, ["\n",Line|Acc]);
- {more, Cont} ->
- lists:reverse(["\n",str2b64_end(Cont)|Acc])
+ {ok, Line, Rest} ->
+ str2b64_final(Rest, ["\n",Line|Acc]);
+ {more, Cont} ->
+ lists:reverse(["\n",str2b64_end(Cont)|Acc])
end.
%%
View
32 applications/wiki/src/utils.erl
@@ -12,7 +12,7 @@
%% Time (as return by calendar:local_time() to string conversion.
time_to_string( {{Y,Mo,D},{H,Mi,S}} ) ->
String = io_lib:format( "~4.4w-~2.2.0w-~2.2.0w ~2.2.0w:~2.2.0w:~2.2.0w",
- [Y,Mo,D,H,Mi,S] ),
+ [Y,Mo,D,H,Mi,S] ),
lists:flatten(String).
@@ -27,10 +27,10 @@ time_to_string( {{Y,Mo,D},{H,Mi,S}} ) ->
fold_files(Dir, Fun, Acc) ->
case file:list_dir(Dir) of
- {ok, Files} ->
- fold_files0(Files, Dir, Fun, Acc);
- {error, _} ->
- Acc
+ {ok, Files} ->
+ fold_files0(Files, Dir, Fun, Acc);
+ {error, _} ->
+ Acc
end.
fold_files0([File | Tail], Dir, Fun, Acc) ->
@@ -53,15 +53,15 @@ fold_files0(FullName, Tail, Dir, Fun, _, _, Acc) ->
fold_files(Dir, RegExp, Recursive, Fun, InitialAcc) ->
{ok, CompiledRegExp} = regexp:parse(RegExp),
Wrapper = fun
- (FullName, false, Acc) ->
- NewAcc = case regexp:match(FullName, CompiledRegExp) of
- {match, _, _} ->
- Fun(FullName, Acc);
- _ ->
- Acc
- end,
- {Recursive, NewAcc};
- (_, true, Acc) ->
- {Recursive, Acc}
- end,
+ (FullName, false, Acc) ->
+ NewAcc = case regexp:match(FullName, CompiledRegExp) of
+ {match, _, _} ->
+ Fun(FullName, Acc);
+ _ ->
+ Acc
+ end,
+ {Recursive, NewAcc};
+ (_, true, Acc) ->
+ {Recursive, Acc}
+ end,
fold_files(Dir, Wrapper, InitialAcc).
View
2,456 applications/wiki/src/wiki.erl
1,228 additions, 1,228 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
32 applications/wiki/src/wiki_diff.erl
@@ -31,14 +31,14 @@ diff(New, Old) ->
check(Patch, New, Old) ->
case patch(New, Patch) of
- Old ->
- true;
- _ ->
- exit(oops)
+ Old ->
+ true;
+ _ ->
+ exit(oops)
end.
patchL(New, Patches) ->
- foldl(fun(Patch, N) -> patch(N, Patch) end, New, Patches).
+ foldl(fun(Patch, N) -> patch(N, Patch) end, New, Patches).
patch(New, Patch) ->
sneaky_flatten(patch1(binary_to_term(Patch), str2lines(New))).
@@ -58,17 +58,17 @@ diff([], _, Patch) ->
term_to_binary(reverse(Patch));
diff(Old = [{_,Str}|T], New, Patch) ->
case match(Old, New) of
- {yes, Ln, Ln, Old1} ->
- case Str of
- "\n" ->
- diff(Old1, New, [Str|Patch]);
- _ ->
- diff(Old1, New, [{Ln,Ln}|Patch])
- end;
- {yes, L1, L2, Old1} ->
- diff(Old1, New, [{L1,L2}|Patch]);
- no ->
- diff(T, New, [Str|Patch])
+ {yes, Ln, Ln, Old1} ->
+ case Str of
+ "\n" ->
+ diff(Old1, New, [Str|Patch]);
+ _ ->
+ diff(Old1, New, [{Ln,Ln}|Patch])
+ end;
+ {yes, L1, L2, Old1} ->
+ diff(Old1, New, [{L1,L2}|Patch]);
+ no ->
+ diff(T, New, [Str|Patch])
end.
match(X=[{Ln,Str}|T], [{L1,Str}|T1]) -> extend_match(T, T1, L1, L1);
View
234 applications/wiki/src/wiki_format_txt.erl
@@ -51,17 +51,17 @@
-import(lists, [member/2, map/2, reverse/1, reverse/2]).
-record(env, {node,
- f,
- f1 = false,
- f2 = false,
- f3 = false,
- h1 = false,
- h2 = false,
- h3 = false,
- u = false,
- n = 0,
- dl = false
- }).
+ f,
+ f1 = false,
+ f2 = false,
+ f3 = false,
+ h1 = false,
+ h2 = false,
+ h3 = false,
+ u = false,
+ n = 0,
+ dl = false
+ }).
format(Str, F, Node) ->
Env = #env{node=Node,f=F},
@@ -76,11 +76,11 @@ blank_line(_) -> no.
format_txt([$\n|T], Env, L, Doc) ->
case blank_line(T) of
- {yes, T1} ->
- {Env1, L1} = clear_line(Env, reverse("<p>\n", L)),
- format_txt(T1, Env1, L1, Doc);
- no ->
- after_nl(T, Env, [$\n|L], Doc)
+ {yes, T1} ->
+ {Env1, L1} = clear_line(Env, reverse("<p>\n", L)),
+ format_txt(T1, Env1, L1, Doc);
+ no ->
+ after_nl(T, Env, [$\n|L], Doc)
end;
format_txt([$\\,H|T], Env, L, Doc) ->
format_txt(T, Env, [H|L], Doc);
@@ -126,23 +126,23 @@ format_txt("ftp://" ++ T, Env, L, Doc) ->
format_txt("slideshow:" ++ T, Env, L, Doc) ->
{X, T1} = collect_wiki_link(T),
Txt = "<a href='slideShow.yaws?node="++wiki:str2urlencoded(Env#env.node)++
- "&next=1'>"++X++ "</a>",
+ "&next=1'>"++X++ "</a>",
format_txt(T1, Env, reverse(Txt, L), Doc);
format_txt("mailto:" ++ T, Env, L, Doc) ->
{X, T1} = collect_mail(T, []),
Txt = "<a href='mailto:" ++ X ++ "'>" ++
- "<img border=0 src='WikiPreferences.files/mailto.png'>"
- ++ X ++ "</a>",
+ "<img border=0 src='WikiPreferences.files/mailto.png'>"
+ ++ X ++ "</a>",
format_txt(T1, Env, reverse(Txt, L), Doc);
format_txt("mailtoall:" ++ T, Env, L, Doc) ->
{Name, T1} = collect_wiki_link(T),
case get_mailto(Doc, []) of
- [] ->
- format_txt(T, Env, L, Doc);
- [F|Rs] ->
- Recipients = [F | [[$,|R] || R <- Rs]],
- Txt = "<a href='mailto:" ++ Recipients ++ "'>" ++ Name ++ "</a>",
- format_txt(T1, Env, reverse(Txt, L), Doc)
+ [] ->
+ format_txt(T, Env, L, Doc);
+ [F|Rs] ->
+ Recipients = [F | [[$,|R] || R <- Rs]],
+ Txt = "<a href='mailto:" ++ Recipients ++ "'>" ++ Name ++ "</a>",
+ format_txt(T1, Env, reverse(Txt, L), Doc)
end;
format_txt("<?plugin " ++ T, Env, L, Doc) ->
Page = Env#env.node,
@@ -198,12 +198,12 @@ format_external_url(F) ->
format_external_url(F, Scheme) ->
F1 = Scheme ++ F,
case is_graphic(F) of
- true ->
- "<img src=\"" ++ F1 ++ "\">";
- false ->
- "<a href=\"" ++ F1 ++ "\">" ++
- "<img border=0 src='WikiPreferences.files/http.png'>"
- ++ F1 ++ "</a> "
+ true ->
+ "<img src=\"" ++ F1 ++ "\">";
+ false ->
+ "<a href=\"" ++ F1 ++ "\">" ++
+ "<img border=0 src='WikiPreferences.files/http.png'>"
+ ++ F1 ++ "</a> "
end.
is_graphic(F) ->
@@ -258,17 +258,17 @@ eregion(T0, Env, L, Doc) ->
Expired = date_less(Date, {date(),time()}),
{Region, T2} = collect_region($], T1, []),
case Expired of
- error ->
- L1 = reverse("ERROR: bad expires date entry - "++DateStr++". "
- "The date should be on the form \"3 Jan 2003 "
- "00:00:00\".", L),
- format_txt(T2, Env, L1, Doc);
- true ->
- format_txt(T2, Env, L, Doc);
- false ->
- {Env1, RTxt} = format_txt(Region, Env, [], Doc),
- L1 = reverse(RTxt, L),
- format_txt(T2, Env1, L1, Doc)
+ error ->
+ L1 = reverse("ERROR: bad expires date entry - "++DateStr++". "
+ "The date should be on the form \"3 Jan 2003 "
+ "00:00:00\".", L),
+ format_txt(T2, Env, L1, Doc);
+ true ->
+ format_txt(T2, Env, L, Doc);
+ false ->
+ {Env1, RTxt} = format_txt(Region, Env, [], Doc),
+ L1 = reverse(RTxt, L),
+ format_txt(T2, Env1, L1, Doc)
end.
collect_region(_, [], Acc) ->
@@ -286,14 +286,14 @@ date_less(D1,D2) ->
Ds1 < Ds2.
-record(date,
- {
- year,
- month,
- day,
- hours,
- minutes,
- seconds
- }).
+ {
+ year,
+ month,
+ day,
+ hours,
+ minutes,
+ seconds
+ }).
parse_date(Date) ->
parse_date(Date, #date{}).
@@ -301,51 +301,51 @@ parse_date(Date) ->
parse_date([], D) ->
Entries = tl(tuple_to_list(D)),
AllDone = lists:all(fun(X) -> if integer(X) -> true;
- true -> false
- end
- end, Entries),
+ true -> false
+ end
+ end, Entries),
if
- AllDone ->
- {{D#date.year,D#date.month,D#date.day},
- {D#date.hours,D#date.minutes,D#date.seconds}};
- true ->
- error
+ AllDone ->
+ {{D#date.year,D#date.month,D#date.day},
+ {D#date.hours,D#date.minutes,D#date.seconds}};
+ true ->
+ error
end;
parse_date([D|Ds], Date) ->
case char_type(D) of
- space -> parse_date(Ds, Date);
- alpha when Date#date.month == undefined ->
- case is_month(lowercase([D|Ds])) of
- false ->
- parse_date(Ds, Date);
- {true, M, Rest} ->
- parse_date(Rest, Date#date{month=M})
- end;
- alpha ->
- parse_date(Ds, Date);
- digit ->
- case parse_time([D|Ds]) of
- error ->
- {Number,Rest} = get_number([D|Ds], 0),
- if
- Number < 32, Date#date.day == undefined ->
- parse_date(Rest, Date#date{day=Number});
- Number < 50, Date#date.year == undefined ->
- parse_date(Rest, Date#date{year=Number+2000});
- Number < 100, Date#date.year == undefined ->
- parse_date(Rest, Date#date{year=Number+1900});
- Number > 1900, Date#date.year == undefined ->
- parse_date(Rest, Date#date{year=Number});
- true ->
- parse_date(Rest, Date)
- end;
- {Hours, Minutes, Seconds, Rest} ->
- parse_date(Rest, Date#date{hours=Hours,
- minutes=Minutes,
- seconds=Seconds})
- end;
- _ ->
- parse_date(Ds, Date)
+ space -> parse_date(Ds, Date);
+ alpha when Date#date.month == undefined ->
+ case is_month(lowercase([D|Ds])) of
+ false ->
+ parse_date(Ds, Date);
+ {true, M, Rest} ->
+ parse_date(Rest, Date#date{month=M})
+ end;
+ alpha ->
+ parse_date(Ds, Date);
+ digit ->
+ case parse_time([D|Ds]) of
+ error ->
+ {Number,Rest} = get_number([D|Ds], 0),
+ if
+ Number < 32, Date#date.day == undefined ->
+ parse_date(Rest, Date#date{day=Number});
+ Number < 50, Date#date.year == undefined ->
+ parse_date(Rest, Date#date{year=Number+2000});
+ Number < 100, Date#date.year == undefined ->
+ parse_date(Rest, Date#date{year=Number+1900});
+ Number > 1900, Date#date.year == undefined ->
+ parse_date(Rest, Date#date{year=Number});
+ true ->
+ parse_date(Rest, Date)
+ end;
+ {Hours, Minutes, Seconds, Rest} ->
+ parse_date(Rest, Date#date{hours=Hours,
+ minutes=Minutes,
+ seconds=Seconds})
+ end;
+ _ ->
+ parse_date(Ds, Date)
end.
lowercase([C|S]) -> [lowercase(C)|lowercase(S)];
@@ -402,17 +402,17 @@ get_number(Rest, N) -> {N, Rest}.
parse_time(Time) ->
F = fun() ->
- {Hour,[$:|R1]} = get_number(Time, 0),
- {Minutes,[$:|R2]} = get_number(R1, 0),
- {Seconds,R3} = get_number(R2, 0),
- {Hour, Minutes, Seconds, R3}
- end,
+ {Hour,[$:|R1]} = get_number(Time, 0),
+ {Minutes,[$:|R2]} = get_number(R1, 0),
+ {Seconds,R3} = get_number(R2, 0),
+ {Hour, Minutes, Seconds, R3}
+ end,
case catch F() of
- {Hour, Minutes, Seconds, Rest} when integer(Hour),
- integer(Minutes),
- integer(Seconds) ->
- {Hour, Minutes, Seconds, Rest};
- _ -> error
+ {Hour, Minutes, Seconds, Rest} when integer(Hour),
+ integer(Minutes),
+ integer(Seconds) ->
+ {Hour, Minutes, Seconds, Rest};
+ _ -> error
end.
note(T, Env, L, Doc) ->
@@ -434,19 +434,19 @@ note_start() ->
<td bgcolor=\"yellow\"><font size=\"-1\">".
note_end() -> "</font></td></tr></table><p>\n".
-
+
mk_list(T, Env, L, Doc) ->
{Lev, T1} = count_indent_levels(T, 0),
{Env1, L1} = adjust_indents(Env, Lev, L),
T2 = skip_blanks(T1),
case T2 of
- [$*|T3] ->
- format_txt(T3,Env1,reverse("<li>", L1), Doc);
- [$[|T4] ->
- {Env2, L2} = open_dl(Env1, L1),
+ [$*|T3] ->
+ format_txt(T3,Env1,reverse("<li>", L1), Doc);
+ [$[|T4] ->
+ {Env2, L2} = open_dl(Env1, L1),
add_dl(T4, Env2, reverse("<dt>", L2), Doc);
- _ ->
- format_txt(T2,Env1,L1, Doc)
+ _ ->
+ format_txt(T2,Env1,L1, Doc)
end.
skip_blanks([$ |T]) -> skip_blanks(T);
@@ -537,10 +537,10 @@ collect_wiki_link([H|T], L, Quoted) when $0 =< H, H =< $9 ->
collect_wiki_link(T, [H|L], Quoted);
collect_wiki_link(S=[H|T], L, Quoted) ->
case member(H, "äÄöÖåÅ") of
- true ->
- collect_wiki_link(T, [H|L], Quoted);
- false ->
- {reverse(L), S}
+ true ->
+ collect_wiki_link(T, [H|L], Quoted);
+ false ->
+ {reverse(L), S}
end;
collect_wiki_link(T, L, Quoted) ->
{reverse(L), T}.
@@ -555,11 +555,11 @@ plugin(Data, Page) ->
0 -> %% Broken plugin syntax
{"", "<?plugin " ++ Data};
EndPluginIndex ->
- PluginData = string:sub_string(Data, 1, EndPluginIndex -1),
- [PluginName| ArgStrings] = string:tokens(PluginData, " "),
- Result = exec_plugin(PluginName, Page, ArgStrings),
- Rest = string:sub_string(Data, EndPluginIndex + 2),
- {Result, Rest}
+ PluginData = string:sub_string(Data, 1, EndPluginIndex -1),
+ [PluginName| ArgStrings] = string:tokens(PluginData, " "),
+ Result = exec_plugin(PluginName, Page, ArgStrings),
+ Rest = string:sub_string(Data, EndPluginIndex + 2),
+ {Result, Rest}
end.
exec_plugin(Name, Page, ArgStrings) ->
View
4 applications/wiki/src/wiki_plugin_backlinks.erl
@@ -21,6 +21,6 @@ run(Page, ArgList) ->
AllRefs = wiki_utils:getallrefs(Page, Root),