templates

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

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

View Source
const AddressPlaceholder = "%%ADDRESS%%"

AddressPlaceholder is replaced by the workspace's postal address.

View Source
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.

View Source
const StarterPrefix = "starter:"

StarterPrefix marks the ids of built-in templates ("starter:weekly-digest").

Variables

This section is empty.

Functions

func Register

func Register(h huma.API, s *Service)

Register adds the template operations.

func StarterAssets

func StarterAssets() fs.FS

StarterAssets are the placeholder images of the starter templates.

func StarterMJML

func StarterMJML(key, address string) (string, bool)

StarterMJML returns a starter's MJML with the workspace address filled in and image URLs pointing at /media/starters/.

func WorkspaceAddress

func WorkspaceAddress(ws *store.Workspace) string

WorkspaceAddress reads the postal address from the workspace branding ({"address": "…"}), used to fill footers.

Types

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 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 {
	Pool  *pgxpool.Pool
	Q     *store.Queries
	Audit *audit.Logger
	Now   func() time.Time
}

Service holds the templates domain dependencies.

func (*Service) Create

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) 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.

func (*Service) Update

Update renames a template or replaces its content.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL