Merge branch 'feature/wiki' into develop
This commit is contained in:
commit
dcb391d341
54 changed files with 1526 additions and 2544 deletions
|
@ -237,3 +237,22 @@ type EditReleaseForm struct {
|
|||
func (f *EditReleaseForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||
}
|
||||
|
||||
// __ __.__ __ .__
|
||||
// / \ / \__| | _|__|
|
||||
// \ \/\/ / | |/ / |
|
||||
// \ /| | <| |
|
||||
// \__/\ / |__|__|_ \__|
|
||||
// \/ \/
|
||||
|
||||
type NewWikiForm struct {
|
||||
OldTitle string
|
||||
Title string `binding:"Required"`
|
||||
Content string `binding:"Required"`
|
||||
Message string
|
||||
}
|
||||
|
||||
// FIXME: use code generation to generate this method.
|
||||
func (f *NewWikiForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||
return validate(errs, ctx.Data, f, ctx.Locale)
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -59,7 +59,7 @@ type Context struct {
|
|||
IsSigned bool
|
||||
IsBasicAuth bool
|
||||
|
||||
Repo RepoContext
|
||||
Repo *RepoContext
|
||||
|
||||
Org struct {
|
||||
IsOwner bool
|
||||
|
@ -73,17 +73,22 @@ type Context struct {
|
|||
}
|
||||
|
||||
// IsOwner returns true if current user is the owner of repository.
|
||||
func (r RepoContext) IsOwner() bool {
|
||||
func (r *RepoContext) IsOwner() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_OWNER
|
||||
}
|
||||
|
||||
// IsAdmin returns true if current user has admin or higher access of repository.
|
||||
func (r RepoContext) IsAdmin() bool {
|
||||
func (r *RepoContext) IsAdmin() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_ADMIN
|
||||
}
|
||||
|
||||
// IsPusher returns true if current user has write or higher access of repository.
|
||||
func (r *RepoContext) IsPusher() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_WRITE
|
||||
}
|
||||
|
||||
// Return if the current user has read access for this repository
|
||||
func (r RepoContext) HasAccess() bool {
|
||||
func (r *RepoContext) HasAccess() bool {
|
||||
return r.AccessMode >= models.ACCESS_MODE_READ
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ package middleware
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
|
@ -223,8 +222,10 @@ func RetrieveBaseRepo(ctx *Context, repo *models.Repository) {
|
|||
}
|
||||
}
|
||||
|
||||
func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
||||
func RepoAssignment(args ...bool) macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
ctx.Repo = &RepoContext{}
|
||||
|
||||
var (
|
||||
displayBare bool // To display bare page if it is a bare repo.
|
||||
)
|
||||
|
@ -311,11 +312,7 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||
return
|
||||
}
|
||||
ctx.Repo.GitRepo = gitRepo
|
||||
ctx.Repo.RepoLink, err = repo.RepoLink()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "RepoLink", err)
|
||||
return
|
||||
}
|
||||
ctx.Repo.RepoLink = repo.RepoLink()
|
||||
ctx.Data["RepoLink"] = ctx.Repo.RepoLink
|
||||
ctx.Data["RepoRelPath"] = ctx.Repo.Owner.Name + "/" + ctx.Repo.Repository.Name
|
||||
|
||||
|
@ -339,14 +336,11 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||
ctx.Data["Owner"] = ctx.Repo.Repository.Owner
|
||||
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner()
|
||||
ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin()
|
||||
ctx.Data["IsRepositoryPusher"] = ctx.Repo.IsPusher()
|
||||
|
||||
ctx.Data["DisableSSH"] = setting.DisableSSH
|
||||
ctx.Repo.CloneLink, err = repo.CloneLink()
|
||||
if err != nil {
|
||||
ctx.Handle(500, "CloneLink", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["CloneLink"] = ctx.Repo.CloneLink
|
||||
ctx.Data["CloneLink"] = repo.CloneLink()
|
||||
ctx.Data["WikiCloneLink"] = repo.WikiCloneLink()
|
||||
|
||||
if ctx.IsSigned {
|
||||
ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.ID)
|
||||
|
@ -401,11 +395,15 @@ func RepoAssignment(redirect bool, args ...bool) macaron.Handler {
|
|||
func RequireRepoAdmin() macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
if !ctx.Repo.IsAdmin() {
|
||||
if !ctx.IsSigned {
|
||||
ctx.SetCookie("redirect_to", "/"+url.QueryEscape(setting.AppSubUrl+ctx.Req.RequestURI), 0, setting.AppSubUrl)
|
||||
ctx.Redirect(setting.AppSubUrl + "/user/login")
|
||||
return
|
||||
}
|
||||
ctx.Handle(404, ctx.Req.RequestURI, nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func RequireRepoPusher() macaron.Handler {
|
||||
return func(ctx *Context) {
|
||||
if !ctx.Repo.IsPusher() {
|
||||
ctx.Handle(404, ctx.Req.RequestURI, nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ func Remove(pid int64) {
|
|||
func Kill(pid int64) error {
|
||||
for i, proc := range Processes {
|
||||
if proc.Pid == pid {
|
||||
if proc.Cmd.Process != nil && proc.Cmd.ProcessState != nil && !proc.Cmd.ProcessState.Exited() {
|
||||
if proc.Cmd != nil && proc.Cmd.Process != nil &&
|
||||
proc.Cmd.ProcessState != nil && !proc.Cmd.ProcessState.Exited() {
|
||||
if err := proc.Cmd.Process.Kill(); err != nil {
|
||||
return fmt.Errorf("fail to kill process(%d/%s): %v", proc.Pid, proc.Description, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue