Repository: tlienart/Franklin.jl
Pull request #685 (2020-11-01 16:10:09)

Fix self-reference URL to tag-feeds.


Patch:
diff --git a/src/manager/rss_generator.jl b/src/manager/rss_generator.jl
index f5093850..f19d4752 100644
--- a/src/manager/rss_generator.jl
+++ b/src/manager/rss_generator.jl
@@ -144,14 +144,16 @@ function rss_generator()::Nothing
         rss_path = joinpath(path(:tag), tag, "feed.xml")
         ## Filter items containing this tag only
         rss_items = OrderedDict{String,RSSItem}(k => v[1] for (k, v) in RSS_DICT_SORTED if tag ∈ v[2])
+        ## Find the relative path for the tag-feeds
+        rss_rel = strip(globvar("tag_page_path"), '/') * "/" * tag * "/"
         ## Write the file
-        write_rss_xml(rss_path, rss_title, rss_descr, rss_link, rss_items)
+        write_rss_xml(rss_path, rss_title, rss_descr, rss_link, rss_items, rss_rel)
     end
 
     return nothing
 end
 
-function write_rss_xml(rss_path, rss_title, rss_descr, rss_link, rss_items)
+function write_rss_xml(rss_path, rss_title, rss_descr, rss_link, rss_items, rss_rel="")
     # is there an RSS file already? if so remove it
     isfile(rss_path) && rm(rss_path)
     # make sure the directory exists
@@ -166,7 +168,7 @@ function write_rss_xml(rss_path, rss_title, rss_descr, rss_link, rss_items)
           <title>$rss_title</title>
           <description><![CDATA[$(fix_relative_links(rss_descr, rss_link))]]></description>
           <link>$rss_link</link>
-          <atom:link href="$(rss_link)feed.xml" rel="self" type="application/rss+xml" />
+          <atom:link href="$(rss_link)$(rss_rel)feed.xml" rel="self" type="application/rss+xml" />
         """)
 
 


Test patch:
diff --git a/test/manager/rss.jl b/test/manager/rss.jl
index f5cdb032..b97252a0 100644
--- a/test/manager/rss.jl
+++ b/test/manager/rss.jl
@@ -66,6 +66,7 @@ end
     @test occursin("<description><![CDATA[Page with tag foo.", fc)
     @test occursin("<pubDate>Fri, 30 Oct 2020 00:00:00 UT</pubDate>", fc)
     @test occursin("<pubDate>Tue, 27 Oct 2020 00:00:00 UT</pubDate>", fc)
+    @test occursin("<atom:link href=\"https://github.com/tlienart/Franklin.jl/feed.xml\" rel=\"self\" type=\"application/rss+xml\" />", fc)
     @test findfirst("Fri, 30 Oct 2020", fc) < findfirst("27 Oct 2020", fc) # ordered by pubDate
 
     ## Tag filtered feeds
@@ -77,6 +78,7 @@ end
     @test occursin("<description><![CDATA[Page with tag foo.", foo_feed)
     @test occursin("<pubDate>Fri, 30 Oct 2020 00:00:00 UT</pubDate>", foo_feed)
     @test occursin("<pubDate>Tue, 27 Oct 2020 00:00:00 UT</pubDate>", foo_feed)
+    @test occursin("<atom:link href=\"https://github.com/tlienart/Franklin.jl/tag/foo/feed.xml\" rel=\"self\" type=\"application/rss+xml\" />", foo_feed)
     @test findfirst("Fri, 30 Oct 2020", foo_feed) < findfirst("27 Oct 2020", foo_feed) # ordered by pubDate
     ### bar tag
     feed = joinpath(F.PATHS[:tag], "bar", "feed.xml")
@@ -86,4 +88,5 @@ end
     @test !occursin("<description><![CDATA[Page with tag foo.", bar_feed)
     @test occursin("<pubDate>Fri, 30 Oct 2020 00:00:00 UT</pubDate>", bar_feed)
     @test !occursin("<pubDate>Tue, 27 Oct 2020 00:00:00 UT</pubDate>", bar_feed)
+    @test occursin("<atom:link href=\"https://github.com/tlienart/Franklin.jl/tag/bar/feed.xml\" rel=\"self\" type=\"application/rss+xml\" />", bar_feed)
 end