From 115a349131242201953a3f5693141679049355c6 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 8 Apr 2014 12:41:33 -0400 Subject: Fix #67 --- modules/base/conf.go | 1 + modules/base/template.go | 3 +++ 2 files changed, 4 insertions(+) (limited to 'modules') diff --git a/modules/base/conf.go b/modules/base/conf.go index 69df49dc..871595e4 100644 --- a/modules/base/conf.go +++ b/modules/base/conf.go @@ -43,6 +43,7 @@ var ( AppName string AppLogo string AppUrl string + IsProdMode bool Domain string SecretKey string RunUser string diff --git a/modules/base/template.go b/modules/base/template.go index 6cd8ade6..5a42107c 100644 --- a/modules/base/template.go +++ b/modules/base/template.go @@ -56,6 +56,9 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{ "AppDomain": func() string { return Domain }, + "IsProdMode": func() bool { + return IsProdMode + }, "LoadTimes": func(startTime time.Time) string { return fmt.Sprint(time.Since(startTime).Nanoseconds()/1e6) + "ms" }, -- cgit v1.2.3 From a773cf1d876d59ab036ebf8a6843bf78da83531e Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 9 Apr 2014 14:11:24 -0400 Subject: Mirror fix --- models/oauth2.go | 20 ++++++++++---------- modules/oauth2/oauth2.go | 15 +++------------ 2 files changed, 13 insertions(+), 22 deletions(-) (limited to 'modules') diff --git a/models/oauth2.go b/models/oauth2.go index 4da98006..cde57b87 100644 --- a/models/oauth2.go +++ b/models/oauth2.go @@ -1,3 +1,7 @@ +// 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 "errors" @@ -16,7 +20,7 @@ var ( type Oauth2 struct { Id int64 - Uid int64 `xorm:"pk"` // userId + Uid int64 // userId User *User `xorm:"-"` Type int `xorm:"pk unique(oauth)"` // twitter,github,google... Identity string `xorm:"pk unique(oauth)"` // id.. @@ -31,18 +35,14 @@ func AddOauth2(oa *Oauth2) (err error) { } func GetOauth2(identity string) (oa *Oauth2, err error) { - oa = &Oauth2{} - oa.Identity = identity - exists, err := orm.Get(oa) + oa = &Oauth2{Identity: identity} + isExist, err := orm.Get(oa) if err != nil { return - } - if !exists { + } else if !isExist { return nil, ErrOauth2RecordNotExists - } - if oa.Uid == 0 { + } else if oa.Uid == 0 { return oa, ErrOauth2NotAssociatedWithUser } - oa.User, err = GetUserById(oa.Uid) - return + return GetUserById(oa.Uid) } diff --git a/modules/oauth2/oauth2.go b/modules/oauth2/oauth2.go index 180c52ca..05ae4606 100644 --- a/modules/oauth2/oauth2.go +++ b/modules/oauth2/oauth2.go @@ -1,16 +1,7 @@ // Copyright 2014 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +// 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 oauth2 contains Martini handlers to provide // user login via an OAuth 2.0 backend. -- cgit v1.2.3 From 3487f1728530fd2b0a447fe6fd7ef079cb53eed4 Mon Sep 17 00:00:00 2001 From: slene Date: Thu, 10 Apr 2014 08:21:51 +0800 Subject: markdown render html --- modules/base/markdown.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/base/markdown.go b/modules/base/markdown.go index 1893ccee..e1ff3856 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -140,7 +140,7 @@ func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte { // htmlFlags |= gfm.HTML_USE_SMARTYPANTS // htmlFlags |= gfm.HTML_SMARTYPANTS_FRACTIONS // htmlFlags |= gfm.HTML_SMARTYPANTS_LATEX_DASHES - htmlFlags |= gfm.HTML_SKIP_HTML + // htmlFlags |= gfm.HTML_SKIP_HTML htmlFlags |= gfm.HTML_SKIP_STYLE htmlFlags |= gfm.HTML_SKIP_SCRIPT htmlFlags |= gfm.HTML_GITHUB_BLOCKCODE -- cgit v1.2.3 From 0f9e07de2d232f19d4201ed739b2039e1881ee3f Mon Sep 17 00:00:00 2001 From: slene Date: Thu, 10 Apr 2014 08:34:19 +0800 Subject: fix render bug --- modules/middleware/render.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/middleware/render.go b/modules/middleware/render.go index 98d485af..66289988 100644 --- a/modules/middleware/render.go +++ b/modules/middleware/render.go @@ -146,7 +146,7 @@ func compile(options RenderOptions) *template.Template { tmpl := t.New(filepath.ToSlash(name)) for _, funcs := range options.Funcs { - tmpl.Funcs(funcs) + tmpl = tmpl.Funcs(funcs) } template.Must(tmpl.Funcs(helperFuncs).Parse(string(buf))) -- cgit v1.2.3 From 5d4025cb5a629716bf84f4f5bf3baa97af716df4 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 9 Apr 2014 21:42:25 -0400 Subject: Add go get meta support --- README.md | 2 +- README_ZH.md | 2 +- gogs.go | 2 +- models/repo.go | 1 + models/user.go | 11 ++++++++++- modules/base/markdown.go | 4 ++-- routers/repo/repo.go | 1 + routers/user/user.go | 14 ++++++++++++++ templates/base/head.tmpl | 1 + templates/repo/setting.tmpl | 13 +++++++++++++ templates/repo/single_bare.tmpl | 14 ++++++++++++++ templates/repo/toolbar.tmpl | 2 +- templates/user/forgot_passwd.tmpl | 2 ++ 13 files changed, 62 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/README.md b/README.md index a4e8901c..619f9a9d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) is a Self Hosted Git Service in the Go Programming Language ![Demo](http://gowalker.org/public/gogs_demo.gif) -##### Current version: 0.2.2 Alpha +##### Current version: 0.2.3 Alpha #### Due to testing purpose, data of [try.gogits.org](http://try.gogits.org) has been reset in April 6, 2014 and will reset multiple times after. Please do NOT put your important data on the site. diff --git a/README_ZH.md b/README_ZH.md index 2f801541..35a0b763 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -5,7 +5,7 @@ Gogs(Go Git Service) 是一个由 Go 语言编写的自助 Git 托管服务。 ![Demo](http://gowalker.org/public/gogs_demo.gif) -##### 当前版本:0.2.2 Alpha +##### 当前版本:0.2.3 Alpha ## 开发目的 diff --git a/gogs.go b/gogs.go index 45be7e87..29710071 100644 --- a/gogs.go +++ b/gogs.go @@ -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.2.2.0409 Alpha" +const APP_VER = "0.2.3.0409 Alpha" func init() { base.AppVer = APP_VER diff --git a/models/repo.go b/models/repo.go index 4f58f407..573e0f4e 100644 --- a/models/repo.go +++ b/models/repo.go @@ -79,6 +79,7 @@ type Repository struct { NumOpenIssues int `xorm:"-"` IsPrivate bool IsBare bool + IsGoget bool Created time.Time `xorm:"created"` Updated time.Time `xorm:"updated"` } diff --git a/models/user.go b/models/user.go index 0fcf7243..b2fddd0a 100644 --- a/models/user.go +++ b/models/user.go @@ -289,11 +289,21 @@ func DeleteUser(user *User) error { // TODO: check issues, other repos' commits + // Delete all followers. + if _, err = orm.Delete(&Follow{FollowId: user.Id}); err != nil { + return err + } + // Delete all feeds. if _, err = orm.Delete(&Action{UserId: user.Id}); err != nil { return err } + // Delete all watches. + if _, err = orm.Delete(&Watch{UserId: user.Id}); err != nil { + return err + } + // Delete all accesses. if _, err = orm.Delete(&Access{UserName: user.LowerName}); err != nil { return err @@ -316,7 +326,6 @@ func DeleteUser(user *User) error { } _, err = orm.Delete(user) - // TODO: delete and update follower information. return err } diff --git a/modules/base/markdown.go b/modules/base/markdown.go index e1ff3856..cc180775 100644 --- a/modules/base/markdown.go +++ b/modules/base/markdown.go @@ -133,7 +133,7 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte { } func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte { - // body := RenderSpecialLink(rawBytes, urlPrefix) + body := RenderSpecialLink(rawBytes, urlPrefix) // fmt.Println(string(body)) htmlFlags := 0 // htmlFlags |= gfm.HTML_USE_XHTML @@ -162,7 +162,7 @@ func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte { extensions |= gfm.EXTENSION_SPACE_HEADERS extensions |= gfm.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK - body := gfm.Markdown(rawBytes, renderer, extensions) + body = gfm.Markdown(body, renderer, extensions) // fmt.Println(string(body)) return body } diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 32c198f2..aebaa65a 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -427,6 +427,7 @@ func SettingPost(ctx *middleware.Context) { ctx.Repo.Repository.Description = ctx.Query("desc") ctx.Repo.Repository.Website = ctx.Query("site") + ctx.Repo.Repository.IsGoget = ctx.Query("goget") == "on" if err := models.UpdateRepository(ctx.Repo.Repository); err != nil { ctx.Handle(404, "repo.SettingPost(update)", err) return diff --git a/routers/user/user.go b/routers/user/user.go index f6a39b86..084d0bbd 100644 --- a/routers/user/user.go +++ b/routers/user/user.go @@ -396,6 +396,10 @@ func Activate(ctx *middleware.Context) { } else { ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60 mailer.SendActiveMail(ctx.Render, ctx.User) + + if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil { + log.Error("Set cache(MailResendLimit) fail: %v", err) + } } } else { ctx.Data["ServiceNotEnabled"] = true @@ -451,7 +455,17 @@ func ForgotPasswd(ctx *middleware.Context) { return } + if ctx.Cache.IsExist("MailResendLimit_" + u.LowerName) { + ctx.Data["ResendLimited"] = true + ctx.HTML(200, "user/forgot_passwd") + return + } + mailer.SendResetPasswdMail(ctx.Render, u) + if err = ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil { + log.Error("Set cache(MailResendLimit) fail: %v", err) + } + ctx.Data["Email"] = email ctx.Data["Hours"] = base.Service.ActiveCodeLives / 60 ctx.Data["IsResetSent"] = true diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 2f88e918..648eb7c4 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -9,6 +9,7 @@ + {{if .Repository.IsGoget}}{{end}} {{if IsProdMode}} diff --git a/templates/repo/setting.tmpl b/templates/repo/setting.tmpl index 85d08c59..1adf0090 100644 --- a/templates/repo/setting.tmpl +++ b/templates/repo/setting.tmpl @@ -43,6 +43,7 @@ +
+ +
+
+
+ +
+
+
+
diff --git a/templates/repo/single_bare.tmpl b/templates/repo/single_bare.tmpl index fc0a3bd9..3f639153 100644 --- a/templates/repo/single_bare.tmpl +++ b/templates/repo/single_bare.tmpl @@ -9,6 +9,20 @@

