Commit 75265fb59e12b464ee95517cd60e3f561280586b

Authored by David RENÉ
1 parent cdc104b7

add helper (formaction, formmethod, main) for html_tag

add button with a String as argument
add form without CoreAttrs as argument

add helper as CoreAttrs for (width, height, width_px, height_px, alt, for, type, placeholder, name, role)
web/making_a_web_site.anubis
@@ -120,14 +120,6 @@ public define String @@ -120,14 +120,6 @@ public define String
120 _HTML_encode_entities(explode(source), []) 120 _HTML_encode_entities(explode(source), [])
121 . 121 .
122 122
123 -//public define String  
124 -// encode_HTML_entities  
125 -// (  
126 -// String source  
127 -// )=  
128 -//.  
129 -  
130 -//read CXM_html_tooltip.anubis  
131 123
132 * (1) Structure of a web site. 124 * (1) Structure of a web site.
133 125
@@ -1302,9 +1294,17 @@ url, @@ -1302,9 +1294,17 @@ url,
1302 week 1294 week
1303 . 1295 .
1304 1296
  1297 +public type FormMethod:
  1298 + get,
  1299 + post
  1300 +.
1305 1301
1306 //public type HTML_Body:... 1302 //public type HTML_Body:...
1307 1303
  1304 +public define CoreAttrs formaction(WEB_Action_Name action, List((String,String)) extra_ops) = attr("formaction", format_web_action_name(action, extra_ops)).
  1305 +public define CoreAttrs formaction(WEB_Action_Name action, (String,String) extra_op) = attr("formaction", format_web_action_name(action, extra_op)).
  1306 +public define CoreAttrs formaction(WEB_Action_Name action) = attr("formaction", format_web_action_name(action)).
  1307 +public define CoreAttrs formmethod(FormMethod method) = attr("formmethod", if method is { get then "get", post then "post"}).
1308 1308
1309 1309
1310 'HTML_Off_Form' defines all the elements you may put outside any form. 1310 'HTML_Off_Form' defines all the elements you may put outside any form.
@@ -1357,6 +1357,7 @@ public define HTML_Off_Form button(List(CoreAttrs) attrs, HTML_Off_Form content) @@ -1357,6 +1357,7 @@ public define HTML_Off_Form button(List(CoreAttrs) attrs, HTML_Off_Form content)
1357 public define HTML_Off_Form button(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("button", [attr], content). 1357 public define HTML_Off_Form button(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("button", [attr], content).
1358 public define HTML_Off_Form button(CoreAttrs attr, HTML_Off_Form content) = html_tag("button", [attr], [content]). 1358 public define HTML_Off_Form button(CoreAttrs attr, HTML_Off_Form content) = html_tag("button", [attr], [content]).
1359 public define HTML_Off_Form button(List(CoreAttrs) attrs) = html_tag("button", attrs, []). 1359 public define HTML_Off_Form button(List(CoreAttrs) attrs) = html_tag("button", attrs, []).
  1360 +public define HTML_Off_Form button(List(CoreAttrs) attrs, String string) = html_tag("button", attrs, [text(string)]).
1360 public define HTML_Off_Form button(List(HTML_Off_Form) content) = html_tag("button", [], content). 1361 public define HTML_Off_Form button(List(HTML_Off_Form) content) = html_tag("button", [], content).
1361 public define HTML_Off_Form button(HTML_Off_Form content) = html_tag("button", [], [content]). 1362 public define HTML_Off_Form button(HTML_Off_Form content) = html_tag("button", [], [content]).
1362 1363
@@ -1444,6 +1445,8 @@ public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content) @@ -1444,6 +1445,8 @@ public define HTML_Off_Form form(CoreAttrs attr, List(HTML_Off_Form) content)
1444 public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]). 1445 public define HTML_Off_Form form(CoreAttrs attr, HTML_Off_Form content) = html_tag("form", [attr], [content]).
1445 public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []). 1446 public define HTML_Off_Form form(List(CoreAttrs) attrs) = html_tag("form", attrs, []).
1446 public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []). 1447 public define HTML_Off_Form form(CoreAttrs attr) = html_tag("form", [attr], []).
  1448 +public define HTML_Off_Form form(List(HTML_Off_Form) content) = html_tag("form", [], content).
  1449 +public define HTML_Off_Form form(HTML_Off_Form content) = html_tag("form", [], [content]).
