diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | README_ZH.md | 2 | ||||
-rw-r--r-- | fix.go | 44 | ||||
-rw-r--r-- | gogs.go | 3 | ||||
-rw-r--r-- | models/fix.go | 6 | ||||
-rw-r--r-- | modules/middleware/repo.go | 9 | ||||
-rw-r--r-- | public/js/app.js | 15 | ||||
-rw-r--r-- | templates/base/navbar.tmpl | 4 | ||||
-rw-r--r-- | templates/install.tmpl | 2 |
9 files changed, 78 insertions, 9 deletions
@@ -63,7 +63,7 @@ There are 3 ways to install Gogs: - 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. -- Thanks [lavachen](http://www.lavachen.cn/) for designing Logo. +- Thanks [lavachen](http://www.lavachen.cn/) and [Rocker](http://weibo.com/rocker1989) for designing Logo. - Thanks [gobuild.io](http://gobuild.io) for providing binary compile and download service. - Great thanks to [Docker China](http://www.dockboard.org/) for providing [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles). diff --git a/README_ZH.md b/README_ZH.md index b8278223..177c679a 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -56,7 +56,7 @@ Gogs 完全使用 Go 语言来实现对 Git 数据的操作,实现 **零** 依 - [beego](http://beego.me) 模块的使用与修改。 - [martini](http://martini.codegangsta.io/) 的路由与中间件机制。 - 感谢 [gobuild.io](http://gobuild.io) 提供二进制编译与下载服务。 -- 感谢 [lavachen](http://www.lavachen.cn/) 设计的 Logo。 +- 感谢 [lavachen](http://www.lavachen.cn/) 和 [Rocker](http://weibo.com/rocker1989) 设计的 Logo。 - 感谢 [Docker 中文社区](http://www.dockboard.org/) 提供的 [dockerfiles](https://github.com/gogits/gogs/tree/master/dockerfiles)。 ## 贡献成员 @@ -0,0 +1,44 @@ +// 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 main + +import ( + "fmt" + "os" + + "github.com/codegangsta/cli" + "github.com/gogits/gogs/models" + "github.com/gogits/gogs/modules/base" +) + +var CmdFix = cli.Command{ + Name: "fix", + Usage: "This command for upgrade from old version", + Description: ` +gogs fix provide upgrade from old version`, + Action: runFix, + Flags: []cli.Flag{}, +} + +func runFix(k *cli.Context) { + execDir, _ := base.ExecDir() + newLogger(execDir) + + base.NewConfigContext() + models.LoadModelsConfig() + + if models.UseSQLite3 { + os.Chdir(execDir) + } + + models.SetEngine() + + err := models.Fix() + if err != nil { + fmt.Println(err) + } else { + fmt.Println("Fix successfully!") + } +} @@ -19,7 +19,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.3.1.0427 Alpha" +const APP_VER = "0.3.1.0430 Alpha" func init() { base.AppVer = APP_VER @@ -35,6 +35,7 @@ func main() { CmdWeb, CmdServ, CmdUpdate, + CmdFix, } app.Flags = append(app.Flags, []cli.Flag{}...) app.Run(os.Args) diff --git a/models/fix.go b/models/fix.go new file mode 100644 index 00000000..9fc141bd --- /dev/null +++ b/models/fix.go @@ -0,0 +1,6 @@ +package models + +func Fix() error { + _, err := orm.Exec("alter table repository drop column num_releases") + return err +} diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go index 2d2778cb..e31deac5 100644 --- a/modules/middleware/repo.go +++ b/modules/middleware/repo.go @@ -51,11 +51,14 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { if !ctx.Repo.IsOwner { user, err = models.GetUserByName(params["username"]) if err != nil { - if redirect { + if err == models.ErrUserNotExist { + ctx.Handle(404, "RepoAssignment", err) + return + } else if redirect { ctx.Redirect("/") return } - ctx.Handle(200, "RepoAssignment", err) + ctx.Handle(500, "RepoAssignment", err) return } } else { @@ -67,7 +70,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler { ctx.Redirect("/") return } - ctx.Handle(200, "RepoAssignment", errors.New("invliad user account for single repository")) + ctx.Handle(403, "RepoAssignment", errors.New("invliad user account for single repository")) return } ctx.Repo.Owner = user diff --git a/public/js/app.js b/public/js/app.js index b7b5deb8..30e9d5d0 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -468,6 +468,9 @@ function initRepository() { function initInstall() { // database type change (function () { + var mysql_default = '127.0.0.1:3306' + var postgres_default = '127.0.0.1:5432' + $('#install-database').on("change", function () { var val = $(this).val(); if (val != "SQLite3") { @@ -475,6 +478,18 @@ function initInstall() { $('.sqlite-setting').addClass("hide"); if (val == "PostgreSQL") { $('.pgsql-setting').removeClass("hide"); + + // Change the host value to the Postgres default, but only + // if the user hasn't already changed it from the MySQL + // default. + if ($('#database-host').val() == mysql_default) { + $('#database-host').val(postgres_default); + } + } else if (val == 'MySQL') { + $('.pgsql-setting').addClass("hide"); + if ($('#database-host').val() == postgres_default) { + $('#database-host').val(mysql_default); + } } else { $('.pgsql-setting').addClass("hide"); } diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index b8cba5fa..da6865b8 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -4,7 +4,7 @@ <a id="nav-logo" class="nav-item pull-left{{if .PageIsHome}} active{{end}}" href="/"><img src="/img/favicon.png" alt="Gogs Logo" id="logo"></a> <a class="nav-item pull-left{{if .PageIsUserDashboard}} active{{end}}" href="/">Dashboard</a> <a class="nav-item pull-left{{if .PageIsHelp}} active{{end}}" target="_blank" href="https://github.com/gogits/gogs/wiki">Help</a>{{if .IsSigned}} - {{if .HasAccess}}<!-- <form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form"> + {{if .HasAccess}}<form class="nav-item pull-left{{if .PageIsNewRepo}} active{{end}}" id="nav-search-form"> <div class="input-group"> <div class="input-group-btn"> <button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown">{{if .Repository}}This Repository{{else}}All Repositories{{end}} <span class="caret"></span></button> @@ -16,7 +16,7 @@ </div> <input type="search" class="form-control input-sm" name="q" placeholder="search code, commits and issues"/> </div> - </form> -->{{end}} + </form>{{end}} <a id="nav-out" class="nav-item navbar-right navbar-btn btn btn-danger" href="/user/logout/"><i class="fa fa-power-off fa-lg"></i></a> <a id="nav-avatar" class="nav-item navbar-right{{if .PageIsUserProfile}} active{{end}}" href="{{.SignedUser.HomeLink}}" data-toggle="tooltip" data-placement="bottom" title="{{.SignedUserName}}"> <img src="{{.SignedUser.AvatarLink}}?s=28" alt="user-avatar" title="username"/> diff --git a/templates/install.tmpl b/templates/install.tmpl index 8fe678e5..eb6327d2 100644 --- a/templates/install.tmpl +++ b/templates/install.tmpl @@ -21,7 +21,7 @@ <div class="form-group"> <label class="col-md-3 control-label">Host: </label> <div class="col-md-8"> - <input name="host" class="form-control" placeholder="Type database server host" value="{{.host}}"> + <input name="host" id="database-host" class="form-control" placeholder="Type database server host" value="{{.host}}"> </div> </div> |