diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-28 14:46:33 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-28 14:46:33 +0200 |
commit | 6a3d1037b31706f69d23b46d4c80bafc33f9759d (patch) | |
tree | 0c94106578159d8c77543de9282fd8c92151b33d | |
parent | 342b6fe8a584a84b83159da430773fcdb7b174e4 (diff) | |
download | hugo-6a3d1037b31706f69d23b46d4c80bafc33f9759d.tar.gz hugo-6a3d1037b31706f69d23b46d4c80bafc33f9759d.zip |
Fix RSS Title regression
And add tests to make sure it doesn't happen again.
Fixes #2645
-rw-r--r-- | hugolib/rss_test.go | 35 | ||||
-rw-r--r-- | hugolib/site.go | 2 | ||||
-rw-r--r-- | hugolib/site_test.go | 1 |
3 files changed, 12 insertions, 26 deletions
diff --git a/hugolib/rss_test.go b/hugolib/rss_test.go index 2bf849f9e..966b00af0 100644 --- a/hugolib/rss_test.go +++ b/hugolib/rss_test.go @@ -20,44 +20,27 @@ import ( "github.com/spf13/viper" ) -const rssTemplate = `<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> - <channel> - <title>{{ .Title }} on {{ .Site.Title }} </title> - <link>{{ .Permalink }}</link> - <language>en-us</language> - <author>Steve Francia</author> - <rights>Francia; all rights reserved.</rights> - <updated>{{ .Date }}</updated> - {{ range .Data.Pages }} - <item> - <title>{{ .Title }}</title> - <link>{{ .Permalink }}</link> - <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 MST" }}</pubDate> - <author>Steve Francia</author> - <guid>{{ .Permalink }}</guid> - <description>{{ .Content | html }}</description> - </item> - {{ end }} - </channel> -</rss>` - func TestRSSOutput(t *testing.T) { testCommonResetState() - rssURI := "public/customrss.xml" + rssURI := "customrss.xml" viper.Set("baseURL", "http://auth/bub/") viper.Set("rssURI", rssURI) + viper.Set("title", "RSSTest") for _, s := range weightedSources { - writeSource(t, filepath.Join("content", s.Name), string(s.Content)) + writeSource(t, filepath.Join("content", "sect", s.Name), string(s.Content)) } - writeSource(t, filepath.Join("layouts", "rss.xml"), rssTemplate) - if err := buildAndRenderSite(newSiteDefaultLang()); err != nil { t.Fatalf("Failed to build site: %s", err) } - assertFileContent(t, filepath.Join("public", rssURI), true, "<?xml", "rss version") + // Home RSS + assertFileContent(t, filepath.Join("public", rssURI), true, "<?xml", "rss version", "RSSTest") + // Section RSS + assertFileContent(t, filepath.Join("public", "sect", rssURI), true, "<?xml", "rss version", "Sects on RSSTest") + // Taxonomy RSS + assertFileContent(t, filepath.Join("public", "categories", "hugo", rssURI), true, "<?xml", "rss version", "Hugo on RSSTest") } diff --git a/hugolib/site.go b/hugolib/site.go index b094142af..6aa274a43 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1883,6 +1883,7 @@ func taxonomyRenderer(prepare bool, s *Site, taxes <-chan taxRenderInfo, results if !viper.GetBool("disableRSS") { // XML Feed rssNode := s.newNode(fmt.Sprintf("%s-%s-rss", t.plural, t.key)) + rssNode.Title = n.Title rssURI := viper.GetString("rssURI") s.setURLs(rssNode, base+"/"+rssURI) rssNode.Data = n.Data @@ -2016,6 +2017,7 @@ func (s *Site) renderSectionLists(prepare bool) error { // XML Feed rssURI := viper.GetString("rssURI") rssNode := s.newSectionListNode(true, sectionName+"-rss", section, data, 0) + rssNode.Title = n.Title s.setURLs(rssNode, section+"/"+rssURI) rssLayouts := []string{"section/" + section + ".rss.xml", "_default/rss.xml", "rss.xml", "_internal/_default/rss.xml"} if err := s.renderAndWriteXML("section "+section+" rss", rssNode.addLangPathPrefix(section+"/"+rssURI), rssNode, s.appendThemeTemplates(rssLayouts)...); err != nil { diff --git a/hugolib/site_test.go b/hugolib/site_test.go index bc43fca0f..f368a959f 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -623,6 +623,7 @@ date = "2012-01-01" publishdate = "2012-01-01" my_param = "baz" my_date = 2010-05-27T07:32:00Z +categories = [ "hugo" ] +++ Front Matter with Ordered Pages 4. This is longer content`) |