1447 1450
1448 // <header> 1451 // <header>
1449 public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content). 1452 public define HTML_Off_Form header(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("header", attrs, content).
@@ -1490,9 +1493,9 @@ public define HTML_Off_Form hr(CoreAttrs attr) @@ -1490,9 +1493,9 @@ public define HTML_Off_Form hr(CoreAttrs attr)
1490 1493
1491 // <iframe> 1494 // <iframe>
1492 public define HTML_Off_Form iframe(CoreAttrs _attr, String src, Int width, Int height) = 1495 public define HTML_Off_Form iframe(CoreAttrs _attr, String src, Int width, Int height) =
1493 - html_tag("iframe", [_attr, attr("src",src), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], []). 1496 + html_tag("iframe", [_attr, attr("src",src), width_px(width), height_px(height)], []).
1494 public define HTML_Off_Form iframe(String src, Int width, Int height) = 1497 public define HTML_Off_Form iframe(String src, Int width, Int height) =
1495 - html_tag("iframe", [attr("src",src), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], []). 1498 + html_tag("iframe", [attr("src",src), width_px(width), height_px(height)], []).
1496 public define HTML_Off_Form iframe(String src) = html_tag("iframe", [attr("src",src)], []). 1499 public define HTML_Off_Form iframe(String src) = html_tag("iframe", [attr("src",src)], []).
1497 1500
1498 // <input> 1501 // <input>
@@ -1525,10 +1528,12 @@ public define HTML_Off_Form img(CoreAttrs attr, String src) @@ -1525,10 +1528,12 @@ public define HTML_Off_Form img(CoreAttrs attr, String src)
1525 public define HTML_Off_Form img(String src, Int width, Int height) = img([attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], src, src). 1528 public define HTML_Off_Form img(String src, Int width, Int height) = img([attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")], src, src).
1526 public define HTML_Off_Form img(String src, String alt, Int width, Int height) = 1529 public define HTML_Off_Form img(String src, String alt, Int width, Int height) =
1527 html_void_tag("img", [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]). 1530 html_void_tag("img", [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]).
  1531 +
1528 public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt, Int width, Int height) = 1532 public define HTML_Off_Form img(List(CoreAttrs) attrs, String src, String alt, Int width, Int height) =
1529 html_void_tag("img", attrs + [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]). 1533 html_void_tag("img", attrs + [attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]).
  1534 +
1530 public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt, Int width, Int height) = 1535 public define HTML_Off_Form img(CoreAttrs _attr, String src, String alt, Int width, Int height) =
1531 - html_void_tag("img", [_attr, attr("src",src), attr("alt",alt), attr("width",to_String(width)+"px"), attr("height",to_String(height)+"px")]). 1536 + html_void_tag("img", [_attr, attr("src",src), attr("alt",alt), width_px(width), height_px(height)]).
1532 1537
1533 // <label> 1538 // <label>
1534 public define HTML_Off_Form label(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("label", attrs, content). 1539 public define HTML_Off_Form label(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("label", attrs, content).
@@ -1549,6 +1554,14 @@ public define HTML_Off_Form li(String string) @@ -1549,6 +1554,14 @@ public define HTML_Off_Form li(String string)
1549 public define HTML_Off_Form li(CoreAttrs attr, String string) = html_tag("li", [attr], [text(string)]). 1554 public define HTML_Off_Form li(CoreAttrs attr, String string) = html_tag("li", [attr], [text(string)]).
1550 public define HTML_Off_Form li(List(CoreAttrs) attrs, String string) = html_tag("li", attrs, [text(string)]). 1555 public define HTML_Off_Form li(List(CoreAttrs) attrs, String string) = html_tag("li", attrs, [text(string)]).
1551 1556
  1557 + // <main>
  1558 +public define HTML_Off_Form main(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("main", attrs, content).
  1559 +public define HTML_Off_Form main(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("main", attrs, [content]).
  1560 +public define HTML_Off_Form main(CoreAttrs attr, List(HTML_Off_Form) content) = html_tag("main", [attr], content).
  1561 +public define HTML_Off_Form main(CoreAttrs attr, HTML_Off_Form content) = html_tag("main", [attr], [content]).
  1562 +public define HTML_Off_Form main(List(HTML_Off_Form) content) = html_tag("main", [], content).
  1563 +public define HTML_Off_Form main(HTML_Off_Form content) = html_tag("main", [], [content]).
  1564 +
1552 // <nav> 1565 // <nav>
1553 public define HTML_Off_Form nav(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("nav", attrs, content). 1566 public define HTML_Off_Form nav(List(CoreAttrs) attrs, List(HTML_Off_Form) content) = html_tag("nav", attrs, content).
1554 public define HTML_Off_Form nav(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("nav", attrs, [content]). 1567 public define HTML_Off_Form nav(List(CoreAttrs) attrs, HTML_Off_Form content) = html_tag("nav", attrs, [content]).
web/types/making_a_web_site.anubis
@@ -571,8 +571,19 @@ public type CoreAttrs: @@ -571,8 +571,19 @@ public type CoreAttrs:
571 spellcheck(Bool) //Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking. 571 spellcheck(Bool) //Specifies whether the element represents an element whose contents are subject to spell checking and grammar checking.
572 . 572 .
573 573
574 -public define CoreAttrs colspan(Int value)= attr("colspan", to_String(value)).  
575 -public define CoreAttrs rowspan(Int value)= attr("rowspan", to_String(value)). 574 +public define CoreAttrs colspan(Int value) = attr("colspan", to_String(value)).
  575 +public define CoreAttrs rowspan(Int value) = attr("rowspan", to_String(value)).
  576 +public define CoreAttrs width(Int value) = attr("width", to_String(value)).
  577 +public define CoreAttrs height(Int value) = attr("height", to_String(value)).
  578 +public define CoreAttrs width_px(Int value) = attr("width", to_String(value)+"px").
  579 +public define CoreAttrs height_px(Int value) = attr("height", to_String(value)+"px").
  580 +public define CoreAttrs alt(String value) = attr("alt", value).
  581 +
  582 +public define CoreAttrs for(String value) = attr("for", value).
  583 +public define CoreAttrs type(String value) = attr("type", value).
  584 +public define CoreAttrs placeholder(String value) = attr("placeholder", value).
  585 +public define CoreAttrs name(String value) = attr("name", value).
  586 +public define CoreAttrs role(String value) = attr("role", value).
576 587
577 public define CoreAttrs 588 public define CoreAttrs
578 boolean 589 boolean