Commit df66115b0cf46dabe9d7493193925fdf6549868a
1 parent
89e465d6
remove duplicate js filenames when formating html head tags
Showing
1 changed file
with
38 additions
and
11 deletions
Show diff stats
web/CXM_making_a_web_site.anubis
| @@ -50,7 +50,9 @@ | @@ -50,7 +50,9 @@ | ||
| 50 | read tools/basis.anubis | 50 | read tools/basis.anubis |
| 51 | read tools/printable_tree.anubis | 51 | read tools/printable_tree.anubis |
| 52 | read tools/base64.anubis | 52 | read tools/base64.anubis |
| 53 | -read tools/random.anubis | 53 | +read tools/random.anubis |
| 54 | +read tools/dictionaries.anubis | ||
| 55 | +read system/lists.anubis | ||
| 54 | read system/string.anubis | 56 | read system/string.anubis |
| 55 | read system/logger.anubis | 57 | read system/logger.anubis |
| 56 | read CXM_common.anubis | 58 | read CXM_common.anubis |
| @@ -4577,14 +4579,29 @@ define Printable_tree | @@ -4577,14 +4579,29 @@ define Printable_tree | ||
| 4577 | [h . t] then [format(cinfo,state_name,h,is_https) | 4579 | [h . t] then [format(cinfo,state_name,h,is_https) |
| 4578 | . format(cinfo,state_name,t,is_https,charset)] | 4580 | . format(cinfo,state_name,t,is_https,charset)] |
| 4579 | }. | 4581 | }. |
| 4580 | - | 4582 | + |
| 4583 | + define List(HTML_Head_Tag) | ||
| 4584 | + rebuild_html_head_tags | ||
| 4585 | + ( | ||
| 4586 | + List(HTML_Head_Tag) lwf, | ||
| 4587 | + List(HTML_Head_Tag) so_far | ||
| 4588 | + ) = | ||
| 4589 | + if lwf is | ||
| 4590 | + { | ||
| 4591 | + [] then so_far, | ||
| 4592 | + [h . t] then | ||
| 4593 | + rebuild_html_head_tags(t, append_once(so_far, h)) | ||
| 4594 | + }. | ||
| 4595 | + | ||
| 4581 | define Printable_tree | 4596 | define Printable_tree |
| 4582 | _format_html_head | 4597 | _format_html_head |
| 4583 | ( | 4598 | ( |
| 4584 | List(HTML_Head_Tag) lwf, | 4599 | List(HTML_Head_Tag) lwf, |
| 4585 | - Printable_tree so_far | 4600 | + Printable_tree so_far, |
| 4601 | + Dictionary(String, Word32) js_dict | ||
| 4586 | ) | 4602 | ) |
| 4587 | = | 4603 | = |
| 4604 | + //with lwf_ = rebuild_html_head_tags(lwf, []), | ||
| 4588 | if lwf is | 4605 | if lwf is |
| 4589 | { | 4606 | { |
| 4590 | [] then reverse(so_far), | 4607 | [] then reverse(so_far), |
| @@ -4592,21 +4609,31 @@ define Printable_tree | @@ -4592,21 +4609,31 @@ define Printable_tree | ||
| 4592 | if h is | 4609 | if h is |
| 4593 | { | 4610 | { |
| 4594 | meta(meta) then | 4611 | meta(meta) then |
| 4595 | - [format(meta) . _format_html_head(t, so_far)], | 4612 | + [format(meta) . _format_html_head(t, so_far, js_dict)], |
| 4596 | title(title) then | 4613 | title(title) then |
| 4597 | - ["<title>"+title+"</title>\n" . _format_html_head(t, so_far)], | 4614 | + ["<title>"+title+"</title>\n" . _format_html_head(t, so_far, js_dict)], |
| 4598 | js(jsf) then | 4615 | js(jsf) then |
| 4599 | - [add_js_files([jsf]) . _format_html_head(t, so_far)], | 4616 | + since jsf is js_file(filename, _), |
| 4617 | + if js_dict.get(filename) is | ||
| 4618 | + { | ||
| 4619 | + failure then | ||
| 4620 | + forget(js_dict.insert(filename, 0)); | ||
| 4621 | + [add_js_files([jsf]) . _format_html_head(t, so_far, js_dict)], | ||
| 4622 | + | ||
| 4623 | + success(_) then | ||
| 4624 | + _format_html_head(t, so_far, js_dict), | ||
| 4625 | + } | ||
| 4600 | js_inline(jsi) then | 4626 | js_inline(jsi) then |
| 4601 | if jsi is | 4627 | if jsi is |
| 4602 | { | 4628 | { |
| 4603 | - script(type, _) then ["<script type=\"" + type + "\">"+content(jsi)+"</script>\n" . _format_html_head(t, so_far)], | 4629 | + script(type, _) then |
| 4630 | + ["<script type=\"" + type + "\">"+content(jsi)+"</script>\n" . _format_html_head(t, so_far, js_dict)], | ||
| 4604 | } | 4631 | } |
| 4605 | css(cssf) then | 4632 | css(cssf) then |
| 4606 | since cssf is css_file(file_name, media), | 4633 | since cssf is css_file(file_name, media), |
| 4607 | - ["<link rel=\"stylesheet\" type=\"text/css\" href=\""+file_name+"\" media=\""+to_String(media)+"\" />\n" . _format_html_head(t, so_far)], | 4634 | + ["<link rel=\"stylesheet\" type=\"text/css\" href=\""+file_name+"\" media=\""+to_String(media)+"\" />\n" . _format_html_head(t, so_far, js_dict)], |
| 4608 | css_inline(cssi) then | 4635 | css_inline(cssi) then |
| 4609 | - ["<style>"+cssi+"</style>\n" . _format_html_head(t, so_far)] | 4636 | + ["<style>"+cssi+"</style>\n" . _format_html_head(t, so_far, js_dict)] |
| 4610 | } | 4637 | } |
| 4611 | } | 4638 | } |
| 4612 | . | 4639 | . |
| @@ -4618,7 +4645,7 @@ public define Printable_tree | @@ -4618,7 +4645,7 @@ public define Printable_tree | ||
| 4618 | String charset | 4645 | String charset |
| 4619 | ) | 4646 | ) |
| 4620 | = | 4647 | = |
| 4621 | - _format_html_head((List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], []). | 4648 | + _format_html_head((List(HTML_Head_Tag))[ meta(http_equiv("content-type", "text/html; charset="+charset)) . lwf], [], make_dictionary((Word32)0, dictionaryComparerString)). |
| 4622 | 4649 | ||
| 4623 | public define Printable_tree | 4650 | public define Printable_tree |
| 4624 | format_html_head | 4651 | format_html_head |
| @@ -4626,7 +4653,7 @@ public define Printable_tree | @@ -4626,7 +4653,7 @@ public define Printable_tree | ||
| 4626 | List(HTML_Head_Tag) lwf | 4653 | List(HTML_Head_Tag) lwf |
| 4627 | ) | 4654 | ) |
| 4628 | = | 4655 | = |
| 4629 | - _format_html_head(lwf, []). | 4656 | + _format_html_head(lwf, [], make_dictionary((Word32)0, dictionaryComparerString)). |
| 4630 | 4657 | ||
| 4631 | 4658 | ||
| 4632 | public type HTML_ajax_content: | 4659 | public type HTML_ajax_content: |