Documentation
¶
Overview ¶
Package gallery shows photo albums. An album has a translated title, slug and Markdown description, an optional cover image and an ordered list of images from the media library. Captions and alt text are the images' own per-language title and alt text in the library. Add one instance per gallery, for example:
app.Use(gallery.Module("photos", "Photos"))
Mounted on a page, the module serves two templates:
- gallery/list.gohtml at the page itself, with a ListView of the published albums (without their images).
- gallery/album.gohtml at /{slug}, with an Album including its Images.
Album.CoverURL is the cover image, or the first image when no cover is set. Images are shown as copies at most media.ImageWidth wide with a srcset (see frontend.Frontend.Image); Image.LargeURL is a copy for a lightbox and Image.OriginalURL the uploaded file. The album form chooses the images and adds new ones at the end; "Image order" in the admin moves them up and down.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIAlbum ¶
type APIAlbum struct {
ID string `json:"id"`
Slug string `json:"slug"`
Title string `json:"title"`
// DescriptionHTML is the album's description as HTML (api.HTML); only
// the album's own endpoint has it.
DescriptionHTML string `json:"description_html,omitempty"`
// Cover is the cover image, or the first image when the editors chose
// none; null for an album without images.
Cover *api.Image `json:"cover"`
ImageCount int `json:"image_count"`
// URL is the album's page, null while the gallery is on no page; APIURL
// the album in the API.
URL *string `json:"url"`
APIURL string `json:"api_url"`
UpdatedAt time.Time `json:"updated_at"`
}
APIAlbum is a published album in the content API (see package api), in the list of /api/v1/<key>/albums and, with its images, at /api/v1/<key>/albums/{id} (APIAlbumImages).
type APIAlbumImages ¶
APIAlbumImages is a published album with its images in their order, at /api/v1/<key>/albums/{id}.
type APIImage ¶
APIImage is an image of an album: its media library ID, its title in the request's language and the image as pages show it (api.Image).
type Album ¶
type Album struct {
ID string
Title string
Description template.HTML
// URL is the album's page, empty when the gallery is on no page.
URL string
// CoverURL is the cover as pages show it, at most media.ImageWidth wide;
// CoverSrcset lists smaller copies for a srcset attribute, CoverWidth
// and CoverHeight are the size of CoverURL and CoverOriginalURL is the
// uploaded file. All are empty for an album without images.
CoverURL string
CoverSrcset string
CoverOriginalURL string
CoverWidth int
CoverHeight int
ImageCount int
Images []Image
}
Album is a published album as templates see it. Images is only filled on the album page.
type AlbumFields ¶
AlbumFields are the language-independent parts of an album.
type AlbumItem ¶
type AlbumItem = content.Item[AlbumFields, AlbumText]
AlbumItem is an album with its translations, as the store keeps it.
type AlbumText ¶
type AlbumText struct {
Slug string `db:"slug"`
Title string `db:"title"`
Description string `db:"description"`
}
AlbumText is an album in one language. Description is Markdown.
type Image ¶
type Image struct {
ID string
// URL is the image as pages show it, at most media.ImageWidth wide, and
// Srcset smaller copies for a srcset attribute; Width and Height are the
// size of URL.
URL string
Srcset string
Width int
Height int
// LargeURL is a copy at most media.LargeImageWidth wide, for the image
// on its own, such as in a lightbox.
LargeURL string
// OriginalURL is the uploaded file, for downloads.
OriginalURL string
Title string
Alt string
}
Image is one image of an album. Title and Alt come from the media library in the page's language.
type ImageRow ¶
type ImageRow struct {
Name string
// URL shows the image; it is empty when the file is no longer in the
// media library.
URL string
// Moves are the image's up and down arrows; nil without the right to
// edit albums.
Moves []admin.Move
}
ImageRow is one image of an album.
type ImagesView ¶
ImagesView is the data of templates/admin/images.gohtml: the images of one album in order.
type OrderAlbum ¶
OrderAlbum is one album on the order screen.
type OrderView ¶
type OrderView struct {
BackURL string
// BackLabel names the albums overview BackURL leads to, as a
// translation key.
BackLabel string
Albums []OrderAlbum
}
OrderView is the data of templates/admin/order.gohtml: the albums whose images can be put in order.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is one Gallery instance, for the website's own code (for example albums on the home page).
func (*Service) Album ¶
Album returns one published album with its images, for example for a carousel on another page. The slug may be from any language; the album is returned in locale.