Skip to content

Commit 739e6e2

Browse files
author
Daniel Yrovas
committed
switch rewriter to web_content & fix duplicated shared entry content
1 parent 07f6f5c commit 739e6e2

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

reader/rewrite/rewriter.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,55 +61,55 @@ func parseRules(rulesText string) (rules []rule) {
6161
func applyRule(entryURL string, entry *model.Entry, rule rule) {
6262
switch rule.name {
6363
case "add_image_title":
64-
entry.Content = addImageTitle(entryURL, entry.Content)
64+
entry.WebContent = addImageTitle(entryURL, entry.WebContent)
6565
case "add_mailto_subject":
66-
entry.Content = addMailtoSubject(entryURL, entry.Content)
66+
entry.WebContent = addMailtoSubject(entryURL, entry.WebContent)
6767
case "add_dynamic_image":
68-
entry.Content = addDynamicImage(entryURL, entry.Content)
68+
entry.WebContent = addDynamicImage(entryURL, entry.WebContent)
6969
case "add_youtube_video":
70-
entry.Content = addYoutubeVideo(entryURL, entry.Content)
70+
entry.WebContent = addYoutubeVideo(entryURL, entry.WebContent)
7171
case "add_invidious_video":
72-
entry.Content = addInvidiousVideo(entryURL, entry.Content)
72+
entry.WebContent = addInvidiousVideo(entryURL, entry.WebContent)
7373
case "add_youtube_video_using_invidious_player":
74-
entry.Content = addYoutubeVideoUsingInvidiousPlayer(entryURL, entry.Content)
74+
entry.WebContent = addYoutubeVideoUsingInvidiousPlayer(entryURL, entry.WebContent)
7575
case "add_youtube_video_from_id":
76-
entry.Content = addYoutubeVideoFromId(entry.Content)
76+
entry.WebContent = addYoutubeVideoFromId(entry.WebContent)
7777
case "add_pdf_download_link":
78-
entry.Content = addPDFLink(entryURL, entry.Content)
78+
entry.WebContent = addPDFLink(entryURL, entry.WebContent)
7979
case "nl2br":
80-
entry.Content = replaceLineFeeds(entry.Content)
80+
entry.WebContent = replaceLineFeeds(entry.WebContent)
8181
case "convert_text_link", "convert_text_links":
82-
entry.Content = replaceTextLinks(entry.Content)
82+
entry.WebContent = replaceTextLinks(entry.WebContent)
8383
case "fix_medium_images":
84-
entry.Content = fixMediumImages(entryURL, entry.Content)
84+
entry.WebContent = fixMediumImages(entryURL, entry.WebContent)
8585
case "use_noscript_figure_images":
86-
entry.Content = useNoScriptImages(entryURL, entry.Content)
86+
entry.WebContent = useNoScriptImages(entryURL, entry.WebContent)
8787
case "replace":
8888
// Format: replace("search-term"|"replace-term")
8989
if len(rule.args) >= 2 {
90-
entry.Content = replaceCustom(entry.Content, rule.args[0], rule.args[1])
90+
entry.WebContent = replaceCustom(entry.WebContent, rule.args[0], rule.args[1])
9191
} else {
9292
logger.Debug("[Rewrite] Cannot find search and replace terms for replace rule %s", rule)
9393
}
9494
case "remove":
9595
// Format: remove("#selector > .element, .another")
9696
if len(rule.args) >= 1 {
97-
entry.Content = removeCustom(entry.Content, rule.args[0])
97+
entry.WebContent = removeCustom(entry.WebContent, rule.args[0])
9898
} else {
9999
logger.Debug("[Rewrite] Cannot find selector for remove rule %s", rule)
100100
}
101101
case "add_castopod_episode":
102-
entry.Content = addCastopodEpisode(entryURL, entry.Content)
102+
entry.WebContent = addCastopodEpisode(entryURL, entry.WebContent)
103103
case "base64_decode":
104104
if len(rule.args) >= 1 {
105-
entry.Content = applyFuncOnTextContent(entry.Content, rule.args[0], decodeBase64Content)
105+
entry.WebContent = applyFuncOnTextContent(entry.WebContent, rule.args[0], decodeBase64Content)
106106
} else {
107-
entry.Content = applyFuncOnTextContent(entry.Content, "body", decodeBase64Content)
107+
entry.WebContent = applyFuncOnTextContent(entry.WebContent, "body", decodeBase64Content)
108108
}
109109
case "parse_markdown":
110-
entry.Content = parseMarkdown(entry.Content)
110+
entry.WebContent = parseMarkdown(entry.WebContent)
111111
case "remove_tables":
112-
entry.Content = removeTables(entry.Content)
112+
entry.WebContent = removeTables(entry.WebContent)
113113
case "remove_clickbait":
114114
entry.Title = removeClickbait(entry.Title)
115115
}

template/templates/views/entry.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ <h1 dir="auto">
198198
{{ noescape (proxyFilter .entry.Content) }}
199199
{{ end }}
200200
{{ else }}
201-
{{ noescape .entry.Content }}
202201
{{ if .entry.WebContent }}
203202
{{ noescape .entry.WebContent }}
204203
{{ else }}
@@ -218,11 +217,11 @@ <h1 dir="auto">
218217
data-last-position="{{ .MediaProgression }}"
219218
data-save-url="{{ route "saveEnclosureProgression" "enclosureID" .ID }}"
220219
>
221-
{{ if (and $.user (mustBeProxyfied "audio")) }}
222-
<source src="{{ proxyURL .URL }}" type="{{ .Html5MimeType }}">
223-
{{ else }}
224-
<source src="{{ .URL | safeURL }}" type="{{ .Html5MimeType }}">
225-
{{ end }}
220+
{{ if (and $.user (mustBeProxyfied "audio")) }}
221+
<source src="{{ proxyURL .URL }}" type="{{ .Html5MimeType }}">
222+
{{ else }}
223+
<source src="{{ .URL | safeURL }}" type="{{ .Html5MimeType }}">
224+
{{ end }}
226225
</audio>
227226
</div>
228227
{{ else if hasPrefix .MimeType "video/" }}
@@ -231,11 +230,11 @@ <h1 dir="auto">
231230
data-last-position="{{ .MediaProgression }}"
232231
data-save-url="{{ route "saveEnclosureProgression" "enclosureID" .ID }}"
233232
>
234-
{{ if (and $.user (mustBeProxyfied "video")) }}
235-
<source src="{{ proxyURL .URL }}" type="{{ .Html5MimeType }}">
236-
{{ else }}
237-
<source src="{{ .URL | safeURL }}" type="{{ .Html5MimeType }}">
238-
{{ end }}
233+
{{ if (and $.user (mustBeProxyfied "video")) }}
234+
<source src="{{ proxyURL .URL }}" type="{{ .Html5MimeType }}">
235+
{{ else }}
236+
<source src="{{ .URL | safeURL }}" type="{{ .Html5MimeType }}">
237+
{{ end }}
239238
</video>
240239
</div>
241240
{{ else if hasPrefix .MimeType "image/" }}

0 commit comments

Comments
 (0)