Finishing getting rid of html.elements from basis
parent
3ec78f3766
commit
b206c5a2d1
|
@ -10,7 +10,6 @@ xml.writer
|
||||||
xml.traversal
|
xml.traversal
|
||||||
xml.syntax
|
xml.syntax
|
||||||
html.components
|
html.components
|
||||||
html.elements
|
|
||||||
html.forms
|
html.forms
|
||||||
html.templates
|
html.templates
|
||||||
html.templates.chloe
|
html.templates.chloe
|
||||||
|
@ -58,14 +57,6 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
|
||||||
#! Side-effects current namespace.
|
#! Side-effects current namespace.
|
||||||
'[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
|
'[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
|
||||||
|
|
||||||
: a-start-tag ( tag -- )
|
|
||||||
[ <a ] [code]
|
|
||||||
[ attrs>> non-chloe-attrs-only compile-attrs ]
|
|
||||||
[ compile-link-attrs ]
|
|
||||||
[ compile-a-url ]
|
|
||||||
tri
|
|
||||||
[ =href a> ] [code] ;
|
|
||||||
|
|
||||||
: process-attrs ( assoc -- newassoc )
|
: process-attrs ( assoc -- newassoc )
|
||||||
[ "@" ?head [ value present ] when ] assoc-map ;
|
[ "@" ?head [ value present ] when ] assoc-map ;
|
||||||
|
|
||||||
|
@ -76,54 +67,61 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
|
||||||
[ non-chloe-attrs ]
|
[ non-chloe-attrs ]
|
||||||
[ compile-link-attrs ]
|
[ compile-link-attrs ]
|
||||||
[ compile-a-url ] tri
|
[ compile-a-url ] tri
|
||||||
[ swap "href" swap set-at ] [code] ;
|
[ present swap "href" swap [ set-at ] keep ] [code] ;
|
||||||
|
|
||||||
CHLOE: a
|
CHLOE: a
|
||||||
|
[
|
||||||
[ a-attrs ]
|
[ a-attrs ]
|
||||||
[ compile-children>string ] bi
|
[ compile-children>string ] bi
|
||||||
[ <unescaped> [XML <a><-></a> XML] swap >>attrs ]
|
[ <unescaped> [XML <a><-></a> XML] second swap >>attrs ]
|
||||||
[xml-code] ;
|
[xml-code]
|
||||||
|
] compile-with-scope ;
|
||||||
|
|
||||||
CHLOE: base
|
CHLOE: base
|
||||||
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
|
compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
|
||||||
|
|
||||||
|
USE: io.streams.string
|
||||||
|
|
||||||
: compile-hidden-form-fields ( for -- )
|
: compile-hidden-form-fields ( for -- )
|
||||||
'[
|
'[
|
||||||
<div "display: none;" =style div>
|
[
|
||||||
_ [ "," split [ hidden render ] each ] when*
|
_ [ "," split [ hidden render ] each ] when*
|
||||||
nested-forms get " " join f like nested-forms-key hidden-form-field
|
nested-forms get " " join f like nested-forms-key hidden-form-field
|
||||||
[ modify-form ] each-responder
|
[ modify-form ] each-responder
|
||||||
</div>
|
] with-string-writer <unescaped>
|
||||||
|
[XML <div style="display:none;"><-></div> XML]
|
||||||
] [code] ;
|
] [code] ;
|
||||||
|
|
||||||
: compile-form-attrs ( method action attrs -- )
|
: (compile-form-attrs) ( method action -- )
|
||||||
[ <form ] [code]
|
! Leaves an assoc on the stack at runtime
|
||||||
[ compile-attr [ =method ] [code] ]
|
[ compile-attr [ "method" pick set-at ] [code] ]
|
||||||
[ compile-attr [ resolve-base-path =action ] [code] ]
|
[ compile-attr [ resolve-base-path "action" pick set-at ] [code] ]
|
||||||
[ compile-attrs ]
|
bi* ;
|
||||||
tri*
|
|
||||||
[ form> ] [code] ;
|
|
||||||
|
|
||||||
: form-start-tag ( tag -- )
|
: compile-method/action ( tag -- )
|
||||||
[
|
! generated code is ( assoc -- assoc )
|
||||||
[ "method" optional-attr "post" or ]
|
[ "method" optional-attr "post" or ]
|
||||||
[ "action" required-attr ]
|
[ "action" required-attr ] bi
|
||||||
[ attrs>> non-chloe-attrs-only ] tri
|
(compile-form-attrs) ;
|
||||||
compile-form-attrs
|
|
||||||
]
|
|
||||||
[ "for" optional-attr compile-hidden-form-fields ] bi ;
|
|
||||||
|
|
||||||
: form-end-tag ( tag -- )
|
: compile-form-attrs ( tag -- )
|
||||||
drop [ </form> ] [code] ;
|
[ non-chloe-attrs ]
|
||||||
|
[ compile-link-attrs ]
|
||||||
|
[ compile-method/action ] tri ;
|
||||||
|
|
||||||
|
: hidden-fields ( tag -- )
|
||||||
|
"for" optional-attr compile-hidden-form-fields ;
|
||||||
|
|
||||||
CHLOE: form
|
CHLOE: form
|
||||||
[
|
[
|
||||||
{
|
[ compile-form-attrs ]
|
||||||
[ compile-link-attrs ]
|
[ hidden-fields ]
|
||||||
[ form-start-tag ]
|
[ compile-children>string ] tri
|
||||||
[ compile-children ]
|
[
|
||||||
[ form-end-tag ]
|
<unescaped> [XML <form><-><-></form> XML] second
|
||||||
} cleave
|
swap >>attrs
|
||||||
|
write-xml
|
||||||
|
] [code]
|
||||||
] compile-with-scope ;
|
] compile-with-scope ;
|
||||||
|
|
||||||
: button-tag-markup ( -- xml )
|
: button-tag-markup ( -- xml )
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: namespaces make assocs sequences kernel classes splitting
|
USING: namespaces make assocs sequences kernel classes splitting
|
||||||
words vocabs.loader accessors strings combinators arrays
|
words vocabs.loader accessors strings combinators arrays
|
||||||
continuations present fry urls http http.server xml.literals xml.writer
|
continuations present fry urls http http.server xml.syntax xml.writer
|
||||||
http.server.redirection http.server.remapping ;
|
http.server.redirection http.server.remapping ;
|
||||||
IN: furnace.utilities
|
IN: furnace.utilities
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ IN: html.components
|
||||||
|
|
||||||
GENERIC: render* ( value name renderer -- xml )
|
GENERIC: render* ( value name renderer -- xml )
|
||||||
|
|
||||||
: render ( name renderer -- )
|
: render>xml ( name renderer -- xml )
|
||||||
prepare-value
|
prepare-value
|
||||||
[
|
[
|
||||||
dup validation-error?
|
dup validation-error?
|
||||||
|
@ -20,7 +20,10 @@ GENERIC: render* ( value name renderer -- xml )
|
||||||
if
|
if
|
||||||
] 2dip
|
] 2dip
|
||||||
render*
|
render*
|
||||||
swap 2array write-xml ;
|
swap 2array ;
|
||||||
|
|
||||||
|
: render ( name renderer -- )
|
||||||
|
render>xml write-xml ;
|
||||||
|
|
||||||
SINGLETON: label
|
SINGLETON: label
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue