Documentation
¶
Overview ¶
Package siteadmin is the Site settings section of the admin: the site's languages, time zone, texts, social media profiles, performance, security, review and trash settings, the Theme screen where editors choose the theme and set its values, and the Backup screen where administrators download the site as a zip file.
Index ¶
- func New(settings *site.Service, options Options) admin.Section
- func NewBackup(settings *site.Service, options Options) admin.Section
- func NewTheme(settings *site.Service, options Options) admin.Section
- type BackupManifest
- type BackupView
- type Fixed
- type GuideStep
- type GuideView
- type MailView
- type Options
- type PageRow
- type PagesView
- type ThemeChoice
- type ThemeView
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns the Site settings section of the admin, with the setup guide that leads administrators through a new site's settings (see guide.go).
Types ¶
type BackupManifest ¶
type BackupManifest struct {
// Site is the site's title in its default language.
Site string `json:"site"`
// CreatedAt is when the backup was made, in UTC.
CreatedAt time.Time `json:"created_at"`
// Dialect is the site's database: sqlite, postgres or mysql.
Dialect db.Dialect `json:"dialect"`
// DatabaseIncluded is set when the zip holds the database as
// site.sqlite, which it does on SQLite.
DatabaseIncluded bool `json:"database_included"`
// SchemaVersions are the schema versions of core and every module type
// by owner, as db.SchemaVersions reads them.
SchemaVersions map[string]int64 `json:"schema_versions"`
// MediaFiles is the number of files below media/.
MediaFiles int `json:"media_files"`
}
BackupManifest is manifest.json in a backup: where the backup comes from and what it holds.
type BackupView ¶
type BackupView struct {
// Database is set when the download holds the database: on SQLite.
Database bool
// Server names the database the download leaves out, such as
// PostgreSQL; Dump is the tool that backs it up, such as pg_dump, and
// Load the one that restores it, such as psql. They are empty on
// SQLite.
Server string
Dump string
Load string
// DocsURL is the guide to backups.
DocsURL string
// Download is the button. It posts, so prefetching a link never makes
// a backup, and outside HTMX, so the browser saves the file.
Download form.RenderModel
}
BackupView is the data of the Backup screen.
type Fixed ¶
type Fixed struct {
// ContentSecurityPolicy is the Content-Security-Policy the
// configuration sets: site.CSPOff, site.CSPReportOnly or
// site.CSPEnforce. Empty follows the setting.
ContentSecurityPolicy string
// OutputCache is set when the configuration decides how long the
// output cache keeps pages: OutputCacheTTL, which is zero when the
// configuration turns the cache off.
OutputCache bool
OutputCacheTTL time.Duration
}
Fixed are the settings the server configuration decides instead of the site settings (see webthings.Config). The cards show the value that applies, with the control disabled and the note "Set by the server configuration.", and saving a card keeps the stored setting.
type GuideStep ¶
type GuideStep struct {
ID string
// Title is a translation key.
Title string
URL string
Number int
Current bool
Done bool
Skipped bool
}
GuideStep is a step in the guide's rail.
type GuideView ¶
type GuideView struct {
// Step is the current step's ID: welcome, site, theme, mail, pages,
// security or done.
Step string
Steps []GuideStep
// Number is the current step's place among the steps that count, from
// 1, and Total their number; Handled how many are finished or skipped.
Number int
Total int
Handled int
// Site has the cards of the Site, Theme (the logo) and Security steps,
// Theme those of the Theme step.
Site *View
Theme *ThemeView
// Mail and Pages are the Mail and Pages steps.
Mail *MailView
Pages *PagesView
// Skip is the "Skip for now" button of a step that is neither
// finished nor skipped; Next leads on to the next step once it is.
Skip *form.RenderModel
Next string
// UploadURL leads to the media library, for a logo, while it has no
// images.
UploadURL string
// Start begins the guide on the welcome page; Dashboard leaves it.
Start string
Dashboard string
// Website, NewPage and Accounts are the last page's next steps, and
// Finish its button.
Website string
NewPage string
Accounts string
Finish *form.RenderModel
}
GuideView is a page of the setup guide: the rail of its steps and the cards of the current one.
type MailView ¶
type MailView struct {
// Sender says how the site sends, as its mail.Describer describes it;
// empty for a sender that does not describe itself. Logged is set when
// mail is written to the server log instead of sent (mail.Log).
Sender string
Logged bool
// NoBaseURL is set when the site has no public address: links in
// e-mail then use the address each request names, and outside local
// development the admin offers no password reset.
NoBaseURL bool
// To is the administrator's address, which the test e-mail goes to.
To string
Test form.RenderModel
}
MailView is the guide's Mail step: how the site sends e-mail, and a test e-mail to the administrator.
type Options ¶
type Options struct {
// Media offers the images, such as the logo, that the settings can
// use; Backup downloads its files.
Media *media.Service
// DB is the site's database, which Backup copies on SQLite and whose
// schema versions its manifest names.
DB *db.DB
// Fixed are the settings the server configuration decides.
Fixed Fixed
// Frontend has the themes, with their pictures; Public returns the
// public site handler, for previews.
Frontend *frontend.Frontend
Public func() http.Handler
// Pages is the page tree, on which the guide's Pages step places the
// Modules: the module instances that can be on a page.
Pages *pages.Service
Modules func() []pageadmin.Module
// Mail is the site's sender, which the Mail step describes
// (mail.Describer) and tests, and BaseURL the site's public address
// (webthings.Config.BaseURL).
Mail mail.Sender
BaseURL string
}
Options are what the Site settings, Theme and Backup sections need besides the settings themselves.
type PageRow ¶
type PageRow struct {
// Title is the module's title or the page's.
Title string
// Module is the module instance's key; empty for an ordinary page.
Module string
// OnPage is the title of the page that has it already, with the
// address of its editor; empty while there is none.
OnPage string
EditURL string
// Fields are the names of the row's fields in Form: the box to create
// the page and its title in each language.
Fields []string
}
PageRow is one page the step offers.
type PagesView ¶
type PagesView struct {
Rows []PageRow
Form *form.RenderModel
Errors form.FieldErrors
// Actions are the dashboard's quick actions, "Write the first …",
// once there are pages.
Actions []admin.QuickAction
// Modules is set when the site has modules that can be on a page.
Modules bool
}
PagesView is the guide's Pages step: a row for each module instance the site can show on a page, and for a few ordinary pages most sites have. Module pages are made below Home and published at once, so visitors can reach the modules; ordinary pages are made as drafts, to write first.
type ThemeChoice ¶
type ThemeChoice struct {
Name string
Title string
Description string
Active bool
URL string
PreviewURL string
// Screenshot is the address of the picture of the theme its
// theme.json names (frontend.Theme.Screenshot); empty without one.
Screenshot string
// Activate is the "Use this theme" button; nil for the active theme
// and without the right to edit.
Activate *form.RenderModel
}
ThemeChoice is one theme the site can use, with links to choose and to preview it.
type ThemeView ¶
type ThemeView struct {
Themes []ThemeChoice
// Screenshots is set when a theme has a picture (ThemeChoice.Screenshot):
// the others then show a placeholder of the same size, so the cards
// line up.
Screenshots bool
// Selected is the theme whose settings are shown.
Selected ThemeChoice
// Form is the form of the selected theme's settings (a form.Schema made
// from its theme.json), read-only without CanEdit; nil for a theme
// without settings.
Form *form.RenderModel
Errors form.FieldErrors
// CanEdit offers choosing a theme and saving its settings; others see
// the settings without their button.
CanEdit bool
}
ThemeView is the theme section: the themes and the settings of one.
type View ¶
type View struct {
Tabs []admin.LocaleTab
Settings form.RenderModel
SettingsErrors form.FieldErrors
Text form.RenderModel
TextErrors form.FieldErrors
Profiles form.RenderModel
ProfilesErrors form.FieldErrors
// Performance is the form of compression and page caching.
Performance form.RenderModel
PerformanceErrors form.FieldErrors
// Security is the form of which sites may frame the site's pages. Only
// administrators may change it: SecurityReadOnly shows it to others
// without its button.
Security form.RenderModel
SecurityErrors form.FieldErrors
SecurityReadOnly bool
// Review turns the review workflow on per section; nil when no section
// can be reviewed. Only administrators may change it: ReviewReadOnly
// shows it to others without its button.
Review *form.RenderModel
ReviewErrors form.FieldErrors
ReviewReadOnly bool
// Trash is the form of after how many days the trash deletes items
// for good.
Trash form.RenderModel
TrashErrors form.FieldErrors
// ReadOnly is set for users who may view the settings but not edit
// them: the forms are then read-only (disabled, without their buttons).
ReadOnly bool
// GeneralFields and TextFields limit the General and Texts cards to
// the fields named, as the setup guide shows them; empty shows every
// field.
GeneralFields []string
TextFields []string
// GeneralHeading replaces the General card's heading, a translation
// key, such as "Logo" when the guide shows only the logo.
GeneralHeading string
// GuideURL continues the setup guide while it is not finished, and
// Reopen opens it again once it is; both are for administrators only.
GuideURL string
Reopen *form.RenderModel
}
View is the data of the Site settings screen: one form per group of settings, the translated texts in the language of the selected tab.