summaryrefslogtreecommitdiffstats
path: root/pkg/html
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/html')
-rw-r--r--pkg/html/service.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/pkg/html/service.go b/pkg/html/service.go
index bead902..42351fb 100644
--- a/pkg/html/service.go
+++ b/pkg/html/service.go
@@ -1,6 +1,7 @@
package html
import (
+ "strings"
"time"
"git.leonardobishop.net/stash/pkg/entries"
@@ -51,7 +52,7 @@ func (s *service) GenerateHtml(entries []entries.EntryRow) (string, error) {
}
str += "</a>"
- str += "<span class=\"entry-description\">" + entry.Description + "</span>"
+ str += "<span class=\"entry-description\">" + truncateText(entry.Description, 300) + "</span>"
str += "<i class=\"entry-date\">on " + date.Format("02 Jan 2006") + "</i>"
str += "</span>"
}
@@ -62,3 +63,10 @@ func (s *service) GenerateHtml(entries []entries.EntryRow) (string, error) {
return str, nil
}
+
+func truncateText(s string, max int) string {
+ if max > len(s) {
+ return s
+ }
+ return s[:strings.LastIndex(s[:max], " ")] + "..."
+}