Merge branch 'master' of github.com:shxsun/gogs

tokarchuk/v1.17
skyblue 11 years ago
commit 6e972afb15
  1. 1
      .gobuild.yml
  2. 42
      CONTRIBUTING.md
  3. 6
      README.md
  4. 10
      README_ZH.md
  5. 2
      conf/app.ini
  6. 2
      gogs.go
  7. 19
      models/issue.go
  8. 2
      models/repo.go
  9. 7
      models/user.go
  10. 28
      modules/avatar/avatar.go
  11. 13
      modules/avatar/avatar_test.go
  12. 13
      modules/base/conf.go
  13. 9
      modules/log/log.go
  14. 2
      modules/middleware/auth.go
  15. 38
      routers/repo/branch.go
  16. 35
      routers/repo/commit.go
  17. 44
      routers/repo/issue.go
  18. 21
      routers/repo/pull.go
  19. 55
      routers/repo/repo.go
  20. 1
      templates/admin/config.tmpl
  21. 4
      templates/repo/nav.tmpl
  22. 12
      templates/repo/toolbar.tmpl
  23. 6
      templates/user/dashboard.tmpl
  24. 4
      templates/user/issues.tmpl
  25. 2
      templates/user/profile.tmpl
  26. 4
      templates/user/setting_nav.tmpl
  27. 10
      web.go

@ -5,3 +5,4 @@ filesets:
- conf - conf
- LICENSE - LICENSE
- README.md - README.md
- README_ZH.md

