]> gitweb.factorcode.org Git - factor.git/commitdiff
Fixing some things I broke
authorDaniel Ehrenberg <littledan@Macintosh-103.local>
Sat, 31 Jan 2009 01:28:16 +0000 (19:28 -0600)
committerDaniel Ehrenberg <littledan@Macintosh-103.local>
Sat, 31 Jan 2009 01:28:16 +0000 (19:28 -0600)
18 files changed:
basis/farkup/farkup.factor
basis/furnace/actions/actions.factor
basis/furnace/chloe-tags/chloe-tags.factor
basis/help/html/html.factor
basis/html/components/components.factor
basis/html/elements/elements-docs.factor
basis/html/elements/elements.factor
basis/html/forms/forms.factor
basis/html/html.factor [new file with mode: 0644]
basis/html/streams/streams.factor
basis/html/templates/chloe/chloe.factor
basis/html/templates/chloe/syntax/syntax.factor
basis/html/templates/fhtml/fhtml.factor
basis/html/templates/templates.factor
basis/http/server/responses/responses.factor
basis/http/server/server.factor
basis/http/server/static/static.factor
basis/xmode/code2html/code2html.factor

index a752694764573c219a8afcc7bcf80a83c8ab2ffb..bad41296ee882dc36d6249a85331627e69c23130 100755 (executable)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays combinators html.elements io
+USING: accessors arrays combinators io
 io.streams.string kernel math namespaces peg peg.ebnf
 sequences sequences.deep strings xml.entities xml.literals
 vectors splitting xmode.code2html urls.encoding xml.data
index 72a7b76d23b086188e99d14fcd09cc3892dee05e..97cb73c9cb694086b1f7dc8c38d0ddc7f935af39 100644 (file)
@@ -10,7 +10,6 @@ furnace.utilities
 furnace.redirection\r
 furnace.conversations\r
 html.forms\r
-html.elements\r
 html.components\r
 html.components\r
 html.templates.chloe\r
index 1c320182bf39c30b2fe6ac2f4dafa3e88b87fdb3..dd24d8dcde6a4a8481962f466d0739e25a28319a 100644 (file)
@@ -8,6 +8,7 @@ xml.data
 xml.entities
 xml.writer
 xml.utilities
+xml.literals
 html.components
 html.elements
 html.forms
@@ -20,7 +21,6 @@ http.server
 http.server.redirection
 http.server.responses
 furnace.utilities ;
-QUALIFIED-WITH: assocs a
 IN: furnace.chloe-tags
 
 ! Chloe tags
@@ -56,11 +56,11 @@ CHLOE: write-atom drop [ write-atom-feeds ] [code] ;
 
 : compile-link-attrs ( tag -- )
     #! Side-effects current namespace.
-    attrs>> '[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
+    '[ [ [ _ ] dip link-attr ] each-responder ] [code] ;
 
 : a-start-tag ( tag -- )
     [ <a ] [code]
-    [ non-chloe-attrs-only compile-attrs ]
+    [ attrs>> non-chloe-attrs-only compile-attrs ]
     [ compile-link-attrs ]
     [ compile-a-url ]
     tri
@@ -116,17 +116,18 @@ CHLOE: form
         } cleave
     ] compile-with-scope ;
 
-STRING: button-tag-markup
-<t:form class="inline" xmlns:t="http://factorcode.org/chloe/1.0">
-    <div style="display: inline;"><button type="submit"></button></div>
-</t:form>
-;
+: button-tag-markup ( -- xml )
+    <XML
+        <t:form class="inline" xmlns:t="http://factorcode.org/chloe/1.0">
+            <div style="display: inline;"><button type="submit"></button></div>
+        </t:form>
+    XML> ;
 
 : add-tag-attrs ( attrs tag -- )
     attrs>> swap update ;
 
 CHLOE: button
