diff --git a/.gobuild.yml b/.gobuild.yml new file mode 100644 index 0000000000..d667c93082 --- /dev/null +++ b/.gobuild.yml @@ -0,0 +1,7 @@ +filesets: + includes: + - templates + - public + - conf + - LICENSE + - README.md \ No newline at end of file diff --git a/README.md b/README.md index fd1a14e0da..08d9787189 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ There are some very good products in this category such as [gitlab](http://gitla - Please see [Wiki](https://github.com/gogits/gogs/wiki) for project design, develop specification, change log and road map. - See [Trello Broad](https://trello.com/b/uxAoeLUl/gogs-go-git-service) to follow the develop team. +- Try it before anything? Go down to **Installation -> Install from binary** section!. ## Features @@ -33,7 +34,7 @@ Make sure you install [Prerequirements](https://github.com/gogits/gogs/wiki/Prer There are two ways to install Gogs: -- [Install from binary](https://github.com/gogits/gogs/wiki/Install-from-binary) +- [Install from binary](https://github.com/gogits/gogs/wiki/Install-from-binary): **STRONGLY RECOMMENDED** for just try and deployment! - [Install from source](https://github.com/gogits/gogs/wiki/Install-from-source) ## Acknowledgments diff --git a/conf/app.ini b/conf/app.ini index 1c7021072f..5dc21a676e 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -1,12 +1,14 @@ -# App name that shows on every page title +; App name that shows on every page title APP_NAME = Gogs: Go Git Service -# !!MUST CHANGE TO YOUR USER NAME!! +; !!MUST CHANGE TO YOUR USER NAME!! RUN_USER = lunny +; Either "dev", "prod" or "test", based on martini +RUN_MODE = dev [repository] ROOT = /Users/%(RUN_USER)s/git/gogs-repositories -LANG_IGNS=Google Go|C|Python|Ruby|C Sharp -LICENSES=Apache v2 License|GPL v2|MIT License|Affero GPL|BSD (3-Clause) License +LANG_IGNS = Google Go|C|Python|Ruby|C Sharp +LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|BSD (3-Clause) License [server] DOMAIN = gogits.org @@ -14,15 +16,25 @@ HTTP_ADDR = HTTP_PORT = 3000 [database] -# Either "mysql" or "postgres", it's your choice +; Either "mysql" or "postgres", it's your choice DB_TYPE = mysql HOST = NAME = gogs USER = root PASSWD = -# For "postgres" only, either "disable" or "verify-full" +; For "postgres" only, either "disable", "require" or "verify-full" SSL_MODE = disable [security] -# !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! +; !!CHANGE THIS TO KEEP YOUR USER DATA SAFE!! USER_PASSWD_SALT = !#@FDEWREWR&*( + +[mailer] +ENABLED = false +; Name displayed in mail title +NAME = %(APP_NAME)s +; Mail server +HOST = +; Mailer user name and password +USER = +PASSWD = \ No newline at end of file diff --git a/gogs.go b/gogs.go index 433b9af094..2757fbc115 100644 --- a/gogs.go +++ b/gogs.go @@ -20,7 +20,7 @@ import ( // Test that go1.1 tag above is included in builds. main.go refers to this definition. const go11tag = true -const APP_VER = "0.1.0.0317.1" +const APP_VER = "0.1.0.0318.1" func init() { base.AppVer = APP_VER diff --git a/models/action.go b/models/action.go index 7917929df4..d388bca991 100644 --- a/models/action.go +++ b/models/action.go @@ -22,8 +22,8 @@ const ( // Action represents user operation type and information to the repository. type Action struct { Id int64 - UserId int64 // Receiver user id. - OpType int + UserId int64 // Receiver user id. + OpType int // Operations: CREATE DELETE STAR ... ActUserId int64 // Action user id. ActUserName string // Action user name. RepoId int64 diff --git a/models/repo.go b/models/repo.go index 1331bbf450..6abfee747a 100644 --- a/models/repo.go +++ b/models/repo.go @@ -401,15 +401,6 @@ func DeleteRepository(userId, repoId int64, userName string) (err error) { return nil } -// Commit represents a git commit. -type Commit struct { - Author string - Email string - Date time.Time - SHA string - Message string -} - var ( ErrRepoFileNotLoaded = fmt.Errorf("repo file not loaded") ) @@ -569,38 +560,6 @@ func GetCommit(userName, repoName, branchname, commitid string) (*git.Commit, er return r.LastCommit() } -/* -// GetLastestCommit returns the latest commit of given repository. -func GetLastestCommit(userName, repoName string) (*Commit, error) { - stdout, _, err := com.ExecCmd("git", "--git-dir="+RepoPath(userName, repoName), "log", "-1") - if err != nil { - return nil, err - } - - commit := new(Commit) - for _, line := range strings.Split(stdout, "\n") { - if len(line) == 0 { - continue - } - switch { - case line[0] == 'c': - commit.SHA = line[7:] - case line[0] == 'A': - infos := strings.SplitN(line, " ", 3) - commit.Author = infos[1] - commit.Email = infos[2][1 : len(infos[2])-1] - case line[0] == 'D': - commit.Date, err = time.Parse("Mon Jan 02 15:04:05 2006 -0700", line[8:]) - if err != nil { - return nil, err - } - case line[:4] == " ": - commit.Message = line[4:] - } - } - return commit, nil -}*/ - // GetCommits returns all commits of given branch of repository. func GetCommits(userName, reposName, branchname string) (*list.List, error) { repo, err := git.OpenRepository(RepoPath(userName, reposName)) diff --git a/models/user.go b/models/user.go index 87c644b2b6..80af9bd4ba 100644 --- a/models/user.go +++ b/models/user.go @@ -252,7 +252,7 @@ func LoginUserPlain(name, passwd string) (*User, error) { } else if !has { err = ErrUserNotExist } - return &user, nil + return &user, err } // FollowUser marks someone be another's follower. diff --git a/modules/base/conf.go b/modules/base/conf.go index 9ed5545e8a..83c7f8872d 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -13,13 +13,23 @@ import ( "github.com/Unknwon/com" "github.com/Unknwon/goconfig" + + "github.com/gogits/gogs/modules/log" ) +// Mailer represents a mail service. +type Mailer struct { + Name string + Host string + User, Passwd string +} + var ( - AppVer string - AppName string - Domain string - Cfg *goconfig.ConfigFile + AppVer string + AppName string + Domain string + Cfg *goconfig.ConfigFile + MailService *Mailer ) func exeDir() (string, error) { @@ -59,6 +69,17 @@ func init() { } Cfg.BlockMode = false - AppName = Cfg.MustValue("", "APP_NAME") + AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service") Domain = Cfg.MustValue("server", "DOMAIN") + + // Check mailer setting. + if Cfg.MustBool("mailer", "ENABLED") { + MailService = &Mailer{ + Name: Cfg.MustValue("mailer", "NAME", AppName), + Host: Cfg.MustValue("mailer", "HOST", "127.0.0.1:25"), + User: Cfg.MustValue("mailer", "USER", "example@example.com"), + Passwd: Cfg.MustValue("mailer", "PASSWD", "******"), + } + log.Info("Mail Service Enabled") + } } diff --git a/routers/dashboard.go b/routers/dashboard.go index ddaef0cb56..d5358f0a00 100644 --- a/routers/dashboard.go +++ b/routers/dashboard.go @@ -18,6 +18,7 @@ func Home(ctx *middleware.Context) { ctx.Render.HTML(200, "home", ctx.Data) } -func Help(ctx *middleware.Context) string { - return "This is help page" +func Help(ctx *middleware.Context) { + ctx.Data["PageIsHelp"] = true + ctx.Render.HTML(200, "help", ctx.Data) } diff --git a/routers/repo/single.go b/routers/repo/single.go index 2ed5cfed23..d64248d990 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -97,7 +97,7 @@ func Single(ctx *middleware.Context, params martini.Params) { ctx.Render.Error(404) return } - ctx.Data["CurrentCommit"] = commit + ctx.Data["LastCommit"] = commit var readmeFile *models.RepoFile @@ -182,10 +182,12 @@ func Commits(ctx *middleware.Context, params martini.Params) { ctx.Render.HTML(200, "repo/commits", ctx.Data) } -func Issues(ctx *middleware.Context) string { - return "This is issues page" +func Issues(ctx *middleware.Context) { + ctx.Data["IsRepoToolbarIssues"] = true + ctx.Render.HTML(200, "repo/issues", ctx.Data) } -func Pulls(ctx *middleware.Context) string { - return "This is pulls page" +func Pulls(ctx *middleware.Context) { + ctx.Data["IsRepoToolbarPulls"] = true + ctx.Render.HTML(200, "repo/pulls", ctx.Data) } diff --git a/routers/user/setting.go b/routers/user/setting.go index 91e992b18e..3f60c6c6fb 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -14,9 +14,11 @@ import ( "github.com/gogits/gogs/modules/middleware" ) +// Render user setting page (email, website modify) func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) { ctx.Data["Title"] = "Setting" - ctx.Data["PageIsUserSetting"] = true + ctx.Data["PageIsUserSetting"] = true // For navbar arrow. + ctx.Data["IsUserPageSetting"] = true // For setting nav highlight. user := ctx.User ctx.Data["Owner"] = user @@ -26,6 +28,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) { return } + // below is for POST requests if hasErr, ok := ctx.Data["HasError"]; ok && hasErr.(bool) { ctx.Render.HTML(200, "user/setting", ctx.Data) return @@ -48,6 +51,7 @@ func Setting(ctx *middleware.Context, form auth.UpdateProfileForm) { func SettingPassword(ctx *middleware.Context, form auth.UpdatePasswdForm) { ctx.Data["Title"] = "Password" ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingPasswd"] = true if ctx.Req.Method == "GET" { ctx.Render.HTML(200, "user/password", ctx.Data) @@ -147,20 +151,23 @@ func SettingSSHKeys(ctx *middleware.Context, form auth.AddSSHKeyForm) { } ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingSSH"] = true ctx.Data["Keys"] = keys ctx.Render.HTML(200, "user/publickey", ctx.Data) } func SettingNotification(ctx *middleware.Context) { - // todo user setting notification + // TODO: user setting notification ctx.Data["Title"] = "Notification" ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingNotify"] = true ctx.Render.HTML(200, "user/notification", ctx.Data) } func SettingSecurity(ctx *middleware.Context) { - // todo user setting security + // TODO: user setting security ctx.Data["Title"] = "Security" ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingSecurity"] = true ctx.Render.HTML(200, "user/security", ctx.Data) } diff --git a/routers/user/user.go b/routers/user/user.go index c43cf84a24..f8c9b4d3dd 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -151,6 +151,8 @@ func SignUp(ctx *middleware.Context, form auth.RegisterForm) { func Delete(ctx *middleware.Context) { ctx.Data["Title"] = "Delete Account" + ctx.Data["PageIsUserSetting"] = true + ctx.Data["IsUserPageSettingDelete"] = true if ctx.Req.Method == "GET" { ctx.Render.HTML(200, "user/delete", ctx.Data) @@ -182,7 +184,7 @@ func Delete(ctx *middleware.Context) { } const ( - feedTpl = ` + TPL_FEED = `
%s
%s
` ) @@ -194,20 +196,20 @@ func Feeds(ctx *middleware.Context, form auth.FeedsForm) { feeds := make([]string, len(actions)) for i := range actions { - feeds[i] = fmt.Sprintf(feedTpl, base.ActionIcon(actions[i].OpType), + feeds[i] = fmt.Sprintf(TPL_FEED, base.ActionIcon(actions[i].OpType), base.TimeSince(actions[i].Created), base.ActionDesc(actions[i], ctx.User.AvatarLink())) } ctx.Render.JSON(200, &feeds) } -func Issues(ctx *middleware.Context) string { - return "This is issues page" +func Issues(ctx *middleware.Context) { + ctx.Render.HTML(200, "user/issues", ctx.Data) } -func Pulls(ctx *middleware.Context) string { - return "This is pulls page" +func Pulls(ctx *middleware.Context) { + ctx.Render.HTML(200, "user/pulls", ctx.Data) } -func Stars(ctx *middleware.Context) string { - return "This is stars page" +func Stars(ctx *middleware.Context) { + ctx.Render.HTML(200, "user/stars", ctx.Data) } diff --git a/templates/base/navbar.tmpl b/templates/base/navbar.tmpl index 181beb5a44..4902ce2593 100644 --- a/templates/base/navbar.tmpl +++ b/templates/base/navbar.tmpl @@ -3,7 +3,7 @@