diff --git a/basis/help/html/html-tests.factor b/basis/help/html/html-tests.factor
index 475b2114b3..61414cdfa2 100644
--- a/basis/help/html/html-tests.factor
+++ b/basis/help/html/html-tests.factor
@@ -1,5 +1,4 @@
IN: help.html.tests
-USING: html.streams classes.predicate help.topics help.markup
-io.streams.string accessors prettyprint kernel tools.test ;
+USING: help.html tools.test help.topics kernel ;
-[ ] [ [ [ \ predicate-instance? def>> . ] with-html-writer ] with-string-writer drop ] unit-test
+[ ] [ "xml" >link help>html drop ] unit-test
diff --git a/basis/help/html/html.factor b/basis/help/html/html.factor
index 820261dd32..26fc4e2637 100644
--- a/basis/help/html/html.factor
+++ b/basis/help/html/html.factor
@@ -1,11 +1,11 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 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 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 html.elements html ;
+sorting debugger html xml.literals xml.writer ;
IN: help.html
: escape-char ( ch -- )
@@ -51,17 +51,21 @@ M: f topic>filename* drop \ f topic>filename* ;
] "" make
] [ 2drop f ] if ;
-M: topic browser-link-href topic>filename ;
+M: topic url-of topic>filename ;
-: help-stylesheet ( -- )
- "resource:basis/help/html/stylesheet.css" ascii file-contents write ;
+: help-stylesheet ( -- string )
+ "resource:basis/help/html/stylesheet.css" ascii file-contents
+ [XML XML] ;
-: help>html ( topic -- )
- dup topic>filename utf8 [
- dup article-title
- [ ]
- [ [ help ] with-html-writer ] simple-page
- ] with-file-writer ;
+: help>html ( topic -- xml )
+ [ article-title ]
+ [ drop help-stylesheet ]
+ [ [ help ] with-html-writer ]
+ tri simple-page ;
+
+: generate-help-file ( topic -- )
+ dup .
+ dup topic>filename utf8 [ help>html write-xml ] with-file-writer ;
: all-vocabs-really ( -- seq )
#! Hack.
@@ -87,7 +91,7 @@ M: topic browser-link-href topic>filename ;
all-vocabs-really [ dup vocab-name ] { } map>assoc "vocabs.idx" serialize-index ;
: generate-help-files ( -- )
- all-topics [ '[ _ help>html ] try ] each ;
+ all-topics [ '[ _ generate-help-file ] try ] each ;
: generate-help ( -- )
"docs" temp-file
diff --git a/basis/html/components/components-docs.factor b/basis/html/components/components-docs.factor
index 39c17a4708..ce4bddde6a 100644
--- a/basis/html/components/components-docs.factor
+++ b/basis/html/components/components-docs.factor
@@ -1,4 +1,4 @@
-! Copyright (C) 2008 Your name.
+! Copyright (C) 2008 Slava Pestov
! See http://factorcode.org/license.txt for BSD license.
USING: help.markup help.syntax io.streams.string kernel strings
urls lcs inspector present io ;
@@ -100,6 +100,6 @@ $nl
{ $subsection farkup }
"Creating custom components:"
{ $subsection render* }
-"Custom components can emit HTML using the " { $vocab-link "html.elements" } " vocabulary." ;
+"Custom components can emit HTML using the " { $vocab-link "xml.literals" } " vocabulary." ;
ABOUT: "html.components"
diff --git a/basis/html/components/components-tests.factor b/basis/html/components/components-tests.factor
index 09bb5860ad..410c3ce223 100644
--- a/basis/html/components/components-tests.factor
+++ b/basis/html/components/components-tests.factor
@@ -1,7 +1,8 @@
IN: html.components.tests
USING: tools.test kernel io.streams.string
io.streams.null accessors inspector html.streams
-html.elements html.components html.forms namespaces ;
+html.components html.forms namespaces
+xml.writer ;
[ ] [ begin-form ] unit-test
@@ -31,6 +32,11 @@ TUPLE: color red green blue ;
] with-string-writer
] unit-test
+[ "\" name=\"red\" type=\"hidden\"/>" ] [
+ [
+ "red" hidden render
+ ] with-string-writer
+] unit-test
[ "\" name=\"red\" type=\"hidden\"/>" ] [
[
"red" hidden render
@@ -163,9 +169,7 @@ M: link-test link-href drop "http://www.apple.com/foo&bar" ;
[ t ] [
[ "object" inspector render ] with-string-writer
- USING: splitting sequences ;
- "\"" split "'" join ! replace " with ' for now
- [ "object" value [ describe ] with-html-writer ] with-string-writer
+ "object" value [ describe ] with-html-writer xml>string
=
] unit-test
@@ -185,3 +189,9 @@ M: link-test link-href drop "http://www.apple.com/foo&bar" ;
}
}
] [ values ] unit-test
+
+[ ] [ "error" "blah" "error" set-value ] unit-test
+
+[ ] [
+ "error" hidden render
+] unit-test
diff --git a/basis/html/components/components.factor b/basis/html/components/components.factor
index be197d10e6..f811343df2 100644
--- a/basis/html/components/components.factor
+++ b/basis/html/components/components.factor
@@ -15,19 +15,12 @@ GENERIC: render* ( value name renderer -- xml )
prepare-value
[
dup validation-error?
- [ [ message>> ] [ value>> ] bi ]
+ [ [ message>> render-error ] [ value>> ] bi ]
[ f swap ]
if
] 2dip
- render* write-xml
- [ render-error ] when* ;
-
- name=<-> type=<->/> XML] ;
-
-PRIVATE>
+ render*
+ swap 2array write-xml ;
SINGLETON: label
@@ -37,7 +30,7 @@ M: label render*
SINGLETON: hidden
M: hidden render*
- drop "hidden" render-input ;
+ drop [XML name=<-> type="hidden"/> XML] ;
: render-field ( value name size type -- xml )
[XML name=<-> size=<-> type=<->/> XML] ;
@@ -163,9 +156,7 @@ M: farkup render*
SINGLETON: inspector
M: inspector render*
- 2drop [
- [ describe ] with-html-writer
- ] with-string-writer ;
+ 2drop [ describe ] with-html-writer ;
! Diff component
SINGLETON: comparison
diff --git a/basis/html/elements/elements-docs.factor b/basis/html/elements/elements-docs.factor
index 05b202e08e..7f60eca93f 100644
--- a/basis/html/elements/elements-docs.factor
+++ b/basis/html/elements/elements-docs.factor
@@ -20,10 +20,6 @@ $nl
$nl
"Writing unescaped HTML to " { $vocab-link "html.streams" } ":"
{ $subsection write-html }
-{ $subsection print-html }
-"Writing some common HTML patterns:"
-{ $subsection xhtml-preamble }
-{ $subsection simple-page }
-{ $subsection render-error } ;
+{ $subsection print-html } ;
ABOUT: "html.elements"
diff --git a/basis/html/elements/elements.factor b/basis/html/elements/elements.factor
index b0e46984d7..e23d929d6d 100644
--- a/basis/html/elements/elements.factor
+++ b/basis/html/elements/elements.factor
@@ -6,6 +6,14 @@ xml.data xml.literals urls math math.parser combinators
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" ;
diff --git a/basis/html/html.factor b/basis/html/html.factor
index 5469941972..5e86add10e 100644
--- a/basis/html/html.factor
+++ b/basis/html/html.factor
@@ -1,23 +1,10 @@
-! Copyright (C) 2004, 2009 Chris Double, Daniel Ehrenberg.
+! Copyright (C) 2004, 2009 Chris Double, Daniel Ehrenberg,
+! Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: io kernel xml.data xml.writer io.streams.string
-xml.literals io.styles ;
+USING: kernel xml.data xml.writer xml.literals urls.encoding ;
IN: html
-SYMBOL: html
-
-: write-html ( str -- )
- H{ { html t } } format ;
-
-: print-html ( str -- )
- write-html "\n" write-html ;
-
-: xhtml-preamble ( -- )
- "" write-html
- "" write-html ;
-
-: simple-page ( title head-quot body-quot -- )
- [ with-string-writer ] bi@
+: simple-page ( title head body -- xml )
@@ -28,7 +15,10 @@ SYMBOL: html
<->