aboutsummaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-05 00:51:51 -0500
committerUnknwon <u@gogs.io>2016-03-05 00:51:51 -0500
commita2f13eae559c71d35662b7767a8b8347a26eb53e (patch)
tree35a02d0e6afaf1d9269dc9cee10b478d6c847560 /modules/base
parent2a931937a8a92d5b1f3bca9e9cf4cbe23c862ce9 (diff)
downloadgitea-a2f13eae559c71d35662b7767a8b8347a26eb53e.tar.gz
gitea-a2f13eae559c71d35662b7767a8b8347a26eb53e.zip
#1157 some avatar setting changes
- Allow to delete current avatar
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index bc6ff81a14..45d0aea5bc 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -464,6 +464,15 @@ func EllipsisString(str string, length int) string {
return str[:length-3] + "..."
}
+// TruncateString returns a truncated string with given limit,
+// it returns input string if length is not reached limit.
+func TruncateString(str string, limit int) string {
+ if len(str) < limit {
+ return str
+ }
+ return str[:limit]
+}
+
// StringsToInt64s converts a slice of string to a slice of int64.
func StringsToInt64s(strs []string) []int64 {
ints := make([]int64, len(strs))