Skip to content

Commit

Permalink
rss support RSSNEXT/Follow claim
Browse files Browse the repository at this point in the history
  • Loading branch information
Weaxs committed Oct 28, 2024
1 parent c2db79e commit 948467b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
4 changes: 4 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,7 @@ forgejoDefaultServer = "https://v8.next.forgejo.org"
# bing = ""
# pinterest = ""
# yandex = ""

[RSSNext]
# feedId = ""
# userId = ""
4 changes: 4 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ smartTOCHideUnfocusedChildren = false
# bing = ""
# pinterest = ""
# yandex = ""

[RSSNext]
# feedId = ""
# userId = ""
42 changes: 24 additions & 18 deletions layouts/_default/rss.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
Expand All @@ -27,6 +27,12 @@
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ if and (.Site.Params.RSSNext.feedId) (.Site.Params.RSSNext.userId) }}
<follow_challenge>
<feedId>{{ .Site.Params.RSSNext.feedId }}</feedId>
<userId>{{ .Site.Params.RSSNext.userId }}</userId>
</follow_challenge>
{{ end }}
{{ range $pages }}
<item>
<title>{{ .Title }}</title>
Expand All @@ -36,12 +42,12 @@
<guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description>
{{ range ( where .Site.RegularPages ".RelPermalink" .RelPermalink | first 1 ) }}
{{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="{{ $featured.Permalink }}" />
{{- end -}}
{{- $images := .Resources.ByType "image" -}}
{{- $featured := $images.GetMatch "*feature*" -}}
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- with $featured -}}
<media:content xmlns:media="http://search.yahoo.com/mrss/" url="{{ $featured.Permalink }}" />
{{- end -}}
{{ end }}
</item>
{{ end }}
Expand Down

0 comments on commit 948467b

Please sign in to comment.