themeinstall

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package themeinstall installs, updates and removes the themes kept in their own git repositories (app theme …, internal/app/theme.go): a theme's repository is its directory (theme.yaml at its root), its releases are its tags (v1.2.0). A theme is installed into themes/<name>/ at a tag, and themes/themes.lock (themes.Lock) records its source, tag, commit and files' checksum; the files are the site's to commit (as vendoring), the deploy carries them, Verify checks they are what the lock says.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(dir string) (string, error)

Hash - the checksum of the theme files in dir (dirhash's "h1:…", as go.sum's): every file but the minified ones the build makes (*.min.css, *.min.js) and the system's (.DS_Store), by path.

func NameOf

func NameOf(source string) string

NameOf - a theme's name from its repository's address: the last part, without ".git" and a "kosatka-theme-" prefix ("…/kosatka-theme-sand.git" → "sand").

func ReadSources

func ReadSources(file string) ([]string, error)

ReadSources - the repositories listed in file (one a line; blank lines and # comments skipped), each once.

Types

type Finding

type Finding struct {
	Problem bool
	File    string
	Line    int
	Text    string
}

Finding - one thing Check found in a theme: a Problem (a site or the themes catalog would refuse it or show it wrong) or a warning. File and Line - where, File relative to the theme's directory ("" - the theme as a whole, Line 0 - the file as a whole).

func (Finding) String

func (f Finding) String() string

type Installer

type Installer struct {
	Git string
	Log io.Writer
}

Installer - the themes of the project in paths.ThemesDir. Git - the git binary ("" - "git" from PATH); Log - where progress goes (nil - none).

func (Installer) Add

func (in Installer) Add(ctx context.Context, source, version, name string) (themes.LockEntry, error)

Add installs the theme in source at version ("" - its newest release) as themes/<name> (name "" - the repository's name, without a "kosatka-theme-" prefix). A theme directory already there is refused.

func (Installer) BuildIndex

func (in Installer) BuildIndex(ctx context.Context, sources []string, stats StatsFunc) (themes.Catalog, []error)

BuildIndex - the catalog of sources' newest releases (stats - nil for none); the repositories that failed, each with its error.

func (Installer) Check

func (in Installer) Check(ctx context.Context, dir string, engine []i18n.Source) ([]Finding, error)

Check checks the theme in dir before a release (app theme check):

  • the manifest (as installing checks it) and what the catalog asks of it, the files it names (screenshot, stylesheets);
  • the theme's files its templates, scripts and stylesheets refer to;
  • resources loaded from other servers (CDNs, web fonts), which the catalog doesn't accept;
  • each language's catalog (translations/<lang>.json): the theme's strings it lacks, translations that can't stand for their source, strings the theme doesn't use - engine is the engine's and the modules' strings (translations.Sources), translated by their own catalogs, not the theme's;
  • its own demo sets (demo/<lang>.yaml): each loads, in the theme's regions;
  • in a theme's own git repository, its version against the latest release tag.

func (Installer) Remove

func (in Installer) Remove(name string) error

Remove deletes installed theme name and its lock entry. Its blocks' placements and settings stay in the database (harmless, as a theme's that is just not active); a site with it active falls back to the engine's templates.

func (Installer) Tags

func (in Installer) Tags(ctx context.Context, source string) ([]string, error)

Tags - source's release tags (semver, "v1.2.0"), the newest first; pre-releases (v1.2.0-rc1) after the releases.

func (Installer) Update

func (in Installer) Update(ctx context.Context, name, version string) (themes.LockEntry, error)

Update moves installed theme name to version ("" - its source's newest release).

type Problem

type Problem struct {
	Theme  string
	Reason string
}

Problem - an installed theme that isn't what the lock says.

func Verify

func Verify() ([]Problem, error)

Verify checks each theme of the lock: its directory is there and its files' checksum is the lock's (no file changed, added or removed since it was installed; a theme is changed by a new release, not in place).

type RepoStats

type RepoStats struct {
	Stars   int
	Updated time.Time
}

RepoStats - a repository's stars and last update from its host.

type StatsFunc

type StatsFunc func(ctx context.Context, source string) (stats RepoStats, ok bool, err error)

StatsFunc - source's stats; ok=false - its host isn't one the func knows.

func GitHubStats

func GitHubStats(client *http.Client, api, token string) StatsFunc

GitHubStats - stats from GitHub's API (api - its address, "" - the public one; token - "" for the anonymous limit, 60 requests an hour).

Jump to

Keyboard shortcuts

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