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
- Variables
- func Clauses(query string) html3.Order
- func Description(section, platform, brand, title null.String) string
- func Error(c echo.Context, err error) error
- func FileHref(logger *zap.SugaredLogger, id int64) string
- func FileLinkPad(width int, name null.String) string
- func Filename(width int, name null.String) string
- func GlobTo(name string) string
- func ID(c echo.Context) string
- func LeadFS(width int, size null.Int64) string
- func LeadFSInt(width, size int) string
- func LeadInt(width, i int) string
- func Leading(count int) string
- func ListInfo(tt RecordsBy, current, id string) (string, string)
- func Pagi(page int, maxPage uint) (int, int, int)
- func Query(c echo.Context, db *sql.DB, tt RecordsBy, offset int) (int, int, int64, models.FileSlice, error)
- func QueryAsArt(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (int, int, int64, models.FileSlice, error)
- func QueryAsDocument(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (int, int, int64, models.FileSlice, error)
- func QueryAsSoftware(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (int, int, int64, models.FileSlice, error)
- func QueryByGroup(ctx context.Context, exec boil.ContextExecutor, c echo.Context) (int, int, int64, models.FileSlice, error)
- func QueryByPlatform(ctx context.Context, exec boil.ContextExecutor, c echo.Context, offset int) (int, int, int64, models.FileSlice, error)
- func QueryBySection(ctx context.Context, exec boil.ContextExecutor, c echo.Context, offset int) (int, int, int64, models.FileSlice, error)
- func QueryEverything(ctx context.Context, exec boil.ContextExecutor, clause string, offset int) (int, int, int64, models.FileSlice, error)
- func Routes(e *echo.Echo, db *sql.DB, logger *zap.SugaredLogger) *echo.Group
- func Sorter(query string) map[string]string
- func Sortings() map[Sort]string
- func TemplateFuncMap(db *sql.DB, logger *zap.SugaredLogger) template.FuncMap
- func Templates(db *sql.DB, logger *zap.SugaredLogger, fs embed.FS) map[string]*template.Template
- type File
- type Navigate
- type RecordsBy
- type Sort
- type Sugared
- func (s *Sugared) All(c echo.Context, db *sql.DB) error
- func (s *Sugared) Art(c echo.Context, db *sql.DB) error
- func (s *Sugared) Categories(c echo.Context) error
- func (s *Sugared) Category(c echo.Context, db *sql.DB) error
- func (s *Sugared) Documents(c echo.Context, db *sql.DB) error
- func (s *Sugared) Group(c echo.Context, db *sql.DB) error
- func (s *Sugared) Groups(c echo.Context, db *sql.DB) error
- func (s *Sugared) Index(c echo.Context, db *sql.DB) error
- func (s *Sugared) List(c echo.Context, db *sql.DB, tt RecordsBy) error
- func (s *Sugared) Platform(c echo.Context, db *sql.DB) error
- func (s *Sugared) Platforms(c echo.Context) error
- func (s *Sugared) Software(c echo.Context, db *sql.DB) error
- type Templ
Constants ¶
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.
const Prefix = "/html3"
Prefix is the root path of the HTML3 router group.
Variables ¶
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 Description ¶
func Description(section, platform, brand, title null.String) string
Description returns a HTML3 friendly file description.
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 ¶
FileLinkPad adds whitespace padding after the hyperlinked filename.
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 LeadInt ¶
LeadInt takes an int and returns it as a string, w characters wide with whitespace padding.
func Pagi ¶
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 ¶
Sorter creates the query string for the sortable columns. Replacing the O key value with the opposite value, either A or D.
func TemplateFuncMap ¶
TemplateFuncMap are a collection of mapped functions that can be used in a template.
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 ¶
Description returns a HTML3 friendly file description.
func (File) FileLinkPad ¶
FileLinkPad adds whitespace padding after the hyperlinked filename.
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. )
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) Categories ¶
Categories lists the names, descriptions and sums of the category (section) tags.
func (*Sugared) Category ¶
Category lists the file records associated with the category tag that is provided by the ID param in the URL.
func (*Sugared) Documents ¶
Documents lists the file records described as document + text art files.
func (*Sugared) Group ¶
Group lists the file records associated with the group that is provided by the ID param in the URL.
func (*Sugared) Platform ¶
Platform lists the file records associated with the platform tag that is provided by the ID param in the URL.