theme

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package theme is the owner's look for the app: its name, palette, brand colour, corner shape and fonts, kept in one database row and served at /api/roux/theme. Whatever the owner has not chosen is the application's default, so the answer is always a whole theme. The page itself carries the saved theme too (see kit/spa), so the first paint already looks right.

GET /api/roux/theme   anyone, signed out too: the page needs it before sign-in
PUT /api/roux/theme   whoever holds theme.manage, from the version they read

Index

Constants

View Source
const Path = "/api/roux/theme"

Path is where the theme is served.

View Source
const ThemeManage = "theme.manage"

ThemeManage lets someone change the theme. The migration grants it to OWNER.

Variables

View Source
var Migration = pgdb.Migration{Name: "roux-theme", FS: migrations, Dir: "migrations", After: []string{"roux-authz"}}

Migration is the theme's schema. It runs after the roles, whose OWNER it grants ThemeManage.

Functions

func Register

func Register(mux *api.Mux, host *authn.Host, svc Service)

Register serves the theme: GET for anyone, PUT for whoever holds theme.manage.

Types

type Request

type Request struct {
	AppName     *string `json:"appName"`
	Palette     *string `json:"palette"`
	BrandColor  *string `json:"brandColor"`
	Shape       *string `json:"shape"`
	HeadingFont *string `json:"headingFont"`
	BodyFont    *string `json:"bodyFont"`
	Version     *int64  `json:"version"`
}

Request is the owner's new theme, edited from Version. Members are pointers so that one left out is told apart from one that is blank.

type Response

type Response struct {
	AppName     string `json:"appName"`
	Palette     string `json:"palette"`
	BrandColor  string `json:"brandColor"`
	Shape       string `json:"shape"`
	HeadingFont string `json:"headingFont"`
	BodyFont    string `json:"bodyFont"`
	Version     int64  `json:"version"`
}

Response is the theme as the API answers it: every part, the owner's or the application's default, and the version an edit must send back (0 until the owner first saves).

type Service

type Service struct {
	Pool     *pgxpool.Pool
	Defaults spa.Theme // for every part the owner has not chosen
	Clock    func() time.Time
}

Service reads and changes the theme.

func (Service) Current

func (s Service) Current(ctx context.Context) (Response, error)

Current is the theme as it looks now, and the version an edit must be made from.

func (Service) Shell

func (s Service) Shell(ctx context.Context) (spa.Theme, error)

Shell is Current as the page carries it: for spa.Config.Theme.

func (Service) Update

func (s Service) Update(ctx context.Context, req Request, actor uuid.UUID) (Response, error)

Update saves the owner's theme, if the request's version is still current.

Jump to

Keyboard shortcuts

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