-    button-tag-markup string>xml body>>
+    button-tag-markup body>>
     {
         [ [ attrs>> chloe-attrs-only ] dip add-tag-attrs ]
         [ [ attrs>> non-chloe-attrs-only ] dip "button" deep-tag-named add-tag-attrs ]
index ec52264643e52a76a73812ef55cb1cf76f5c1955..820261dd32ad2c67016ef37235370dc1a2233101 100644 (file)
@@ -1,11 +1,11 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: io.encodings.utf8 io.encodings.ascii io.encodings.binary
-io.files io.files.temp io.directories html.streams html.elements help kernel
+io.files io.files.temp io.directories html.streams help kernel
 assocs sequences make words accessors arrays help.topics vocabs
 tools.vocabs tools.vocabs.browser namespaces prettyprint io
 vocabs.loader serialize fry memoize unicode.case math.order
-sorting debugger ;
+sorting debugger html.elements html ;
 IN: help.html
 
 : escape-char ( ch -- )
index eec7508c5ebc832a264894dbca692f32f53c38d6..be197d10e6eb900654eadc41f41d203ee064e1eb 100644 (file)
@@ -6,7 +6,7 @@ hashtables combinators continuations math strings inspector
 fry locals calendar calendar.format xml.entities xml.data
 validators urls present xml.writer xml.literals xml
 xmode.code2html lcs.diff2html farkup io.streams.string
-html.elements html.streams html.forms ;
+html html.streams html.forms ;
 IN: html.components
 
 GENERIC: render* ( value name renderer -- xml )
index dab937641363ae207e52a9debcf7080c9a604c76..05b202e08e5cf3f8126e746f12e531ba0e706b14 100644 (file)
@@ -1,5 +1,5 @@
+USING: help.markup help.syntax io present html ;
 IN: html.elements
-USING: help.markup help.syntax io present ;
 
 ARTICLE: "html.elements" "HTML elements"
 "The " { $vocab-link "html.elements" } " vocabulary provides words for writing HTML tags to the " { $link output-stream } " with a familiar look and feel in the code."
index 005d67f22120f65f1e25681371f6691fd1f6505d..b0e46984d79f8424e8795864930b7aa0e385b68c 100644 (file)
@@ -3,18 +3,9 @@
 USING: io io.styles kernel namespaces prettyprint quotations
 sequences strings words xml.entities compiler.units effects
 xml.data xml.literals urls math math.parser combinators
-present fry io.streams.string xml.writer ;
-
+present fry io.streams.string xml.writer html ;
 IN: html.elements
 
-SYMBOL: html
-
-: write-html ( str -- )
-    H{ { html t } } format ;
-
-: print-html ( str -- )
-    write-html "\n" write-html ;
-
 <<
 
 : elements-vocab ( -- vocab-name ) "html.elements" ;
@@ -127,24 +118,3 @@ SYMBOL: html
 ] [ define-attribute-word ] each
 
 >>
-
-: xhtml-preamble ( -- )
-    "<?xml version=\"1.0\"?>" write-html
-    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" write-html ;
-
-: simple-page ( title head-quot body-quot -- )
-    [ with-string-writer <unescaped> ] bi@
-    <XML
-        <?xml version="1.0"?>
-        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-            <head>
-                <title><-></title>
-                <->
-            </head>
-            <body><-></body>
-        </html>
-    XML> write-xml ; inline
-
-: render-error ( message -- )
-    [XML <span class="error"><-></span> XML] write-xml ;
index f92f8d0764036ea58777f3bbdc6ce59376450569..0a69e2ed70320238f1018273eab9ffe284f0c86e 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2008 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel accessors strings namespaces assocs hashtables io
-mirrors math fry sequences words continuations html.elements
-xml.entities ;
+mirrors math fry sequences words continuations
+xml.entities xml.writer xml.literals ;
 IN: html.forms
 
 TUPLE: form errors values validation-failed ;
@@ -109,7 +109,6 @@ C: <validation-error> validation-error
 : render-validation-errors ( -- )
     form get errors>>
     [
-        <ul "errors" =class ul>
-            [ <li> escape-string write </li> ] each
-        </ul>
+        [ [XML <li><-></li> XML] ] map
+        [XML <ul class="errors"><-></ul> XML] write-xml
     ] unless-empty ;
