Class EmailLayout
java.lang.Object
io.meeds.portal.mail.util.EmailLayout
The one look of the emails of the platform: a header band in the brand
color that carries the company name and the title, then a single column of
text that follows the direction of the language (left to right, or right to
left for Arabic, Hebrew, Persian...) with the action as a button. It is made of tables
and inline styles, the only markup every mail client renders alike, and
every text it is given is escaped.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringactionLink(EmailBrand brand, String label, String href, boolean primary) A button for an email that is laid out by its own template, such as a notification: a flat button with rounded corners.static StringactionLink(String label, String href, boolean primary) The same button with the brand of the sitestatic StringbuttonRowMargin(String lang, String pull) The margin of a row of buttons that sits in the text column of an email with an avatar: it pulls the row back to the start of the content column, where the buttons of every other email are, on the left for a left to right language and on the right for a right to left one.static StringThe closing row of an email laid out by its own template: the space under the last block, as the account emails have, with no frame and no link (the button of the email and the plain address under it are the ways to the site)static StringThe dark styles of the notification emails, to put once before the header row: the colors of those templates are inline, the rules match them.static Stringstatic Stringstatic StringentityLink(String label, String url) The name of an entity (event, calendar, person, space) inside a sentence: escaped, bold and in the link color, a link when the address is a safe http or https one, plain bold text otherwise.static StringentityStyled(String html) Same aslinkStyled(String)for the links that name a person, a space or any entity (built in Java, so without style): bold, in the link color, not underlinedstatic StringA box of labelled values (where, when, who) in an email laid out by its own template: the quote look with a fixed label column.static StringSame asfacts(String...), with the bar on the side where the text oflangstartsstatic StringThe fonts of the text of an email that keeps its own template: the font of the platform branding first, then the fonts that every mail client hasstatic StringfontStack(EmailBrand brand) static Stringstatic Stringstatic StringheaderRow(EmailBrand brand, String title) The header of an email as a table row, for the emails that are laid out by their own template (the notifications) and only share the look of the header: the company name and the title in the brand colorstatic StringheaderRow(EmailBrand brand, String title, String lang) The same header for a reader whose language is written from right to left, whenlangsays sostatic booleanTells whether a language is written from right to left, as Arabic, Hebrew, Persian or Urdu are.static Stringstatic StringThe color of the links in the text of an email that keeps its own template, so that they follow the primary color of the sitestatic StringlinkColor(EmailBrand brand) static StringlinkStyled(String html) Gives the links of a label (the footer sentence that holds the link to the notification settings) the link style of the emails, as their onlystyleattribute: the label may already carry one, and a tag with two of them is not validstatic StringquoteEnd()static StringOpens the block that quotes what somebody wrote (a message, a comment, a description) in an email laid out by its own template: a bar in the brand color and a light background, the same as the key value of the other emails.static StringquoteStart(boolean spaceAfter) Same asquoteStart();spaceAfterfalse leaves out the space under the box, for a quote that is the last block of its cell and is followed by a button, which brings its own spacestatic StringquoteStart(boolean spaceAfter, String lang) The general form: space under the box or not, bar on the start side of the languagestatic StringquoteStart(String lang) Same asquoteStart(), the bar on the side where the text of the language startsstatic Stringrender(EmailModel model, EmailBrand brand) static Stringstatic StringviewAction(String description, String label, String href) The action markup alone, for an email whose main link is in its text (a link in a quote) and has no button
-
Method Details
-
greeting
-
leadIn
-
isRtl
Tells whether a language is written from right to left, as Arabic, Hebrew, Persian or Urdu are. The platform's own locale configuration only declares Arabic as such, so the direction of an email is taken from the language itself.- Parameters:
lang- a BCP 47 language tag or a Java locale name, such as ar, he-IL, fa_IR or ku-Arab- Returns:
- true when the language, or its script, is written from right to left
-
render
- Parameters:
model- what the email saysbrand- how it is dressed- Returns:
- the complete html document
- Throws:
IllegalArgumentException- when the link of the button is not an http, https or mailto address
-
darkStyle
The dark styles of the notification emails, to put once before the header row: the colors of those templates are inline, the rules match them.- Returns:
- a
<style>element
-
headerRow
The header of an email as a table row, for the emails that are laid out by their own template (the notifications) and only share the look of the header: the company name and the title in the brand color- Parameters:
brand- how the email is dressedtitle- the headline, in plain text- Returns:
- a
<tr>to include in a table
-
headerRow
The same header for a reader whose language is written from right to left, whenlangsays so -
quoteStart
Opens the block that quotes what somebody wrote (a message, a comment, a description) in an email laid out by its own template: a bar in the brand color and a light background, the same as the key value of the other emails. The text follows, thenquoteEnd().- Returns:
- the opening of a table that holds the quote
-
quoteStart
Same asquoteStart(), the bar on the side where the text of the language starts -
quoteStart
Same asquoteStart();spaceAfterfalse leaves out the space under the box, for a quote that is the last block of its cell and is followed by a button, which brings its own space -
quoteStart
-
quoteEnd
- Returns:
- the end of the block opened by
quoteStart()
-
entityLink
The name of an entity (event, calendar, person, space) inside a sentence: escaped, bold and in the link color, a link when the address is a safe http or https one, plain bold text otherwise.- Parameters:
label- the name, plain texturl- the address it points to, or null- Returns:
- the html of the name
-
facts
A box of labelled values (where, when, who) in an email laid out by its own template: the quote look with a fixed label column. A pair whose value is blank is left out.- Parameters:
labelsAndValues- label, value, label, value...: the label is plain text, the value is html that the caller has already escaped- Returns:
- the html of the box, or an empty text when no value is left
-
factsIn
Same asfacts(String...), with the bar on the side where the text oflangstarts -
buttonRowMargin
The margin of a row of buttons that sits in the text column of an email with an avatar: it pulls the row back to the start of the content column, where the buttons of every other email are, on the left for a left to right language and on the right for a right to left one.- Parameters:
lang- the language of the emailpull- the width of the avatar column, such as64px- Returns:
- the value of a
margindeclaration
-
linkStyled
Gives the links of a label (the footer sentence that holds the link to the notification settings) the link style of the emails, as their onlystyleattribute: the label may already carry one, and a tag with two of them is not valid- Parameters:
html- a label that holds<a>tags, or null- Returns:
- the label whose links are underlined in the link color
-
entityStyled
Same aslinkStyled(String)for the links that name a person, a space or any entity (built in Java, so without style): bold, in the link color, not underlined- Parameters:
html- a label or a message that holds<a>tags, or null- Returns:
- the same text whose links are styled as the names of the emails
-
closingRow
The closing row of an email laid out by its own template: the space under the last block, as the account emails have, with no frame and no link (the button of the email and the plain address under it are the ways to the site)- Returns:
- a
<tr>to include in a table
-
actionLink
A button for an email that is laid out by its own template, such as a notification: a flat button with rounded corners. Buttons that follow each other sit on one line, as wide as their label and never wider than the screen, and wrap onto the next line when the screen is too narrow, so that they read the same on a computer and on a phone without a media query. The primary one is filled with the brand color; the secondary ones are quiet, outlined in the primary color, so that buttons side by side do not compete.- Parameters:
brand- how the email is dressedlabel- the text of the button, in plain texthref- an http or https address; for any other address only the label is writtenprimary- true for the main action of the email- Returns:
- the html of the button
-
linkColor
The color of the links in the text of an email that keeps its own template, so that they follow the primary color of the site -
fontStack
The fonts of the text of an email that keeps its own template: the font of the platform branding first, then the fonts that every mail client has -
fontStack
-
linkColor
-
viewAction
The action markup alone, for an email whose main link is in its text (a link in a quote) and has no button- Parameters:
description- what the email is about, in plain textlabel- the name of the action, in plain texthref- the address, which only counts when it is https- Returns:
- the markup, or nothing for any other address
-
actionLink
-
dir
-
start
-
end
-
gap
-