webconfig

Main package containing all neccesarry functions

Modules

aliases
module webconfig.aliases

Members

Enums

colorSetting
enum colorSetting

Adds type="color" to string types

dateSetting
enum dateSetting

Adds type="date" to string types

datetimeLocalSetting
enum datetimeLocalSetting

Adds type="datetime-local" to string types

disabledSetting
enum disabledSetting

Adds disabled to any input

emailSetting
enum emailSetting

Adds type="email" to string types

monthSetting
enum monthSetting

Adds type="month" to string types

multilineSetting
enum multilineSetting

Makes string types textareas

nonAutomaticSetting
enum nonAutomaticSetting

Disables automatic JS saving when changing the input

optionsSetting
enum optionsSetting

Changes a dropdown to a radio button list

passwordSetting
enum passwordSetting

Adds type="password" to string types

rangeSetting
enum rangeSetting

Adds type="range" to numeric types

requiredSetting
enum requiredSetting

Adds required to any input

timeSetting
enum timeSetting

Adds type="time" to string types

urlSetting
enum urlSetting

Adds type="url" to string types

weekSetting
enum weekSetting

Adds type="week" to string types

Functions

makeHumanName
string makeHumanName(string identifier)

Converts correctBookISBN_number to "Correct Book ISBN Number"

processSetting
bool processSetting(HTTPServerRequest req, Config config, bool strict, bool post)

Function processing user input and validating for correctness.

The following validations are done:
If the setting is a disabledSetting, it will always skip this field.
If the setting has a settingPattern, it will validate the raw value (no matter what type) against this regex.
If the setting is a number, std.conv.to will be used to try to convert it to a double and then it will be cast to the type after checking min/max/step.
If the setting is a BitFlags!T every passed argument will be checked if it is contained inside the enum T or when submitted via JS only the one specified argument will get validated and inverted if starting with !
If the setting is an enum the value will be checked if it is contained inside the enum.
Additionally if the setting is a floating point number and there hasn't been a min/max setup but it is a rangeSetting, the number will be finite.
Integral numbers will always be checked if finite & if no range is given they will be clamped.

Attributes for strings:
emailSetting is validated using std.net.isemail.isEmail(CheckDns.no, EmailStatusCode.any)
urlSetting is validated using vibe.inet.url.URL
timeSetting is checked against pattern 00:00 + checking if 0 <= hour < 24 && 0 <= minute < 60
weekSetting is checked against pattern 0{4,6}-W00 + checking if 1 <= year <= 200000 && 1 <= week <= 52
monthSetting is checked against pattern 0{4,6}-00 + checking if 1 <= year <= 200000 && 1 <= month <= 12
datetimeLocalSetting is checked against pattern 0000-00-00T00:00 + passing into std.datetime.SysTime.fromISOExtString`
dateSetting is checked against pattern 0000-00-00 + checking the date using std.datetime.Date
colorSetting is checked against pattern #FFFFFF
Values using these attributes can be used without the need to validate the input.

processSettings
ulong processSettings(HTTPServerRequest req, T config, bool strict, bool post)

Function processing user input and validating for correctness.

The following validations are done:
If the setting is a disabledSetting, it will always skip this field.
If the setting has a settingPattern, it will validate the raw value (no matter what type) against this regex.
If the setting is a number, std.conv.to will be used to try to convert it to a double and then it will be cast to the type after checking min/max/step.
If the setting is a BitFlags!T every passed argument will be checked if it is contained inside the enum T or when submitted via JS only the one specified argument will get validated and inverted if starting with !
If the setting is an enum the value will be checked if it is contained inside the enum.
Additionally if the setting is a floating point number and there hasn't been a min/max setup but it is a rangeSetting, the number will be finite.
Integral numbers will always be checked if finite & if no range is given they will be clamped.

Attributes for strings:
emailSetting is validated using std.net.isemail.isEmail(CheckDns.no, EmailStatusCode.any)
urlSetting is validated using vibe.inet.url.URL
timeSetting is checked against pattern 00:00 + checking if 0 <= hour < 24 && 0 <= minute < 60
weekSetting is checked against pattern 0{4,6}-W00 + checking if 1 <= year <= 200000 && 1 <= week <= 52
monthSetting is checked against pattern 0{4,6}-00 + checking if 1 <= year <= 200000 && 1 <= month <= 12
datetimeLocalSetting is checked against pattern 0000-00-00T00:00 + passing into std.datetime.SysTime.fromISOExtString`
dateSetting is checked against pattern 0000-00-00 + checking the date using std.datetime.Date
colorSetting is checked against pattern #FFFFFF
Values using these attributes can be used without the need to validate the input.