diff --git a/basis/html/html.factor b/basis/html/html.factor
new file mode 100644 (file)
index 0000000..5469941
--- /dev/null
@@ -0,0 +1,34 @@
+! Copyright (C) 2004, 2009 Chris Double, Daniel Ehrenberg.
+! See http://factorcode.org/license.txt for BSD license.
+USING: io kernel xml.data xml.writer io.streams.string
+xml.literals io.styles ;
+IN: html
+
+SYMBOL: html
+
+: write-html ( str -- )
+    H{ { html t } } format ;
+
+: print-html ( str -- )
+    write-html "\n" write-html ;
+
+: xhtml-preamble ( -- )
+    "<?xml version=\"1.0\"?>" write-html
+    "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">" write-html ;
+
+: simple-page ( title head-quot body-quot -- )
+    [ with-string-writer <unescaped> ] bi@
+    <XML
+        <?xml version="1.0"?>
+        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+        <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+            <head>
+                <title><-></title>
+                <->
+            </head>
+            <body><-></body>
+        </html>
+    XML> write-xml ; inline
+
+: render-error ( message -- )
+    [XML <span class="error"><-></span> XML] write-xml ;
index 24d9dceb8024a6c1a9bd365e30d299d49c2af4a0..483ace064ed43c6a7ed641735c600d8777d091a4 100644 (file)
@@ -4,7 +4,7 @@ USING: combinators generic assocs help http io io.styles
 io.files continuations io.streams.string kernel math math.order
 math.parser namespaces make quotations assocs sequences strings
 words html.elements xml.entities sbufs continuations destructors
-accessors arrays urls.encoding ;
+accessors arrays urls.encoding html ;
 IN: html.streams
 
 GENERIC: browser-link-href ( presented -- href )
index c3c1ec2b9e29172f966eb9693565705f43b84be5..47c7934c835072ac1278c2312c676fcf9a2ed779 100644 (file)
@@ -5,8 +5,9 @@ namespaces make classes.tuple assocs splitting words arrays io
 io.files io.files.info io.encodings.utf8 io.streams.string
 unicode.case mirrors math urls present multiline quotations xml
 logging continuations
-xml.data
+xml.data xml.writer xml.literals strings
 html.forms
+html
 html.elements
 html.components
 html.templates
index fb457ff1df4d0b74e0ddb0b0f15dbc46f80b9a92..c2ecd4506b342a4d98f18356c47545217aac4d20 100644 (file)
@@ -6,7 +6,6 @@ classes.tuple assocs splitting words arrays memoize parser lexer
 io io.files io.encodings.utf8 io.streams.string
 unicode.case mirrors fry math urls
 multiline xml xml.data xml.writer xml.utilities
-html.elements
 html.components
 html.templates ;
 
index 992b6600704e61eeead4472f4166e255febfa98e..23bb4696271da24aadaafdf1d680108d6ac78435 100644 (file)
@@ -5,7 +5,7 @@ USING: continuations sequences kernel namespaces debugger
 combinators math quotations generic strings splitting
 accessors assocs fry vocabs.parser
 parser lexer io io.files io.streams.string io.encodings.utf8
-html.elements
+html
 html.templates ;
 IN: html.templates.fhtml
 
index 57418a3e02a0e0b6fa8aa9fb8ff6018b4ad69708..6951f09efed70772bde9f0693360ccb93a4d1331 100644 (file)
@@ -2,8 +2,8 @@
 ! 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.elements io.streams.string
-quotations xml.data xml.writer ;
+arrays strings html io.streams.string
+quotations xml.data xml.writer xml.literals ;
 IN: html.templates
 
 MIXIN: template
@@ -53,9 +53,13 @@ SYMBOL: atom-feeds
 
 : write-atom-feeds ( -- )
     atom-feeds get [
-        <link "alternate" =rel "application/atom+xml" =type
-        first2 [ =title ] [ =href ] bi*
-        link/>
+        first2 [XML
+            <link
+                rel="alternate"
+                type="application/atom+xml"
+                title=<->
+                href=<->/>
+        XML] write-xml
     ] each ;
 
 SYMBOL: nested-template?
