Commit c74f137176a21f204f7c4fcf325c9b60403802f7
1 parent
290f8559
add some helper for functions which took list of CoreAttrs to make available wit…
…h only one CoreAttrs argument. This make the source more readable
Showing
2 changed files
with
97 additions
and
11 deletions
Show diff stats
web/CXM_making_a_web_site.anubis
| ... | ... | @@ -2173,12 +2173,16 @@ public define HTML_Off_Form input(CoreAttrs attr) |
| 2173 | 2173 | |
| 2174 | 2174 | // <img> |
| 2175 | 2175 | public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt) = html_void_tag("img", attrs + [attr("src",src), attr("alt",alt)] ). |
| 2176 | +public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt) = html_void_tag("img", [_attr, attr("src",src), attr("alt",alt)] ). | |
| 2176 | 2177 | public define HTML_Off_Form img(String src) = img([], src, ""). |
| 2177 | 2178 | public define HTML_Off_Form img(String src, String alt) = img([], src, alt). |
| 2178 | 2179 | public define HTML_Off_Form img(List(CoreAttrs) attrs, String src) = img(attrs, src, ""). |
| 2180 | +public define HTML_Off_Form img(CoreAttrs attr, String src) = img([attr], src, ""). | |
| 2179 | 2181 | public define HTML_Off_Form img(String src, Int width, Int height) = img([attr("witdh",to_String(width)), attr("height",to_String(height))], src, src). |
| 2180 | 2182 | public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt, Int width, Int height) = |
| 2181 | 2183 | html_void_tag("img", attrs + [attr("src",src), attr("alt",alt), attr("witdh",to_String(width)), attr("height",to_String(height))]). |
| 2184 | +public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt, Int width, Int height) = | |
| 2185 | + html_void_tag("img", [_attr, attr("src",src), attr("alt",alt), attr("witdh",to_String(width)), attr("height",to_String(height))]). | |
| 2182 | 2186 | |
| 2183 | 2187 | // <li> |
| 2184 | 2188 | public define HTML_Off_Form li(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("li", attrs, content). |
| ... | ... | @@ -2391,11 +2395,12 @@ public define HTML_Off_Form |
| 2391 | 2395 | . |
| 2392 | 2396 | |
| 2393 | 2397 | public define HTML_Off_Form |
| 2394 | - table | |
| 2395 | - ( | |
| 2396 | - List(HTML_Row(HTML_Off_Form)) rows | |
| 2397 | - ) = | |
| 2398 | - table([],empty,rows,empty). | |
| 2398 | + table | |
| 2399 | + ( | |
| 2400 | + List(HTML_Row(HTML_Off_Form)) rows | |
| 2401 | + )= | |
| 2402 | + table([], empty, rows,empty) | |
| 2403 | +. | |
| 2399 | 2404 | |
| 2400 | 2405 | public define HTML_Off_Form |
| 2401 | 2406 | table |
| ... | ... | @@ -2403,7 +2408,8 @@ public define HTML_Off_Form |
| 2403 | 2408 | List(Table_Option) options, |
| 2404 | 2409 | List(HTML_Row(HTML_Off_Form)) rows |
| 2405 | 2410 | ) = |
| 2406 | - table(options,empty,rows,empty). | |
| 2411 | + table(options,empty,rows,empty) | |
| 2412 | +. | |
| 2407 | 2413 | |
| 2408 | 2414 | public define HTML_Off_Form |
| 2409 | 2415 | table |
| ... | ... | @@ -2411,7 +2417,8 @@ public define HTML_Off_Form |
| 2411 | 2417 | Table_Option option, |
| 2412 | 2418 | HTML_Row(HTML_Off_Form) row |
| 2413 | 2419 | ) = |
| 2414 | - table([option], empty, [row], empty). | |
| 2420 | + table([option], empty, [row], empty) | |
| 2421 | +. | |
| 2415 | 2422 | |
| 2416 | 2423 | public define HTML_Off_Form |
| 2417 | 2424 | table |
| ... | ... | @@ -2419,7 +2426,8 @@ public define HTML_Off_Form |
| 2419 | 2426 | HTML_Header_Row(HTML_Off_Form) h_row, |
| 2420 | 2427 | List(HTML_Row(HTML_Off_Form)) rows |
| 2421 | 2428 | ) = |
| 2422 | - table([],h_row,rows,empty). | |
| 2429 | + table([],h_row,rows,empty) | |
| 2430 | +. | |
| 2423 | 2431 | |
| 2424 | 2432 | public define HTML_Off_Form |
| 2425 | 2433 | table |
| ... | ... | @@ -2428,7 +2436,18 @@ public define HTML_Off_Form |
| 2428 | 2436 | HTML_Header_Row(HTML_Off_Form) h_row, |
| 2429 | 2437 | List(HTML_Row(HTML_Off_Form)) rows |
| 2430 | 2438 | ) = |
| 2431 | - table(options,h_row,rows,empty). | |
| 2439 | + table(options,h_row,rows,empty) | |
| 2440 | +. | |
| 2441 | + | |
| 2442 | +public define HTML_Off_Form | |
| 2443 | + table | |
| 2444 | + ( | |
| 2445 | + Table_Option option, | |
| 2446 | + HTML_Header_Row(HTML_Off_Form) h_row, | |
| 2447 | + List(HTML_Row(HTML_Off_Form)) rows | |
| 2448 | + ) = | |
| 2449 | + table([option], h_row, rows,empty) | |
| 2450 | +. | |
| 2432 | 2451 | |
| 2433 | 2452 | We add two convenience functions for 'row'. The reason why we add two functions, one |
| 2434 | 2453 | for 'HTML_In_Form' and one for 'HTML_Off_Form', is that adding a schema with an |
| ... | ... | @@ -2615,7 +2634,11 @@ public define HTML_Partial_Content |
| 2615 | 2634 | )= |
| 2616 | 2635 | list_to_pcontent(l_p_content, [], []). |
| 2617 | 2636 | |
| 2618 | - | |
| 2637 | +public define HTML_Partial_Content | |
| 2638 | + partial_empty | |
| 2639 | + = | |
| 2640 | + partial_content(empty) | |
| 2641 | +. | |
| 2619 | 2642 | |
| 2620 | 2643 | define String |
| 2621 | 2644 | format |
| ... | ... | @@ -2735,7 +2758,51 @@ public define HTTP_Answer |
| 2735 | 2758 | HTML_Body body |
| 2736 | 2759 | ) = |
| 2737 | 2760 | html_page(http_ok, title, metas, styles, [], [], [], body). |
| 2738 | - | |
| 2761 | + | |
| 2762 | +public define HTTP_Answer | |
| 2763 | + web_controller_error_page | |
| 2764 | + ( | |
| 2765 | + String name | |
| 2766 | + ) | |
| 2767 | + = | |
| 2768 | + html_page | |
| 2769 | + ( | |
| 2770 | + name+" Controller error", // title of web site | |
| 2771 | + [], // list of 'META' tags (empty for this site) | |
| 2772 | + body // body of page | |
| 2773 | + ( | |
| 2774 | + // list of body options | |
| 2775 | + [ | |
| 2776 | + background_color(rgb(255,200,200)) | |
| 2777 | + // add more body options here | |
| 2778 | + ], | |
| 2779 | + | |
| 2780 | + // content of page | |
| 2781 | + center(text(name+" Controller error")) | |
| 2782 | + ) | |
| 2783 | + ) | |
| 2784 | +. | |
| 2785 | + | |
| 2786 | +define (WEB_Session)-> WEB_Controller_Result | |
| 2787 | + web_controller_error | |
| 2788 | + ( | |
| 2789 | + String name | |
| 2790 | + )= | |
| 2791 | + ( | |
| 2792 | + WEB_Session session | |
| 2793 | + ) |-> | |
| 2794 | + http_answer(session, web_controller_error_page(name)). | |
| 2795 | + | |
| 2796 | +public define WEB_Controller | |
| 2797 | + web_controller | |
| 2798 | + ( | |
| 2799 | + String name, //controller name | |
| 2800 | + Var(List(WEB_Action)) controller_actions //list of all actions of that controller | |
| 2801 | + //(WEB_Session)-> WEB_Controller_Result error //Error renderer | |
| 2802 | + )= | |
| 2803 | + web_controller(name, controller_actions, web_controller_error(name)) | |
| 2804 | +. | |
| 2805 | + | |
| 2739 | 2806 | 'HTTP_Answer' represents the final product of the construction of a web page. |
| 2740 | 2807 | |
| 2741 | 2808 | ... | ... |
web/fonts/awesome.anubis
| ... | ... | @@ -40,6 +40,16 @@ public define HTML_Off_Form |
| 40 | 40 | to_HTML |
| 41 | 41 | ( |
| 42 | 42 | Font_Awesome fa, |
| 43 | + CoreAttrs attr | |
| 44 | + )= | |
| 45 | + to_HTML(fa, [attr], "") | |
| 46 | +. | |
| 47 | + | |
| 48 | + | |
| 49 | +public define HTML_Off_Form | |
| 50 | + to_HTML | |
| 51 | + ( | |
| 52 | + Font_Awesome fa, | |
| 43 | 53 | String text |
| 44 | 54 | )= |
| 45 | 55 | to_HTML(fa, [], text) |
| ... | ... | @@ -73,6 +83,15 @@ public define HTML_In_Form |
| 73 | 83 | to_HTML(fa, attrs, "") |
| 74 | 84 | . |
| 75 | 85 | |
| 86 | +public define HTML_In_Form | |
| 87 | + to_HTML | |
| 88 | + ( | |
| 89 | + Font_Awesome fa, | |
| 90 | + CoreAttrs attr | |
| 91 | + )= | |
| 92 | + to_HTML(fa, [attr], "") | |
| 93 | +. | |
| 94 | + | |
| 76 | 95 | |
| 77 | 96 | public define HTML_In_Form |
| 78 | 97 | to_HTML | ... | ... |