resources

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.

Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.

Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.

Copyright (c) 2024 Eli Janssen Use of this source code is governed by an MIT-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateMaxPageNum

func CalculateMaxPageNum(size, step int) int

func FileServer

func FileServer(fsys fs.FS, stripPrefix string) http.HandlerFunc

func NewStaticFS

func NewStaticFS(loc Location) fs.FS

func ServeSingle

func ServeSingle(fsys fs.FS, filePath string) http.HandlerFunc

Types

type Location

type Location int
const (
	Embed      Location = 1
	Filesystem Location = 2
)

type Page

type Page struct {
	IsCurrent bool
	// contains filtered or unexported fields
}

func (*Page) String

func (p *Page) String() string

type PaginationResult

type PaginationResult struct {
	Pages   []*Page
	Start   int
	Stop    int
	Size    int
	HasPrev bool
	HasNext bool
}

type Paginator

type Paginator struct {
	Pages     [][]int
	ShowNear  int
	ShowStart int
	ShowEnd   int
}

func NewPaginator

func NewPaginator(showNear, showStart, showEnd int) *Paginator

func (*Paginator) AddPage

func (p *Paginator) AddPage(start, end int) *Paginator

func (*Paginator) AddPages

func (p *Paginator) AddPages(size, step int) *Paginator

func (*Paginator) Paginate

func (p *Paginator) Paginate(current int) []*Page

type PgInput

type PgInput struct {
	// baseurl to work around some funky issues with browser pushstate
	BaseUrl    string
	ExtraQargs template.URL
	Max        int
	Step       int
	Current    int
}

func NewPgInput

func NewPgInput(max, step, current int, baseUrl string, extraQargs url.Values) *PgInput

type TContainer

type TContainer struct {
	// contains filtered or unexported fields
}

func ParseTemplates

func ParseTemplates(loc Location) (*TContainer, error)

func (*TContainer) Get

func (tc *TContainer) Get(name string) (TExecuter, error)

type TExecuter

type TExecuter interface {
	Execute(wr io.Writer, data any) error
	ExecuteTemplate(io.Writer, string, any) error
}

type TGetter

type TGetter interface {
	Get(string) (TExecuter, error)
}

type TemplateMap

type TemplateMap map[string]TExecuter

func (*TemplateMap) Get

func (tm *TemplateMap) Get(name string) (TExecuter, error)

Jump to

Keyboard shortcuts

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