]> gitweb.factorcode.org Git - factor.git/commitdiff
Getting rid of html.elements from most vocabs
authorDaniel Ehrenberg <littledan@Macintosh-103.local>
Thu, 5 Feb 2009 20:34:55 +0000 (14:34 -0600)
committerDaniel Ehrenberg <littledan@Macintosh-103.local>
Thu, 5 Feb 2009 20:34:55 +0000 (14:34 -0600)
basis/furnace/chloe-tags/chloe-tags.factor
basis/furnace/furnace-tests.factor
basis/furnace/sessions/sessions.factor
basis/furnace/utilities/utilities.factor
basis/html/templates/chloe/chloe-docs.factor
basis/html/templates/chloe/chloe-tests.factor
basis/html/templates/chloe/chloe.factor
basis/html/templates/chloe/compiler/compiler.factor
basis/html/templates/templates.factor
extra/webapps/user-admin/user-admin.factor

index dd24d8dcde6a4a8481962f466d0739e25a28319a..be24eb5224137f808f39bad5ba00d2473191d968 100644 (file)
@@ -66,16 +66,26 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
     tri
     [ =href a> ] [code] ;
 
-: a-end-tag ( tag -- )
-    drop [ </a> ] [code] ;
+: process-attrs ( assoc -- newassoc )
+    [ "@" ?head [ value present ] when ] assoc-map ;
+
+: non-chloe-attrs ( tag -- )
+    attrs>> non-chloe-attrs-only [ process-attrs ] [code-with] ;
+
+: a-attrs ( tag -- )
+    [ non-chloe-attrs ]
+    [ compile-link-attrs ]
+    [ compile-a-url ] tri
+    [ swap "href" swap set-at ] [code] ;
 
 CHLOE: a
-    [
-        [ a-start-tag ] [ compile-children ] [ a-end-tag ] tri
-    ] compile-with-scope ;
+    [ a-attrs ]
+    [ compile-children>string ] bi
+    [ <unescaped> [XML <a><-></a> XML] swap >>attrs ]
+    [xml-code] ;
 
 CHLOE: base
-    compile-a-url [ <base =href base/> ] [code] ;
+    compile-a-url [ [XML <base href=<->/> XML] ] [xml-code] ;
 
 : compile-hidden-form-fields ( for -- )
     '[
@@ -121,13 +131,13 @@ CHLOE: form
         <t:form class="inline" xmlns:t="http://factorcode.org/chloe/1.0">
             <div style="display: inline;"><button type="submit"></button></div>
         </t:form>
-    XML> ;
+    XML> body>> clone ;
 
 : add-tag-attrs ( attrs tag -- )
     attrs>> swap update ;
 
 CHLOE: button
-    button-tag-markup body>>
+    button-tag-markup
     {
         [ [ attrs>> chloe-attrs-only ] dip add-tag-attrs ]
         [ [ attrs>> non-chloe-attrs-only ] dip "button" deep-tag-named add-tag-attrs ]
index f6e543499768997bb5624d3988f741456d0d5875..f01260c68b02ee5f515670a098be20b02bcee671 100644 (file)
@@ -30,7 +30,7 @@ M: base-path-check-responder call-responder*
     "a/b/c" split-path main-responder get call-responder body>>
 ] unit-test
 
-[ "<input type='hidden' name='foo' value='&amp;&amp;&amp;'/>" ]
+[ "<input type=\"hidden\" value=\"&amp;&amp;&amp;\" name=\"foo\"/>" ]
 [ [ "&&&" "foo" hidden-form-field ] with-string-writer ]
 unit-test
 
index 8b7e1ab83f1789550b0d129a4245921dfe622a59..52e705c153b7a17d140b9cdb1d8f8dbadf5aece7 100644 (file)
@@ -5,7 +5,7 @@ strings random accessors quotations hashtables sequences
 continuations fry calendar combinators combinators.short-circuit
 destructors alarms io.sockets db db.tuples db.types
 http http.server http.server.dispatchers http.server.filters
-html.elements furnace.cache furnace.scopes furnace.utilities ;
+furnace.cache furnace.scopes furnace.utilities ;
 IN: furnace.sessions
 
 TUPLE: session < scope user-agent client ;
index e09047b74a769edf8d0907f1c747508db5182c3b..4a9f71e8a9b3246563a0cbec8bd6eea31fa7d4c3 100755 (executable)
@@ -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 html.elements http http.server
+continuations present fry urls http http.server xml.literals xml.writer
 http.server.redirection http.server.remapping ;
 IN: furnace.utilities
 
@@ -83,11 +83,8 @@ M: object modify-form drop ;
 
 : hidden-form-field ( value name -- )
     over [
-        <input
-            "hidden" =type
-            =name
-            present =value
-        input/>
+        [XML <input type="hidden" value=<-> name=<->/> XML]
+        write-xml
     ] [ 2drop ] if ;
 
 : nested-forms-key "__n" ;
index f6408d3b5917e82ac2f9da0a9daeae9b3b0316f2..b2259e629e0db4ad2969b0cb98dd082d2ec4b0b4 100644 (file)
@@ -128,7 +128,7 @@ ARTICLE: "html.templates.chloe.tags.form" "Chloe link and form tags"
             "<a href=\"http://mysite.org/wiki/view/Factor\""
             "   class=\"small-link\">"
             "    View"
