Skip to content

Commit 6a74d64

Browse files
authored
Merge pull request #667 from ocsigen/mrmime
Remove dependency to ocamlnet
2 parents 31792a0 + e02f6ad commit 6a74d64

File tree

7 files changed

+85
-97
lines changed

7 files changed

+85
-97
lines changed

Makefile.options

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ SASS_TEMPORARY_PROJECT_NAME := os_temporary_project_name
5555

5656
# OCamlfind packages for the server
5757
SERVER_PACKAGES := calendar safepass \
58-
ocsigen-toolkit.server yojson re.str cohttp-lwt-unix \
59-
netstring
58+
ocsigen-toolkit.server yojson re.str cohttp-lwt-unix
6059

6160
SERVER_PPX_PACKAGES := lwt_ppx js_of_ocaml-ppx_deriving_json ocsigen-ppx-rpc
6261

opam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ depends: [
3131
"resource-pooling" {>= "1.0" & < "2.0"}
3232
"cohttp-lwt-unix"
3333
"conf-npm" {>= "1"}
34-
"ocamlnet"
3534
"re" {>= "1.7.2"}
3635
]
3736
depexts: [

src/os_email.eliom

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,41 +33,28 @@ let email_pattern = email_pattern
3333
let email_regexp = Str.regexp_case_fold email_pattern
3434
let is_valid email = Str.string_match email_regexp email 0
3535

36-
let default_send ?url ~from_addr ~to_addrs ~subject content =
37-
(* TODO with fork ou mieux en utilisant l'event loop de ocamlnet *)
36+
let default_send ?url:_ ~from_addr ~to_addrs ~subject:_ content =
3837
let echo = printf "%s\n" in
3938
let flush () = printf "%!" in
39+
let print_tuple (a, b) = printf " (%s,%s)\n" a b in
4040
let content =
41-
match url with Some url -> content @ [url] | None -> content
41+
if List.length content = 0
42+
then ""
43+
else
44+
List.fold_left
45+
(fun s1 s2 -> s1 ^ "\n" ^ s2)
46+
(List.hd content) (List.tl content)
4247
in
43-
try
44-
let content =
45-
if List.length content = 0
46-
then ""
47-
else
48-
List.fold_left
49-
(fun s1 s2 -> s1 ^ "\n" ^ s2)
50-
(List.hd content) (List.tl content)
51-
in
52-
let print_tuple (a, b) = printf " (%s,%s)\n" a b in
53-
echo "Sending e-mail:";
54-
echo "[from_addr]: ";
55-
print_tuple from_addr;
56-
echo "[to_addrs]: [";
57-
List.iter print_tuple to_addrs;
58-
echo "]";
59-
printf "[content]:\n%s\n" content;
60-
let%lwt () =
61-
Lwt_preemptive.detach
62-
(Netsendmail.sendmail ~mailer:!mailer)
63-
(Netsendmail.compose ~from_addr ~to_addrs ~subject content)
64-
in
65-
echo "[SUCCESS]: e-mail has been sent!";
66-
Lwt.return_unit
67-
with Netchannels.Command_failure (Unix.WEXITED 127) ->
68-
echo "[FAIL]: e-mail has not been sent!";
69-
flush ();
70-
Lwt.fail (Invalid_mailer (!mailer ^ " not found"))
48+
echo "Sending e-mail:";
49+
echo "[from_addr]: ";
50+
print_tuple from_addr;
51+
echo "[to_addrs]: [";
52+
List.iter print_tuple to_addrs;
53+
echo "]";
54+
printf "[content]:\n%s\n" content;
55+
echo "Please set your own sendmail function using Os_email.set_send";
56+
flush ();
57+
Lwt.return ()
7158

7259
let send_ref = ref default_send
7360

template.distillery/demo_pgocaml_db.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ open Os_db
1010

1111
let get () =
1212
full_transaction_block (fun dbh ->
13-
[%pgsql dbh "SELECT lastname FROM ocsigen_start.users"])
13+
[%pgsql dbh "SELECT lastname FROM ocsigen_start.users"])

template.distillery/mobile!eliom_loader.ml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
module XmlHttpRequest = Js_of_ocaml_lwt.XmlHttpRequest
1616

1717
(* Debug mode. Set to true if you want to use the debug mode. Used by "log".
18-
*)
18+
*)
1919
let debug = false
2020

