Documentation
¶
Overview ¶
Package legal carries the storefront's conventional legal-document vocabulary: which documents a compliant store publishes, how those documents resolve against the published page set in a given language, and the consent evidence recorded when a visitor affirms them. Orders, auth, and the SSR engine share this package so a single resolution drives both rendering (the banner and the consent checkboxes) and enforcement (the checkout and registration gates).
Index ¶
Constants ¶
const ( // PlaceholderCookiePolicy is the token the cookie-notice translation // carries where the policy link belongs. Translations stay plain text; // the renderer splits the notice on this token and escapes every piece, // so no translation can inject markup. PlaceholderCookiePolicy = "{cookie_policy}" )
Variables ¶
var ( // StoreNoticeCopy is the storefront cookie-notice wording: it names the // language and currency preferences and the cart because the commerce // edition actually stores those. The commerce edition adopts it; every // other edition renders the neutral pair (no currency, no cart). StoreNoticeCopy = NoticeCopy{ PlainKey: "ui.cookie_notice_store", PlainDefault: "We use cookies to remember your language and currency preferences. The cart uses strictly necessary storage only and always works.", PolicyKey: "ui.cookie_notice_store_policy", PolicyDefault: "We use cookies to remember your language and currency preferences. See our {cookie_policy} for details. The cart uses strictly necessary storage only and always works.", } )
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct {
PageID int
Slug string
Language string
TranslationGroupID *int
UpdatedAt time.Time
}
Candidate is one published page row projected onto the resolver's vocabulary. TranslationGroupID links a translated page to its group anchor; the anchor itself carries nil and is keyed by its own PageID.
type Consent ¶
type Consent struct {
AcceptedAt time.Time `json:"acceptedAt"`
Terms Document `json:"terms"`
Privacy Document `json:"privacy"`
}
Consent is the evidence recorded when a visitor affirms the terms: when the acceptance happened and the document revisions it referred to.
type Document ¶
type Document struct {
Page Page `json:"page"`
PageID int `json:"pageId"`
Slug string `json:"slug"`
Language string `json:"language"`
UpdatedAt time.Time `json:"updatedAt"`
}
Document is one resolved legal document: the page that answers for it at the moment it was resolved. PageID plus UpdatedAt is the document version recorded as consent evidence; Slug and Language keep the record readable.
type NavPlacement ¶
type NavPlacement string
NavPlacement controls where conventional legal pages appear in the site chrome. The footer always carries the full site map; a placement other than footer additionally lists legal pages in the header.
const ( NavFooter NavPlacement = "footer" NavHeader NavPlacement = "header" // footer always lists every published page. NavBoth NavPlacement = "both" )
type NoticeCopy ¶
type NoticeCopy struct {
PlainKey string
PlainDefault string
PolicyKey string
PolicyDefault string
}
NoticeCopy carries one edition's cookie-notice wording: the i18n keys to look up plus the English defaults used when no UI catalog is installed. The zero value selects the neutral pair (no currency, no cart); the commerce edition adopts StoreNoticeCopy instead.
type Page ¶
type Page string
Page names one conventionally resolved legal document. The values are the canonical (English) slugs: a group is anchored by the page published under this slug and its siblings are found through the translation group, so localized slugs (e.g. kebijakan-privasi) resolve without a slug table.
const ( // PageCookiePolicy is the cookie notice the consent banner links. PageCookiePolicy Page = "cookie-policy" // PagePrivacyPolicy is the data-processing notice consent refers to. PagePrivacyPolicy Page = "privacy-policy" // PageTermsOfService is the contract consent refers to. PageTermsOfService Page = "terms-of-service" // PageReturnsPolicy is the returns and refunds policy. It carries no // consent gate; it is resolved so navigation can place it. PageReturnsPolicy Page = "returns-refunds" )
type Resolution ¶
type Resolution struct {
Documents map[Page]Document
// Groups holds the translation-group keys of every conventional page
// row, so a page in a language the resolver did not pick still reads as
// legal for navigation placement.
Groups map[int]bool
}
Resolution is the outcome of resolving the conventional documents against the published page set.
func Resolve ¶
func Resolve(candidates []Candidate, languages []string) Resolution
Resolve resolves each conventional document against the published page set. languages is the preference chain: the first language a document exists in wins, which makes the visitor's negotiated chain produce the localized page and a primary-first chain produce the canonical revision.
A document is present only when a row with the canonical slug exists: the anchor is what names the group. Once anchored, the best-ranked translation in the group answers for it, so a visitor reading Indonesian gets the kebijakan-cookie sibling of cookie-policy.
func (Resolution) Document ¶
func (r Resolution) Document(page Page) (Document, bool)
Document returns the resolved document for page.
func (Resolution) Has ¶
func (r Resolution) Has(page Page) bool
Has reports whether the document resolved.
func (Resolution) IsLegalGroup ¶
func (r Resolution) IsLegalGroup(key int) bool
IsLegalGroup reports whether the group key belongs to a conventional document.