mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 23:02:41 +01:00
#3320 code cleanup
This commit is contained in:
parent
90dd0657b5
commit
99385db0c4
12 changed files with 52 additions and 33 deletions
|
@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
|
|||
|
||||
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||
|
||||
##### Current tip version: 0.9.65 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||
##### Current tip version: 0.9.66 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||
|
||||
| Web | UI | Preview |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
@ -45,7 +45,7 @@ The goal of this project is to make the easiest, fastest, and most painless way
|
|||
- Repository Git hooks/deploy keys
|
||||
- Repository issues, pull requests and wiki
|
||||
- Add/Remove repository collaborators
|
||||
- Gravatar and custom source
|
||||
- Gravatar and Federated avatar with custom source
|
||||
- Mail service
|
||||
- Administration panel
|
||||
- Supports MySQL, PostgreSQL, SQLite3 and [TiDB](https://github.com/pingcap/tidb) (experimental)
|
||||
|
@ -87,6 +87,7 @@ There are 5 ways to install Gogs:
|
|||
|
||||
### Screencasts
|
||||
|
||||
- [How to install Gogs on a Linux Server (DigitalOcean)](https://www.youtube.com/watch?v=deSfX0gqefE)
|
||||
- [Instalando Gogs no Ubuntu](https://www.youtube.com/watch?v=4UkHAR1F7ZA) (Português)
|
||||
|
||||
### Deploy to Cloud
|
||||
|
|
|
@ -26,7 +26,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
|
|||
- 支持仓库 Git 钩子和部署密钥
|
||||
- 支持仓库工单(Issue)、合并请求(Pull Request)以及 Wiki
|
||||
- 支持添加和删除仓库协作者
|
||||
- 支持 Gravatar 以及自定义源
|
||||
- 支持自定义源的 Gravatar 和 Federated Avatar
|
||||
- 支持邮件服务
|
||||
- 支持后台管理面板
|
||||
- 支持 MySQL、PostgreSQL、SQLite3 和 [TiDB](https://github.com/pingcap/tidb)(实验性支持) 数据库
|
||||
|
|
|
@ -229,9 +229,11 @@ AVATAR_UPLOAD_PATH = data/avatars
|
|||
; Chinese users can choose "duoshuo"
|
||||
; or a custom avatar source, like: http://cn.gravatar.com/avatar/
|
||||
GRAVATAR_SOURCE = gravatar
|
||||
; This value will be forced to be true in offline mode.
|
||||
DISABLE_GRAVATAR = false
|
||||
; Federated avatar lookup uses DNS to discover avatar associated
|
||||
; with emails, see http://www.libravatar.org
|
||||
; This value will be forced to be false in offline mode or Gravatar is disbaled.
|
||||
ENABLE_FEDERATED_AVATAR = false
|
||||
|
||||
[attachment]
|
||||
|
|
|
@ -97,6 +97,7 @@ offline_mode_popup = Disable CDN even in production mode, all resource files wil
|
|||
disable_gravatar = Disable Gravatar Service
|
||||
disable_gravatar_popup = Disable Gravatar and custom sources, all avatars are uploaded by users or default.
|
||||
federated_avatar_lookup = Enable Federated Avatars Lookup
|
||||
federated_avatar_lookup_popup = Enable federated avatars lookup to use federated open source service based on libravatar.
|
||||
disable_registration = Disable Self-registration
|
||||
disable_registration_popup = Disable user self-registration, only admin can create accounts.
|
||||
enable_captcha = Enable Captcha
|
||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.9.65.0806"
|
||||
const APP_VER = "0.9.66.0806"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
|
|
@ -204,26 +204,23 @@ func HashEmail(email string) string {
|
|||
return hex.EncodeToString(h.Sum(nil))
|
||||
}
|
||||
|
||||
// AvatarLink returns avatar link by given email.
|
||||
// AvatarLink returns relative avatar link to the site domain by given email,
|
||||
// which includes app sub-url as prefix. However, it is possible
|
||||
// to return full URL if user enables Gravatar-like service.
|
||||
func AvatarLink(email string) (url string) {
|
||||
|
||||
if !setting.OfflineMode {
|
||||
if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
|
||||
var err error
|
||||
url, err = setting.LibravatarService.FromEmail(email)
|
||||
if err != nil {
|
||||
log.Error(1, "LibravatarService.FromEmail:: %v", err)
|
||||
}
|
||||
}
|
||||
if len(url) == 0 && !setting.DisableGravatar {
|
||||
url = setting.GravatarSource + HashEmail(email)
|
||||
if setting.EnableFederatedAvatar && setting.LibravatarService != nil {
|
||||
var err error
|
||||
url, err = setting.LibravatarService.FromEmail(email)
|
||||
if err != nil {
|
||||
log.Error(1, "LibravatarService.FromEmail: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(url) == 0 && !setting.DisableGravatar {
|
||||
url = setting.GravatarSource + HashEmail(email)
|
||||
}
|
||||
if len(url) == 0 {
|
||||
url = setting.AppSubUrl + "/img/avatar_default.png"
|
||||
}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,8 +20,8 @@ import (
|
|||
_ "github.com/go-macaron/cache/redis"
|
||||
"github.com/go-macaron/session"
|
||||
_ "github.com/go-macaron/session/redis"
|
||||
"gopkg.in/ini.v1"
|
||||
"github.com/strk/go-libravatar"
|
||||
"gopkg.in/ini.v1"
|
||||
|
||||
"github.com/gogits/gogs/modules/bindata"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
|
@ -141,11 +141,11 @@ var (
|
|||
}
|
||||
|
||||
// Picture settings
|
||||
AvatarUploadPath string
|
||||
GravatarSource string
|
||||
DisableGravatar bool
|
||||
EnableFederatedAvatar bool
|
||||
LibravatarService *libravatar.Libravatar
|
||||
AvatarUploadPath string
|
||||
GravatarSource string
|
||||
DisableGravatar bool
|
||||
EnableFederatedAvatar bool
|
||||
LibravatarService *libravatar.Libravatar
|
||||
|
||||
// Log settings
|
||||
LogRootPath string
|
||||
|
@ -470,8 +470,11 @@ func NewContext() {
|
|||
DisableGravatar = true
|
||||
EnableFederatedAvatar = false
|
||||
}
|
||||
if DisableGravatar {
|
||||
EnableFederatedAvatar = false
|
||||
}
|
||||
|
||||
if !DisableGravatar && EnableFederatedAvatar {
|
||||
if EnableFederatedAvatar {
|
||||
LibravatarService = libravatar.New()
|
||||
parts := strings.Split(GravatarSource, "/")
|
||||
if len(parts) >= 3 {
|
||||
|
|
|
@ -187,9 +187,24 @@ function initInstall() {
|
|||
}
|
||||
});
|
||||
|
||||
// TODO: better handling of exclusive relations.
|
||||
$('#offline-mode input').change(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#disable-gravatar').checkbox('check');
|
||||
$('#federated-avatar-lookup').checkbox('uncheck');
|
||||
}
|
||||
});
|
||||
$('#disable-gravatar input').change(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#federated-avatar-lookup').checkbox('uncheck');
|
||||
} else {
|
||||
$('#offline-mode').checkbox('uncheck');
|
||||
}
|
||||
});
|
||||
$('#federated-avatar-lookup input').change(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$('#disable-gravatar').checkbox('uncheck');
|
||||
$('#offline-mode').checkbox('uncheck');
|
||||
}
|
||||
});
|
||||
$('#disable-registration input').change(function () {
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.9.65.0806
|
||||
0.9.66.0806
|
|
@ -179,7 +179,7 @@
|
|||
</div>
|
||||
<div class="inline field">
|
||||
<div class="ui checkbox" id="federated-avatar-lookup">
|
||||
<label class="poping up" data-content="{{.i18n.Tr "install.federated_avatar_lookup"}}"><strong>{{.i18n.Tr "install.federated_avatar_lookup"}}</strong></label>
|
||||
<label class="poping up" data-content="{{.i18n.Tr "install.federated_avatar_lookup_popup"}}"><strong>{{.i18n.Tr "install.federated_avatar_lookup"}}</strong></label>
|
||||
<input name="enable_federated_avatar" type="checkbox" {{if .enable_federated_avatar}}checked{{end}}>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{{.CsrfTokenHtml}}
|
||||
{{if not DisableGravatar}}
|
||||
<div class="inline field">
|
||||
<div class="ui radio">
|
||||
<div class="ui radio checkbox">
|
||||
<input name="source" value="lookup" type="radio" {{if not .SignedUser.UseCustomAvatar}}checked{{end}}>
|
||||
<label>{{.i18n.Tr "settings.lookup_avatar_by_mail"}}</label>
|
||||
</div>
|
||||
|
@ -26,7 +26,7 @@
|
|||
{{end}}
|
||||
|
||||
<div class="inline field">
|
||||
<div class="ui radio">
|
||||
<div class="ui radio checkbox">
|
||||
<input name="source" value="local" type="radio" {{if .SignedUser.UseCustomAvatar}}checked{{end}}>
|
||||
<label>{{.i18n.Tr "settings.enable_custom_avatar"}}</label>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue