html3

package
v1.5.14 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package html3 renders the html3 sub-route of the website. This generates pages for the website for browsing of the file database using HTML3 styled tables.

Index

Constants

View Source
const (
	NameAsc      = "C=N&O=A"     // Name ascending order.
	NameDes      = "C=N&O=D"     // Name descending order.
	PublAsc      = "C=D&O=A"     // Date published ascending order.
	PublDes      = "C=D&O=D"     // Date published descending order.
	PostAsc      = "C=P&O=A"     // Posted ascending order.
	PostDes      = "C=P&O=D"     // Posted descending order.
	SizeAsc      = "C=S&O=A"     // Size ascending order.
	SizeDes      = "C=S&O=D"     // Size descending order.
	DescAsc      = "C=I&O=A"     // Description ascending order.
	DescDes      = "C=I&O=D"     // Description descending order.
	Name    Sort = "Name"        // Sort records by the filename.
	Publish Sort = "Publish"     // Sort records by the published year, month and day.
	Posted  Sort = "Posted"      // Sort records by the record creation dated.
	Size    Sort = "Size"        // Sort records by the file size in byte units.
	Desc    Sort = "Description" // Sort the records by the title.
)

Sort and order the records by the column name.

View Source
const Prefix = "/html3"

Prefix is the root path of the HTML3 router group.

Variables

View Source
var (
	ErrConn   = errors.New("the server cannot connect to the database")
	ErrDB     = errors.New("database value is nil")
	ErrPage   = errors.New("unknown records by type")
	ErrRoutes = errors.New("echo instance is nil")
	ErrSQL    = errors.New("database connection problem or a SQL error")
	ErrTag    = errors.New("no database query was for the tag")
	ErrTmpl   = errors.New("cannot render the template")
	ErrZap    = errors.New("zap logger is nil")
)

Functions

func Clauses

func Clauses(query string) html3.Order

Clauses for ordering file record queries.

func Description

func Description(section, platform, brand, title null.String) string

Description returns a HTML3 friendly file description.

func Error

func Error(c echo.Context, err error) error

Error renders a custom HTTP error page for the HTML3 sub-group.

func FileHref

func FileHref(logger *zap.SugaredLogger, id int64) string

FileHref creates a URL to link to the file download of the ID.

func FileLinkPad

func FileLinkPad(width int, name null.String) string

FileLinkPad adds whitespace padding after the hyperlinked filename.

func Filename

func Filename(width int, name null.String) string

Filename returns a truncated filename with to the w maximum width.

func GlobTo

func GlobTo(name string) string

GlobTo returns the path to the template file.

func ID

func ID(c echo.Context) string

ID returns the ID from the URL path. This is only used for the category and platform routes.

func LeadFS

func LeadFS(width int, size null.Int64) string

LeadFS formats the file size to the fixed-width length w value.

func LeadFSInt

func LeadFSInt(width, size int) string

LeadFSInt formats the file size to the fixed-width length w value.

func LeadInt

func LeadInt(width, i int) string

LeadInt takes an int and returns it as a string, w characters wide with whitespace padding.

func Leading

func Leading(count int) string

Leading repeats the number of space characters.

func ListInfo

func ListInfo(tt RecordsBy, current, id string) (string, string)

ListInfo returns the title and description for the RecordsBy grouping.

func Pagi

func Pagi(page int, maxPage uint) (int, int, int)

Pagi returns up to three page numbers for pagination links. The absolute numbers will always be in sequence except for returned values of zero, which should be skipped.

func Query

func Query(c echo.Context, db *sql.DB, tt RecordsBy, offset int) (int, int, int64, models.FileSlice, error)

Query returns a slice of records based on the RecordsBy grouping. The three integers returned are the limit, the total count of records and the file sizes summed.

func QueryAsArt

func QueryAsArt(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryAsArt returns a slice of all the records filtered by "Digital + pixel art".

func QueryAsDocument

func QueryAsDocument(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryAsDocument returns a slice of all the records filtered by "Document + text art".

func QueryAsSoftware

func QueryAsSoftware(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryAsSoftware returns a slice of all the records filtered by "Software".

func QueryByGroup

func QueryByGroup(ctx context.Context, exec boil.ContextExecutor, c echo.Context) (
	int, int, int64, models.FileSlice, error,
)

QueryByGroup returns a slice of all the records filtered by the group id, "by Group". The group records do not use pagination limits or offsets.

func QueryByPlatform

func QueryByPlatform(ctx context.Context, exec boil.ContextExecutor, c echo.Context, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryByPlatform returns a slice of all the records filtered by the platform id, "by Platform and media".

func QueryBySection

func QueryBySection(ctx context.Context, exec boil.ContextExecutor, c echo.Context, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryBySection returns a slice of all the records filtered by the section id, "by Category".

func QueryEverything

func QueryEverything(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (
	int, int, int64, models.FileSlice, error,
)

QueryEverything returns a slice of all the records, "Everything".

func Routes

func Routes(e *echo.Echo, db *sql.DB, logger *zap.SugaredLogger) *echo.Group

Routes for the /html3 sub-route group. Any errors are logged and rendered to the client using HTTP codes and the custom /html3, group errror template.

func Sorter

func Sorter(query string) map[string]string

Sorter creates the query string for the sortable columns. Replacing the O key value with the opposite value, either A or D.

func Sortings

func Sortings() map[Sort]string

Sortings are the name and order of columns that the records can be ordered by.

func TemplateFuncMap

func TemplateFuncMap(db *sql.DB, logger *zap.SugaredLogger) template.FuncMap

TemplateFuncMap are a collection of mapped functions that can be used in a template.

func Templates

func Templates(db *sql.DB, logger *zap.SugaredLogger, fs embed.FS) map[string]*template.Template

Templates returns a map of the templates used by the HTML3 sub-group route.

Types

type File

type File struct {
	Filename string // Filename of the file.
	Title    string // Title of the file.
	GroupBy  string // Group name that's is credited with the file.
	Section  string // Section is a tag categorization.
	Platform string // Platform or operating system of the file.
	Size     int64  // Size of the file in bytes.
}

File record details.

func (File) Description

func (f File) Description() string

Description returns a HTML3 friendly file description.

func (File) FileLinkPad

func (f File) FileLinkPad(width int) string

FileLinkPad adds whitespace padding after the hyperlinked filename.

func (File) IsOS

func (f File) IsOS() bool

IsOS returns true if the platform matches Windows, macOS, Linux, MS-DOS or Java.

func (File) LeadFS

func (f File) LeadFS(width int) string

LeadFS formats the file size to the fixed-width length w value.

func (File) OS

func (f File) OS() string

OS returns the platform operating system description or an empty string for generic platforms and media.

type Navigate struct {
	Current  string // Current name of the active record query.
	QueryStr string // QueryStr to append to all pagination links.
	Limit    int    // Limit the number of records to return per query.
	Link1    int    // Link1 of the dynamic pagination.
	Link2    int    // Link2 of the dynamic pagination.
	Link3    int    // Link3 of the dynamic pagination.
	Page     int    // Page number of the current record query.
	PagePrev int    // PagePrev is the page number to the previous record query.
	PageNext int    // PageNext is the page number to the next record query.
	PageMax  int    // PageMax is the maximum and last page number of the record query.
}

Navigate handles offset and record limit pagination.

func Navi(limit, page int, maxPage uint, current, qs string) Navigate

Navi returns a populated Navigate struct for pagination.

type RecordsBy

type RecordsBy int

RecordsBy are the record groupings.

const (
	Everything RecordsBy = iota // Everything displays all records from the file table.
	BySection                   // BySection groups records by the section file table column.
	ByPlatform                  // BySection groups records by the platform file table column.
	ByGroup                     // ByGroup groups the records by the distinct, group_brand_for file table column.
	AsArt                       // AsArt group records as art.
	AsDocument                  // AsDocument group records as documents.
	AsSoftware                  // AsSoftware group records as software.
)

func (RecordsBy) Parent

func (t RecordsBy) Parent() string

Parent returns the parent route for the current route.

func (RecordsBy) String

func (t RecordsBy) String() string

RecordsBy are the record groupings.

type Sort

type Sort string

Sort is the display name of column that can be used to sort and order the records.

type Sugared

type Sugared struct {
	Log *zap.SugaredLogger
}

Sugared logger passthrough.

func (*Sugared) All

func (s *Sugared) All(c echo.Context, db *sql.DB) error

All method lists every release.

func (*Sugared) Art

func (s *Sugared) Art(c echo.Context, db *sql.DB) error

Art lists the file records described as art are digital + pixel art files.

func (*Sugared) Categories

func (s *Sugared) Categories(c echo.Context) error

Categories lists the names, descriptions and sums of the category (section) tags.

func (*Sugared) Category

func (s *Sugared) Category(c echo.Context, db *sql.DB) error

Category lists the file records associated with the category tag that is provided by the ID param in the URL.

func (*Sugared) Documents

func (s *Sugared) Documents(c echo.Context, db *sql.DB) error

Documents lists the file records described as document + text art files.

func (*Sugared) Group

func (s *Sugared) Group(c echo.Context, db *sql.DB) error

Group lists the file records associated with the group that is provided by the ID param in the URL.

func (*Sugared) Groups

func (s *Sugared) Groups(c echo.Context, db *sql.DB) error

Groups lists the names and sums of all the distinct scene groups.

func (*Sugared) Index

func (s *Sugared) Index(c echo.Context, db *sql.DB) error

Index method is the homepage of the /html3 sub-route.

func (*Sugared) List

func (s *Sugared) List(c echo.Context, db *sql.DB, tt RecordsBy) error

List all the records associated with the RecordsBy grouping.

func (*Sugared) Platform

func (s *Sugared) Platform(c echo.Context, db *sql.DB) error

Platform lists the file records associated with the platform tag that is provided by the ID param in the URL.

func (*Sugared) Platforms

func (s *Sugared) Platforms(c echo.Context) error

Platforms lists the names, descriptions and sums of the platform tags.

func (*Sugared) Software

func (s *Sugared) Software(c echo.Context, db *sql.DB) error

Software lists the file records described as software files.

type Templ

type Templ string // Template name

Directories

Path Synopsis
Package ext contains common filename extensions used by the file records.
Package ext contains common filename extensions used by the file records.

Jump to

Keyboard shortcuts

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