context

package
v0.11.43 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2018 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const DOC_URL = "https://github.com/gogits/go-gogs-client/wiki"

FIXME: move to github.com/gogits/go-gogs-client

Variables

This section is empty.

Functions

func APIContexter

func APIContexter() macaron.Handler

func Contexter

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

func GitHookService

func GitHookService() macaron.Handler

GitHookService checks if repository Git hooks service has been enabled.

func HandleOrgAssignment

func HandleOrgAssignment(c *Context, args ...bool)

func OrgAssignment

func OrgAssignment(args ...bool) macaron.Handler

func RepoAssignment

func RepoAssignment(pages ...bool) macaron.Handler

[0]: issues, [1]: wiki

func RepoRef

func RepoRef() macaron.Handler

RepoRef handles repository reference name including those contain `/`.

func RequireRepoAdmin

func RequireRepoAdmin() macaron.Handler

func RequireRepoWriter

func RequireRepoWriter() macaron.Handler

func Toggle

func Toggle(options *ToggleOptions) macaron.Handler

Types

type APIContext

type APIContext struct {
	*Context
	Org *APIOrganization
}

func (*APIContext) Error

func (c *APIContext) Error(status int, title string, obj interface{})

Error responses error message to client with given message. If status is 500, also it prints error to log.

func (*APIContext) SetLinkHeader

func (c *APIContext) SetLinkHeader(total, pageSize int)

SetLinkHeader sets pagination link header by given totol number and page size.

type APIOrganization

type APIOrganization struct {
	Organization *models.User
	Team         *models.Team
}

type Context

type Context struct {
	*macaron.Context
	Cache cache.Cache

	Flash   *session.Flash
	Session session.Store

	Link        string // Current request URL
	User        *models.User
	IsLogged    bool
	IsBasicAuth bool

	Repo *Repository
	Org  *Organization
	// contains filtered or unexported fields
}

Context represents context of a request.

func (*Context) FormErr added in v0.11.19

func (c *Context) FormErr(names ...string)

FormErr sets "Err_xxx" field in template data.

func (*Context) GetErrMsg

func (c *Context) GetErrMsg() string

func (*Context) HTML

func (c *Context) HTML(status int, name string)

HTML responses template with given status.

func (*Context) Handle

func (c *Context) Handle(status int, title string, err error)

Handle handles and logs error by given status.

func (*Context) HandleText

func (c *Context) HandleText(status int, title string)

func (*Context) HasApiError

func (c *Context) HasApiError() bool

HasError returns true if error occurs in form validation.

func (*Context) HasError

func (c *Context) HasError() bool

HasError returns true if error occurs in form validation.

func (*Context) HasValue

func (c *Context) HasValue(name string) bool

HasValue returns true if value of given name exists.

func (*Context) JSONSuccess added in v0.11.19

func (c *Context) JSONSuccess(data interface{})

JSONSuccess responses JSON with status http.StatusOK.

func (*Context) NotFound

func (c *Context) NotFound()

NotFound renders the 404 page.

func (*Context) NotFoundOrServerError

func (c *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)

NotFoundOrServerError use error check function to determine if the error is about not found. It responses with 404 status code for not found error, or error context description for logging purpose of 500 server error.

func (*Context) PageIs added in v0.11.19

func (c *Context) PageIs(name string)

PageIs sets "PageIsxxx" field in template data.

func (*Context) RenderWithErr

func (c *Context) RenderWithErr(msg, tpl string, f interface{})

RenderWithErr used for page has form validation but need to prompt error to users.

func (*Context) Require added in v0.11.19

func (c *Context) Require(name string)

Require sets "Requirexxx" field in template data.

func (*Context) RequireHighlightJS added in v0.11.19

func (c *Context) RequireHighlightJS()

func (*Context) RequireSimpleMDE added in v0.11.19

func (c *Context) RequireSimpleMDE()

func (*Context) ServeContent

func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})

func (*Context) ServerError

func (c *Context) ServerError(title string, err error)

ServerError renders the 500 page.

func (*Context) SubURLRedirect added in v0.11.19

func (c *Context) SubURLRedirect(location string, status ...int)

SubURLRedirect responses redirection wtih given location and status. It prepends setting.AppSubURL to the location string.

func (*Context) Success

func (c *Context) Success(name string)

Success responses template with status http.StatusOK.

func (*Context) Title added in v0.11.19

func (c *Context) Title(locale string)

Title sets "Title" field in template data.

func (*Context) UserID

func (c *Context) UserID() int64

UserID returns ID of current logged in user. It returns 0 if visitor is anonymous.

type Organization

type Organization struct {
	IsOwner      bool
	IsMember     bool
	IsTeamMember bool // Is member of team.
	IsTeamAdmin  bool // In owner team or team that has admin permission level.
	Organization *models.User
	OrgLink      string

	Team *models.Team
}

type PullRequest

type PullRequest struct {
	BaseRepo *models.Repository
	Allowed  bool
	SameRepo bool
	HeadInfo string // [<user>:]<branch>
}

type Repository

type Repository struct {
	AccessMode   models.AccessMode
	IsWatching   bool
	IsViewBranch bool
	IsViewTag    bool
	IsViewCommit bool
	Repository   *models.Repository
	Owner        *models.User
	Commit       *git.Commit
	Tag          *git.Tag
	GitRepo      *git.Repository
	BranchName   string
	TagName      string
	TreePath     string
	CommitID     string
	RepoLink     string
	CloneLink    models.CloneLink
	CommitsCount int64
	Mirror       *models.Mirror

	PullRequest *PullRequest
}

func (*Repository) CanEnableEditor

func (r *Repository) CanEnableEditor() bool

CanEnableEditor returns true if repository is editable and user has proper access level.

func (*Repository) GetEditorconfig

func (r *Repository) GetEditorconfig() (*editorconfig.Editorconfig, error)

GetEditorconfig returns the .editorconfig definition if found in the HEAD of the default repo branch.

func (*Repository) HasAccess

func (r *Repository) HasAccess() bool

HasAccess returns true if the current user has at least read access for this repository

func (*Repository) IsAdmin

func (r *Repository) IsAdmin() bool

IsAdmin returns true if current user has admin or higher access of repository.

func (*Repository) IsOwner

func (r *Repository) IsOwner() bool

IsOwner returns true if current user is the owner of repository.

func (*Repository) IsWriter

func (r *Repository) IsWriter() bool

IsWriter returns true if current user has write or higher access of repository.

func (*Repository) PullRequestURL

func (r *Repository) PullRequestURL(baseBranch, headBranch string) string

PullRequestURL returns URL for composing a pull request. This function does not check if the repository can actually compose a pull request.

type ToggleOptions

type ToggleOptions struct {
	SignInRequired  bool
	SignOutRequired bool
	AdminRequired   bool
	DisableCSRF     bool
}

Jump to

Keyboard shortcuts

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