2008-11-24 21:26:11 -05:00
USING: assocs help.markup help.syntax kernel
2014-11-04 01:26:22 -05:00
quotations sequences strings urls xml.data http words ;
2008-11-24 21:26:11 -05:00
IN: furnace.utilities
HELP: adjust-redirect-url
{ $values { "url" url } { "url'" url } }
{ $description "Adjusts a redirection URL by filtering the URL's query parameters through the " { $link modify-redirect-query } " generic word on every responder involved in handling the current request." } ;
HELP: adjust-url
{ $values { "url" url } { "url'" url } }
{ $description "Adjusts a link URL by filtering the URL's query parameters through the " { $link modify-query } " generic word on every responder involved in handling the current request." } ;
HELP: client-state
{ $values { "key" string } { "value/f" { $maybe string } } }
{ $description "Looks up a cookie (if the current request is a GET or HEAD request) or a POST parameter (if the current request is a POST request)." }
{ $notes "This word is used by session management, conversation scope and asides." } ;
HELP: each-responder
2014-05-18 23:09:10 -04:00
{ $values { "quot" { $quotation ( ... responder -- ... ) } } }
2008-11-24 21:26:11 -05:00
{ $description "Applies the quotation to each responder involved in processing the current request." } ;
HELP: hidden-form-field
2009-02-08 21:32:11 -05:00
{ $values { "value" string } { "name" string } { "xml" "an XML chunk" } }
{ $description "Renders an HTML hidden form field tag as XML." }
2008-11-24 21:26:11 -05:00
{ $notes "This word is used by session management, conversation scope and asides." }
{ $examples
{ $example
2009-02-09 17:46:02 -05:00
"USING: furnace.utilities io xml.writer ;"
"\"bar\" \"foo\" hidden-form-field write-xml nl"
2009-02-06 23:43:11 -05:00
"<input type=\"hidden\" value=\"bar\" name=\"foo\"/>"
2008-11-24 21:26:11 -05:00
}
} ;
HELP: link-attr
{ $values { "tag" tag } { "responder" "a responder" } }
{ $contract "Modifies an XHTML " { $snippet "a" } " tag." }
{ $notes "This word is called by " { $link "html.templates.chloe.tags.form" } "." }
{ $examples "Conversation scope adds attributes to link tags." } ;
HELP: modify-form
2009-02-08 21:32:11 -05:00
{ $values { "responder" "a responder" } { "xml/f" "an XML chunk or f" } }
2008-11-24 21:26:11 -05:00
{ $contract "Emits hidden form fields using " { $link hidden-form-field } "." }
{ $notes "This word is called by " { $link "html.templates.chloe.tags.form" } "." }
{ $examples "Session management, conversation scope and asides use hidden form fields to pass state." } ;
HELP: modify-query
{ $values { "query" assoc } { "responder" "a responder" } { "query'" assoc } }
{ $contract "Modifies the query parameters of a URL destined to be displayed as a link." }
{ $notes "This word is called by " { $link "html.templates.chloe.tags.form" } "." }
{ $examples "Asides add query parameters to URLs." } ;
HELP: modify-redirect-query
{ $values { "query" assoc } { "responder" "a responder" } { "query'" assoc } }
{ $contract "Modifies the query parameters of a URL destined to be used with a redirect." }
{ $notes "This word is called by " { $link "furnace.redirection" } "." }
{ $examples "Conversation scope and asides add query parameters to redirect URLs." } ;
HELP: nested-responders
{ $values { "seq" "a sequence of responders" } }
2009-01-30 17:52:03 -05:00
{ $description "Outputs a sequence of responders which participated in the processing of the current request, with the main responder first and the innermost responder last." } ;
2008-11-24 21:26:11 -05:00
HELP: referrer
{ $values { "referrer/f" { $maybe string } } }
{ $description "Outputs the current request's referrer URL." } ;
HELP: resolve-base-path
{ $values { "string" string } { "string'" string } }
2009-01-30 17:52:03 -05:00
{ $description "Resolves a responder-relative URL." } ;
2008-11-24 21:26:11 -05:00
HELP: resolve-template-path
{ $values { "pair" "a pair with shape " { $snippet "{ class string }" } } { "path" "a pathname string" } }
2009-01-30 17:52:03 -05:00
{ $description "Resolves a responder-relative template path." } ;
2008-11-24 21:26:11 -05:00
HELP: same-host?
2014-05-23 23:20:15 -04:00
{ $values { "url" url } { "?" boolean } }
2008-11-24 21:26:11 -05:00
{ $description "Tests if the given URL is located on the same host as the URL of the current request." } ;
HELP: user-agent
{ $values { "user-agent" { $maybe string } } }
{ $description "Outputs the user agent reported by the client for the current request." } ;
2014-11-04 01:26:22 -05:00
HELP: resolve-word-path
{ $values { "word" word } { "path/f" { $maybe "a pathname string" } } }
{ $description "Outputs the full pathname of the word's vocabulary's directory." } ;
2008-11-24 21:26:11 -05:00
HELP: exit-with
{ $values { "value" object } }
{ $description "Exits from an outer " { $link with-exit-continuation } "." } ;
HELP: with-exit-continuation
2014-05-18 23:09:10 -04:00
{ $values { "quot" { $quotation ( -- value ) } } { "value" "a value returned by the quotation or an " { $link exit-with } " invocation" } }
2008-11-24 21:26:11 -05:00
{ $description "Runs a quotation with the " { $link exit-continuation } " variable bound. Calling " { $link exit-with } " in the quotation will immediately return." }
{ $notes "Furnace actions and authentication realms wrap their execution in this combinator, allowing form validation failures and login requests, respectively, to immediately return an HTTP response to the client without running any more responder code." } ;
ARTICLE: "furnace.extension-points" "Furnace extension points"
"Furnace features such as session management, conversation scope and asides need to modify URLs in links and redirects, and insert hidden form fields, to implement state on top of the stateless HTTP protocol. In order to decouple the server-side state management code from the HTML templating code, a series of hooks are used."
$nl
"Responders can implement methods on the following generic words:"
2009-10-01 15:56:36 -04:00
{ $subsections
modify-query
modify-redirect-query
link-attr
modify-form
}
2008-11-24 21:26:11 -05:00
"Presentation-level code can call the following words:"
2009-10-01 15:56:36 -04:00
{ $subsections
adjust-url
adjust-redirect-url
} ;
2008-11-24 21:26:11 -05:00
ARTICLE: "furnace.misc" "Miscellaneous Furnace features"
"Inspecting the chain of responders handling the current request:"
2009-10-01 15:56:36 -04:00
{ $subsections
nested-responders
each-responder
resolve-base-path
}
2008-11-24 21:26:11 -05:00
"Vocabulary root-relative resources:"
2009-10-01 15:56:36 -04:00
{ $subsections
2014-11-04 01:26:22 -05:00
resolve-word-path
2009-10-01 15:56:36 -04:00
resolve-template-path
}
2008-11-24 21:26:11 -05:00
"Early return from a responder:"
2009-10-01 15:56:36 -04:00
{ $subsections
with-exit-continuation
exit-with
}
2008-11-24 21:26:11 -05:00
"Other useful words:"
2009-10-01 15:56:36 -04:00
{ $subsections
hidden-form-field
client-state
user-agent
} ;