mirror of https://github.com/go-gitea/gitea.git
Merge branch 'master' of github.com:shxsun/gogs
This commit is contained in:
commit
6e972afb15
|
@ -4,4 +4,5 @@ filesets:
|
|||
- public
|
||||
- conf
|
||||
- LICENSE
|
||||
- README.md
|
||||
- README.md
|
||||
- README_ZH.md
|
|
@ -1,49 +1,31 @@
|
|||
# Contributing to Gogs
|
||||
|
||||
Want to hack on Gogs? Awesome! Here are instructions to get you
|
||||
started. They are probably not perfect, please let us know if anything
|
||||
feels wrong or incomplete.
|
||||
> Thanks [drone](https://github.com/drone/drone) because this guidelines sheet is forked from its [CONTRIBUTING.md](https://github.com/drone/drone/blob/master/CONTRIBUTING.md).
|
||||
|
||||
**This document is pre^3 release, we're not ready for receiving contribution until v0.5.0 release.**
|
||||
|
||||
Want to hack on Gogs? Awesome! Here are instructions to get you started. They are probably not perfect, please let us know if anything feels wrong or incomplete.
|
||||
|
||||
## Contribution guidelines
|
||||
|
||||
### Pull requests are always welcome
|
||||
|
||||
We are always thrilled to receive pull requests, and do our best to
|
||||
process them as fast as possible. Not sure if that typo is worth a pull
|
||||
request? Do it! We will appreciate it.
|
||||
We are always thrilled to receive pull requests, and do our best to process them as fast as possible. Not sure if that typo is worth a pull request? Do it! We will appreciate it.
|
||||
|
||||
If your pull request is not accepted on the first try, don't be
|
||||
discouraged! If there's a problem with the implementation, hopefully you
|
||||
received feedback on what to improve.
|
||||
If your pull request is not accepted on the first try, don't be discouraged! If there's a problem with the implementation, hopefully you received feedback on what to improve.
|
||||
|
||||
We're trying very hard to keep Gogs lean and focused. We don't want it
|
||||
to do everything for everybody. This means that we might decide against
|
||||
incorporating a new feature.
|
||||
We're trying very hard to keep Gogs lean and focused. We don't want it to do everything for everybody. This means that we might decide against incorporating a new feature.
|
||||
|
||||
### Discuss your design on the mailing list
|
||||
|
||||
We recommend discussing your plans [on the mailing
|
||||
list](https://groups.google.com/forum/#!forum/gogits)
|
||||
before starting to code - especially for more ambitious contributions.
|
||||
This gives other contributors a chance to point you in the right
|
||||
direction, give feedback on your design, and maybe point out if someone
|
||||
else is working on the same thing.
|
||||
We recommend discussing your plans [on the mailing list](https://groups.google.com/forum/#!forum/gogits) before starting to code - especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give feedback on your design, and maybe point out if someone else is working on the same thing.
|
||||
|
||||
We may close your pull request if not first discussed on the mailing
|
||||
list. We aren't doing this to be jerks. We are doing this to prevent
|
||||
people from spending large amounts of time on changes that may need
|
||||
to be designed or architected in a specific way, or may not align with
|
||||
the vision of the project.
|
||||
We may close your pull request if not first discussed on the mailing list. We aren't doing this to be jerks. We are doing this to prevent people from spending large amounts of time on changes that may need to be designed or architected in a specific way, or may not align with the vision of the project.
|
||||
|
||||
### Create issues...
|
||||
|
||||
Any significant improvement should be documented as [a GitHub
|
||||
issue](https://github.com/gogits/gogs/issues) before anybody
|
||||
starts working on it.
|
||||
Any significant improvement should be documented as [a GitHub issue](https://github.com/gogits/gogs/issues) before anybody starts working on it.
|
||||
|
||||
### ...but check for existing issues first!
|
||||
|
||||
Please take a moment to check that an issue doesn't already exist
|
||||
documenting your bug report or improvement proposal. If it does, it
|
||||
never hurts to add a quick "+1" or "I have this problem too". This will
|
||||
help prioritize the most common problems and requests.
|
||||
Please take a moment to check that an issue doesn't already exist documenting your bug report or improvement proposal. If it does, it never hurts to add a quick "+1" or "I have this problem too". This will help prioritize the most common problems and requests.
|
|
@ -1,4 +1,4 @@
|
|||
Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gogits/gogs/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
||||
Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest)
|
||||
=====================
|
||||
|
||||
Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language.
|
||||
|
@ -48,9 +48,11 @@ There are two ways to install Gogs:
|
|||
|
||||
## Acknowledgments
|
||||
|
||||
- Logo is inspired by [martini](https://github.com/martini-contrib).
|
||||
- Logo is inspired by [martini-contrib](https://github.com/martini-contrib).
|
||||
- Router and middleware mechanism of [martini](http://martini.codegangsta.io/).
|
||||
- Mail Service, modules design is inspired by [WeTalk](https://github.com/beego/wetalk).
|
||||
- System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog).
|
||||
- Usage and modification from [beego](http://beego.me) modules.
|
||||
|
||||
## Contributors
|
||||
|
||||
|
|
10
README_ZH.md
10
README_ZH.md
|
@ -1,4 +1,4 @@
|
|||
Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest) [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/gogits/gogs/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
||||
Gogs - Go Git Service [![wercker status](https://app.wercker.com/status/ad0bdb0bc450ac6f09bc56b9640a50aa/s/ "wercker status")](https://app.wercker.com/project/bykey/ad0bdb0bc450ac6f09bc56b9640a50aa) [![Build Status](https://drone.io/github.com/gogits/gogs/status.png)](https://drone.io/github.com/gogits/gogs/latest)
|
||||
=====================
|
||||
|
||||
Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
|
||||
|
@ -44,9 +44,11 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
|
|||
|
||||
## 特别鸣谢
|
||||
|
||||
- Logo 基于 [martini](https://github.com/martini-contrib) 修改而来。
|
||||
- 邮件服务、模块设计基于 [WeTalk](https://github.com/beego/wetalk) 修改而来。
|
||||
- 系统监视状态基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改而来。
|
||||
- Logo 基于 [martini-contrib](https://github.com/martini-contrib) 修改而来。
|
||||
- 基于 [WeTalk](https://github.com/beego/wetalk) 修改的邮件服务和模块设计。
|
||||
- 基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改的系统监视状态。
|
||||
- [beego](http://beego.me) 模块的使用与修改。
|
||||
- [martini](http://martini.codegangsta.io/) 的路由与中间件机制。
|
||||
|
||||
## 贡献成员
|
||||
|
||||
|
|
|
@ -52,6 +52,8 @@ DISENABLE_REGISTERATION = false
|
|||
REQUIRE_SIGNIN_VIEW = false
|
||||
; Cache avatar as picture
|
||||
ENABLE_CACHE_AVATAR = false
|
||||
; Mail notification
|
||||
ENABLE_NOTIFY_MAIL = false
|
||||
|
||||
[mailer]
|
||||
ENABLED = false
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -20,7 +20,7 @@ import (
|
|||
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
|
||||
const go12tag = true
|
||||
|
||||
const APP_VER = "0.1.7.0323.1"
|
||||
const APP_VER = "0.1.7.0324"
|
||||
|
||||
func init() {
|
||||
base.AppVer = APP_VER
|
||||
|
|
|
@ -58,6 +58,7 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co
|
|||
Content: content,
|
||||
}
|
||||
_, err = orm.Insert(issue)
|
||||
// TODO: newIssueAction
|
||||
return issue, err
|
||||
}
|
||||
|
||||
|
@ -67,9 +68,9 @@ func GetIssueCount(repoId int64) (int64, error) {
|
|||
}
|
||||
|
||||
// GetIssueById returns issue object by given id.
|
||||
func GetIssueById(id int64) (*Issue, error) {
|
||||
issue := new(Issue)
|
||||
has, err := orm.Id(id).Get(issue)
|
||||
func GetIssueByIndex(repoId, index int64) (*Issue, error) {
|
||||
issue := &Issue{RepoId: repoId, Index: index}
|
||||
has, err := orm.Get(issue)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
|
@ -126,6 +127,18 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed,
|
|||
return issues, err
|
||||
}
|
||||
|
||||
// UpdateIssue updates information of issue.
|
||||
func UpdateIssue(issue *Issue) error {
|
||||
_, err := orm.Update(issue, &Issue{RepoId: issue.RepoId, Index: issue.Index})
|
||||
return err
|
||||
}
|
||||
|
||||
func CloseIssue() {
|
||||
}
|
||||
|
||||
func ReopenIssue() {
|
||||
}
|
||||
|
||||
// Label represents a list of labels of repository for issues.
|
||||
type Label struct {
|
||||
Id int64
|
||||
|
|
|
@ -387,7 +387,7 @@ func UpdateRepository(repo *Repository) error {
|
|||
repo.Website = repo.Website[:255]
|
||||
}
|
||||
|
||||
_, err := orm.Id(repo.Id).UseBool().Cols("description", "website").Update(repo)
|
||||
_, err := orm.Id(repo.Id).UseBool().Cols("description", "website", "updated").Update(repo)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,10 @@ func (user *User) HomeLink() string {
|
|||
|
||||
// AvatarLink returns the user gravatar link.
|
||||
func (user *User) AvatarLink() string {
|
||||
return "/avatar/" + user.Avatar
|
||||
if base.Service.EnableCacheAvatar {
|
||||
return "/avatar/" + user.Avatar
|
||||
}
|
||||
return "http://1.gravatar.com/avatar/" + user.Avatar
|
||||
}
|
||||
|
||||
// NewGitSig generates and returns the signature of given user.
|
||||
|
@ -208,7 +211,7 @@ func UpdateUser(user *User) (err error) {
|
|||
user.Website = user.Website[:255]
|
||||
}
|
||||
|
||||
_, err = orm.Id(user.Id).UseBool().Cols("website", "location", "is_active", "is_admin").Update(user)
|
||||
_, err = orm.Id(user.Id).UseBool().Cols("email", "passwd", "avatar", "avatar_email", "website", "location", "is_active", "is_admin", "updated").Update(user)
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
// for www.gravatar.com image cache
|
||||
|
||||
/*
|
||||
It is recommend to use this way
|
||||
|
||||
cacheDir := "./cache"
|
||||
defaultImg := "./default.jpg"
|
||||
http.Handle("/avatar/", avatar.HttpHandler(cacheDir, defaultImg))
|
||||
*/
|
||||
package avatar
|
||||
|
||||
import (
|
||||
|
@ -14,7 +22,6 @@ import (
|
|||
"image/jpeg"
|
||||
"image/png"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -23,6 +30,7 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/nfnt/resize"
|
||||
)
|
||||
|
||||
|
@ -30,12 +38,6 @@ var (
|
|||
gravatar = "http://www.gravatar.com/avatar"
|
||||
)
|
||||
|
||||
func debug(a ...interface{}) {
|
||||
if true {
|
||||
log.Println(a...)
|
||||
}
|
||||
}
|
||||
|
||||
// hash email to md5 string
|
||||
// keep this func in order to make this package indenpent
|
||||
func HashEmail(email string) string {
|
||||
|
@ -125,7 +127,7 @@ func (this *Avatar) UpdateTimeout(timeout time.Duration) error {
|
|||
var err error
|
||||
select {
|
||||
case <-time.After(timeout):
|
||||
err = errors.New("get gravatar image timeout")
|
||||
err = fmt.Errorf("get gravatar image %s timeout", this.Hash)
|
||||
case err = <-thunder.GoFetch(gravatar+"/"+this.Hash+"?"+this.reqParams,
|
||||
this.imagePath):
|
||||
}
|
||||
|
@ -150,16 +152,14 @@ func (this *avatarHandler) mustInt(r *http.Request, defaultValue int, keys ...st
|
|||
func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
urlPath := r.URL.Path
|
||||
hash := urlPath[strings.LastIndex(urlPath, "/")+1:]
|
||||
//hash = HashEmail(hash)
|
||||
size := this.mustInt(r, 80, "s", "size") // size = 80*80
|
||||
size := this.mustInt(r, 80, "s", "size") // default size = 80*80
|
||||
|
||||
avatar := New(hash, this.cacheDir)
|
||||
avatar.AlterImage = this.altImage
|
||||
if avatar.Expired() {
|
||||
err := avatar.UpdateTimeout(time.Millisecond * 500)
|
||||
if err != nil {
|
||||
debug(err)
|
||||
//log.Trace("avatar update error: %v", err)
|
||||
log.Trace("avatar update error: %v", err)
|
||||
}
|
||||
}
|
||||
if modtime, err := avatar.Modtime(); err == nil {
|
||||
|
@ -177,8 +177,7 @@ func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
w.Header().Set("Content-Type", "image/jpeg")
|
||||
err := avatar.Encode(w, size)
|
||||
if err != nil {
|
||||
//log.Warn("avatar encode error: %v", err) // will panic when err != nil
|
||||
debug(err)
|
||||
log.Warn("avatar encode error: %v", err)
|
||||
w.WriteHeader(500)
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +250,6 @@ func (this *thunderTask) Fetch() {
|
|||
var client = &http.Client{}
|
||||
|
||||
func (this *thunderTask) fetch() error {
|
||||
//log.Println("thunder, fetch", this.Url)
|
||||
req, _ := http.NewRequest("GET", this.Url, nil)
|
||||
req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
|
||||
req.Header.Set("Accept-Encoding", "gzip,deflate,sdch")
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
package avatar_test
|
||||
|
||||
import (
|
||||
"log"
|
||||
"errors"
|
||||
"os"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/gogits/gogs/modules/avatar"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
)
|
||||
|
||||
const TMPDIR = "test-avatar"
|
||||
|
@ -28,7 +29,7 @@ func TestFetchMany(t *testing.T) {
|
|||
os.Mkdir(TMPDIR, 0755)
|
||||
defer os.RemoveAll(TMPDIR)
|
||||
|
||||
log.Println("start")
|
||||
t.Log("start")
|
||||
var n = 5
|
||||
ch := make(chan bool, n)
|
||||
for i := 0; i < n; i++ {
|
||||
|
@ -36,14 +37,14 @@ func TestFetchMany(t *testing.T) {
|
|||
hash := avatar.HashEmail(strconv.Itoa(i) + "ssx205@gmail.com")
|
||||
a := avatar.New(hash, TMPDIR)
|
||||
a.Update()
|
||||
log.Println("finish", hash)
|
||||
t.Log("finish", hash)
|
||||
ch <- true
|
||||
}(i)
|
||||
}
|
||||
for i := 0; i < n; i++ {
|
||||
<-ch
|
||||
}
|
||||
log.Println("end")
|
||||
t.Log("end")
|
||||
}
|
||||
|
||||
// cat
|
||||
|
@ -54,3 +55,7 @@ func TestHttp(t *testing.T) {
|
|||
http.ListenAndServe(":8001", nil)
|
||||
}
|
||||
*/
|
||||
|
||||
func TestLogTrace(t *testing.T) {
|
||||
log.Trace("%v", errors.New("console log test"))
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ var Service struct {
|
|||
DisenableRegisteration bool
|
||||
RequireSignInView bool
|
||||
EnableCacheAvatar bool
|
||||
NotifyMail bool
|
||||
ActiveCodeLives int
|
||||
ResetPwdCodeLives int
|
||||
}
|
||||
|
@ -230,6 +231,17 @@ func newRegisterMailService() {
|
|||
log.Info("Register Mail Service Enabled")
|
||||
}
|
||||
|
||||
func newNotifyMailService() {
|
||||
if !Cfg.MustBool("service", "ENABLE_NOTIFY_MAIL") {
|
||||
return
|
||||
} else if MailService == nil {
|
||||
log.Warn("Notify Mail Service: Mail Service is not enabled")
|
||||
return
|
||||
}
|
||||
Service.NotifyMail = true
|
||||
log.Info("Notify Mail Service Enabled")
|
||||
}
|
||||
|
||||
func NewConfigContext() {
|
||||
var err error
|
||||
workDir, err := exeDir()
|
||||
|
@ -284,4 +296,5 @@ func NewServices() {
|
|||
newSessionService()
|
||||
newMailService()
|
||||
newRegisterMailService()
|
||||
newNotifyMailService()
|
||||
}
|
||||
|
|
|
@ -11,6 +11,11 @@ import (
|
|||
|
||||
var logger *logs.BeeLogger
|
||||
|
||||
func init() {
|
||||
logger = logs.NewLogger(10000)
|
||||
logger.SetLogger("console", `{"level": 0}`)
|
||||
}
|
||||
|
||||
func NewLogger(bufLen int64, mode, config string) {
|
||||
logger = logs.NewLogger(bufLen)
|
||||
logger.SetLogger(mode, config)
|
||||
|
@ -20,6 +25,10 @@ func Trace(format string, v ...interface{}) {
|
|||
logger.Trace(format, v...)
|
||||
}
|
||||
|
||||
func Debug(format string, v ...interface{}) {
|
||||
logger.Debug(format, v...)
|
||||
}
|
||||
|
||||
func Info(format string, v ...interface{}) {
|
||||
logger.Info(format, v...)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ type ToggleOptions struct {
|
|||
|
||||
func Toggle(options *ToggleOptions) martini.Handler {
|
||||
return func(ctx *Context) {
|
||||
if options.SignOutRequire && ctx.IsSigned {
|
||||
if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
|
||||
ctx.Redirect("/")
|
||||
return
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/codegangsta/martini"
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Branches(ctx *middleware.Context, params martini.Params) {
|
||||
if !ctx.Repo.IsValid {
|
||||
return
|
||||
}
|
||||
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Branches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "repo.Branches", nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
|
||||
if len(params["branchname"]) == 0 {
|
||||
params["branchname"] = "master"
|
||||
}
|
||||
ctx.Data["Branchname"] = params["branchname"]
|
||||
ctx.Data["Branches"] = brs
|
||||
ctx.Data["IsRepoToolbarBranches"] = true
|
||||
|
||||
ctx.HTML(200, "repo/branches")
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/codegangsta/martini"
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Commits(ctx *middleware.Context, params martini.Params) {
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Commits", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "repo.Commits", nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
commits, err := models.GetCommits(params["username"],
|
||||
params["reponame"], params["branchname"])
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Commits", nil)
|
||||
return
|
||||
}
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.HTML(200, "repo/commits")
|
||||
}
|
|
@ -31,6 +31,10 @@ func Issues(ctx *middleware.Context, params martini.Params) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(params["branchname"]) == 0 {
|
||||
params["branchname"] = "master"
|
||||
}
|
||||
ctx.Data["Branchname"] = params["branchname"]
|
||||
ctx.HTML(200, "repo/issues")
|
||||
}
|
||||
|
||||
|
@ -63,13 +67,13 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
}
|
||||
|
||||
func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
||||
issueid, err := base.StrTo(params["issueid"]).Int()
|
||||
index, err := base.StrTo(params["index"]).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.ViewIssue", err)
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := models.GetIssueById(int64(issueid))
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
ctx.Handle(404, "issue.ViewIssue", err)
|
||||
|
@ -83,3 +87,39 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.Data["Issue"] = issue
|
||||
ctx.HTML(200, "issue/view")
|
||||
}
|
||||
|
||||
func UpdateIssue(ctx *middleware.Context, params martini.Params, form auth.CreateIssueForm) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Handle(404, "issue.UpdateIssue", nil)
|
||||
return
|
||||
}
|
||||
|
||||
index, err := base.StrTo(params["index"]).Int()
|
||||
if err != nil {
|
||||
ctx.Handle(404, "issue.UpdateIssue", err)
|
||||
return
|
||||
}
|
||||
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
|
||||
if err != nil {
|
||||
if err == models.ErrIssueNotExist {
|
||||
ctx.Handle(404, "issue.UpdateIssue", err)
|
||||
} else {
|
||||
ctx.Handle(200, "issue.UpdateIssue", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
issue.Name = form.IssueName
|
||||
issue.MilestoneId = form.MilestoneId
|
||||
issue.AssigneeId = form.AssigneeId
|
||||
issue.Labels = form.Labels
|
||||
issue.Content = form.Content
|
||||
if err = models.UpdateIssue(issue); err != nil {
|
||||
ctx.Handle(200, "issue.UpdateIssue", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Title"] = issue.Name
|
||||
ctx.Data["Issue"] = issue
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/codegangsta/martini"
|
||||
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Pulls(ctx *middleware.Context, params martini.Params) {
|
||||
ctx.Data["IsRepoToolbarPulls"] = true
|
||||
if len(params["branchname"]) == 0 {
|
||||
params["branchname"] = "master"
|
||||
}
|
||||
|
||||
ctx.Data["Branchname"] = params["branchname"]
|
||||
ctx.HTML(200, "repo/pulls")
|
||||
}
|
|
@ -52,30 +52,6 @@ func Create(ctx *middleware.Context, form auth.CreateRepoForm) {
|
|||
ctx.Handle(200, "repo.Create", err)
|
||||
}
|
||||
|
||||
func Branches(ctx *middleware.Context, params martini.Params) {
|
||||
if !ctx.Repo.IsValid {
|
||||
return
|
||||
}
|
||||
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Branches", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "repo.Branches", nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
|
||||
ctx.Data["Branchname"] = brs[0]
|
||||
ctx.Data["Branches"] = brs
|
||||
ctx.Data["IsRepoToolbarBranches"] = true
|
||||
|
||||
ctx.HTML(200, "repo/branches")
|
||||
}
|
||||
|
||||
func Single(ctx *middleware.Context, params martini.Params) {
|
||||
if !ctx.Repo.IsValid {
|
||||
return
|
||||
|
@ -276,7 +252,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
|
|||
ctx.HTML(200, "repo/setting")
|
||||
}
|
||||
|
||||
func SettingPost(ctx *middleware.Context, params martini.Params) {
|
||||
func SettingPost(ctx *middleware.Context) {
|
||||
if !ctx.Repo.IsOwner {
|
||||
ctx.Error(404)
|
||||
return
|
||||
|
@ -310,35 +286,6 @@ func SettingPost(ctx *middleware.Context, params martini.Params) {
|
|||
}
|
||||
}
|
||||
|
||||
func Commits(ctx *middleware.Context, params martini.Params) {
|
||||
brs, err := models.GetBranches(params["username"], params["reponame"])
|
||||
if err != nil {
|
||||
ctx.Handle(200, "repo.Commits", err)
|
||||
return
|
||||
} else if len(brs) == 0 {
|
||||
ctx.Handle(404, "repo.Commits", nil)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Data["IsRepoToolbarCommits"] = true
|
||||
commits, err := models.GetCommits(params["username"],
|
||||
params["reponame"], params["branchname"])
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Commits", nil)
|
||||
return
|
||||
}
|
||||
ctx.Data["Username"] = params["username"]
|
||||
ctx.Data["Reponame"] = params["reponame"]
|
||||
ctx.Data["CommitCount"] = commits.Len()
|
||||
ctx.Data["Commits"] = commits
|
||||
ctx.HTML(200, "repo/commits")
|
||||
}
|
||||
|
||||
func Pulls(ctx *middleware.Context) {
|
||||
ctx.Data["IsRepoToolbarPulls"] = true
|
||||
ctx.HTML(200, "repo/pulls")
|
||||
}
|
||||
|
||||
func Action(ctx *middleware.Context, params martini.Params) {
|
||||
var err error
|
||||
switch params["action"] {
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<div><b>Register Email Confirmation:</b> <i class="fa fa{{if .Service.RegisterEmailConfirm}}-check{{end}}-square-o"></i></div>
|
||||
<div><b>Disenable Registeration:</b> <i class="fa fa{{if .Service.DisenableRegisteration}}-check{{end}}-square-o"></i></div>
|
||||
<div><b>Require Sign In View:</b> <i class="fa fa{{if .Service.RequireSignInView}}-check{{end}}-square-o"></i></div>
|
||||
<div><b>Mail Notification:</b> <i class="fa fa{{if .Service.NotifyMail}}-check{{end}}-square-o"></i></div>
|
||||
<div><b>Enable Cache Avatar:</b> <i class="fa fa{{if .Service.EnableCacheAvatar}}-check{{end}}-square-o"></i></div>
|
||||
<hr/>
|
||||
<div><b>Active Code Lives:</b> {{.Service.ActiveCodeLives}} minutes</div>
|
||||
|
|
|
@ -53,9 +53,9 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<!-- <div class="btn-group">
|
||||
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Star"><i class="fa fa-star"></i> {{.Repository.NumStars}}</button>
|
||||
</div>
|
||||
</div> -->
|
||||
{{end}}
|
||||
<div class="btn-group">
|
||||
<a type="button" {{if not .IsRepositoryOwner}}href="/{{.Username}}/{{.Reponame}}/fork"{{end}} class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Fork"><i class="fa fa-code-fork fa-lg"></i> {{.Repository.NumForks}}</a>
|
||||
|
|
|
@ -6,27 +6,27 @@
|
|||
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li>
|
||||
{{if not .IsBareRepo}}
|
||||
<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="/{{.RepositoryLink}}/commits/{{.Branchname}}">Commits</a></li>
|
||||
<li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li>
|
||||
<li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li>
|
||||
<!-- <li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="/{{.RepositoryLink}}/branches">Branches</a></li> -->
|
||||
<!-- <li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="/{{.RepositoryLink}}/pulls">Pull Requests</a></li> -->
|
||||
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="/{{.RepositoryLink}}/issues">Issues <!--<span class="badge">42</span>--></a></li>
|
||||
<li class="dropdown">
|
||||
<!-- <li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/{{.RepositoryLink}}/release">Release</a></li>
|
||||
<li><a href="//{{.RepositoryLink}}/wiki">Wiki</a></li>
|
||||
</ul>
|
||||
</li>{{end}}
|
||||
</li> -->{{end}}
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{{if not .IsBareRepo}}
|
||||
<li class="dropdown">
|
||||
<!-- <li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#">Graphic</a></li>
|
||||
<li><a href="#">Pulse</a></li>
|
||||
<li><a href="#">Network</a></li>
|
||||
</ul>
|
||||
</li>{{end}}{{if .IsRepositoryOwner}}
|
||||
</li> -->{{end}}{{if .IsRepositoryOwner}}
|
||||
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a>
|
||||
</li>{{end}}
|
||||
</ul>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<ul class="nav nav-pills pull-right">
|
||||
<li class="active"><a href="/">Feed</a></li>
|
||||
<li><a href="/issues">Issues</a></li>
|
||||
<li><a href="/pulls">Pull Requests</a></li>
|
||||
<li><a href="/stars">Stars</a></li>
|
||||
<!-- <li><a href="/pulls">Pull Requests</a></li>
|
||||
<li><a href="/stars">Stars</a></li> -->
|
||||
</ul>
|
||||
<h3>News Feed</h3>
|
||||
</div>
|
||||
|
@ -34,7 +34,7 @@
|
|||
<div class="panel-body">
|
||||
<ul class="list-group">{{range .MyRepos}}
|
||||
<li class="list-group-item"><a href="/{{$.SignedUserName}}/{{.Name}}">
|
||||
<span class="stars pull-right"><i class="fa fa-star"></i>{{.NumStars}}</span>
|
||||
<!-- <span class="stars pull-right"><i class="fa fa-star"></i>{{.NumStars}}</span> -->
|
||||
<i class="fa fa-book"></i>{{.Name}}</a>
|
||||
</li>{{end}}
|
||||
</ul>
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<ul class="nav nav-pills pull-right">
|
||||
<li><a href="/">Feed</a></li>
|
||||
<li class="active"><a href="/issues">Issues</a></li>
|
||||
<li><a href="/pulls">Pull Requests</a></li>
|
||||
<li><a href="/stars">Stars</a></li>
|
||||
<!-- <li><a href="/pulls">Pull Requests</a></li>
|
||||
<li><a href="/stars">Stars</a></li> -->
|
||||
</ul>
|
||||
<h3>Issues</h3>
|
||||
</div>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<ul class="list-unstyled repo-list">
|
||||
{{range .Repos}}
|
||||
<li>
|
||||
<div class="meta pull-right"><i class="fa fa-star"></i> {{.NumStars}} <i class="fa fa-code-fork"></i> {{.NumForks}}</div>
|
||||
<div class="meta pull-right"><!-- <i class="fa fa-star"></i> {{.NumStars}} --> <i class="fa fa-code-fork"></i> {{.NumForks}}</div>
|
||||
<h4>
|
||||
<a href="/{{$owner.Name}}/{{.LowerName}}">{{.LowerName}}</a>
|
||||
</h4>
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
<ul class="list-group">
|
||||
<li class="list-group-item{{if .IsUserPageSetting}} list-group-item-success{{end}}"><a href="/user/setting">Account Profile</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingPasswd}} list-group-item-success{{end}}"><a href="/user/setting/password">Password</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingNotify}} list-group-item-success{{end}}"><a href="/user/setting/notification">Notifications</a></li>
|
||||
<!-- <li class="list-group-item{{if .IsUserPageSettingNotify}} list-group-item-success{{end}}"><a href="/user/setting/notification">Notifications</a></li> -->
|
||||
<li class="list-group-item{{if .IsUserPageSettingSSH}} list-group-item-success{{end}}"><a href="/user/setting/ssh/">SSH Keys</a></li>
|
||||
<li class="list-group-item{{if .IsUserPageSettingSecurity}} list-group-item-success{{end}}"><a href="/user/setting/security">Security</a></li>
|
||||
<!-- <li class="list-group-item{{if .IsUserPageSettingSecurity}} list-group-item-success{{end}}"><a href="/user/setting/security">Security</a></li> -->
|
||||
<li class="list-group-item{{if .IsUserPageSettingDelete}} list-group-item-success{{end}}"><a href="/user/delete">Delete Account</a></li>
|
||||
</ul>
|
||||
</div>
|
10
web.go
10
web.go
|
@ -31,9 +31,10 @@ import (
|
|||
|
||||
var CmdWeb = cli.Command{
|
||||
Name: "web",
|
||||
Usage: "just run",
|
||||
Usage: "Gogs web server",
|
||||
Description: `
|
||||
gogs web`,
|
||||
gogs web server is the only thing you need to run,
|
||||
and it takes care of all the other things for you`,
|
||||
Action: runWeb,
|
||||
Flags: []cli.Flag{},
|
||||
}
|
||||
|
@ -88,7 +89,7 @@ func runWeb(*cli.Context) {
|
|||
reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true})
|
||||
|
||||
// Routers.
|
||||
m.Get("/", ignSignIn, routers.Home)
|
||||
m.Get("/", reqSignIn, routers.Home)
|
||||
m.Get("/issues", reqSignIn, user.Issues)
|
||||
m.Get("/pulls", reqSignIn, user.Pulls)
|
||||
m.Get("/stars", reqSignIn, user.Stars)
|
||||
|
@ -145,7 +146,8 @@ func runWeb(*cli.Context) {
|
|||
r.Get("/commits/:branchname", repo.Commits)
|
||||
r.Get("/issues", repo.Issues)
|
||||
r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue)
|
||||
r.Get("/issues/:issueid", repo.ViewIssue)
|
||||
r.Get("/issues/:index", repo.ViewIssue)
|
||||
r.Post("/issues/:index", binding.BindIgnErr(auth.CreateIssueForm{}), repo.UpdateIssue)
|
||||
r.Get("/pulls", repo.Pulls)
|
||||
r.Get("/branches", repo.Branches)
|
||||
r.Get("/src/:branchname", repo.Single)
|
||||
|
|
Loading…
Reference in New Issue