Documentation
¶
Overview ¶
Package templates holds the composer's template gallery: the starter templates that ship with ReputeCast (MJML files embedded in the binary, their placeholder images served at /media/starters/), the workspace's saved templates and its saved sections (reusable blocks).
Index ¶
- Constants
- func DefaultAddressIn(l i18n.Lang) string
- func Picture(src string) string
- func Register(h huma.API, s *Service)
- func StarterAssets() fs.FS
- func StarterMJML(key, address string) (string, bool)
- func StarterMJMLIn(l i18n.Lang, key, address string) (string, bool)
- func WorkspaceAddress(ws *store.Workspace) string
- type Brand
- type EmailTemplateDetail
- type EmailTemplateGallery
- type EmailTemplateInput
- type EmailTemplateLastCampaign
- type EmailTemplatePreview
- type EmailTemplateSummary
- type Service
- func (s *Service) Create(ctx context.Context, ws *store.Workspace, actor *uuid.UUID, ...) (EmailTemplateDetail, error)
- func (s *Service) Delete(ctx context.Context, ws *store.Workspace, actor *uuid.UUID, id string) error
- func (s *Service) Gallery(ctx context.Context, ws *store.Workspace) (EmailTemplateGallery, error)
- func (s *Service) GalleryFor(ctx context.Context, ws *store.Workspace, digest bool) (EmailTemplateGallery, error)
- func (s *Service) Get(ctx context.Context, ws *store.Workspace, id, address string) (EmailTemplateDetail, error)
- func (s *Service) Preview(ctx context.Context, ws *store.Workspace, id, address string) (EmailTemplatePreview, error)
- func (s *Service) Update(ctx context.Context, ws *store.Workspace, actor *uuid.UUID, id string, ...) (EmailTemplateDetail, error)
Constants ¶
const AddressPlaceholder = "%%ADDRESS%%"
AddressPlaceholder is replaced by the workspace's postal address.
const BlogDigestStarter = "blog-digest"
BlogDigestStarter is the key of the recurring digest's starter.
const DefaultAddress = "Your company · Street and number · City, postcode"
DefaultAddress is shown when the workspace has no postal address yet; the content check flags it until it is replaced.
const StarterPrefix = "starter:"
StarterPrefix marks the ids of built-in templates ("starter:weekly-digest").
Variables ¶
This section is empty.
Functions ¶
func DefaultAddressIn ¶
DefaultAddressIn is DefaultAddress in a reader's language: the line a starter's footer shows until the workspace sets its postal address.
func Picture ¶
Picture turns an email's HTML into a picture of it: personalization shows its fallbacks (a reader without a first name), and links, scripts, frames, form controls, event handlers and focus order are taken out.
func StarterAssets ¶
StarterAssets are the placeholder images of the starter templates.
func StarterMJML ¶
StarterMJML returns a starter's MJML with the workspace address filled in and image URLs pointing at /media/starters/, its sample content in English.
func StarterMJMLIn ¶
StarterMJMLIn is StarterMJML with the sample content written in l, for the readers of the email someone starts from it.
func WorkspaceAddress ¶
WorkspaceAddress reads the postal address from the workspace branding ({"address": "…"}), used to fill footers.
Types ¶
type Brand ¶
Brand puts the workspace's brand kit on a starter: its colours, fonts, button style and logo, and its synced Header and Footer (internal/brandkit, CO-11).
type EmailTemplateDetail ¶
type EmailTemplateDetail struct {
EmailTemplateSummary
MJML string `json:"mjml"`
HTML string `json:"html"`
}
EmailTemplateDetail adds the content.
type EmailTemplateGallery ¶
type EmailTemplateGallery struct {
Starters []EmailTemplateSummary `json:"starters"`
Templates []EmailTemplateSummary `json:"templates"`
Sections []EmailTemplateSummary `json:"sections"`
LastCampaign *EmailTemplateLastCampaign `json:"lastCampaign,omitempty"`
}
EmailTemplateGallery is the empty-canvas gallery and the Templates tab.
type EmailTemplateInput ¶
type EmailTemplateInput struct {
Kind string `json:"kind,omitempty" enum:"template,section" default:"template"`
Name string `json:"name" minLength:"1" maxLength:"120"`
Description string `json:"description,omitempty" maxLength:"300"`
MJML string `json:"mjml" minLength:"1" maxLength:"2000000"`
HTML string `json:"html,omitempty" maxLength:"2000000"`
SourceCampaignID string `json:"sourceCampaignId,omitempty" format:"uuid"`
}
EmailTemplateInput is a new or changed template or saved section.
type EmailTemplateLastCampaign ¶
type EmailTemplateLastCampaign struct {
ID string `json:"id"`
Name string `json:"name"`
SentAt time.Time `json:"sentAt"`
Thumb []mjml.MJMLThumbItem `json:"thumb"`
}
EmailTemplateLastCampaign is the most recent sent campaign, offered as "Copy of …".
type EmailTemplatePreview ¶
type EmailTemplatePreview struct {
HTML string `` /* 155-byte string literal not displayed */
}
EmailTemplatePreview is a template as its email reads, for the gallery.
type EmailTemplateSummary ¶
type EmailTemplateSummary struct {
ID string `json:"id" example:"starter:weekly-digest"`
Kind string `json:"kind" enum:"template,section"`
Name string `json:"name"`
Description string `json:"description"`
Thumb []mjml.MJMLThumbItem `json:"thumb"`
Builtin bool `json:"builtin"`
UpdatedAt *time.Time `json:"updatedAt,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
SizeBytes int `json:"sizeBytes"`
// SourceCampaignID is the campaign a template was saved from.
SourceCampaignID string `json:"sourceCampaignId,omitempty"`
}
EmailTemplateSummary is one tile of the gallery.
type Service ¶
type Service struct {
// Brand, when set, starts starters from the brand kit.
Brand Brand
Pool *pgxpool.Pool
Q *store.Queries
Audit *audit.Logger
Now func() time.Time
}
Service holds the templates domain dependencies.
func (*Service) Create ¶
func (s *Service) Create(ctx context.Context, ws *store.Workspace, actor *uuid.UUID, in EmailTemplateInput) (EmailTemplateDetail, error)
Create saves a template or a section.
func (*Service) Delete ¶
func (s *Service) Delete(ctx context.Context, ws *store.Workspace, actor *uuid.UUID, id string) error
Delete removes a template or saved section.
func (*Service) Gallery ¶
Gallery lists starters, the workspace's templates and saved sections, and the last sent campaign.
func (*Service) GalleryFor ¶
func (s *Service) GalleryFor(ctx context.Context, ws *store.Workspace, digest bool) (EmailTemplateGallery, error)
GalleryFor is the gallery of the composer's regular mode, or of its digest mode (digest true), which adds the digest starters.
func (*Service) Get ¶
func (s *Service) Get(ctx context.Context, ws *store.Workspace, id, address string) (EmailTemplateDetail, error)
Get returns a template (starter or saved) with its content. address fills a starter's footer.