mirror of https://github.com/go-gitea/gitea.git
#2287 Truncate repository name if too long
This commit is contained in:
parent
a2ef9a2b64
commit
f43cc90841
|
@ -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)
|
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
|
||||||
|
|
||||||
##### Current version: 0.8.19
|
##### Current version: 0.8.20
|
||||||
|
|
||||||
| Web | UI | Preview |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
2
gogs.go
2
gogs.go
|
@ -17,7 +17,7 @@ import (
|
||||||
"github.com/gogits/gogs/modules/setting"
|
"github.com/gogits/gogs/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
const APP_VER = "0.8.19.0111"
|
const APP_VER = "0.8.20.0111"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -90,54 +90,66 @@ func (a *Action) AfterSet(colName string, _ xorm.Cell) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetOpType() int {
|
func (a *Action) GetOpType() int {
|
||||||
return int(a.OpType)
|
return int(a.OpType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetActUserName() string {
|
func (a *Action) GetActUserName() string {
|
||||||
return a.ActUserName
|
return a.ActUserName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetActEmail() string {
|
func (a *Action) ShortActUserName() string {
|
||||||
|
return base.EllipsisString(a.ActUserName, 20)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Action) GetActEmail() string {
|
||||||
return a.ActEmail
|
return a.ActEmail
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetRepoUserName() string {
|
func (a *Action) GetRepoUserName() string {
|
||||||
return a.RepoUserName
|
return a.RepoUserName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetRepoName() string {
|
func (a *Action) ShortRepoUserName() string {
|
||||||
|
return base.EllipsisString(a.RepoUserName, 20)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Action) GetRepoName() string {
|
||||||
return a.RepoName
|
return a.RepoName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetRepoPath() string {
|
func (a *Action) ShortRepoName() string {
|
||||||
return path.Join(a.RepoUserName, a.RepoName)
|
return base.EllipsisString(a.RepoName, 33)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetRepoLink() string {
|
func (a *Action) GetRepoPath() string {
|
||||||
|
return path.Join(a.ShortRepoUserName(), a.ShortRepoName())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Action) GetRepoLink() string {
|
||||||
if len(setting.AppSubUrl) > 0 {
|
if len(setting.AppSubUrl) > 0 {
|
||||||
return path.Join(setting.AppSubUrl, a.GetRepoPath())
|
return path.Join(setting.AppSubUrl, a.GetRepoPath())
|
||||||
}
|
}
|
||||||
return "/" + a.GetRepoPath()
|
return "/" + a.GetRepoPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetBranch() string {
|
func (a *Action) GetBranch() string {
|
||||||
return a.RefName
|
return a.RefName
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetContent() string {
|
func (a *Action) GetContent() string {
|
||||||
return a.Content
|
return a.Content
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetCreate() time.Time {
|
func (a *Action) GetCreate() time.Time {
|
||||||
return a.Created
|
return a.Created
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetIssueInfos() []string {
|
func (a *Action) GetIssueInfos() []string {
|
||||||
return strings.SplitN(a.Content, "|", 2)
|
return strings.SplitN(a.Content, "|", 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetIssueTitle() string {
|
func (a *Action) GetIssueTitle() string {
|
||||||
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
|
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
|
||||||
issue, err := GetIssueByIndex(a.RepoID, index)
|
issue, err := GetIssueByIndex(a.RepoID, index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -147,7 +159,7 @@ func (a Action) GetIssueTitle() string {
|
||||||
return issue.Name
|
return issue.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a Action) GetIssueContent() string {
|
func (a *Action) GetIssueContent() string {
|
||||||
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
|
index := com.StrTo(a.GetIssueInfos()[0]).MustInt64()
|
||||||
issue, err := GetIssueByIndex(a.RepoID, index)
|
issue, err := GetIssueByIndex(a.RepoID, index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -429,13 +429,8 @@ func (u *User) DisplayName() string {
|
||||||
return u.Name
|
return u.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShortName returns shorted user name with given maximum length,
|
|
||||||
// it adds "..." at the end if user name has more length than maximum.
|
|
||||||
func (u *User) ShortName(length int) string {
|
func (u *User) ShortName(length int) string {
|
||||||
if len(u.Name) < length {
|
return base.EllipsisString(u.Name, length)
|
||||||
return u.Name
|
|
||||||
}
|
|
||||||
return u.Name[:length] + "..."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUserExist checks if given user name exist,
|
// IsUserExist checks if given user name exist,
|
||||||
|
|
|
@ -453,6 +453,15 @@ func Subtract(left interface{}, right interface{}) interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EllipsisString returns a truncated short string,
|
||||||
|
// it appends '...' in the end of the length of string is too large.
|
||||||
|
func EllipsisString(str string, length int) string {
|
||||||
|
if len(str) < length {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
return str[:length-3] + "..."
|
||||||
|
}
|
||||||
|
|
||||||
// StringsToInt64s converts a slice of string to a slice of int64.
|
// StringsToInt64s converts a slice of string to a slice of int64.
|
||||||
func StringsToInt64s(strs []string) []int64 {
|
func StringsToInt64s(strs []string) []int64 {
|
||||||
ints := make([]int64, len(strs))
|
ints := make([]int64, len(strs))
|
||||||
|
|
|
@ -3057,6 +3057,18 @@ footer .container .links > *:first-child {
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
color: #888;
|
color: #888;
|
||||||
}
|
}
|
||||||
|
.feeds .list .repo-owner-name-list .item-name {
|
||||||
|
max-width: 70%;
|
||||||
|
margin-bottom: -4px;
|
||||||
|
}
|
||||||
|
.feeds .list #collaborative-repo-list .owner-and-repo {
|
||||||
|
max-width: 80%;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
}
|
||||||
|
.feeds .list #collaborative-repo-list .owner-name {
|
||||||
|
max-width: 120px;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
}
|
||||||
.admin {
|
.admin {
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
padding-bottom: 80px;
|
padding-bottom: 80px;
|
||||||
|
@ -3117,6 +3129,9 @@ footer .container .links > *:first-child {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
.ui.repository.list .item .ui.header .name {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
.ui.repository.list .item .ui.header .metas {
|
.ui.repository.list .item .ui.header .metas {
|
||||||
color: #888;
|
color: #888;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
|
@ -123,5 +123,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.repo-owner-name-list {
|
||||||
|
.item-name {
|
||||||
|
max-width: 70%;
|
||||||
|
margin-bottom: -4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#collaborative-repo-list {
|
||||||
|
.owner-and-repo {
|
||||||
|
max-width: 80%;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
}
|
||||||
|
.owner-name {
|
||||||
|
max-width: 120px;
|
||||||
|
margin-bottom: -5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
.ui.header {
|
.ui.header {
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
padding-bottom: 10px;
|
padding-bottom: 10px;
|
||||||
|
|
||||||
|
.name {
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
.metas {
|
.metas {
|
||||||
color: #888;
|
color: #888;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.8.19.0111
|
0.8.20.0111
|
|
@ -2,7 +2,7 @@
|
||||||
{{range .Repos}}
|
{{range .Repos}}
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="ui header">
|
<div class="ui header">
|
||||||
<a href="{{AppSubUrl}}/{{if .Owner}}{{.Owner.Name}}{{else if $.Org}}{{$.Org.Name}}{{else}}{{$.Owner.Name}}{{end}}/{{.Name}}">{{if $.PageIsExplore}}{{.Owner.Name}} / {{end}}{{.Name}}</a>
|
<a class="name" href="{{AppSubUrl}}/{{if .Owner}}{{.Owner.Name}}{{else if $.Org}}{{$.Org.Name}}{{else}}{{$.Owner.Name}}{{end}}/{{.Name}}">{{if $.PageIsExplore}}{{.Owner.Name}} / {{end}}{{.Name}}</a>
|
||||||
{{if .IsPrivate}}
|
{{if .IsPrivate}}
|
||||||
<span class="text gold"><i class="icon octicon octicon-lock"></i></span>
|
<span class="text gold"><i class="icon octicon octicon-lock"></i></span>
|
||||||
{{else if .IsFork}}
|
{{else if .IsFork}}
|
||||||
|
|
|
@ -22,12 +22,12 @@
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
<ul>
|
<ul class="repo-owner-name-list">
|
||||||
{{range .Repos}}
|
{{range .Repos}}
|
||||||
<li {{if .IsPrivate}}class="private"{{end}}>
|
<li {{if .IsPrivate}}class="private"{{end}}>
|
||||||
<a href="{{AppSubUrl}}/{{$.ContextUser.Name}}/{{.Name}}">
|
<a href="{{AppSubUrl}}/{{$.ContextUser.Name}}/{{.Name}}">
|
||||||
<i class="icon octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
<i class="icon octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
||||||
<strong>{{.Name}}</strong>
|
<strong class="text truncate item-name">{{.Name}}</strong>
|
||||||
<span class="ui right text light grey">
|
<span class="ui right text light grey">
|
||||||
<i class="octicon octicon-star"></i>{{.NumStars}}
|
<i class="octicon octicon-star"></i>{{.NumStars}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -42,12 +42,14 @@
|
||||||
{{.i18n.Tr "home.collaborative_repos"}} <span class="ui grey label">{{.CollaborateCount}}</span>
|
{{.i18n.Tr "home.collaborative_repos"}} <span class="ui grey label">{{.CollaborateCount}}</span>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
<ul>
|
<ul id="collaborative-repo-list">
|
||||||
{{range .CollaborativeRepos}}
|
{{range .CollaborativeRepos}}
|
||||||
<li {{if .IsPrivate}}class="private"{{end}}>
|
<li {{if .IsPrivate}}class="private"{{end}}>
|
||||||
<a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">
|
<a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">
|
||||||
<i class="icon octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
<i class="icon octicon octicon-{{if .IsPrivate}}lock{{else if .IsFork}}repo-forked{{else if .IsMirror}}repo-clone{{else}}repo{{end}}"></i>
|
||||||
{{.Owner.Name}} / <strong>{{.Name}}</strong>
|
<span class="text truncate owner-and-repo">
|
||||||
|
<span class="text truncate owner-name">{{.Owner.Name}}</span> / <strong>{{.Name}}</strong>
|
||||||
|
</span>
|
||||||
<span class="ui right text light grey">
|
<span class="ui right text light grey">
|
||||||
<i class="octicon octicon-star"></i>{{.NumStars}}
|
<i class="octicon octicon-star"></i>{{.NumStars}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -68,12 +70,12 @@
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
<ul>
|
<ul class="repo-owner-name-list">
|
||||||
{{range .ContextUser.Orgs}}
|
{{range .ContextUser.Orgs}}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{AppSubUrl}}/{{.Name}}">
|
<a href="{{AppSubUrl}}/{{.Name}}">
|
||||||
<i class="icon octicon octicon-organization"></i>
|
<i class="icon octicon octicon-organization"></i>
|
||||||
<strong>{{.ShortName 20}}</strong>
|
<strong class="text truncate item-name">{{.Name}}</strong>
|
||||||
<span class="ui right text light grey">
|
<span class="ui right text light grey">
|
||||||
<i class="octicon octicon-repo"></i>{{.NumRepos}}
|
<i class="octicon octicon-repo"></i>{{.NumRepos}}
|
||||||
</span>
|
</span>
|
||||||
|
@ -93,12 +95,12 @@
|
||||||
</div>
|
</div>
|
||||||
</h4>
|
</h4>
|
||||||
<div class="ui attached table segment">
|
<div class="ui attached table segment">
|
||||||
<ul>
|
<ul class="repo-owner-name-list">
|
||||||
{{range .Mirrors}}
|
{{range .Mirrors}}
|
||||||
<li {{if .IsPrivate}}class="private"{{end}}>
|
<li {{if .IsPrivate}}class="private"{{end}}>
|
||||||
<a href="{{AppSubUrl}}/{{$.ContextUser.Name}}/{{.Name}}">
|
<a href="{{AppSubUrl}}/{{$.ContextUser.Name}}/{{.Name}}">
|
||||||
<i class="icon octicon octicon-repo-clone"></i>
|
<i class="icon octicon octicon-repo-clone"></i>
|
||||||
<strong>{{.Name}}</strong>
|
<strong class="text truncate item-name">{{.Name}}</strong>
|
||||||
<span class="ui right text light grey">
|
<span class="ui right text light grey">
|
||||||
<i class="octicon octicon-sync"></i>{{.Interval}}H
|
<i class="octicon octicon-sync"></i>{{.Interval}}H
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="ui fifteen wide column">
|
<div class="ui fifteen wide column">
|
||||||
<div class="{{if eq .GetOpType 5}}push news{{end}}">
|
<div class="{{if eq .GetOpType 5}}push news{{end}}">
|
||||||
<p>
|
<p>
|
||||||
<a href="{{AppSubUrl}}/{{.GetActUserName}}">{{.GetActUserName}}</a>
|
<a href="{{AppSubUrl}}/{{.GetActUserName}}">{{.ShortActUserName}}</a>
|
||||||
{{if eq .GetOpType 1}}
|
{{if eq .GetOpType 1}}
|
||||||
{{$.i18n.Tr "action.create_repo" .GetRepoLink .GetRepoPath | Str2html}}
|
{{$.i18n.Tr "action.create_repo" .GetRepoLink .GetRepoPath | Str2html}}
|
||||||
{{else if eq .GetOpType 2}}
|
{{else if eq .GetOpType 2}}
|
||||||
|
|
Loading…
Reference in New Issue