From d3fddff4e6adc0aacc1859d3d1d80cbaa6312885 Mon Sep 17 00:00:00 2001 From: adnano Date: Sat, 2 Oct 2021 16:19:08 -0400 Subject: [PATCH] Remove support for deprecated feeds --- dir.go | 28 +++++----------------------- site.go | 42 ------------------------------------------ 2 files changed, 5 insertions(+), 65 deletions(-) diff --git a/dir.go b/dir.go index 423f2f6..917c626 100644 --- a/dir.go +++ b/dir.go @@ -208,35 +208,17 @@ func (d Dir) buildFeed(cfg *Site, feed Feed) ([]byte, error) { Pages []*Page } - // DeprecatedFeed represents a deprecated feed. - type DeprecatedFeed struct { - Title string - Permalink string - Updated time.Time - Entries []*Page - } - tmpl, ok := cfg.templates.FindTemplate(d.Permalink, feed.Template) if !ok { return nil, fmt.Errorf("failed to generate feed %q: missing feed template %q", feed.Title, feed.Template) } var b bytes.Buffer - var data interface{} - if !feed.deprecated { - data = Feed{ - Title: feed.Title, - Permalink: d.Permalink, - Updated: time.Now(), - Pages: d.Pages, - } - } else { - data = DeprecatedFeed{ - Title: feed.Title, - Permalink: d.Permalink, - Updated: time.Now(), - Entries: d.Pages, - } + data := Feed{ + Title: feed.Title, + Permalink: d.Permalink, + Updated: time.Now(), + Pages: d.Pages, } if err := tmpl.Execute(&b, data); err != nil { return nil, err diff --git a/site.go b/site.go index 215ab8f..42972b6 100644 --- a/site.go +++ b/site.go @@ -2,10 +2,7 @@ package main import ( "fmt" - "log" "os" - "path" - "strings" "text/template" "github.com/pelletier/go-toml" @@ -16,7 +13,6 @@ type Site struct { Title string `toml:"title"` URLs []string `toml:"urls"` Tasks []*Task `toml:"tasks"` - Feeds map[string]string `toml:"feeds"` // Deprecated. Use Task.Feeds instead Params map[string]string `toml:"params"` Permalinks map[string]string `toml:"permalinks"` permalinks map[string]*template.Template @@ -43,9 +39,6 @@ type Feed struct { Title string `toml:"title"` Template string `toml:"template"` Output string `toml:"output"` - - // if true, the feed was specified using deprecated configuration options. - deprecated bool } func (t *Task) Match(ext string) bool { @@ -104,41 +97,6 @@ func LoadSite(config string) (*Site, error) { } } - // Populate task feeds map with deprecated feeds - for dir, title := range site.Feeds { - // Deprecated feeds apply to every task - for _, task := range site.Tasks { - if _, ok := task.feeds[dir]; !ok { - dir = strings.TrimSuffix(dir, "/") - task.feeds[dir] = append(task.feeds[dir], Feed{ - InputDir: dir, - Title: title, - Template: "atom.xml", - Output: path.Join(dir, "atom.xml"), - deprecated: true, - }) - } - } - } - - // Print deprecation warning for [feeds] - if len(site.Feeds) > 0 { - log.Println("WARNING: The [feeds] configuration is deprecated. Please use [[tasks.feeds]] instead:") - for permalink, title := range site.Feeds { - dir := strings.Trim(permalink, "/") - output := path.Join(dir, "atom.xml") - fmt.Fprintf(log.Writer(), `[[tasks.feeds]] -input_dir = %q -title = %q -template = "atom.xml" -output = %q - -`, dir, title, output) - } - - fmt.Fprintf(log.Writer(), "# NOTE: You will also need to use .Pages instead of .Entries in your feed templates\n") - } - return site, nil }