diff --git a/basis/furnace/chloe-tags/chloe-tags.factor b/basis/furnace/chloe-tags/chloe-tags.factor index 2be19c00c3..2bdaacdcba 100644 --- a/basis/furnace/chloe-tags/chloe-tags.factor +++ b/basis/furnace/chloe-tags/chloe-tags.factor @@ -10,7 +10,6 @@ xml.writer xml.traversal xml.syntax html.components -html.elements html.forms html.templates html.templates.chloe @@ -58,14 +57,6 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ; #! Side-effects current namespace. '[ [ [ _ ] dip link-attr ] each-responder ] [code] ; -: a-start-tag ( tag -- ) - [ > non-chloe-attrs-only compile-attrs ] - [ compile-link-attrs ] - [ compile-a-url ] - tri - [ =href a> ] [code] ; - : process-attrs ( assoc -- newassoc ) [ "@" ?head [ value present ] when ] assoc-map ; @@ -76,54 +67,61 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ; [ non-chloe-attrs ] [ compile-link-attrs ] [ compile-a-url ] tri - [ swap "href" swap set-at ] [code] ; + [ present swap "href" swap [ set-at ] keep ] [code] ; CHLOE: a - [ a-attrs ] - [ compile-children>string ] bi - [ [XML <-> XML] swap >>attrs ] - [xml-code] ; + [ + [ a-attrs ] + [ compile-children>string ] bi + [ [XML <-> XML] second swap >>attrs ] + [xml-code] + ] compile-with-scope ; CHLOE: base compile-a-url [ [XML /> XML] ] [xml-code] ; +USE: io.streams.string + : compile-hidden-form-fields ( for -- ) '[ -
+ [ _ [ "," split [ hidden render ] each ] when* nested-forms get " " join f like nested-forms-key hidden-form-field [ modify-form ] each-responder -
+ ] with-string-writer + [XML
<->
XML] ] [code] ; -: compile-form-attrs ( method action attrs -- ) - [
] [code] ; +: (compile-form-attrs) ( method action -- ) + ! Leaves an assoc on the stack at runtime + [ compile-attr [ "method" pick set-at ] [code] ] + [ compile-attr [ resolve-base-path "action" pick set-at ] [code] ] + bi* ; -: form-start-tag ( tag -- ) - [ - [ "method" optional-attr "post" or ] - [ "action" required-attr ] - [ attrs>> non-chloe-attrs-only ] tri - compile-form-attrs - ] - [ "for" optional-attr compile-hidden-form-fields ] bi ; +: compile-method/action ( tag -- ) + ! generated code is ( assoc -- assoc ) + [ "method" optional-attr "post" or ] + [ "action" required-attr ] bi + (compile-form-attrs) ; -: form-end-tag ( tag -- ) - drop [
] [code] ; +: compile-form-attrs ( tag -- ) + [ non-chloe-attrs ] + [ compile-link-attrs ] + [ compile-method/action ] tri ; + +: hidden-fields ( tag -- ) + "for" optional-attr compile-hidden-form-fields ; CHLOE: form [ - { - [ compile-link-attrs ] - [ form-start-tag ] - [ compile-children ] - [ form-end-tag ] - } cleave + [ compile-form-attrs ] + [ hidden-fields ] + [ compile-children>string ] tri + [ + [XML
<-><->
XML] second + swap >>attrs + write-xml + ] [code] ] compile-with-scope ; : button-tag-markup ( -- xml ) diff --git a/basis/furnace/utilities/utilities.factor b/basis/furnace/utilities/utilities.factor index 4a9f71e8a9..716e708303 100755 --- a/basis/furnace/utilities/utilities.factor +++ b/basis/furnace/utilities/utilities.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: namespaces make assocs sequences kernel classes splitting 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 ; IN: furnace.utilities diff --git a/basis/html/components/components.factor b/basis/html/components/components.factor index 82bb75015e..2b18e28351 100644 --- a/basis/html/components/components.factor +++ b/basis/html/components/components.factor @@ -11,7 +11,7 @@ IN: html.components GENERIC: render* ( value name renderer -- xml ) -: render ( name renderer -- ) +: render>xml ( name renderer -- xml ) prepare-value [ dup validation-error? @@ -20,7 +20,10 @@ GENERIC: render* ( value name renderer -- xml ) if ] 2dip render* - swap 2array write-xml ; + swap 2array ; + +: render ( name renderer -- ) + render>xml write-xml ; SINGLETON: label diff --git a/basis/html/elements/authors.txt b/extra/html/elements/authors.txt similarity index 100% rename from basis/html/elements/authors.txt rename to extra/html/elements/authors.txt diff --git a/basis/html/elements/elements-docs.factor b/extra/html/elements/elements-docs.factor similarity index 100% rename from basis/html/elements/elements-docs.factor rename to extra/html/elements/elements-docs.factor diff --git a/basis/html/elements/elements-tests.factor b/extra/html/elements/elements-tests.factor similarity index 100% rename from basis/html/elements/elements-tests.factor rename to extra/html/elements/elements-tests.factor diff --git a/basis/html/elements/elements.factor b/extra/html/elements/elements.factor similarity index 100% rename from basis/html/elements/elements.factor rename to extra/html/elements/elements.factor diff --git a/basis/html/elements/summary.txt b/extra/html/elements/summary.txt similarity index 100% rename from basis/html/elements/summary.txt rename to extra/html/elements/summary.txt diff --git a/basis/html/elements/tags.txt b/extra/html/elements/tags.txt similarity index 100% rename from basis/html/elements/tags.txt rename to extra/html/elements/tags.txt