Documentation ¶
Overview ¶
Package gpage provides useful paging functionality for web pages.
Index ¶
- Constants
- type Page
- func (p *Page) FirstPage() string
- func (p *Page) GetContent(mode int) string
- func (p *Page) GetLink(page int, text, title string) string
- func (p *Page) GetUrl(page int) string
- func (p *Page) LastPage() string
- func (p *Page) NextPage() string
- func (p *Page) PageBar() string
- func (p *Page) PrevPage() string
- func (p *Page) SelectBar() string
Constants ¶
const ( // DefaultPageName defines the default page name. DefaultPageName = "page" // DefaultPagePlaceHolder defines the placeholder for the URL template. DefaultPagePlaceHolder = "{.page}" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Page ¶
type Page struct { TotalSize int // Total size. TotalPage int // Total page, which is automatically calculated. CurrentPage int // Current page number >= 1. UrlTemplate string // Custom url template for page url producing. LinkStyle string // CSS style name for HTML link tag `a`. SpanStyle string // CSS style name for HTML span tag `span`, which is used for first, current and last page tag. SelectStyle string // CSS style name for HTML select tag `select`. NextPageTag string // Tag name for next p. PrevPageTag string // Tag name for prev p. FirstPageTag string // Tag name for first p. LastPageTag string // Tag name for last p. PrevBarTag string // Tag string for prev bar. NextBarTag string // Tag string for next bar. PageBarNum int // Page bar number for displaying. AjaxActionName string // Ajax function name. Ajax is enabled if this attribute is not empty. }
Page is the pagination implementer. All the attributes are public, you can change them when necessary.
func New ¶
New creates and returns a pagination manager. Note that the parameter `urlTemplate` specifies the URL producing template, like: /user/list/{.page}, /user/list/{.page}.html, /user/list?page={.page}&type=1, etc. The build-in variable in `urlTemplate` "{.page}" specifies the page number, which will be replaced by certain page number when producing.
func (*Page) GetContent ¶
GetContent returns the page content for predefined mode. These predefined contents are mainly for Chinese localization purposes.You can define your own page function to retrieve the page content according to the implementation of this function.
func (*Page) GetUrl ¶
GetUrl parses the UrlTemplate with given page number and returns the URL string. The UrlTemplate attribute can be a URL or URI string containing the "{.page}" placeholder, which will be replaced by the actual page number.