@ -1,49 +1,31 @@
# Contributing to Gogs # Contributing to Gogs
Want to hack on Gogs? Awesome! Here are instructions to get you > 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).
started. They are probably not perfect, please let us know if anything
feels wrong or incomplete. **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 ## Contribution guidelines
### Pull requests are always welcome ### Pull requests are always welcome
We are always thrilled to receive pull requests, and do our best to 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.
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 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.
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 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.
to do everything for everybody. This means that we might decide against
incorporating a new feature.
### Discuss your design on the mailing list ### Discuss your design on the mailing list
We recommend discussing your plans [on the mailing 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.
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 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.
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... ### Create issues...
Any significant improvement should be documented as [a GitHub Any significant improvement should be documented as [a GitHub issue](https://github.com/gogits/gogs/issues) before anybody starts working on it.
issue](https://github.com/gogits/gogs/issues) before anybody
starts working on it.
### ...but check for existing issues first! ### ...but check for existing issues first!
Please take a moment to check that an issue doesn't already exist 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.
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. 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 ## 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). - 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). - System Monitor Status is inspired by [GoBlog](https://github.com/fuxiaohei/goblog).
- Usage and modification from [beego](http://beego.me) modules.
## Contributors ## Contributors

@ -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 托管服务。 Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。
@ -44,9 +44,11 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依
## 特别鸣谢 ## 特别鸣谢
- Logo 基于 [martini](https://github.com/martini-contrib) 修改而来。 - Logo 基于 [martini-contrib](https://github.com/martini-contrib) 修改而来。
- 邮件服务、模块设计基于 [WeTalk](https://github.com/beego/wetalk) 修改而来。 - 基于 [WeTalk](https://github.com/beego/wetalk) 修改的邮件服务和模块设计。
- 系统监视状态基于 [GoBlog](https://github.com/fuxiaohei/goblog) 修改而来。 - 基于 [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 REQUIRE_SIGNIN_VIEW = false
; Cache avatar as picture ; Cache avatar as picture
ENABLE_CACHE_AVATAR = false ENABLE_CACHE_AVATAR = false
; Mail notification
ENABLE_NOTIFY_MAIL = false
[mailer] [mailer]
ENABLED = false ENABLED = false

@ -20,7 +20,7 @@ import (
// Test that go1.2 tag above is included in builds. main.go refers to this definition. // Test that go1.2 tag above is included in builds. main.go refers to this definition.
const go12tag = true const go12tag = true
const APP_VER = "0.1.7.0323.1" const APP_VER = "0.1.7.0324"
func init() { func init() {
base.AppVer = APP_VER base.AppVer = APP_VER

@ -58,6 +58,7 @@ func CreateIssue(userId, repoId, milestoneId, assigneeId int64, name, labels, co
Content: content, Content: content,
} }
_, err = orm.Insert(issue) _, err = orm.Insert(issue)
// TODO: newIssueAction
return issue, err return issue, err
} }
@ -67,9 +68,9 @@ func GetIssueCount(repoId int64) (int64, error) {
} }
// GetIssueById returns issue object by given id. // GetIssueById returns issue object by given id.
func GetIssueById(id int64) (*Issue, error) { func GetIssueByIndex(repoId, index int64) (*Issue, error) {
issue := new(Issue) issue := &Issue{RepoId: repoId, Index: index}
has, err := orm.Id(id).Get(issue) has, err := orm.Get(issue)
if err != nil { if err != nil {
return nil, err return nil, err
} else if !has { } else if !has {
@ -126,6 +127,18 @@ func GetIssues(userId, repoId, posterId, milestoneId int64, page int, isClosed,
return issues, err 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. // Label represents a list of labels of repository for issues.
type Label struct { type Label struct {
Id int64 Id int64

@ -387,7 +387,7 @@ func UpdateRepository(repo *Repository) error {
repo.Website = repo.Website[:255] 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 return err
} }

@ -72,7 +72,10 @@ func (user *User) HomeLink() string {
// AvatarLink returns the user gravatar link. // AvatarLink returns the user gravatar link.
func (user *User) AvatarLink() string { 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. // NewGitSig generates and returns the signature of given user.
@ -208,7 +211,7 @@ func UpdateUser(user *User) (err error) {
user.Website = user.Website[:255] 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 return err
} }

@ -3,6 +3,14 @@
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// for www.gravatar.com image cache // 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 package avatar
import ( import (
@ -14,7 +22,6 @@ import (
"image/jpeg" "image/jpeg"
"image/png" "image/png"
"io" "io"
"log"
"net/http" "net/http"
"net/url" "net/url"
"os" "os"
@ -23,6 +30,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/gogits/gogs/modules/log"
"github.com/nfnt/resize" "github.com/nfnt/resize"
) )
@ -30,12 +38,6 @@ var (
gravatar = "http://www.gravatar.com/avatar" gravatar = "http://www.gravatar.com/avatar"
) )
func debug(a ...interface{}) {
if true {
log.Println(a...)
}
}
// hash email to md5 string // hash email to md5 string
// keep this func in order to make this package indenpent // keep this func in order to make this package indenpent
func HashEmail(email string) string { func HashEmail(email string) string {
@ -125,7 +127,7 @@ func (this *Avatar) UpdateTimeout(timeout time.Duration) error {
var err error var err error
select { select {
case <-time.After(timeout): 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, case err = <-thunder.GoFetch(gravatar+"/"+this.Hash+"?"+this.reqParams,
this.imagePath): 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) { func (this *avatarHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
urlPath := r.URL.Path urlPath := r.URL.Path
hash := urlPath[strings.LastIndex(urlPath, "/")+1:] hash := urlPath[strings.LastIndex(urlPath, "/")+1:]
//hash = HashEmail(hash) size := this.mustInt(r, 80, "s", "size") // default size = 80*80
size := this.mustInt(r, 80, "s", "size") // size = 80*80
avatar := New(hash, this.cacheDir) avatar := New(hash, this.cacheDir)
avatar.AlterImage = this.altImage avatar.AlterImage = this.altImage
if avatar.Expired() { if avatar.Expired() {
err := avatar.UpdateTimeout(time.Millisecond * 500) err := avatar.UpdateTimeout(time.Millisecond * 500)
if err != nil { 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 { 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") w.Header().Set("Content-Type", "image/jpeg")
err := avatar.Encode(w, size) err := avatar.Encode(w, size)
if err != nil { if err != nil {
//log.Warn("avatar encode error: %v", err) // will panic when err != nil log.Warn("avatar encode error: %v", err)
debug(err)
w.WriteHeader(500) w.WriteHeader(500)
} }
} }
@ -251,7 +250,6 @@ func (this *thunderTask) Fetch() {
var client = &http.Client{} var client = &http.Client{}
func (this *thunderTask) fetch() error { func (this *thunderTask) fetch() error {
//log.Println("thunder, fetch", this.Url)
req, _ := http.NewRequest("GET", this.Url, nil) 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", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
req.Header.Set("Accept-Encoding", "gzip,deflate,sdch") req.Header.Set("Accept-Encoding", "gzip,deflate,sdch")

@ -4,13 +4,14 @@
package avatar_test package avatar_test
import ( import (
"log" "errors"
"os" "os"
"strconv" "strconv"
"testing" "testing"
"time" "time"
"github.com/gogits/gogs/modules/avatar" "github.com/gogits/gogs/modules/avatar"
"github.com/gogits/gogs/modules/log"
) )
const TMPDIR = "test-avatar" const TMPDIR = "test-avatar"
@ -28,7 +29,7 @@ func TestFetchMany(t *testing.T) {
os.Mkdir(TMPDIR, 0755) os.Mkdir(TMPDIR, 0755)
defer os.RemoveAll(TMPDIR) defer os.RemoveAll(TMPDIR)
log.Println("start") t.Log("start")
var n = 5 var n = 5
ch := make(chan bool, n) ch := make(chan bool, n)
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
@ -36,14 +37,14 @@ func TestFetchMany(t *testing.T) {
hash := avatar.HashEmail(strconv.Itoa(i) + "ssx205@gmail.com") hash := avatar.HashEmail(strconv.Itoa(i) + "ssx205@gmail.com")
a := avatar.New(hash, TMPDIR) a := avatar.New(hash, TMPDIR)
a.Update() a.Update()
log.Println("finish", hash) t.Log("finish", hash)
ch <- true ch <- true
}(i) }(i)
} }
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
<-ch <-ch
} }
log.Println("end") t.Log("end")
} }
// cat // cat
@ -54,3 +55,7 @@ func TestHttp(t *testing.T) {
http.ListenAndServe(":8001", nil) 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 DisenableRegisteration bool
RequireSignInView bool RequireSignInView bool
EnableCacheAvatar bool EnableCacheAvatar bool
NotifyMail bool
ActiveCodeLives int ActiveCodeLives int
ResetPwdCodeLives int ResetPwdCodeLives int
} }
@ -230,6 +231,17 @@ func newRegisterMailService() {
log.Info("Register Mail Service Enabled") 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() { func NewConfigContext() {
var err error var err error
workDir, err := exeDir() workDir, err := exeDir()
@ -284,4 +296,5 @@ func NewServices() {
newSessionService() newSessionService()
newMailService() newMailService()
newRegisterMailService() newRegisterMailService()
newNotifyMailService()
} }

@ -11,6 +11,11 @@ import (
var logger *logs.BeeLogger var logger *logs.BeeLogger
func init() {
logger = logs.NewLogger(10000)
logger.SetLogger("console", `{"level": 0}`)
}
func NewLogger(bufLen int64, mode, config string) { func NewLogger(bufLen int64, mode, config string) {
logger = logs.NewLogger(bufLen) logger = logs.NewLogger(bufLen)
logger.SetLogger(mode, config) logger.SetLogger(mode, config)
@ -20,6 +25,10 @@ func Trace(format string, v ...interface{}) {
logger.Trace(format, v...) logger.Trace(format, v...)
} }
func Debug(format string, v ...interface{}) {
logger.Debug(format, v...)
}
func Info(format string, v ...interface{}) { func Info(format string, v ...interface{}) {
logger.Info(format, v...) logger.Info(format, v...)
} }

@ -21,7 +21,7 @@ type ToggleOptions struct {
func Toggle(options *ToggleOptions) martini.Handler { func Toggle(options *ToggleOptions) martini.Handler {
return func(ctx *Context) { return func(ctx *Context) {
if options.SignOutRequire && ctx.IsSigned { if options.SignOutRequire && ctx.IsSigned && ctx.Req.RequestURI != "/" {
ctx.Redirect("/") ctx.Redirect("/")
return 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 return
} }
if len(params["branchname"]) == 0 {
params["branchname"] = "master"
}
ctx.Data["Branchname"] = params["branchname"]
ctx.HTML(200, "repo/issues") 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) { 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 { if err != nil {
ctx.Handle(404, "issue.ViewIssue", err) ctx.Handle(404, "issue.ViewIssue", err)
return return
} }
issue, err := models.GetIssueById(int64(issueid)) issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
if err != nil { if err != nil {
if err == models.ErrIssueNotExist { if err == models.ErrIssueNotExist {
ctx.Handle(404, "issue.ViewIssue", err) ctx.Handle(404, "issue.ViewIssue", err)
@ -83,3 +87,39 @@ func ViewIssue(ctx *middleware.Context, params martini.Params) {
ctx.Data["Issue"] = issue ctx.Data["Issue"] = issue
ctx.HTML(200, "issue/view") 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) 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) { func Single(ctx *middleware.Context, params martini.Params) {
if !ctx.Repo.IsValid { if !ctx.Repo.IsValid {
return return
@ -276,7 +252,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
ctx.HTML(200, "repo/setting") ctx.HTML(200, "repo/setting")
} }
func SettingPost(ctx *middleware.Context, params martini.Params) { func SettingPost(ctx *middleware.Context) {
if !ctx.Repo.IsOwner { if !ctx.Repo.IsOwner {
ctx.Error(404) ctx.Error(404)
return 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) { func Action(ctx *middleware.Context, params martini.Params) {
var err error var err error
switch params["action"] { 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>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>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>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> <div><b>Enable Cache Avatar:</b> <i class="fa fa{{if .Service.EnableCacheAvatar}}-check{{end}}-square-o"></i></div>
<hr/> <hr/>
<div><b>Active Code Lives:</b> {{.Service.ActiveCodeLives}} minutes</div> <div><b>Active Code Lives:</b> {{.Service.ActiveCodeLives}} minutes</div>

@ -53,9 +53,9 @@
</div> </div>
</div> </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>&nbsp;{{.Repository.NumStars}}</button> <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Star"><i class="fa fa-star"></i>&nbsp;{{.Repository.NumStars}}</button>
</div> </div> -->
{{end}} {{end}}
<div class="btn-group"> <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>&nbsp;{{.Repository.NumForks}}</a> <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>&nbsp;{{.Repository.NumForks}}</a>

@ -6,27 +6,27 @@
<li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li> <li class="{{if .IsRepoToolbarSource}}active{{end}}"><a href="/{{.RepositoryLink}}">Source</a></li>
{{if not .IsBareRepo}} {{if not .IsBareRepo}}
<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="/{{.RepositoryLink}}/commits/{{.Branchname}}">Commits</a></li> <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 .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 .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="{{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> <a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="/{{.RepositoryLink}}/release">Release</a></li> <li><a href="/{{.RepositoryLink}}/release">Release</a></li>
<li><a href="//{{.RepositoryLink}}/wiki">Wiki</a></li> <li><a href="//{{.RepositoryLink}}/wiki">Wiki</a></li>
</ul> </ul>
</li>{{end}} </li> -->{{end}}
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{{if not .IsBareRepo}} {{if not .IsBareRepo}}
<li class="dropdown"> <!-- <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Statistic <b class="caret"></b></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a href="#">Graphic</a></li> <li><a href="#">Graphic</a></li>
<li><a href="#">Pulse</a></li> <li><a href="#">Pulse</a></li>
<li><a href="#">Network</a></li> <li><a href="#">Network</a></li>
</ul> </ul>
</li>{{end}}{{if .IsRepositoryOwner}} </li> -->{{end}}{{if .IsRepositoryOwner}}
<li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a> <li class="{{if .IsRepoToolbarSetting}}active{{end}}"><a href="/{{.RepositoryLink}}/settings">Settings</a>
</li>{{end}} </li>{{end}}
</ul> </ul>

@ -5,8 +5,8 @@
<ul class="nav nav-pills pull-right"> <ul class="nav nav-pills pull-right">
<li class="active"><a href="/">Feed</a></li> <li class="active"><a href="/">Feed</a></li>
<li><a href="/issues">Issues</a></li> <li><a href="/issues">Issues</a></li>
<li><a href="/pulls">Pull Requests</a></li> <!-- <li><a href="/pulls">Pull Requests</a></li>
<li><a href="/stars">Stars</a></li> <li><a href="/stars">Stars</a></li> -->
</ul> </ul>
<h3>News Feed</h3> <h3>News Feed</h3>
</div> </div>
@ -34,7 +34,7 @@
<div class="panel-body"> <div class="panel-body">
<ul class="list-group">{{range .MyRepos}} <ul class="list-group">{{range .MyRepos}}
<li class="list-group-item"><a href="/{{$.SignedUserName}}/{{.Name}}"> <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> <i class="fa fa-book"></i>{{.Name}}</a>
</li>{{end}} </li>{{end}}
</ul> </ul>

@ -5,8 +5,8 @@
<ul class="nav nav-pills pull-right"> <ul class="nav nav-pills pull-right">
<li><a href="/">Feed</a></li> <li><a href="/">Feed</a></li>
<li class="active"><a href="/issues">Issues</a></li> <li class="active"><a href="/issues">Issues</a></li>
<li><a href="/pulls">Pull Requests</a></li> <!-- <li><a href="/pulls">Pull Requests</a></li>
<li><a href="/stars">Stars</a></li> <li><a href="/stars">Stars</a></li> -->
</ul> </ul>
<h3>Issues</h3> <h3>Issues</h3>
</div> </div>

@ -50,7 +50,7 @@
<ul class="list-unstyled repo-list"> <ul class="list-unstyled repo-list">
{{range .Repos}} {{range .Repos}}
<li> <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> <h4>
<a href="/{{$owner.Name}}/{{.LowerName}}">{{.LowerName}}</a> <a href="/{{$owner.Name}}/{{.LowerName}}">{{.LowerName}}</a>
</h4> </h4>

@ -3,9 +3,9 @@
<ul class="list-group"> <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 .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 .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 .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> <li class="list-group-item{{if .IsUserPageSettingDelete}} list-group-item-success{{end}}"><a href="/user/delete">Delete Account</a></li>
</ul> </ul>
</div> </div>

@ -31,9 +31,10 @@ import (
var CmdWeb = cli.Command{ var CmdWeb = cli.Command{
Name: "web", Name: "web",
Usage: "just run", Usage: "Gogs web server",
Description: ` 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, Action: runWeb,
Flags: []cli.Flag{}, Flags: []cli.Flag{},
} }
@ -88,7 +89,7 @@ func runWeb(*cli.Context) {
reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true}) reqSignOut := middleware.Toggle(&middleware.ToggleOptions{SignOutRequire: true})
// Routers. // Routers.
m.Get("/", ignSignIn, routers.Home) m.Get("/", reqSignIn, routers.Home)
m.Get("/issues", reqSignIn, user.Issues) m.Get("/issues", reqSignIn, user.Issues)
m.Get("/pulls", reqSignIn, user.Pulls) m.Get("/pulls", reqSignIn, user.Pulls)
m.Get("/stars", reqSignIn, user.Stars) m.Get("/stars", reqSignIn, user.Stars)
@ -145,7 +146,8 @@ func runWeb(*cli.Context) {
r.Get("/commits/:branchname", repo.Commits) r.Get("/commits/:branchname", repo.Commits)
r.Get("/issues", repo.Issues) r.Get("/issues", repo.Issues)
r.Any("/issues/new", binding.BindIgnErr(auth.CreateIssueForm{}), repo.CreateIssue) 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("/pulls", repo.Pulls)
r.Get("/branches", repo.Branches) r.Get("/branches", repo.Branches)
r.Get("/src/:branchname", repo.Single) r.Get("/src/:branchname", repo.Single)

Loading…
Cancel
Save