Compare commits

...

24 Commits

Author SHA1 Message Date
mcnesium 440b6570ae
Merge abdc35b142 into 9233568da3 2024-04-26 19:25:37 +02:00
dependabot[bot] 9233568da3 Bump github.com/tdewolff/minify/v2 from 2.20.19 to 2.20.20
Bumps [github.com/tdewolff/minify/v2](https://github.com/tdewolff/minify) from 2.20.19 to 2.20.20.
- [Release notes](https://github.com/tdewolff/minify/releases)
- [Commits](https://github.com/tdewolff/minify/compare/v2.20.19...v2.20.20)

---
updated-dependencies:
- dependency-name: github.com/tdewolff/minify/v2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 19:09:18 -07:00
Frédéric Guillot fb075b60b5 reader/processor: minifier is breaking HTML entry content 2024-04-23 20:31:52 -07:00
mcnesium abdc35b142
Merge branch 'miniflux:main' into patch-1 2024-04-19 15:43:39 +02:00
mcnesium 47903f69ca
Merge branch 'patch-1' of github.com:mcnesium/miniflux into patch-1 2024-03-12 17:34:32 +01:00
mcnesium 2c8d51b4ed
Merge branch 'main' into patch-1 2024-03-12 14:53:30 +01:00
mcnesium d90738005f
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2024-03-12 14:22:52 +01:00
mcnesium 51e54b2ade
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2024-02-20 18:50:11 +01:00
mcnesium 99314992ed
Merge branch 'main' into patch-1 2024-02-05 10:37:44 +01:00
mcnesium 893dea24c0
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2024-01-07 13:00:46 +01:00
mcnesium 4b4cd22caa
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2023-10-18 09:42:51 +02:00
mcnesium 1589c9cc11
Merge remote-tracking branch 'upstream/main' into patch-1 2023-10-16 08:11:27 +02:00
mcnesium 2e228bac62
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2023-08-21 14:52:32 +02:00
mcnesium d9925d7309
Merge branch 'patch-1' of github.com:mcnesium/miniflux into patch-1 2023-08-21 14:50:20 +02:00
mcnesium a272e91633
Merge remote-tracking branch 'upstream/main' into patch-1 2023-08-21 14:47:41 +02:00
mcnesium 2aab9ad5c4
Merge branch 'main' into patch-1 2023-07-06 18:20:01 +02:00
mcnesium 5912df50fe
Merge branch 'patch-1' of github.com:mcnesium/miniflux into patch-1 2023-07-06 18:19:14 +02:00
mcnesium 7dbfc555cc
replace em element with less semantic span 2023-06-05 16:12:37 +02:00
mcnesium c32ec02376
Merge branch 'main' of github.com:miniflux/v2 into patch-1 2023-04-10 19:51:23 +02:00
mcnesium c16f445a59
Merge branch 'main' into patch-1 2022-11-15 10:26:55 +01:00
mcnesium e2ee4606ac
Merge remote-tracking branch 'upstream/master' into patch-1 2022-07-20 13:55:04 +02:00
mcnesium 052d87a85d
Merge branch 'miniflux:master' into patch-1 2022-05-28 12:56:46 +02:00
mcnesium 91c8598d33
add title attribute with the author name not truncated 2022-05-17 17:00:35 +02:00
mcnesium 317a4d642a
Show author of a post in the feed list
IMHO it is interesting to see the author of an entry right in the list.
Truncated to 35 characters as the feed title is.
2022-04-27 18:28:57 +02:00
5 changed files with 38 additions and 22 deletions

4
go.mod
View File

@ -11,7 +11,7 @@ require (
github.com/gorilla/mux v1.8.1
github.com/lib/pq v1.10.9
github.com/prometheus/client_golang v1.19.0
github.com/tdewolff/minify/v2 v2.20.19
github.com/tdewolff/minify/v2 v2.20.20
github.com/yuin/goldmark v1.7.1
golang.org/x/crypto v0.22.0
golang.org/x/net v0.24.0
@ -38,7 +38,7 @@ require (
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/tdewolff/parse/v2 v2.7.12 // indirect
github.com/tdewolff/parse/v2 v2.7.13 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/sys v0.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect

8
go.sum
View File

@ -48,10 +48,10 @@ github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tdewolff/minify/v2 v2.20.19 h1:tX0SR0LUrIqGoLjXnkIzRSIbKJ7PaNnSENLD4CyH6Xo=
github.com/tdewolff/minify/v2 v2.20.19/go.mod h1:ulkFoeAVWMLEyjuDz1ZIWOA31g5aWOawCFRp9R/MudM=
github.com/tdewolff/parse/v2 v2.7.12 h1:tgavkHc2ZDEQVKy1oWxwIyh5bP4F5fEh/JmBwPP/3LQ=
github.com/tdewolff/parse/v2 v2.7.12/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/minify/v2 v2.20.20 h1:vhULb+VsW2twkplgsawAoUY957efb+EdiZ7zu5fUhhk=
github.com/tdewolff/minify/v2 v2.20.20/go.mod h1:GYaLXFpIIwsX99apQHXfGdISUdlA98wmaoWxjT9C37k=
github.com/tdewolff/parse/v2 v2.7.13 h1:iSiwOUkCYLNfapHoqdLcqZVgvQ0jrsao8YYKP/UJYTI=
github.com/tdewolff/parse/v2 v2.7.13/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739/go.mod h1:XPuWBzvdUzhCuxWO1ojpXsyzsA5bFoS3tO/Q3kFuTG8=

View File

@ -38,9 +38,6 @@ var (
func ProcessFeedEntries(store *storage.Storage, feed *model.Feed, user *model.User, forceRefresh bool) {
var filteredEntries model.Entries
minifier := minify.New()
minifier.AddFunc("text/html", html.Minify)
// Process older entries first
for i := len(feed.Entries) - 1; i >= 0; i-- {
entry := feed.Entries[i]
@ -107,11 +104,7 @@ func ProcessFeedEntries(store *storage.Storage, feed *model.Feed, user *model.Us
)
} else if content != "" {
// We replace the entry content only if the scraper doesn't return any error.
if minifiedHTML, err := minifier.String("text/html", content); err == nil {
entry.Content = minifiedHTML
} else {
entry.Content = content
}
entry.Content = minifyEntryContent(content)
}
}
@ -189,9 +182,6 @@ func isAllowedEntry(feed *model.Feed, entry *model.Entry) bool {
// ProcessEntryWebPage downloads the entry web page and apply rewrite rules.
func ProcessEntryWebPage(feed *model.Feed, entry *model.Entry, user *model.User) error {
minifier := minify.New()
minifier.AddFunc("text/html", html.Minify)
startTime := time.Now()
websiteURL := getUrlFromEntry(feed, entry)
@ -223,11 +213,7 @@ func ProcessEntryWebPage(feed *model.Feed, entry *model.Entry, user *model.User)
}
if content != "" {
if minifiedHTML, err := minifier.String("text/html", content); err == nil {
entry.Content = minifiedHTML
} else {
entry.Content = content
}
entry.Content = minifyEntryContent(content)
if user.ShowReadingTime {
entry.ReadingTime = readingtime.EstimateReadingTime(entry.Content, user.DefaultReadingSpeed, user.CJKReadingSpeed)
}
@ -439,3 +425,19 @@ func isRecentEntry(entry *model.Entry) bool {
}
return false
}
func minifyEntryContent(entryContent string) string {
m := minify.New()
// Options required to avoid breaking the HTML content.
m.Add("text/html", &html.Minifier{
KeepEndTags: true,
KeepQuotes: true,
})
if minifiedHTML, err := m.String("text/html", entryContent); err == nil {
entryContent = minifiedHTML
}
return entryContent
}

View File

@ -117,3 +117,12 @@ func TestIsRecentEntry(t *testing.T) {
}
}
}
func TestMinifyEntryContent(t *testing.T) {
input := `<p> Some text with a <a href="http://example.org/"> link </a> </p>`
expected := `<p>Some text with a <a href="http://example.org/">link</a></p>`
result := minifyEntryContent(input)
if expected != result {
t.Errorf(`Unexpected result, got %q`, result)
}
}

View File

@ -4,6 +4,11 @@
<li class="item-meta-info-title">
<a href="{{ route "feedEntries" "feedID" .entry.Feed.ID }}" title="{{ .entry.Feed.SiteURL }}" data-feed-link="true">{{ truncate .entry.Feed.Title 35 }}</a>
</li>
{{ if .entry.Author }}
<li class="item-meta-info-author">
<span title="{{ .entry.Author }}">{{ truncate .entry.Author 35 }}</span>
</li>
{{ end }}
<li class="item-meta-info-timestamp">
<time datetime="{{ isodate .entry.Date }}" title="{{ isodate .entry.Date }}">{{ elapsed .user.Timezone .entry.Date }}</time>
</li>