Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/main/learnocaml_main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ end

open Args

let process_html_file orig_file dest_file base_url =
let process_html_file orig_file dest_file base_url no_secret =
let transform_tag e tag attrs attr =
let attr_pair = ("", attr) in
match List.assoc_opt attr_pair attrs with
Expand All @@ -266,6 +266,9 @@ let process_html_file orig_file dest_file base_url =
| `Start_element ((e, "script"), attrs) -> transform_tag e "script" attrs "src"
| `Start_element ((e, "img"), attrs) -> transform_tag e "img" attrs "src"
| `Start_element ((e, "a"), attrs) -> transform_tag e "a" attrs "href"
| `Start_element ((e, "div"),attrs)
when no_secret && List.mem (("", "id"), "secret-section") attrs ->
`Start_element ((e, "div"), (("", "style"), "display:none")::attrs)
| t -> t)
|> Markup.pretty_print
|> Markup.write_html
Expand Down Expand Up @@ -330,9 +333,10 @@ let main o =
Printf.printf "Base URL: %s\n%!" o.builder.Builder.base_url;
Lwt_unix.files_of_directory o.builder.Builder.contents_dir
|> Lwt_stream.iter_s (fun file ->
let config_secret = json_config.ServerData.secret in
if Filename.extension file = ".html" then
process_html_file (o.builder.Builder.contents_dir/file)
(o.app_dir/file) o.builder.Builder.base_url
process_html_file (o.builder.Builder.contents_dir/file)
(o.app_dir/file) o.builder.Builder.base_url (config_secret = None)
else
Lwt.return_unit) >>= fun () ->
let if_enabled opt dir f = (match opt with
Expand Down
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h4 id="txt_first_connection"><!-- First connection --></h4>
<input id="login-nickname-input" type="text" placeholder="Nickname"
minlength="2" autocomplete="off"></input>
</div>
<div>
<div id="secret-section">
<div id="txt_first_connection_secret"><!-- Enter the secret --></div>
<div class="filler_h"></div>
<input id="login-secret-input" type="text" placeholder="Secret"
Expand Down