mirror of
https://github.com/miniflux/v2.git
synced 2025-08-06 17:41:00 +00:00
feat(rewrite): add a rule to remove useless heading images on phoronix
This commit is contained in:
parent
240ec8bd0a
commit
9eea9873b5
2 changed files with 20 additions and 0 deletions
|
@ -5,6 +5,8 @@ package rewrite // import "miniflux.app/v2/internal/reader/rewrite"
|
|||
|
||||
// List of predefined rewrite rules (alphabetically sorted)
|
||||
// domain => rule name
|
||||
//
|
||||
// See https://miniflux.app/docs/rules.html#rewrite-rules
|
||||
var predefinedRules = map[string]string{
|
||||
"abstrusegoose.com": "add_image_title",
|
||||
"amazingsuperpowers.com": "add_image_title",
|
||||
|
@ -25,6 +27,7 @@ var predefinedRules = map[string]string{
|
|||
"oglaf.com": `replace("media.oglaf.com/story/tt(.+).gif"|"media.oglaf.com/comic/$1.jpg"),add_image_title`,
|
||||
"optipess.com": "add_image_title",
|
||||
"peebleslab.com": "add_image_title",
|
||||
"phoronix.com": `remove("img[src^='/assets/categories/']")`,
|
||||
"quantamagazine.org": `add_youtube_video_from_id, remove("h6:not(.byline,.post__title__kicker), #comments, .next-post__content, .footer__section, figure .outer--content, script")`,
|
||||
"qwantz.com": "add_image_title,add_mailto_subject",
|
||||
"sentfromthemoon.com": "add_image_title",
|
||||
|
|
|
@ -797,6 +797,23 @@ func TestRewriteRemoveCustom(t *testing.T) {
|
|||
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
|
||||
}
|
||||
}
|
||||
func TestRewriteRemoveQuotedSelector(t *testing.T) {
|
||||
controlEntry := &model.Entry{
|
||||
URL: "https://example.org/article",
|
||||
Title: `A title`,
|
||||
Content: `<div>Lorem Ipsum</div>`,
|
||||
}
|
||||
testEntry := &model.Entry{
|
||||
URL: "https://example.org/article",
|
||||
Title: `A title`,
|
||||
Content: `<div>Lorem Ipsum<img alt="LINUX KERNEL" src="/assets/categories/linuxkernel.webp" width="100" height="100"></div>`,
|
||||
}
|
||||
ApplyContentRewriteRules(testEntry, `remove("img[src^='/assets/categories/']")`)
|
||||
|
||||
if !reflect.DeepEqual(testEntry, controlEntry) {
|
||||
t.Errorf(`Not expected output: got "%+v" instead of "%+v"`, testEntry, controlEntry)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRewriteAddCastopodEpisode(t *testing.T) {
|
||||
controlEntry := &model.Entry{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue