The OpenD Programming Language

arsd.html

This module includes functions to work with HTML and CSS in a more specialized manner than arsd.dom. Most of this is obsolete from my really old D web stuff, but there's still some useful stuff. View source before you decide to use it, as the implementations may suck more than you want to use.

It publically imports the DOM module to get started. Then it adds a number of functions to enhance html DOM documents and make other changes, like scripts and stylesheets.

Public Imports

arsd.dom
public import arsd.dom;
Undocumented in source.

Members

Classes

CssMacroExpander
class CssMacroExpander
Undocumented in source.
JavascriptMacroExpander
class JavascriptMacroExpander
Undocumented in source.
MacroExpander
class MacroExpander
Undocumented in source.

Enums

HtmlFeatures
enum HtmlFeatures

This is a list of features you can allow when using the sanitizedHtml function.

UriFeatures
enum UriFeatures

The things to allow in links, images, css, and aother urls. FIXME: implement this for better flexibility

Functions

addOnLoad
void addOnLoad(Document document)

Adds some script to run onload FIXME: not implemented

appearsToBeHtml
bool appearsToBeHtml(string src)

Returns true of the string appears to be html/xml - if it matches the pattern for tags or entities.

checkbox
Element checkbox(string name, string value, string label, bool checked)
denestCss
const(CssPart)[] denestCss(CssPart[] css)

Translates nested css

favicon
string favicon(Document document)

Get the favicon out of a document, or return the default a browser would attempt if it isn't there.

linkify
Html linkify(string text)

Given arbitrary user input, find links and add <a href> wrappers, otherwise just escaping the rest of it for HTML display.

makePostLink
Form makePostLink(string href, string innerText, string[string] params)

Convenience function to create a small <form> to POST, but the creation function is more like a link than a DOM form.

makePostLink
Form makePostLink(string href, Html innerHtml, string[string] params)

Similar to the above, but lets you pass HTML rather than just text. It puts the html inside a <button type="submit"> element.

makePostLink
Form makePostLink(string href, Element submitButtonContents, string[string] params)

Like the Html overload, this uses a <button> tag to get fancier with the submit button. The element you pass is appended to the submit button.

makePostLink
Form makePostLink(Element link)

Given an existing link, create a POST item from it. You can use this to do something like:

nl2br
Html nl2br(string text)

Given user text, converts newlines to <br> and encodes the rest.

paragraphsToP
Html paragraphsToP(Html html)

Given existing encoded HTML, turns \n\n into <p>.

sanitizeUrl
string sanitizeUrl(string url)
sanitizedHtml
Element sanitizedHtml(Element userContent, string idPrefix, HtmlFeatures allow)

This returns an element wrapping sanitized content, using a whitelist for html tags and attributes, and a blacklist for css. Javascript is never allowed.

sanitizedHtml
Element sanitizedHtml(Html userContent, string idPrefix, HtmlFeatures allow)
translateDateInputs
void translateDateInputs(Document document)

makes input[type=date] to call displayDatePicker with a button

translateFiltering
void translateFiltering(Document document)

tries to make an input to filter a list. it kinda sucks.

translateInputTitles
void translateInputTitles(Element rootElement)

find <input> elements with a title. Make the title the default internal content

translateStriping
void translateStriping(Document document)

finds class="striped" and adds class="odd"/class="even" to the relevant children

translateValidation
void translateValidation(Document document)

Translates validate="" tags to inline javascript. "this" is the thing being checked.

wrapTextNodes
void wrapTextNodes(Document document, TextWrapperWhitespaceBehavior whatToDoWithWhitespaceNodes)

This wraps every non-empty text mode in the document body with <t:t></t:t>, and sets an xmlns:t to the html root.

Variables

recommendedBasicCssForUserContent
string recommendedBasicCssForUserContent;

This is some basic CSS I suggest you copy/paste into your stylesheet if you use the sanitizedHtml function.

Meta