! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: classes help.markup help.syntax io.streams.string kernel
-quotations sequences strings multiline math db.types db ;
+quotations sequences strings multiline math db.types
+db.tuples.private db ;
IN: db.tuples
+HELP: random-id-generator
+{ $description "Used to tell " { $link eval-generator } " to generate a random number for use as a key." } ;
+
HELP: create-sql-statement
{ $values
{ "class" class }
! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: classes hashtables help.markup help.syntax io.streams.string
-kernel sequences strings math db.tuples db.tuples.private ;
+kernel sequences strings math ;
IN: db.types
HELP: +db-assigned-id+
HELP: user-assigned-id-spec?
{ $values
- { "specs" "a sequence of sql specs" }
+ { "specs" "a sequence of SQL specs" }
{ "?" "a boolean" } }
-{ $description "Tests if any of the sql specs has the type " { $link +user-assigned-id+ } "." } ;
+{ $description "Tests if any of the SQL specs has the type " { $link +user-assigned-id+ } "." } ;
HELP: bind#
{ $values
- { "spec" "a sql spec" } { "obj" object } }
+ { "spec" "a SQL spec" } { "obj" object } }
{ $description "A generic word that lets a database construct a literal binding." } ;
HELP: bind%
{ $values
- { "spec" "a sql spec" } }
+ { "spec" "a SQL spec" } }
{ $description "A generic word that lets a database output a binding." } ;
HELP: db-assigned-id-spec?
{ $values
- { "specs" "a sequence of sql specs" }
+ { "specs" "a sequence of SQL specs" }
{ "?" "a boolean" } }
-{ $description "Tests if any of the sql specs has the type " { $link +db-assigned-id+ } "." } ;
+{ $description "Tests if any of the SQL specs has the type " { $link +db-assigned-id+ } "." } ;
HELP: find-primary-key
{ $values
- { "specs" "a sequence of sql-specs" }
- { "seq" "a sequence of sql-specs" } }
-{ $description "Returns the rows from the sql-specs array that are part of the primary key. Composite primary keys are supported, so this word must return a sequence." }
+ { "specs" "a sequence of SQL specs" }
+ { "seq" "a sequence of SQL specs" } }
+{ $description "Returns the rows from the SQL specs array that are part of the primary key. Composite primary keys are supported, so this word must return a sequence." }
{ $notes "This is a low-level word." } ;
HELP: get-slot-named
HELP: no-sql-type
{ $values
- { "type" "a sql type" } }
-{ $description "Throws an error containing a sql type that is unsupported or the result of a typo." } ;
+ { "type" "a SQL type" } }
+{ $description "Throws an error containing a SQL type that is unsupported or the result of a typo." } ;
HELP: normalize-spec
{ $values
- { "spec" "a sql spec" } }
-{ $description "Normalizes a sql spec." } ;
+ { "spec" "a SQL spec" } }
+{ $description "Normalizes a SQL spec." } ;
HELP: offset-of-slot
{ $values
HELP: primary-key?
{ $values
- { "spec" "a sql spec" }
+ { "spec" "a SQL spec" }
{ "?" "a boolean" } }
-{ $description "Returns true if a sql spec is a primary key." } ;
-
-HELP: random-id-generator
-{ $description "Used to tell " { $link eval-generator } " to generate a random number for use as a key." } ;
+{ $description "Returns true if a SQL spec is a primary key." } ;
HELP: relation?
{ $values
- { "spec" "a sql spec" }
+ { "spec" "a SQL spec" }
{ "?" "a boolean" } }
-{ $description "Returns true if a sql spec is a relation." } ;
+{ $description "Returns true if a SQL spec is a relation." } ;
HELP: unknown-modifier
{ $values { "modifier" string } }
-{ $description "Throws an error containing an unknown sql modifier." } ;
+{ $description "Throws an error containing an unknown SQL modifier." } ;
ARTICLE: "db.types" "Database types"
"The " { $vocab-link "db.types" } " vocabulary maps Factor types to database types." $nl
! 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
furnace.redirection\r
furnace.conversations\r
html.forms\r
-html.elements\r
html.components\r
html.components\r
html.templates.chloe\r
"Instances of subclasses of " { $link realm } " have the following slots which may be set:"
{ $table
{ { $slot "name" } "A string identifying the realm for user interface purposes" }
- { { $slot "users" } { "An authentication provider (see " { $link "furnace.auth.providers" } ". By default, the " { $link users-in-db } " provider is used." } }
+ { { $slot "users" } { "An authentication provider (see " { $link "furnace.auth.providers" } "). By default, the " { $link users-in-db } " provider is used." } }
{ { $slot "checksum" } { "An implementation of the checksum protocol used for verifying passwords (see " { $link "checksums" } "). The " { $link sha-256 } " checksum is used by default." } }
- { { $slot "users" } { "An authentication provider (see " { $link "furnace.auth.providers" } } }
{ { $slot "secure" } { "A boolean, that when set to a true value, forces the client to access the authentication realm via HTTPS. An attempt to access the realm via HTTP results in a redirect to the corresponding HTTPS URL. On by default." } }
} ;
xml.entities
xml.writer
xml.utilities
+xml.literals
html.components
html.elements
html.forms
http.server.redirection
http.server.responses
furnace.utilities ;
-QUALIFIED-WITH: assocs a
IN: furnace.chloe-tags
! Chloe tags
: 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
} 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 ]
! 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 -- )
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 )
+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."
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" ;
] [ 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 ;
! 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 ;
: 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 ;
--- /dev/null
+! 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 ;
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 )
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
html.templates.chloe.syntax ;
IN: html.templates.chloe
-! Chloe is Ed's favorite web designer
TUPLE: chloe path ;
C: <chloe> chloe
[ compile-start-tag ]
[ compile-children ]
[ compile-end-tag ]
- [ drop tag-stack get pop* ]
- } cleave ;
+ } cleave
+ tag-stack get pop* ;
ERROR: unknown-chloe-tag tag ;
[ [ compile-children ] compile-quot ] [ % ] bi* ; inline
: compile-children>string ( tag -- )
- [ with-string-writer ] process-children ;
+ [ with-string-writer ] process-children ;
: compile-with-scope ( quot -- )
compile-quot [ with-scope ] [code] ; inline
bi ;
M: tuple-class component-tag ( tag class -- )
- [ drop "name" required-attr compile-attr ] [ compile-component-attrs ] 2bi
+ [ drop "name" required-attr compile-attr ]
+ [ compile-component-attrs ] 2bi
[ render ] [code] ;
: COMPONENT:
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 ;
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
! 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
: 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?
! 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
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
http.server.responses
http.server.remapping
html.templates
-html.elements
+html
html.streams ;
IN: http.server
[ 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 )
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
\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
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
tokenize-line htmlize-tokens ;
: htmlize-lines ( lines mode -- xml )
- [ f ] 2dip load-mode [ htmlize-line "\n" suffix ] curry map nip ;
+ [ f ] 2dip load-mode [ htmlize-line ] curry map nip
+ { "\n" } join ;
: default-stylesheet ( -- xml )
"resource:basis/xmode/code2html/stylesheet.css"
! Copyright (C) 2007, 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.accessors arrays assocs
-combinators.short-circuit fry hashtables html.elements io
+combinators.short-circuit fry hashtables html io
kernel math namespaces prettyprint quotations sequences
sequences.deep sets slots.private vectors vocabs words
kernel.private ;
: <factor-website> ( -- responder )
factor-website new-dispatcher
- <wiki> "wiki" add-responder
- <user-admin> "user-admin" add-responder
URL" /wiki/view/Front Page" <redirect-responder> "" add-responder ;
SYMBOL: key-password
"password" key-password set-global
common-configuration
<factor-website>
- <pastebin> <factor-boilerplate> <login-config> "pastebin" add-responder
- <planet> <factor-boilerplate> <login-config> "planet" add-responder
+ <wiki> <login-config> <factor-boilerplate> "wiki" add-responder
+ <user-admin> <login-config> <factor-boilerplate> "user-admin" add-responder
+ <pastebin> <login-config> <factor-boilerplate> "pastebin" add-responder
+ <planet> <login-config> <factor-boilerplate> "planet" add-responder
"/tmp/docs/" <help-webapp> "docs" add-responder
test-db <alloy>
main-responder set-global ;
: init-production ( -- )
common-configuration
<vhost-dispatcher>
- <factor-website> <login-config> <factor-boilerplate> test-db <alloy> "concatenative.org" add-responder
+ <factor-website> <wiki> <login-config> <factor-boilerplate> "wiki" add-responder test-db <alloy> "concatenative.org" add-responder
<pastebin> <login-config> <factor-boilerplate> test-db <alloy> "paste.factorcode.org" add-responder
<planet> <login-config> <factor-boilerplate> test-db <alloy> "planet.factorcode.org" add-responder
home "docs" append-path <help-webapp> test-db <alloy> "docs.factorcode.org" add-responder