-            "s</a>"
+            "</a>"
         }
     } }
     { { $snippet "t:base" } { "Outputs an HTML " { $snippet "<base>" } " tag. The attributes are interpreted in the same manner as the attributes of " { $snippet "t:a" } "." } }
@@ -261,8 +261,8 @@ $nl
 ARTICLE: "html.templates.chloe.extend.components.example" "An example of a custom Chloe component"
 "As an example, let's develop a custom Chloe component which renders an image stored in a form value. Since the component does not require any configuration, we can define a singleton class:"
 { $code "SINGLETON: image" }
-"Now we define a method on the " { $link render* } " generic word which renders the image using " { $vocab-link "html.elements" } ":"
-{ $code "M: image render* 2drop <img =src img/> ;" }
+"Now we define a method on the " { $link render* } " generic word which renders the image using " { $vocab-link "xml.literals" } ":"
+{ $code "M: image render* 2drop [XML <img src=<-> /> XML] ;" }
 "Finally, we can define a Chloe component:"
 { $code "COMPONENT: image" }
 "We can use it as follows, assuming the current form has a value named " { $snippet "image" } ":"
index 19b67f70188edff234d7bd7af4bbd085e0c0ce86..184f57051a962aa57d684eb6f79ccfd2b9ad0dab 100644 (file)
@@ -135,7 +135,7 @@ TUPLE: person first-name last-name ;
 
 [ ] [ H{ { "a" H{ { "b" "c" } } } } values set ] unit-test
 
-[ "<form method='post' action='foo'><div style='display: none;'><input type='hidden' name='__n' value='a'/></div></form>" ] [
+[ "<form method='post' action='foo'><div style='display: none;'><input type=\"hidden\" value=\"a\" name=\"__n\"/></div></form>" ] [
     [
         "test10" test-template call-template
     ] run-template
index e5b40fcfaadc2a1316841a644b62b98fd19927be..99afbc31bda34406aff8a313320e5c70087cb380 100644 (file)
@@ -8,7 +8,6 @@ logging continuations
 xml.data xml.writer xml.literals strings
 html.forms
 html
-html.elements
 html.components
 html.templates
 html.templates.chloe.compiler
@@ -28,7 +27,9 @@ CHLOE: write-title
     drop
     "head" tag-stack get member?
     "title" tag-stack get member? not and
-    [ <title> write-title </title> ] [ write-title ] ? [code] ;
+    [ get-title [XML <title><-></title> XML] ]
+    [ get-title ] ?
+    [xml-code] ;
 
 CHLOE: style
     dup "include" optional-attr [
@@ -39,10 +40,9 @@ CHLOE: style
 
 CHLOE: write-style
     drop [
-        <style "text/css" =type style>
-            write-style
-        </style>
-    ] [code] ;
+        get-style
+        [XML <style type="text/css"> <-> </style> XML]
+    ] [xml-code] ;
 
 CHLOE: even
     [ "index" value even? swap when ] process-children ;
index 7180e8cdbcb76fc2f464d4e5e6b2713d31c00229..394b5ef3594d13443cf53a3e6a0f00fd0764eadd 100644 (file)
@@ -42,6 +42,9 @@ DEFER: compile-element
 : [code-with] ( obj quot -- )
     reset-buffer [ , ] [ % ] bi* ;
 
+: [xml-code] ( quot -- )
+    [ write-xml ] compose [code] ;
+
 : expand-attr ( value -- )
     [ value present write ] [code-with] ;
 
index efaf8d6a62ad940f4d486eaeb3fb590f1a4f0f1a..c0fec8d1b634c9495dd282e31da34111b5f099f4 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors kernel fry io io.encodings.utf8 io.files
 debugger prettyprint continuations namespaces boxes sequences
-arrays strings html io.streams.string
+arrays strings html io.streams.string assocs
 quotations xml.data xml.writer xml.literals ;
 IN: html.templates
 
@@ -34,8 +34,11 @@ SYMBOL: title
 : set-title ( string -- )
     title get >box ;
 
+: get-title ( -- string )
+    title get value>> ;
+
 : write-title ( -- )
-    title get value>> write ;
+    get-title write ;
 
 SYMBOL: style
 
@@ -43,24 +46,30 @@ SYMBOL: style
     "\n" style get push-all
          style get push-all ;
 
+: get-style ( -- string )
+    style get >string ;
+
 : write-style ( -- )
-    style get >string write ;
+    get-style write ;
 
 SYMBOL: atom-feeds
 
 : add-atom-feed ( title url -- )
     2array atom-feeds get push ;
 
-: write-atom-feeds ( -- )
+: get-atom-feeds ( -- xml )
     atom-feeds get [
-        first2 [XML
+        [XML
             <link
                 rel="alternate"
                 type="application/atom+xml"
                 title=<->
                 href=<->/>
-        XML] write-xml
-    ] each ;
+        XML]
+    ] { } assoc>map ;
+
+: write-atom-feeds ( -- )
+    get-atom-feeds write-xml ;
 
 SYMBOL: nested-template?
 
index 9d4e348596d14e9a0a7c26308b699786d45758d7..c0cd601af5ec9306b9663df65412b6c9e1b553dd 100644 (file)
@@ -3,7 +3,6 @@
 USING: kernel sequences accessors namespaces combinators words
 assocs db.tuples arrays splitting strings validators urls
 html.forms
-html.elements
 html.components
 furnace
 furnace.boilerplate