renderSetting
string renderSetting(Config config, bool success)

Generates a single input

renderSettings
string renderSettings(T value, string formAttributes, string action, string method, string jsAction)
string renderSettings(T value, ulong set, string formAttributes, string action, string method, string jsAction)

Generates a HTML form for a configuration struct T with automatic instant updates using AJAX. The fields can be annotated with the various UDAs found in this module. (setting enums + structs)
Supported types: enum (drop down lists or radio box lists), std.typecons.BitFlags (checkbox lists), bool (checkbox), string types (text, email, url, etc.), numeric types (number), std.datetime.DateTime (datetime-local), std.datetime.Date (date), std.datetime.TimeOfDay (time), vibe.inet.URL (url), string[] (textarea taking each line)

translateEnum
string translateEnum(T value, string fallback)
Undocumented in source. Be warned that the author may not have intended to support it.
validateColorString
bool validateColorString(string s)

Validates s == pattern "#xxxxxx"

validateDateString
bool validateDateString(string s)

Validates s == pattern "0000-00-00"

validateDatetimeLocalString
bool validateDatetimeLocalString(string s)

Validates s == pattern "0000-00-00T00:00"

validateMonthString
bool validateMonthString(string s)

Validates s == pattern "0{4,6}-00"

validateTimeString
bool validateTimeString(string s)

Validates s == pattern "00:00"

validateWeekString
bool validateWeekString(string s)

Validates s == pattern "0{4,6}-W00"

Manifest constants

DefaultFormTemplate
enum DefaultFormTemplate;
Undocumented in source.
DefaultJavascriptCode
enum DefaultJavascriptCode;

Contains a updateSetting(input) function which automatically sends changes to the server.

Structs

DefaultInputGenerator
struct DefaultInputGenerator

Controls how the input HTML is generated

enumTranslation
struct enumTranslation

Relables all enum member names for a language. Give null as first argument to change the default language

formTemplate
struct formTemplate

Changes how the form HTML template looks

settingClass
struct settingClass

Inserts raw CSS class name for an element.

settingHTML
struct settingHTML

Inserts raw HTML code before an element.

settingLabel
struct settingLabel

Overrides the label of the input

settingLength
struct settingLength

Changes the minlength="" and maxlength="" attribute for string values

settingMax
struct settingMax

Changes the max="" attribute for numerical values

settingMin
struct settingMin

Changes the min="" attribute for numerical values

settingPattern
struct settingPattern

Changes the pattern="regex" attribute

settingPlaceholder
struct settingPlaceholder

Sets the placeholder attribute for elements that support it

settingRange
struct settingRange

Changes the min="" and max="" attribute for numerical values

settingRows
struct settingRows

Sets the number of rows of a textarea

settingStep
struct settingStep

Changes the step="" attribute for numerical values

settingTitle
struct settingTitle

Changes the title="" attribute for custom error messages & tooltips

settingTranslation
struct settingTranslation

Changes the label if the current language (using a WebInterface translation context) matches the given one. You need at least vibe-d v0.8.1-alpha.3 to use this UDA.

See Also

<a href="aliases.html">settings.aliases</a> for shorter UDAs

Meta