diff options
author | Unknwon <u@gogs.io> | 2015-11-18 17:42:20 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-18 17:42:20 -0500 |
commit | f04d773f4f72f8f167b7ceed4d4e9a6fd4e6ad16 (patch) | |
tree | 3c642ab96010e2ace4fce4563857a7d228a4a892 /models | |
parent | 4325b01a589ec9d20b6ef588deec3d14852f0816 (diff) | |
download | gitea-f04d773f4f72f8f167b7ceed4d4e9a6fd4e6ad16.tar.gz gitea-f04d773f4f72f8f167b7ceed4d4e9a6fd4e6ad16.zip |
UI: long organization name in create repository owner list
Diffstat (limited to 'models')
-rw-r--r-- | models/user.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/models/user.go b/models/user.go index 3131a88d55..750f59e5c4 100644 --- a/models/user.go +++ b/models/user.go @@ -373,6 +373,15 @@ func (u *User) DisplayName() string { 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 { + if len(u.Name) < length { + return u.Name + } + return u.Name[:length] + "..." +} + // IsUserExist checks if given user name exist, // the user name should be noncased unique. // If uid is presented, then check will rule out that one, |