2121
(* If debug mode is activated, a paragraph is created and a message is printed
@@ -73,17 +73,17 @@ let rec add_retry_button wake msg =
7373
(Js_of_ocaml.Js.string "Retry"));
7474
btn##.onclick :=
7575
Js_of_ocaml.Dom_html.handler (fun _ ->
76-
Js_of_ocaml.Dom.removeChild container p;
77-
container##.className := Js_of_ocaml.Js.string "app blink";
78-
if !update_failed
79-
then (
80-
update_failed := false;
81-
ignore Js_of_ocaml.Js.Unsafe.global##.chcp##fetchUpdate);
82-
if !data_upload_failed
83-
then (
84-
data_upload_failed := false;
85-
Lwt.async (fun () -> get_data wake));
86-
Js_of_ocaml.Js._false);
76+
Js_of_ocaml.Dom.removeChild container p;
77+
container##.className := Js_of_ocaml.Js.string "app blink";
78+
if !update_failed
79+
then (
80+
update_failed := false;
81+
ignore Js_of_ocaml.Js.Unsafe.global##.chcp##fetchUpdate);
82+
if !data_upload_failed
83+
then (
84+
data_upload_failed := false;
85+
Lwt.async (fun () -> get_data wake));
86+
Js_of_ocaml.Js._false);
8787
btn##.id := Js_of_ocaml.Js.string "retry-button";
8888
Js_of_ocaml.Dom.appendChild p btn;
8989
Js_of_ocaml.Dom.appendChild container p
@@ -119,9 +119,9 @@ let _ =
119119
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
120120
(Js_of_ocaml.Dom_html.Event.make "resume")
121121
(Js_of_ocaml.Dom.handler (fun _ ->
122-
log "Resume";
123-
ignore Js_of_ocaml.Js.Unsafe.global##.chcp##fetchUpdate;
124-
Js_of_ocaml.Js._true))
122+
log "Resume";
123+
ignore Js_of_ocaml.Js.Unsafe.global##.chcp##fetchUpdate;
124+
Js_of_ocaml.Js._true))
125125
Js_of_ocaml.Js._false;
126126
(* Create two threads for success callbacks and error callbacks. *)
127127
let wait_success, wake_success = Lwt.wait () in
@@ -132,26 +132,26 @@ let _ =
132132
*)
133133
let callback ev =
134134
Js_of_ocaml.Dom.handler (fun _ ->
135-
log ev;
136-
update_failed := false;
137-
Lwt.wakeup wake_success ();
138-
Js_of_ocaml.Js._true)
135+
log ev;
136+
update_failed := false;
137+
Lwt.wakeup wake_success ();
138+
Js_of_ocaml.Js._true)
139139
in
140140
(* Callback when errors.
141141
* Calls by the event chcp_nothingToUpdate.
142142
*)
143143
let error_callback name =
144144
Js_of_ocaml.Dom.handler (fun ev ->
145-
log
146-
(name ^ ": "
147-
^ Js_of_ocaml.Js.to_string ev##.detail##.error##.description);
148-
update_failed := true;
149-
if not !data_upload_failed
150-
then
151-
add_retry_button wake_error
152-
(Js_of_ocaml.Js.to_string ev##.detail##.error##.description
153-
^ ". Please try again later.");
154-
Js_of_ocaml.Js.bool true)
145+
log
146+
(name ^ ": "
147+
^ Js_of_ocaml.Js.to_string ev##.detail##.error##.description);
148+
update_failed := true;
149+
if not !data_upload_failed
150+
then
151+
add_retry_button wake_error
152+
(Js_of_ocaml.Js.to_string ev##.detail##.error##.description
153+
^ ". Please try again later.");
154+
Js_of_ocaml.Js.bool true)
155155
in
156156
(* Callback to print a message *)
157157
let status_callback name =
@@ -160,20 +160,20 @@ let _ =
160160
(* Binding to chcp_nothingToUpdate. Calls [callback ev]. *)
161161
List.iter
162162
(fun ev ->
163-
ignore
164-
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
165-
(Js_of_ocaml.Dom_html.Event.make ev)
166-
(callback ev) Js_of_ocaml.Js._false)
163+
ignore
164+
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
165+
(Js_of_ocaml.Dom_html.Event.make ev)
166+
(callback ev) Js_of_ocaml.Js._false)
167167
["chcp_nothingToUpdate"];
168168
(* Binding to chcp_updateLoadFailed, chcp_updateInstallFailed and
169169
* chcp_assetsInstallationError. It calls [error_callback ev].
170170
*)
171171
List.iter
172172
(fun ev ->
173-
ignore
174-
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
175-
(Js_of_ocaml.Dom_html.Event.make ev)
176-
(error_callback ev) Js_of_ocaml.Js._false)
173+
ignore
174+
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
175+
(Js_of_ocaml.Dom_html.Event.make ev)
176+
(error_callback ev) Js_of_ocaml.Js._false)
177177
[ "chcp_updateLoadFailed"
178178
; "chcp_updateInstallFailed"
179179
; "chcp_assetsInstallationError" ];
@@ -182,10 +182,10 @@ let _ =
182182
*)
183183
List.iter
184184
(fun ev ->
185-
ignore
186-
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
187-
(Js_of_ocaml.Dom_html.Event.make ev)
188-
(status_callback ev) Js_of_ocaml.Js._false)
185+
ignore
186+
@@ Js_of_ocaml.Dom.addEventListener Js_of_ocaml.Dom_html.document
187+
(Js_of_ocaml.Dom_html.Event.make ev)
188+
(status_callback ev) Js_of_ocaml.Js._false)
189189
[ "chcp_updateIsReadyToInstall"
190190
; "chcp_beforeInstall"
191191
; "chcp_nothingToInstall"

template.distillery/tools!check_modules.ml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ let modules_from_bytecode_executable nm =
1010
()
1111
done;
1212
let lst = ref [] in
13-
while
14-
let l = input_line ch in
15-
if l <> "" && l.[0] = '\t'
16-
then (
17-
let i = String.rindex l '\t' in
18-
lst := String.sub l (i + 1) (String.length l - i - 1) :: !lst;
19-
true)
20-
else false
21-
do
22-
()
23-
done;
13+
(try
14+
while
15+
let l = input_line ch in
16+
if l <> "" && l.[0] = '\t'
17+
then (
18+
let i = String.rindex l '\t' in
19+
lst := String.sub l (i + 1) (String.length l - i - 1) :: !lst;
20+
true)
21+
else false
22+
do
23+
()
24+
done
25+
with End_of_file -> ());
2426
!lst
2527

2628
let modules_from_bytecode_library nm =
@@ -75,17 +77,17 @@ let _ =
7577
let missing_server_modules =
7678
List.filter_map
7779
(fun (m, sect) ->
78-
let c = List.mem m client_modules in
79-
let s = List.mem m server_modules in
80-
match c, s, sect with true, false, true -> Some m | _ -> None)
80+
let c = List.mem m client_modules in
81+
let s = List.mem m server_modules in
82+
match c, s, sect with true, false, true -> Some m | _ -> None)
8183
eliom_modules
8284
in
8385
let missing_client_modules =
8486
List.filter_map
8587
(fun (m, sect) ->
86-
let c = List.mem m client_modules in
87-
let s = List.mem m server_modules in
88-
match c, s, sect with false, true, true -> Some m | _ -> None)
88+
let c = List.mem m client_modules in
89+
let s = List.mem m server_modules in
90+
match c, s, sect with false, true, true -> Some m | _ -> None)
8991
eliom_modules
9092
in
9193
let missing_modules =

