mirror of https://github.com/miniflux/v2.git
Compare commits
24 Commits
71bb4b8872
...
440b6570ae
Author | SHA1 | Date |
---|---|---|
mcnesium | 440b6570ae | |
dependabot[bot] | 9233568da3 | |
Frédéric Guillot | fb075b60b5 | |
mcnesium | abdc35b142 | |
mcnesium | 47903f69ca | |
mcnesium | 2c8d51b4ed | |
mcnesium | d90738005f | |
mcnesium | 51e54b2ade | |
mcnesium | 99314992ed | |
mcnesium | 893dea24c0 | |
mcnesium | 4b4cd22caa | |
mcnesium | 1589c9cc11 | |
mcnesium | 2e228bac62 | |
mcnesium | d9925d7309 | |
mcnesium | a272e91633 | |
mcnesium | 2aab9ad5c4 | |
mcnesium | 5912df50fe | |
mcnesium | 7dbfc555cc | |
mcnesium | c32ec02376 | |
mcnesium | c16f445a59 | |
mcnesium | e2ee4606ac | |
mcnesium | 052d87a85d | |
mcnesium | 91c8598d33 | |
mcnesium | 317a4d642a |
4
go.mod
4
go.mod
|
@ -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
8
go.sum
|
@ -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=
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue