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 ( PAGE_NAME = "page" // PAGE_NAME defines the default page name. PAGE_PLACE_HOLDER = "{.page}" // PAGE_PLACE_HOLDER defines the place holder for the url template. )
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 purpose. You can defines your own page function retrieving 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. Note that the UrlTemplate attribute can be either an URL or a URI string with "{.page}" place holder specifying the page number position.