aboutsummaryrefslogtreecommitdiffhomepage
path: root/template
diff options
context:
space:
mode:
authorGravatar Dave Z <dzaikos@users.noreply.github.com>2018-07-17 21:48:28 -0400
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-07-17 18:48:28 -0700
commit3b018bc6bf3b182b0ed24ee2956d0d7ef31ebb07 (patch)
treeccff9b2560177c2094a666d1ac93bb3dcec09d95 /template
parent6aa02680d80709d714672dd842dc3dc2533339fe (diff)
Show feed title instead of domain in items list
Diffstat (limited to 'template')
-rw-r--r--template/common.go4
-rw-r--r--template/functions.go13
-rw-r--r--template/html/common/item_meta.html2
3 files changed, 16 insertions, 3 deletions
diff --git a/template/common.go b/template/common.go
index e4d051f..24ec7aa 100644
--- a/template/common.go
+++ b/template/common.go
@@ -26,7 +26,7 @@ var templateCommonMap = map[string]string{
<div class="item-meta">
<ul>
<li>
- <a href="{{ route "feedEntries" "feedID" .entry.Feed.ID }}" title="{{ .entry.Feed.Title }}">{{ domain .entry.Feed.SiteURL }}</a>
+ <a href="{{ route "feedEntries" "feedID" .entry.Feed.ID }}" title="{{ .entry.Feed.SiteURL }}">{{ truncate .entry.Feed.Title 20 }}</a>
</li>
<li>
<time datetime="{{ isodate .entry.Date }}" title="{{ isodate .entry.Date }}">{{ elapsed .user.Timezone .entry.Date }}</time>
@@ -233,7 +233,7 @@ var templateCommonMap = map[string]string{
var templateCommonMapChecksums = map[string]string{
"entry_pagination": "756ef122f3ebc73754b5fc4304bf05e59da0ab4af030b2509ff4c9b4a74096ce",
- "item_meta": "6cff8ae243f19dac936e523867d2975f70aa749b2a461ae63f6ebbca94cf7419",
+ "item_meta": "1c6b60a74f586c778dae8d9c1ba19ec071550e0758603b2cc8380e1d186c61f7",
"layout": "7a4a1ec5fdfe96b20626aa7b9028fd1f166a753e46b497f6d2232f5cd050895d",
"pagination": "b592d58ea9d6abf2dc0b158621404cbfaeea5413b1c8b8b9818725963096b196",
}
diff --git a/template/functions.go b/template/functions.go
index f68d6fb..4673487 100644
--- a/template/functions.go
+++ b/template/functions.go
@@ -5,6 +5,7 @@
package template
import (
+ "bytes"
"html/template"
"net/mail"
"strings"
@@ -77,6 +78,18 @@ func (f *funcMap) Map() template.FuncMap {
return ts.Format("2006-01-02 15:04:05")
},
"dict": dict,
+ "truncate": func(str string, max int) string {
+ if len(str) > max {
+ var buffer bytes.Buffer
+
+ buffer.WriteString(str[:max-1])
+ buffer.WriteString("…")
+
+ return buffer.String()
+ }
+
+ return str
+ },
// These functions are overrided at runtime after the parsing.
"elapsed": func(timezone string, t time.Time) string {
diff --git a/template/html/common/item_meta.html b/template/html/common/item_meta.html
index 7c43ef5..29ab5e3 100644
--- a/template/html/common/item_meta.html
+++ b/template/html/common/item_meta.html
@@ -2,7 +2,7 @@
<div class="item-meta">
<ul>
<li>
- <a href="{{ route "feedEntries" "feedID" .entry.Feed.ID }}" title="{{ .entry.Feed.Title }}">{{ domain .entry.Feed.SiteURL }}</a>
+ <a href="{{ route "feedEntries" "feedID" .entry.Feed.ID }}" title="{{ .entry.Feed.SiteURL }}">{{ truncate .entry.Feed.Title 20 }}</a>
</li>
<li>
<time datetime="{{ isodate .entry.Date }}" title="{{ isodate .entry.Date }}">{{ elapsed .user.Timezone .entry.Date }}</time>