template.distillery/tools!gen_dune.ml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
let with_suffixes nm l f =
22
List.iter
33
(fun suffix ->
4-
if Filename.check_suffix nm suffix then f (Filename.chop_suffix nm suffix))
4+
if Filename.check_suffix nm suffix
5+
then f (Filename.chop_suffix nm suffix))
56
l
67

78
let handle_file_client nm =
@@ -11,9 +12,9 @@ let handle_file_client nm =
1112
then ()
1213
else
1314
with_suffixes nm [".eliom"; ".tsv"] (fun nm ->
14-
Printf.printf
15-
"(rule (target %s.ml) (deps ../%s.eliom)\n\ (action\n\ (with-stdout-to %%{target}\n\ (chdir .. (run tools/eliom_ppx_client.exe --as-pp -server-cmo %%{cmo:../%s} --impl %s.eliom)))))\n"
16-
nm nm nm nm);
15+
Printf.printf
16+
"(rule (target %s.ml) (deps ../%s.eliom)\n\ (action\n\ (with-stdout-to %%{target}\n\ (chdir .. (run tools/eliom_ppx_client.exe --as-pp -server-cmo %%{cmo:../%s} --impl %s.eliom)))))\n"
17+
nm nm nm nm);
1718
if Filename.check_suffix nm ".eliomi"
1819
then
1920
let nm = Filename.chop_suffix nm ".eliomi" in

0 commit comments

Comments
 (0)