page

package
v0.0.0-...-b34ddb9 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TnameError      = `error.html`
	TnameNotFound   = `notfound.html`
	TnameClasslist  = `classlist.html`
	TnameBbsIndex   = `bbsindex.html`
	TnameBbsArticle = `bbsarticle.html`
	TnameAskOver18  = `askover18.html`
	TnameManIndex   = `manindex.html`
	TnameManArticle = `manarticle.html`
	TnameCaptcha    = `captcha.html`

	TnameLayout = `layout.html`
	TnameCommon = `common.html`
)

Variables

This section is empty.

Functions

func ExecutePage

func ExecutePage(w http.ResponseWriter, p Page) error

func ExecuteTemplate

func ExecuteTemplate(w http.ResponseWriter, name string, arg interface{}) error

func LoadTemplates

func LoadTemplates(dir string, funcMap template.FuncMap) error

func WriteAjaxResp

func WriteAjaxResp(w http.ResponseWriter, obj interface{}) error

Types

type ArticlePollResp

type ArticlePollResp struct {
	ContentHtml string `json:"contentHtml"`
	PollUrl     string `json:"pollUrl"`
	Success     bool   `json:"success"`
}

type AskOver18

type AskOver18 struct {
	From string
}

func (AskOver18) TemplateName

func (AskOver18) TemplateName() string

type BbsArticle

type BbsArticle struct {
	Title            string
	Description      string
	Board            *pttbbs.Board
	FileName         string
	Content          template.HTML
	ContentTail      template.HTML
	ContentTruncated bool
	PollUrl          string
	LongPollUrl      string
	CurrOffset       int
}

func (BbsArticle) TemplateName

func (BbsArticle) TemplateName() string

type BbsIndex

type BbsIndex struct {
	Board pttbbs.Board
	Query string

	FirstPage string
	PrevPage  string
	NextPage  string
	LastPage  string

	Articles []pttbbs.Article
	Bottoms  []pttbbs.Article

	IsValid bool
}

func (BbsIndex) TemplateName

func (BbsIndex) TemplateName() string

type Captcha

type Captcha struct {
	// Handle is the opaque handle for getting the verification key from
	// database.
	Handle string

	// VerificationKey will be non-empty if the page should display the
	// verification key. Otherwise, it should display the captcha.
	VerificationKey string

	// InternalErrMessage signals an error, and some error texts should be
	// shown to user.
	InternalErrMessage string

	// CaptchaErr signals types of errors.
	CaptchaErr CaptchaErr

	// RecaptchaSiteKey is the recaptcha site key.
	RecaptchaSiteKey string

	// PostAction is the url to post response to.
	PostAction string
}

func (Captcha) TemplateName

func (Captcha) TemplateName() string

type CaptchaErr

type CaptchaErr struct {
	IsVerifyFailed bool
	IsNotFound     bool
}

type Classlist

type Classlist struct {
	Boards         []pttbbs.Board
	IsHotboardList bool
}

func (Classlist) TemplateName

func (Classlist) TemplateName() string

type Context

type Context interface {
	Request() *http.Request
}

type Error

type Error struct {
	Title       string
	ContentHtml string
}

func (Error) TemplateName

func (Error) TemplateName() string

type ErrorWrapper

type ErrorWrapper func(Context, http.ResponseWriter) error

func (ErrorWrapper) ServeHTTP

func (fn ErrorWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ManArticle

type ManArticle struct {
	Title            string
	Description      string
	Board            *pttbbs.Board
	Path             string
	Content          template.HTML
	ContentTail      template.HTML
	ContentTruncated bool
}

func (ManArticle) TemplateName

func (ManArticle) TemplateName() string

type ManIndex

type ManIndex struct {
	Board   pttbbs.Board
	Path    string
	Entries []*manpb.Entry
}

func (ManIndex) TemplateName

func (ManIndex) TemplateName() string

type NeedToWriteHeaders

type NeedToWriteHeaders interface {
	WriteHeaders(w http.ResponseWriter) error
}

type NoContent

type NoContent struct{}

func (NoContent) TemplateName

func (NoContent) TemplateName() string

type NotFound

type NotFound struct{}

func (NotFound) TemplateName

func (NotFound) TemplateName() string

func (*NotFound) WriteHeaders

func (p *NotFound) WriteHeaders(w http.ResponseWriter) error

type NotFoundError

type NotFoundError struct {
	NotFound
	UnderlyingErr error
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Page

type Page interface {
	TemplateName() string
}

type Redirect

type Redirect struct {
	NoContent
	To string
}

func NewRedirect

func NewRedirect(to string) *Redirect

func (*Redirect) WriteHeaders

func (p *Redirect) WriteHeaders(w http.ResponseWriter) error

type TemplateMap

type TemplateMap map[string]*template.Template

Jump to

Keyboard shortcuts

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