index 4056f0c7f00d1d7494aedb0506bd7279158fb5e7..c9b4600ac8338a8e8b36afe293dda90b285d25d4 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: html.elements math.parser http accessors kernel
+USING: math.parser http accessors kernel xml.literals xml.writer
 io io.streams.string io.encodings.utf8 ;
 IN: http.server.responses
 
@@ -13,11 +13,13 @@ IN: http.server.responses
         swap >>body ;
     
 : trivial-response-body ( code message -- )
-    <html>
-        <body>
-            <h1> [ number>string write bl ] [ write ] bi* </h1>
-        </body>
-    </html> ;
+    <XML
+        <html>
+            <body>
+                <h1><-> <-></h1>
+            </body>
+        </html>
+    XML> write-xml ;
 
 : <trivial-response> ( code message -- response )
     2dup [ trivial-response-body ] with-string-writer
index a886d7bae75c9a75de36506fbc0ae6b574c7d315..90a8ddb51af0f965b79b619b9d5bfe2133eeb49e 100755 (executable)
@@ -24,7 +24,7 @@ http.parsers
 http.server.responses
 http.server.remapping
 html.templates
-html.elements
+html
 html.streams ;
 IN: http.server
 
@@ -174,8 +174,9 @@ main-responder global [ <404> <trivial-responder> or ] change-at
     [ add-responder-nesting ] [ call-responder* ] 2bi ;
 
 : http-error. ( error -- )
-    "Internal server error" [ ] [
-        [ print-error nl :c ] with-html-writer
+    ! TODO: get rid of rot
+    "Internal server error" [ ] rot '[
+        [ _ print-error nl :c ] with-html-writer
     ] simple-page ;
 
 : <500> ( error -- response )
index c910529d734a57cf00f2af3c4939cc36e45e2197..67ce0237a4d4dc5a6641721ca96a6a9af6d8bd01 100644 (file)
@@ -4,9 +4,9 @@ USING: calendar kernel math math.order math.parser namespaces
 parser sequences strings assocs hashtables debugger mime.types\r
 sorting logging calendar.format accessors splitting io io.files\r
 io.files.info io.directories io.pathnames io.encodings.binary\r
-fry xml.entities destructors urls html.elements\r
+fry xml.entities destructors urls html xml.literals\r
 html.templates.fhtml http http.server http.server.responses\r
-http.server.redirection ;\r
+http.server.redirection xml.writer ;\r
 IN: http.server.static\r
 \r
 TUPLE: file-responder root hook special allow-listings ;\r
@@ -56,18 +56,14 @@ TUPLE: file-responder root hook special allow-listings ;
 \r
 \ serve-file NOTICE add-input-logging\r
 \r
-: file. ( name -- )\r
+: file. ( name -- xml )\r
     dup link-info directory? [ "/" append ] when\r
-    dup <a =href a> escape-string write </a> ;\r
+    dup [XML <li><a href=<->><-></a></li> XML] ;\r
 \r
 : directory. ( path -- )\r
     dup file-name [ ] [\r
-        [ <h1> file-name escape-string write </h1> ]\r
-        [\r
-            <ul>\r
-                directory-files [ <li> file. </li> ] each\r
-            </ul>\r
-        ] bi\r
+        [ file-name ] [ directory-files [ file. ] map ] bi\r
+        [XML <h1><-></h1> <ul><-></ul> XML] write-xml\r
     ] simple-page ;\r
 \r
 : list-directory ( directory -- response )\r
index 665d334fd27071f2d3a95a96f1c91da4783d841e..9889a98a999f87b57e3104a30dd0041df1f38eb6 100644 (file)
@@ -1,5 +1,5 @@
 USING: xmode.tokens xmode.marker xmode.catalog kernel locals
-html.elements io io.files sequences words io.encodings.utf8
+io io.files sequences words io.encodings.utf8
 namespaces xml.entities accessors xml.literals locals xml.writer ;
 IN: xmode.code2html