Quick Guide

+
+ {{.CsrfTokenHtml}} +

Clone from existing repository

+
+ + + + + + + +
+
+

Clone this repository

diff --git a/templates/repo/toolbar.tmpl b/templates/repo/toolbar.tmpl index d8ab2621..9c137e51 100644 --- a/templates/repo/toolbar.tmpl +++ b/templates/repo/toolbar.tmpl @@ -11,7 +11,7 @@
  • {{if .Repository.NumOpenIssues}}{{.Repository.NumOpenIssues}} {{end}}Issues
  • {{if .IsRepoToolbarIssues}}
  • {{if .IsRepoToolbarIssuesList}} - {{else}}{{end}}
  • + {{end}} {{end}}
  • {{if .Repository.NumReleases}}{{.Repository.NumReleases}} {{end}}Releases
  • {{if .IsRepoToolbarReleases}} diff --git a/templates/user/forgot_passwd.tmpl b/templates/user/forgot_passwd.tmpl index ff25406f..a099ff27 100644 --- a/templates/user/forgot_passwd.tmpl +++ b/templates/user/forgot_passwd.tmpl @@ -24,6 +24,8 @@
    {{else if .IsResetDisable}}

    Sorry, mail service is not enabled.

    + {{else if .ResendLimited}} +

    Sorry, you are sending e-mail too frequently, please wait 3 minutes.

    {{end}}
    -- cgit v1.2.3