From 64c68220d203cb07be001184cde4b35d4b503344 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 6 Oct 2014 17:50:00 -0400 Subject: Fix #264 --- cmd/web.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 72a58bc9..810e36d3 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -313,6 +313,12 @@ func runWeb(*cli.Context) { r.Get("/hooks/:id", repo.WebHooksEdit) r.Post("/hooks/gogs/:id", bindIgnErr(auth.NewWebhookForm{}), repo.WebHooksEditPost) r.Post("/hooks/slack/:id", bindIgnErr(auth.NewSlackHookForm{}), repo.SlackHooksEditPost) + + m.Group("/hooks/git", func(r *macaron.Router) { + r.Get("", repo.GitHooks) + r.Get("/:name", repo.GitHooksEdit) + r.Post("/:name", repo.GitHooksEditPost) + }, middleware.GitHookService()) }) }, reqSignIn, middleware.RepoAssignment(true), reqTrueOwner) -- cgit v1.2.3 From 1e1f9e716660533dc3c570b51006e4e36b2c3a7f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Mon, 6 Oct 2014 19:12:52 -0400 Subject: Update with macaron --- .bra.toml | 4 ++-- cmd/web.go | 10 +++++++--- modules/middleware/context.go | 2 -- routers/org/setting.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'cmd') diff --git a/.bra.toml b/.bra.toml index a5afa276..a5fcdf6e 100644 --- a/.bra.toml +++ b/.bra.toml @@ -11,7 +11,7 @@ watch_dirs = [ watch_exts = [".go", ".ini"] build_delay = 1500 cmds = [ - ["go", "install"], - ["go", "build"], + ["go", "install", "-tags", "sqlite"], + ["go", "build", "-tags", "sqlite"], ["./gogs", "web"] ] \ No newline at end of file diff --git a/cmd/web.go b/cmd/web.go index 810e36d3..201eb48f 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -61,10 +61,14 @@ func checkVersion() { log.Fatal(4, "Binary and template file version does not match, did you forget to recompile?") } - // Macaron. + // Check dependency version. macaronVer := git.MustParseVersion(strings.Join(strings.Split(macaron.Version(), ".")[:3], ".")) - if macaronVer.LessThan(git.MustParseVersion("0.1.8")) { - log.Fatal(4, "Macaron version does not match, did you forget to update?(github.com/Unknwon/macaron)") + if macaronVer.LessThan(git.MustParseVersion("0.2.0")) { + log.Fatal(4, "Macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)") + } + i18nVer := git.MustParseVersion(i18n.Version()) + if i18nVer.LessThan(git.MustParseVersion("0.0.1")) { + log.Fatal(4, "i18n version is too old, did you forget to update?(github.com/macaron-contrib/i18n)") } } diff --git a/modules/middleware/context.go b/modules/middleware/context.go index 90716d2c..1d9f5738 100644 --- a/modules/middleware/context.go +++ b/modules/middleware/context.go @@ -29,7 +29,6 @@ import ( // Context represents context of a request. type Context struct { *macaron.Context - i18n.Locale Cache cache.Cache csrf csrf.CSRF Flash *session.Flash @@ -162,7 +161,6 @@ func Contexter() macaron.Handler { return func(c *macaron.Context, l i18n.Locale, cache cache.Cache, sess session.Store, f *session.Flash, x csrf.CSRF) { ctx := &Context{ Context: c, - Locale: l, Cache: cache, csrf: x, Flash: f, diff --git a/routers/org/setting.go b/routers/org/setting.go index 0522f998..41ec4a21 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -92,7 +92,7 @@ func SettingsDelete(ctx *middleware.Context) { ctx.Handle(500, "DeleteOrganization", err) } } else { - log.Trace("Organization deleted: %s", ctx.User.Name) + log.Trace("Organization deleted: %s", org.Name) ctx.Redirect(setting.AppSubUrl + "/") } return -- cgit v1.2.3 From fc18741cc78acbb6fac5cf89fa5ae7034178c5ca Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 7 Oct 2014 07:02:53 -0400 Subject: Fix #524 --- .bra.toml | 4 ++-- .gobuild.yml | 4 ++-- cmd/cert.go | 2 ++ cmd/cert_stub.go | 34 ++++++++++++++++++++++++++++++++++ gogs.go | 2 +- templates/.VERSION | 2 +- 6 files changed, 42 insertions(+), 6 deletions(-) create mode 100644 cmd/cert_stub.go (limited to 'cmd') diff --git a/.bra.toml b/.bra.toml index a5fcdf6e..df2e10e6 100644 --- a/.bra.toml +++ b/.bra.toml @@ -11,7 +11,7 @@ watch_dirs = [ watch_exts = [".go", ".ini"] build_delay = 1500 cmds = [ - ["go", "install", "-tags", "sqlite"], - ["go", "build", "-tags", "sqlite"], + ["go", "install", "-tags", "sqlite cert"], + ["go", "build", "-tags", "sqlite cert"], ["./gogs", "web"] ] \ No newline at end of file diff --git a/.gobuild.yml b/.gobuild.yml index 77633fa0..3a2f361d 100644 --- a/.gobuild.yml +++ b/.gobuild.yml @@ -16,6 +16,6 @@ settings: then go install -v else - go get -v -tags "sqlite redis memcache" github.com/gogits/gogs - go install -v -tags "sqlite redis memcache" + go get -v -tags "sqlite redis memcache cert" github.com/gogits/gogs + go install -v -tags "sqlite redis memcache cert" fi diff --git a/cmd/cert.go b/cmd/cert.go index b693b7d9..631c4c68 100644 --- a/cmd/cert.go +++ b/cmd/cert.go @@ -1,3 +1,5 @@ +// +build cert + // Copyright 2009 The Go Authors. All rights reserved. // Copyright 2014 The Gogs Authors. All rights reserved. // Use of this source code is governed by a MIT-style diff --git a/cmd/cert_stub.go b/cmd/cert_stub.go new file mode 100644 index 00000000..2029f4cb --- /dev/null +++ b/cmd/cert_stub.go @@ -0,0 +1,34 @@ +// +build !cert + +// Copyright 2009 The Go Authors. All rights reserved. +// 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 cmd + +import ( + "fmt" + "time" + + "github.com/codegangsta/cli" +) + +var CmdCert = cli.Command{ + Name: "cert", + Usage: "Generate self-signed certificate", + Description: `Generate a self-signed X.509 certificate for a TLS server. +Outputs to 'cert.pem' and 'key.pem' and will overwrite existing files.`, + Action: runCert, + Flags: []cli.Flag{ + cli.StringFlag{"host", "", "Comma-separated hostnames and IPs to generate a certificate for", ""}, + cli.StringFlag{"ecdsa-curve", "", "ECDSA curve to use to generate a key. Valid values are P224, P256, P384, P521", ""}, + cli.IntFlag{"rsa-bits", 2048, "Size of RSA key to generate. Ignored if --ecdsa-curve is set", ""}, + cli.StringFlag{"start-date", "", "Creation date formatted as Jan 1 15:04:05 2011", ""}, + cli.DurationFlag{"duration", 365 * 24 * time.Hour, "Duration that certificate is valid for", ""}, + cli.BoolFlag{"ca", "whether this cert should be its own Certificate Authority", ""}, + }, +} + +func runCert(ctx *cli.Context) { + fmt.Println("Command cert not available, please use build tags 'cert' to rebuild.") +} diff --git a/gogs.go b/gogs.go index 43705061..b1e46096 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.5.1006 Beta" +const APP_VER = "0.5.5.1007 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/templates/.VERSION b/templates/.VERSION index e551dcfe..999f683b 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.5.1006 Beta \ No newline at end of file +0.5.5.1007 Beta \ No newline at end of file -- cgit v1.2.3 From 1aa76bd27913e40780aa66fe6b6c1158e20b7bef Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 8 Oct 2014 18:29:18 -0400 Subject: Fix #532, add system notice --- cmd/web.go | 5 ++++ conf/locale/locale_en-US.ini | 8 ++++++ conf/locale/locale_zh-CN.ini | 8 ++++++ gogs.go | 2 +- models/admin.go | 64 ++++++++++++++++++++++++++++++++++++++++++++ models/models.go | 10 +++---- models/repo.go | 9 +++++-- routers/admin/notice.go | 46 +++++++++++++++++++++++++++++++ routers/admin/users.go | 4 +-- templates/.VERSION | 2 +- templates/admin/nav.tmpl | 1 + templates/admin/notice.tmpl | 54 +++++++++++++++++++++++++++++++++++++ 12 files changed, 202 insertions(+), 11 deletions(-) create mode 100644 models/admin.go create mode 100644 routers/admin/notice.go create mode 100644 templates/admin/notice.tmpl (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 201eb48f..9f2ec8b8 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -243,6 +243,11 @@ func runWeb(*cli.Context) { r.Post("/:authid", bindIgnErr(auth.AuthenticationForm{}), admin.EditAuthSourcePost) r.Post("/:authid/delete", admin.DeleteAuthSource) }) + + m.Group("/notices", func(r *macaron.Router) { + r.Get("", admin.Notices) + r.Get("/:id:int/delete", admin.DeleteNotice) + }) }, adminReq) m.Get("/:username", ignSignIn, user.Profile) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 4fc8c359..15262e63 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -416,6 +416,7 @@ organizations = Organizations repositories = Repositories authentication = Authentications config = Configuration +notices = System Notices monitor = Monitoring prev = Prev. next = Next @@ -593,6 +594,13 @@ monitor.desc = Description monitor.start = Start Time monitor.execute_time = Execution Time +notices.system_notice_list = System Notices +notices.type = Type +notices.type_1 = Repository +notices.desc = Description +notices.op = Op. +notices.delete_success = System notice has been successfully deleted. + [action] create_repo = created repository %s commit_repo = pushed to %s at %s diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index dc454848..8a343d4c 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -416,6 +416,7 @@ organizations = 组织管理 repositories = 仓库管理 authentication = 授权认证管理 config = 应用配置管理 +notices = 系统提示管理 monitor = 应用监控面板 prev = 上一页 next = 下一页 @@ -593,6 +594,13 @@ monitor.desc = 进程描述 monitor.start = 开始时间 monitor.execute_time = 已执行时间 +notices.system_notice_list = 系统提示管理 +notices.type = 提示类型 +notices.type_1 = 仓库 +notices.desc = 描述 +notices.op = 操作 +notices.delete_success = 系统提示删除成功! + [action] create_repo = 创建了仓库 %s commit_repo = 推送了 %s 分支的代码到 %s diff --git a/gogs.go b/gogs.go index b1e46096..250333f3 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.5.5.1007 Beta" +const APP_VER = "0.5.5.1008 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/admin.go b/models/admin.go new file mode 100644 index 00000000..493cc7af --- /dev/null +++ b/models/admin.go @@ -0,0 +1,64 @@ +// 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 models + +import ( + "time" + + "github.com/Unknwon/com" +) + +type NoticeType int + +const ( + NOTICE_REPOSITORY NoticeType = iota + 1 +) + +// Notice represents a system notice for admin. +type Notice struct { + Id int64 + Type NoticeType + Description string `xorm:"TEXT"` + Created time.Time `xorm:"CREATED"` +} + +// TrStr returns a translation format string. +func (n *Notice) TrStr() string { + return "admin.notices.type_" + com.ToStr(n.Type) +} + +// CreateNotice creates new system notice. +func CreateNotice(tp NoticeType, desc string) error { + n := &Notice{ + Type: tp, + Description: desc, + } + _, err := x.Insert(n) + return err +} + +// CreateRepositoryNotice creates new system notice with type NOTICE_REPOSITORY. +func CreateRepositoryNotice(desc string) error { + return CreateNotice(NOTICE_REPOSITORY, desc) +} + +// CountNotices returns number of notices. +func CountNotices() int64 { + count, _ := x.Count(new(Notice)) + return count +} + +// GetNotices returns given number of notices with offset. +func GetNotices(num, offset int) ([]*Notice, error) { + notices := make([]*Notice, 0, num) + err := x.Limit(num, offset).Desc("id").Find(¬ices) + return notices, err +} + +// DeleteNotice deletes a system notice by given ID. +func DeleteNotice(id int64) error { + _, err := x.Id(id).Delete(new(Notice)) + return err +} diff --git a/models/models.go b/models/models.go index 570df0c1..35eb4c96 100644 --- a/models/models.go +++ b/models/models.go @@ -32,12 +32,12 @@ var ( ) func init() { - tables = append(tables, new(User), new(PublicKey), + tables = append(tables, new(User), new(PublicKey), new(Follow), new(Oauth2), new(Repository), new(Watch), new(Star), new(Action), new(Access), - new(Issue), new(Comment), new(Oauth2), new(Follow), - new(Mirror), new(Release), new(LoginSource), new(Webhook), new(IssueUser), - new(Milestone), new(Label), new(HookTask), new(Team), new(OrgUser), new(TeamUser), - new(UpdateTask), new(Attachment)) + new(Issue), new(Comment), new(Attachment), new(IssueUser), new(Label), new(Milestone), + new(Mirror), new(Release), new(LoginSource), new(Webhook), + new(UpdateTask), new(HookTask), new(Team), new(OrgUser), new(TeamUser), + new(Notice)) } func LoadModelsConfig() { diff --git a/models/repo.go b/models/repo.go index 8e29b335..3a26c88f 100644 --- a/models/repo.go +++ b/models/repo.go @@ -934,9 +934,14 @@ func DeleteRepository(uid, repoId int64, userName string) error { sess.Rollback() return err } + + // Remove repository files. if err = os.RemoveAll(RepoPath(userName, repo.Name)); err != nil { - sess.Rollback() - return err + desc := fmt.Sprintf("Fail to delete repository files(%s/%s): %v", userName, repo.Name, err) + log.Warn(desc) + if err = CreateRepositoryNotice(desc); err != nil { + log.Error(4, "Fail to add notice: %v", err) + } } return sess.Commit() } diff --git a/routers/admin/notice.go b/routers/admin/notice.go new file mode 100644 index 00000000..b4319463 --- /dev/null +++ b/routers/admin/notice.go @@ -0,0 +1,46 @@ +// 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 admin + +import ( + "github.com/Unknwon/com" + + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/base" + "github.com/gogits/gogs/modules/log" + "github.com/gogits/gogs/modules/middleware" +) + +const ( + NOTICES base.TplName = "admin/notice" +) + +func Notices(ctx *middleware.Context) { + ctx.Data["Title"] = ctx.Tr("admin.notices") + ctx.Data["PageIsAdmin"] = true + ctx.Data["PageIsAdminNotices"] = true + + pageNum := 50 + p := pagination(ctx, models.CountNotices(), pageNum) + + notices, err := models.GetNotices(pageNum, (p-1)*pageNum) + if err != nil { + ctx.Handle(500, "GetNotices", err) + return + } + ctx.Data["Notices"] = notices + ctx.HTML(200, NOTICES) +} + +func DeleteNotice(ctx *middleware.Context) { + id := com.StrTo(ctx.Params(":id")).MustInt64() + if err := models.DeleteNotice(id); err != nil { + ctx.Handle(500, "DeleteNotice", err) + return + } + log.Trace("System notice deleted by admin(%s): %d", ctx.User.Name, id) + ctx.Flash.Success(ctx.Tr("admin.notices.delete_success")) + ctx.Redirect("/admin/notices") +} diff --git a/routers/admin/users.go b/routers/admin/users.go index fc3b0cbc..e5cd364f 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -48,12 +48,12 @@ func Users(ctx *middleware.Context) { pageNum := 50 p := pagination(ctx, models.CountUsers(), pageNum) - var err error - ctx.Data["Users"], err = models.GetUsers(pageNum, (p-1)*pageNum) + users, err := models.GetUsers(pageNum, (p-1)*pageNum) if err != nil { ctx.Handle(500, "GetUsers", err) return } + ctx.Data["Users"] = users ctx.HTML(200, USERS) } diff --git a/templates/.VERSION b/templates/.VERSION index 999f683b..194ec580 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.5.5.1007 Beta \ No newline at end of file +0.5.5.1008 Beta \ No newline at end of file diff --git a/templates/admin/nav.tmpl b/templates/admin/nav.tmpl index e294cd92..49c4b72c 100644 --- a/templates/admin/nav.tmpl +++ b/templates/admin/nav.tmpl @@ -8,6 +8,7 @@
  • {{.i18n.Tr "admin.repositories"}}
  • {{.i18n.Tr "admin.authentication"}}
  • {{.i18n.Tr "admin.config"}}
  • +
  • {{.i18n.Tr "admin.notices"}}
  • {{.i18n.Tr "admin.monitor"}}
  • diff --git a/templates/admin/notice.tmpl b/templates/admin/notice.tmpl new file mode 100644 index 00000000..b3abbb6b --- /dev/null +++ b/templates/admin/notice.tmpl @@ -0,0 +1,54 @@ +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
    +
    +
    + {{template "admin/nav" .}} +
    +
    + {{template "ng/base/alert" .}} +
    +
    +
    + {{.i18n.Tr "admin.notices.system_notice_list"}} +
    +
    +
    + + + + + + + + + + + + {{range .Notices}} + + + + + + + + {{end}} + +
    Id{{.i18n.Tr "admin.notices.type"}}{{.i18n.Tr "admin.notices.desc"}}{{.i18n.Tr "admin.users.created"}}{{.i18n.Tr "admin.notices.op"}}
    {{.Id}}{{$.i18n.Tr .TrStr}}{{.Description}}{{.Created}}
    + {{if or .LastPageNum .NextPageNum}} + + {{end}} +
    +
    +
    +
    +
    +
    +
    +
    +
    +{{template "ng/base/footer" .}} \ No newline at end of file -- cgit v1.2.3 From 7b03b1df0efab201b48001200b17ed3390fa83da Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 9 Oct 2014 18:35:09 -0400 Subject: Allow custom locale --- cmd/web.go | 12 +++++++----- public/ng/css/gogs.css | 1 + public/ng/less/gogs/base.less | 1 + 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/web.go b/cmd/web.go index 9f2ec8b8..77260b72 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -67,7 +67,7 @@ func checkVersion() { log.Fatal(4, "Macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)") } i18nVer := git.MustParseVersion(i18n.Version()) - if i18nVer.LessThan(git.MustParseVersion("0.0.1")) { + if i18nVer.LessThan(git.MustParseVersion("0.0.2")) { log.Fatal(4, "i18n version is too old, did you forget to update?(github.com/macaron-contrib/i18n)") } } @@ -92,10 +92,12 @@ func newMacaron() *macaron.Macaron { IndentJSON: macaron.Env != macaron.PROD, })) m.Use(i18n.I18n(i18n.Options{ - SubURL: setting.AppSubUrl, - Langs: setting.Langs, - Names: setting.Names, - Redirect: true, + SubURL: setting.AppSubUrl, + Directory: path.Join(setting.ConfRootPath, "locale"), + CustomDirectory: path.Join(setting.CustomPath, "conf/locale"), + Langs: setting.Langs, + Names: setting.Names, + Redirect: true, })) m.Use(cache.Cacher(cache.Options{ Adapter: setting.CacheAdapter, diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index feb21c97..af95092f 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -88,6 +88,7 @@ img.avatar-100 { z-index: 100; font-size: 12px; width: 120%; + min-width: 100px; } #footer-lang .drop-down li > a { padding: 3px 9px; diff --git a/public/ng/less/gogs/base.less b/public/ng/less/gogs/base.less index f715ed06..de1781a4 100644 --- a/public/ng/less/gogs/base.less +++ b/public/ng/less/gogs/base.less @@ -102,6 +102,7 @@ clear: both; z-index: 100; font-size: 12px; width: 120%; + min-width: 100px; li > a { padding: 3px 9px; } -- cgit v1.2.3 From 41dbb4c148cef33984a268e2e891b09fa10b3d94 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 10 Oct 2014 06:15:27 -0400 Subject: Hide org member in collar page --- README.md | 4 ++-- README_ZH.md | 4 ++-- cmd/web.go | 8 ++++++-- conf/locale/locale_en-US.ini | 1 + conf/locale/locale_zh-CN.ini | 1 + routers/repo/setting.go | 23 +++++++++++++++++------ templates/ng/base/alert.tmpl | 3 ++- 7 files changed, 31 insertions(+), 13 deletions(-) (limited to 'cmd') diff --git a/README.md b/README.md index 66e96599..6eb4afbf 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ The goal of this project is to make the easiest, fastest and most painless way t - Slack webhook integration - Supports MySQL, PostgreSQL and SQLite3 - Social account login(GitHub, Google, QQ, Weibo) -- Multi-language support(English, Chinese, Germany, French, Dutch etc.) +- Multi-language support(English, Simplified Chinese, Traditional Chinese, Germany, French, Dutch etc.) ## System Requirements @@ -57,7 +57,7 @@ Make sure you install [Prerequirements](http://gogs.io/docs/installation/) first There are 5 ways to install Gogs: -- [Install from binary](http://gogs.io/docs/installation/install_from_binary.md): **STRONGLY RECOMMENDED** +- [Install from binary](http://gogs.io/docs/installation/install_from_binary.md) - [Install from source](http://gogs.io/docs/installation/install_from_source.md) - [Install from packages](http://gogs.io/docs/installation/install_from_packages.md) - [Ship with Docker](https://github.com/gogits/gogs/tree/master/docker) diff --git a/README_ZH.md b/README_ZH.md index d2d54beb..cb79a43c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -35,7 +35,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - Slack Web 钩子集成 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库 - 社交帐号登录(GitHub、Google、QQ、微博) -- 多语言支持(英文、简体中文、德语、法语、荷兰语等等) +- 多语言支持(英文、简体中文、繁体中文、德语、法语、荷兰语等等) ## 系统要求 @@ -48,7 +48,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 然后,您可以通过以下 5 种方式来安装 Gogs: -- [二进制安装](http://gogs.io/docs/installation/install_from_binary.md): **强烈推荐** +- [二进制安装](http://gogs.io/docs/installation/install_from_binary.md) - [源码安装](http://gogs.io/docs/installation/install_from_source.md) - [包管理安装](http://gogs.io/docs/installation/install_from_packages.md) - [采用 Docker 部署](https://github.com/gogits/gogs/tree/master/docker) diff --git a/cmd/web.go b/cmd/web.go index 77260b72..395658f6 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -64,11 +64,15 @@ func checkVersion() { // Check dependency version. macaronVer := git.MustParseVersion(strings.Join(strings.Split(macaron.Version(), ".")[:3], ".")) if macaronVer.LessThan(git.MustParseVersion("0.2.0")) { - log.Fatal(4, "Macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)") + log.Fatal(4, "Package macaron version is too old, did you forget to update?(github.com/Unknwon/macaron)") } i18nVer := git.MustParseVersion(i18n.Version()) if i18nVer.LessThan(git.MustParseVersion("0.0.2")) { - log.Fatal(4, "i18n version is too old, did you forget to update?(github.com/macaron-contrib/i18n)") + log.Fatal(4, "Package i18n version is too old, did you forget to update?(github.com/macaron-contrib/i18n)") + } + sessionVer := git.MustParseVersion(session.Version()) + if sessionVer.LessThan(git.MustParseVersion("0.0.1")) { + log.Fatal(4, "Package session version is too old, did you forget to update?(github.com/macaron-contrib/session)") } } diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 0f2003b5..2182167c 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -309,6 +309,7 @@ settings.confirm_delete = Confirm Deletion settings.add_collaborator = Add New Collaborator settings.add_collaborator_success = New collaborator has been added. settings.remove_collaborator_success = Collaborator has been removed. +settings.user_is_org_member = User is organization member who cannot be added as a collaborator. settings.add_webhook = Add Webhook settings.hooks_desc = Webhooks allow external services to be notified when certain events happen on Gogs. When the specified events happen, we'll send a POST request to each of the URLs you provide. Learn more in our Webhooks Guide. settings.githooks_desc = Git Hooks are powered by Git itself, you can edit files of supported hooks in the list below to apply custom operations. diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index da26ce9d..a2242b45 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -309,6 +309,7 @@ settings.confirm_delete = 确认删除仓库 settings.add_collaborator = 增加新的协作者 settings.add_collaborator_success = 成功添加新的协作者! settings.remove_collaborator_success = 被操作的协作者已经被收回权限! +settings.user_is_org_member = 被操作的用户是组织成员,因此无法添加为协作者! settings.add_webhook = 添加 Web 钩子 settings.hooks_desc = Web 钩子允许您设定在 Gogs 上发生指定事件时对指定 URL 发送 POST 通知。查看 Webhooks 文档 获取更多信息。 settings.remove_hook_success = Web 钩子删除成功! diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 0e58029e..971c5bef 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -196,9 +196,16 @@ func SettingsCollaboration(ctx *middleware.Context) { return } + // Check if user is organization member. + if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.Id) { + ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member")) + ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") + return + } + if err = models.AddAccess(&models.Access{UserName: name, RepoName: repoLink, Mode: models.WRITABLE}); err != nil { - ctx.Handle(500, "AddAccess2", err) + ctx.Handle(500, "AddAccess", err) return } @@ -247,16 +254,20 @@ func SettingsCollaboration(ctx *middleware.Context) { return } - us := make([]*models.User, len(names)) - for i, name := range names { - us[i], err = models.GetUserByName(name) + collaborators := make([]*models.User, 0, len(names)) + for _, name := range names { + u, err := models.GetUserByName(name) if err != nil { ctx.Handle(500, "GetUserByName", err) return } + // Does not show organization members. + if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.Id) { + continue + } + collaborators = append(collaborators, u) } - - ctx.Data["Collaborators"] = us + ctx.Data["Collaborators"] = collaborators ctx.HTML(200, COLLABORATION) } diff --git a/templates/ng/base/alert.tmpl b/templates/ng/base/alert.tmpl index df14d3c3..329ae910 100644 --- a/templates/ng/base/alert.tmpl +++ b/templates/ng/base/alert.tmpl @@ -1,2 +1,3 @@ {{if .Flash.ErrorMsg}}{{.Flash.ErrorMsg}}{{end}} -{{if .Flash.SuccessMsg}}
    {{.Flash.SuccessMsg}}
    {{end}} \ No newline at end of file +{{if .Flash.SuccessMsg}}
    {{.Flash.SuccessMsg}}
    {{end}} +{{if .Flash.InfoMsg}}
    {{.Flash.InfoMsg}}
    {{end}} \ No newline at end of file -- cgit v1.2.3 From b2632dec099cb2727933149d2d59cc5e46baa15f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Fri, 10 Oct 2014 21:40:51 -0400 Subject: Page: Compare 2 commits --- README.md | 1 + README_ZH.md | 1 + cmd/dump.go | 1 + conf/locale/locale_en-US.ini | 10 +++ conf/locale/locale_zh-CN.ini | 10 +++ models/action.go | 18 ++--- models/update.go | 9 +-- modules/base/template.go | 66 +--------------- public/ng/css/gogs.css | 104 ++++++++++++++++++++++++ public/ng/css/ui.css | 8 ++ public/ng/js/gogs.js | 38 +++++++++ public/ng/js/min/gogs-min.js | 10 +-- public/ng/less/gogs/base.less | 4 + public/ng/less/gogs/repository.less | 153 ++++++++++++++++++++++++++++++------ public/ng/less/ui/panel.less | 8 ++ routers/repo/commit.go | 2 + templates/repo/commits_table.tmpl | 4 +- templates/repo/diff.tmpl | 76 +++++++++--------- templates/user/dashboard/feeds.tmpl | 1 + 19 files changed, 379 insertions(+), 145 deletions(-) (limited to 'cmd') diff --git a/README.md b/README.md index 6eb4afbf..44c62649 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ The goal of this project is to make the easiest, fastest and most painless way t - Activity timeline - SSH/HTTP(S) protocol support - SMTP/LDAP/reverse proxy authentication support +- Reverse proxy suburl support - Register/delete/rename account - Create/manage/delete organization with team management - Create/migrate/mirror/delete/watch/rename/transfer public/private repository diff --git a/README_ZH.md b/README_ZH.md index cb79a43c..9581faf7 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -23,6 +23,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自 - 活动时间线 - 支持 SSH/HTTP(S) 协议 - 支持 SMTP/LDAP/反向代理 用户认证 +- 支持反向代理子路径 - 注册/删除/重命名 用户 - 创建/管理/删除 组织以及团队管理功能 - 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库 diff --git a/cmd/dump.go b/cmd/dump.go index 41491224..fe3763f0 100644 --- a/cmd/dump.go +++ b/cmd/dump.go @@ -60,6 +60,7 @@ func runDump(ctx *cli.Context) { z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql")) z.AddFile("custom/conf/app.ini", path.Join(workDir, "custom/conf/app.ini")) z.AddDir("log", path.Join(workDir, "log")) + // FIXME: SSH key file. if err = z.Close(); err != nil { os.Remove(fileName) log.Fatalf("Fail to save %s: %v", fileName, err) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index 2182167c..92cbf324 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -337,6 +337,15 @@ settings.slack_token = Token settings.slack_domain = Domain settings.slack_channel = Channel +diff.browse_source = Browse Source +diff.parent = parent +diff.commit = commit +diff.data_not_available = Diff Data Not Available. +diff.show_diff_stats = Show Diff Stats +diff.stats_desc = %d changed files with %d additions and %d deletions +diff.bin = BIN +diff.view_file = View File + [org] org_name_holder = Organization Name org_name_helper = Great organization names are short and memorable. @@ -609,6 +618,7 @@ commit_repo = pushed to %s at %s create_issue = opened issue %s#%s comment_issue = commented on issue %s#%s transfer_repo = transfered repository %s to %s +compare_2_commits = View comparison for these 2 commits [tool] ago = ago diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index a2242b45..ed3e1bef 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -337,6 +337,15 @@ settings.slack_token = 令牌 settings.slack_domain = 域名 settings.slack_channel = 频道 +diff.browse_source = 浏览代码 +diff.parent = 父节点 +diff.commit = 当前提交 +diff.data_not_available = 暂无可用数据 +diff.show_diff_stats = 显示文件统计 +diff.stats_desc = 共有 %d 个文件被更改,包括 %d 次插入%d 次删除 +diff.bin = 二进制 +diff.view_file = 查看文件 + [org] org_name_holder = 组织名称 org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。 @@ -609,6 +618,7 @@ commit_repo = 推送了 %s 分支的代码到 %s#%s comment_issue = 评论了工单 %s#%s transfer_repo = 将仓库 %s 转移至 %s +compare_2_commits = 查看 2 次提交的内容对比 [tool] ago = 之前 diff --git a/models/action.go b/models/action.go index 4203ead3..ef111e67 100644 --- a/models/action.go +++ b/models/action.go @@ -181,13 +181,19 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, commit = &base.PushCommits{} } - refName := git.RefEndName(refFullName) + repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) + // if not the first commit, set the compareUrl + if !strings.HasPrefix(oldCommitId, "0000000") { + commit.CompareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) + } bs, err := json.Marshal(commit) if err != nil { return errors.New("action.CommitRepoAction(json): " + err.Error()) } + refName := git.RefEndName(refFullName) + // Change repository bare status and update last updated time. repo, err := GetRepositoryByName(repoUserId, repoName) if err != nil { @@ -211,7 +217,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error()) } - //qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName) // New push event hook. if err := repo.GetOwner(); err != nil { @@ -237,13 +242,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, return nil } - repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName) - compareUrl := "" - // if not the first commit, set the compareUrl - if !strings.HasPrefix(oldCommitId, "0000000") { - compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId) - } - pusher_email, pusher_name := "", "" pusher, err := GetUserByName(userName) if err == nil { @@ -293,7 +291,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string, }, Before: oldCommitId, After: newCommitId, - CompareUrl: compareUrl, + CompareUrl: commit.CompareUrl, } for _, w := range ws { diff --git a/models/update.go b/models/update.go index d939a908..33b7733e 100644 --- a/models/update.go +++ b/models/update.go @@ -106,7 +106,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName if err = CommitRepoAction(userId, ru.Id, userName, actEmail, repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil { - log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) + log.GitLogger.Fatal(4, "CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return err } @@ -116,8 +116,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err) } + // Push new branch. var l *list.List - // if a new branch if isNew { l, err = newCommit.CommitsBefore() if err != nil { @@ -134,7 +134,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName return fmt.Errorf("runUpdate.Commit repoId: %v", err) } - // if commits push + // Push commits. commits := make([]*base.PushCommit, 0) var actEmail string for e := l.Front(); e != nil; e = e.Next() { @@ -153,9 +153,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName } } - //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()}) if err = CommitRepoAction(userId, ru.Id, userName, actEmail, - repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}, oldCommitId, newCommitId); err != nil { + repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil { return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return nil diff --git a/modules/base/template.go b/modules/base/template.go index b1c8c161..6d25cd45 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -5,7 +5,6 @@ package base import ( - "bytes" "container/list" "encoding/json" "errors" @@ -107,7 +106,6 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ return a + b }, "ActionIcon": ActionIcon, - "ActionDesc": ActionDesc, "DateFormat": DateFormat, "List": List, "Mail2Domain": func(mail string) string { @@ -162,19 +160,6 @@ func ActionIcon(opType int) string { } } -// FIXME: Legacy -const ( - TPL_CREATE_REPO = `%s created repository %s` - TPL_COMMIT_REPO = `%s pushed to %s at %s%s` - TPL_COMMIT_REPO_LI = `
    user-avatar %s %s
    ` - TPL_CREATE_ISSUE = `%s opened issue %s#%s -
    user-avatar %s
    ` - TPL_TRANSFER_REPO = `%s transfered repository %s to %s` - TPL_PUSH_TAG = `%s pushed tag %s at %s` - TPL_COMMENT_ISSUE = `%s commented on issue %s#%s -
    user-avatar %s
    ` -) - type PushCommit struct { Sha1 string Message string @@ -183,8 +168,9 @@ type PushCommit struct { } type PushCommits struct { - Len int - Commits []*PushCommit + Len int + Commits []*PushCommit + CompareUrl string } func ActionContent2Commits(act Actioner) *PushCommits { @@ -195,52 +181,6 @@ func ActionContent2Commits(act Actioner) *PushCommits { return push } -// FIXME: Legacy -// ActionDesc accepts int that represents action operation type -// and returns the description. -func ActionDesc(act Actioner) string { - actUserName := act.GetActUserName() - email := act.GetActEmail() - repoUserName := act.GetRepoUserName() - repoName := act.GetRepoName() - repoLink := repoUserName + "/" + repoName - branch := act.GetBranch() - content := act.GetContent() - switch act.GetOpType() { - case 1: // Create repository. - return fmt.Sprintf(TPL_CREATE_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, repoName) - case 5: // Commit repository. - var push *PushCommits - if err := json.Unmarshal([]byte(content), &push); err != nil { - return err.Error() - } - buf := bytes.NewBuffer([]byte("\n")) - for _, commit := range push.Commits { - buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n") - } - if push.Len > 3 { - buf.WriteString(fmt.Sprintf(``, actUserName, repoName, branch, push.Len)) - } - return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink, - buf.String()) - case 6: // Create issue. - infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], - AvatarLink(email), infos[1]) - case 8: // Transfer repository. - newRepoLink := content + "/" + repoName - return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink) - case 9: // Push tag. - return fmt.Sprintf(TPL_PUSH_TAG, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink) - case 10: // Comment issue. - infos := strings.SplitN(content, "|", 2) - return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0], - AvatarLink(email), infos[1]) - default: - return "invalid type" - } -} - func DiffTypeToStr(diffType int) string { diffTypes := map[int]string{ 1: "add", 2: "modify", 3: "del", diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index af95092f..6c8211c7 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -271,6 +271,10 @@ img.avatar-100 { .pagination li { display: inline; } +.list-unstyled { + padding-left: 0; + list-style: none; +} .markdown { background-color: white; font-size: 16px; @@ -1487,6 +1491,106 @@ The register and sign-in page style font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace; font-size: 14px; } +.diff-head-box { + margin-top: 10px; +} +.diff-head-box .panel-body { + padding: 10px 15px 5px 10px; +} +.diff-head-box .author img { + margin-top: -7px; +} +.diff-detail-box { + margin: 15px 0; + line-height: 30px; +} +.diff-detail-box ol { + clear: both; + padding-left: 0; + margin-bottom: 28px; +} +.diff-detail-box ol li { + list-style: none; + padding-bottom: 4px; + margin-bottom: 4px; + border-bottom: 1px dashed #DDD; + padding-left: 6px; +} +.diff-detail-box span.status { + display: inline-block; + width: 12px; + height: 12px; + margin-right: 8px; + vertical-align: middle; +} +.diff-detail-box span.status.modify { + background-color: #f0db88; +} +.diff-detail-box span.status.add { + background-color: #b4e2b4; +} +.diff-detail-box span.status.del { + background-color: #e9aeae; +} +.diff-detail-box span.status.rename { + background-color: #dad8ff; +} +.diff-box .count { + margin-right: 12px; +} +.diff-box .count .bar { + background-color: #e75316; + height: 12px; + width: 40px; + display: inline-block; + margin: 2px 4px 0 4px; + vertical-align: text-top; +} +.diff-box .count .bar .add { + background-color: #77c64a; + height: 12px; +} +.diff-box .file { + color: #888; +} +.diff-box .panel-header { + font-size: 14px; +} +.diff-file-box .code-diff tbody tr:hover td, +.diff-file-box .code-diff tbody tr:hover pre { + background-color: #FFF8D2 !important; + border-color: #F0DB88 !important; +} +.diff-file-box .file-body.file-code .lines-num-old { + border-right: 1px solid #DDD; +} +.file-content .file-body.file-code .lines-num { + text-align: right; + color: #999; + background: #fafafa; + width: 1%; +} +.diff-file-box .code-diff tbody tr.tag-code td, +.diff-file-box .code-diff tbody tr.tag-code pre { + background-color: #E0E0E0 !important; + border-color: #ADADAD !important; +} +.diff-file-box .code-diff tbody tr.del-code td, +.diff-file-box .code-diff tbody tr.del-code pre { + background-color: #ffe2dd !important; + border-color: #e9aeae !important; +} +.diff-file-box .code-diff tbody tr.add-code td, +.diff-file-box .code-diff tbody tr.add-code pre { + background-color: #d1ffd6 !important; + border-color: #b4e2b4 !important; +} +.compare-head-box { + margin-top: 10px; +} +.compare-head-box .compare { + padding: 0 15px 15px 15px; +} #admin-wrapper, #setting-wrapper { padding-bottom: 100px; diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index 3ea6fcd4..cc1a277f 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -713,6 +713,14 @@ ul.menu-radius > li:last-child > a { border-bottom-left-radius: .3em; border-bottom-right-radius: .3em; } +.panel.panel-info { + border-color: #85c5e5; +} +.panel.panel-info > .panel-header { + color: #31708f; + background-color: #d9edf7; + border-color: #85c5e5; +} .panel.panel-warning { border-color: #F0C36D; } diff --git a/public/ng/js/gogs.js b/public/ng/js/gogs.js index 4bcdc5c8..538e6c67 100644 --- a/public/ng/js/gogs.js +++ b/public/ng/js/gogs.js @@ -299,6 +299,9 @@ function initCore() { e.preventDefault(); $.magnificPopup.close(); }); + + // Collapse. + $('.collapse').hide(); } function initUserSetting() { @@ -698,6 +701,37 @@ function initProfile() { }); } +function initTimeSwitch() { + // Time switch. + $(".time-since[title]").on("click", function () { + var $this = $(this); + + var title = $this.attr("title"); + var text = $this.text(); + + $this.text(title); + $this.attr("title", text); + }); +} + +function initDiff() { + $('.diff-detail-box>a').click(function () { + $($(this).data('target')).slideToggle(100); + }) + + var $counter = $('.diff-counter'); + if ($counter.length < 1) { + return; + } + $counter.each(function (i, item) { + var $item = $(item); + var addLine = $item.find('span[data-line].add').data("line"); + var delLine = $item.find('span[data-line].del').data("line"); + var addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100; + $item.find(".bar .add").css("width", addPercent + "%"); + }); +} + $(document).ready(function () { Gogs.AppSubUrl = $('head').data('suburl') || ''; initCore(); @@ -737,6 +771,10 @@ $(document).ready(function () { if ($('#user-profile-page').length) { initProfile(); } + if ($('#diff-page').length) { + initTimeSwitch(); + initDiff(); + } $('#dashboard-sidebar-menu').tabs(); $('#pull-issue-preview').markdown_preview(".issue-add-comment"); diff --git a/public/ng/js/min/gogs-min.js b/public/ng/js/min/gogs-min.js index 1538c363..6b7f408d 100644 --- a/public/ng/js/min/gogs-min.js +++ b/public/ng/js/min/gogs-min.js @@ -1,5 +1,5 @@ -function Tabs(e){function t(e){console.log("hide",e),e.removeClass("js-tab-nav-show"),$(e.data("tab-target")).removeClass("js-tab-show").hide()}function n(e){console.log("show",e),e.addClass("js-tab-nav-show"),$(e.data("tab-target")).addClass("js-tab-show").show()}var r=$(e);if(r.length){var i=r.find(".js-tab-nav-show");i.length&&$(i.data("tab-target")).addClass("js-tab-show"),r.on("click",".js-tab-nav",function(e){e.preventDefault();var o=$(this);o.hasClass("js-tab-nav-show")||(i=r.find(".js-tab-nav-show").eq(0),t(i),n(o))}),console.log("init tabs @",e)}}function Preview(e,t){function n(e){return e.find(".js-preview-input").eq(0)}function r(e){return e.hasClass("js-preview-container")?e:e.find(".js-preview-container").eq(0)}var i=$(e),o=$(t),a=n(o);if(!a.length)return void console.log("[preview]: no preview input");var s=r(o);return s.length?(i.on("click",function(){$.post("/api/v1/markdown",{text:a.val()},function(e){s.html(e)})}),void console.log("[preview]: init preview @",e,"&",t)):void console.log("[preview]: no preview container")}function initCore(){Gogs.renderMarkdown(),Gogs.renderCodeView(),$(".js-tab-nav").click(function(e){$(this).hasClass("js-tab-nav-show")||($(this).parent().find(".js-tab-nav-show").each(function(){$(this).removeClass("js-tab-nav-show"),$($(this).data("tab-target")).hide()}),$(this).addClass("js-tab-nav-show"),$($(this).data("tab-target")).show()),e.preventDefault()}),$(document).on("click",".popup-modal-dismiss",function(e){e.preventDefault(),$.magnificPopup.close()})}function initUserSetting(){var t=$("#username"),n=$("#user-profile-form");$("#change-username-btn").magnificPopup({modal:!0,callbacks:{open:function(){t.data("uname")==t.val()&&($.magnificPopup.close(),n.submit())}}}).click(function(){return t.data("uname")!=t.val()?(e.preventDefault(),!0):void 0}),$("#change-username-submit").click(function(){$.magnificPopup.close(),n.submit()}),$("#ssh-add").click(function(){$("#user-ssh-add-form").removeClass("hide")}),$("#delete-account-btn").magnificPopup({modal:!0}).click(function(e){return e.preventDefault(),!0}),$("#delete-account-submit").click(function(){$.magnificPopup.close(),$("#delete-account-form").submit()})}function initRepoCreate(){$("#repo-create-owner-list").on("click","li",function(){if(!$(this).hasClass("checked")){var e=$(this).data("uid");$("#repo-owner-id").val(e),$("#repo-owner-avatar").attr("src",$(this).find("img").attr("src")),$("#repo-owner-name").text($(this).text().trim()),$(this).parent().find(".checked").removeClass("checked"),$(this).addClass("checked"),console.log("set repo owner to uid :",e,$(this).text().trim())}}),$("#auth-button").click(function(e){$("#repo-migrate-auth").slideToggle("fast"),e.preventDefault()}),console.log("initRepoCreate")}function initRepo(){$("#repo-clone-ssh").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-https").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))}),$("#repo-clone-https").click(function(){$(this).removeClass("btn-gray").addClass("btn-blue"),$("#repo-clone-ssh").removeClass("btn-blue").addClass("btn-gray"),$("#repo-clone-url").val($(this).data("link")),$(".clone-url").text($(this).data("link"))});var e=$("#repo-clone-copy");e.hover(function(){Gogs.bindCopy($(this))}),e.tipsy({fade:!0})}function initHookTypeChange(){$("select#hook-type").on("change",function(){hookTypes=["Gogs","Slack"];var e=$(this).val();hookTypes.forEach(function(t){e===t?$("div#"+t.toLowerCase()).toggleShow():$("div#"+t.toLowerCase()).toggleHide()})})}function initRepoSetting(){var t=$("#repo_name"),n=$("#repo-setting-form");$("#change-reponame-btn").magnificPopup({modal:!0,callbacks:{open:function(){t.data("repo-name")==t.val()&&($.magnificPopup.close(),n.submit())}}}).click(function(){return t.data("repo-name")!=t.val()?(e.preventDefault(),!0):void 0}),$("#change-reponame-submit").click(function(){$.magnificPopup.close(),n.submit()}),initHookTypeChange(),$("#transfer-repo-btn").magnificPopup({modal:!0}),$("#transfer-repo-submit").click(function(){$.magnificPopup.close(),$("#transfer-repo-form").submit()}),$("#delete-repo-btn").magnificPopup({modal:!0}),$("#delete-repo-submit").click(function(){$.magnificPopup.close(),$("#delete-repo-form").submit()}),$("#repo-collab-list hr:last-child").remove();var r=$("#repo-collaborator").next().next().find("ul");$("#repo-collaborator").on("keyup",function(){var e=$(this);return e.val()?void Gogs.searchUsers(e.val(),r):void r.toggleHide()}).on("focus",function(){$(this).val()?r.toggleShow():r.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#repo-collaborator").val($(this).text()),r.toggleHide()})}function initOrgSetting(){var t=$("#orgname"),n=$("#org-setting-form");$("#change-orgname-btn").magnificPopup({modal:!0,callbacks:{open:function(){t.data("orgname")==t.val()&&($.magnificPopup.close(),n.submit())}}}).click(function(){return t.data("orgname")!=t.val()?(e.preventDefault(),!0):void 0}),$("#change-orgname-submit").click(function(){$.magnificPopup.close(),n.submit()}),$("#delete-org-btn").magnificPopup({modal:!0}).click(function(e){return e.preventDefault(),!0}),$("#delete-org-submit").click(function(){$.magnificPopup.close(),$("#delete-org-form").submit()}),initHookTypeChange()}function initInvite(){var e=$("#org-member-invite-list");$("#org-member-invite").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-member-invite").val($(this).text()),e.toggleHide()})}function initOrgTeamCreate(){$("#org-team-delete").magnificPopup({modal:!0}).click(function(e){return e.preventDefault(),!0}),$("#delete-team-submit").click(function(){$.magnificPopup.close();var e=$("#team-create-form");e.attr("action",e.data("delete-url"))})}function initTeamMembersList(){var e=$("#org-team-members-list");$("#org-team-members-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchUsers(t.val(),e):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-members-add").val($(this).text()),e.toggleHide()})}function initTeamRepositoriesList(){var e=$("#org-team-repositories-list");$("#org-team-repositories-add").on("keyup",function(){var t=$(this);return t.val()?void Gogs.searchRepos(t.val(),e,"uid="+t.data("uid")):void e.toggleHide()}).on("focus",function(){$(this).val()?e.toggleShow():e.toggleHide()}).next().next().find("ul").on("click","li",function(){$("#org-team-repositories-add").val($(this).text()),e.toggleHide()})}function initAdmin(){$("#login-type").on("change",function(){var e=$(this).val();e.indexOf("0-")+1?($(".auth-name").toggleHide(),$(".pwd").find("input").attr("required","required").end().toggleShow()):($(".pwd").find("input").removeAttr("required").end().toggleHide(),$(".auth-name").toggleShow())}),$("#delete-account-btn").magnificPopup({modal:!0}).click(function(e){return e.preventDefault(),!0}),$("#delete-account-submit").click(function(){$.magnificPopup.close();var e=$("#user-profile-form");e.attr("action",e.data("delete-url"))}),$("#auth-type").on("change",function(){var e=$(this).val();2==e&&($(".ldap").toggleShow(),$(".smtp").toggleHide()),3==e&&($(".smtp").toggleShow(),$(".ldap").toggleHide())}),$("#delete-auth-btn").magnificPopup({modal:!0}).click(function(e){return e.preventDefault(),!0}),$("#delete-auth-submit").click(function(){$.magnificPopup.close();var e=$("#auth-setting-form");e.attr("action",e.data("delete-url"))})}function initInstall(){!function(){var e="127.0.0.1:3306",t="127.0.0.1:5432";$("#install-database").on("change",function(){var n=$(this).val();"SQLite3"!=n?($(".server-sql").show(),$(".sqlite-setting").addClass("hide"),"PostgreSQL"==n?($(".pgsql-setting").removeClass("hide"),$("#database-host").val()==e&&$("#database-host").val(t)):"MySQL"==n?($(".pgsql-setting").addClass("hide"),$("#database-host").val()==t&&$("#database-host").val(e)):$(".pgsql-setting").addClass("hide")):($(".server-sql").hide(),$(".pgsql-setting").hide(),$(".sqlite-setting").removeClass("hide"))})}()}function initProfile(){$("#profile-avatar").tipsy({fade:!0})}function homepage(){$("#promo-form").submit(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/login",!0):void 0}),$("#register-button").click(function(e){return""===$("#username").val()?(e.preventDefault(),window.location.href=Gogs.AppSubUrl+"/user/sign_up",!0):void $("#promo-form").attr("action",Gogs.AppSubUrl+"/user/sign_up")})}!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=e.length,n=ot.type(e);return"function"===n||ot.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function r(e,t,n){if(ot.isFunction(t))return ot.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return ot.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(pt.test(t))return ot.filter(t,e,n);t=ot.filter(t,e)}return ot.grep(e,function(e){return ot.inArray(e,t)>=0!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t=wt[e]={};return ot.each(e.match(xt)||[],function(e,n){t[n]=!0}),t}function a(){mt.addEventListener?(mt.removeEventListener("DOMContentLoaded",s,!1),e.removeEventListener("load",s,!1)):(mt.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(mt.addEventListener||"load"===event.type||"complete"===mt.readyState)&&(a(),ot.ready())}function l(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace($t,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Tt.test(n)?ot.parseJSON(n):n}catch(i){}ot.data(e,t,n)}else n=void 0}return n}function c(e){var t;for(t in e)if(("data"!==t||!ot.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function u(e,t,n,r){if(ot.acceptData(e)){var i,o,a=ot.expando,s=e.nodeType,l=s?ot.cache:e,c=s?e[a]:e[a]&&a;if(c&&l[c]&&(r||l[c].data)||void 0!==n||"string"!=typeof t)return c||(c=s?e[a]=V.pop()||ot.guid++:a),l[c]||(l[c]=s?{}:{toJSON:ot.noop}),("object"==typeof t||"function"==typeof t)&&(r?l[c]=ot.extend(l[c],t):l[c].data=ot.extend(l[c].data,t)),o=l[c],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[ot.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[ot.camelCase(t)])):i=o,i}}function d(e,t,n){if(ot.acceptData(e)){var r,i,o=e.nodeType,a=o?ot.cache:e,s=o?e[ot.expando]:ot.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){ot.isArray(t)?t=t.concat(ot.map(t,ot.camelCase)):t in r?t=[t]:(t=ot.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!c(r):!ot.isEmptyObject(r))return}(n||(delete a[s].data,c(a[s])))&&(o?ot.cleanData([e],!0):rt.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}function f(){return!0}function p(){return!1}function h(){try{return mt.activeElement}catch(e){}}function m(e){var t=Ht.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function g(e,t){var n,r,i=0,o=typeof e.getElementsByTagName!==St?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==St?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||ot.nodeName(r,t)?o.push(r):ot.merge(o,g(r,t));return void 0===t||t&&ot.nodeName(e,t)?ot.merge([e],o):o}function v(e){jt.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return ot.nodeName(e,"table")&&ot.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==ot.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Zt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,r=0;null!=(n=e[r]);r++)ot._data(n,"globalEval",!t||ot._data(t[r],"globalEval"))}function C(e,t){if(1===t.nodeType&&ot.hasData(e)){var n,r,i,o=ot._data(e),a=ot._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)ot.event.add(t,n,s[n][r])}a.data&&(a.data=ot.extend({},a.data))}}function S(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!rt.noCloneEvent&&t[ot.expando]){i=ot._data(t);for(r in i.events)ot.removeEvent(t,r,i.handle);t.removeAttribute(ot.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),rt.html5Clone&&e.innerHTML&&!ot.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&jt.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function k(t,n){var r,i=ot(n.createElement(t)).appendTo(n.body),o=e.getDefaultComputedStyle&&(r=e.getDefaultComputedStyle(i[0]))?r.display:ot.css(i[0],"display");return i.detach(),o}function T(e){var t=mt,n=Jt[e];return n||(n=k(e,t),"none"!==n&&n||(Kt=(Kt||ot("