diff --git a/internal/goeland/fetch/feed.go b/internal/goeland/fetch/feed.go index b6789c7..febe0a4 100644 --- a/internal/goeland/fetch/feed.go +++ b/internal/goeland/fetch/feed.go @@ -88,6 +88,7 @@ func fetchFeed(source *goeland.Source, feedLocation string, isFile bool) error { source.Entries = append(source.Entries, entry) } source.Title = feed.Title + source.URL = feed.Link return nil } diff --git a/internal/goeland/fetch/imgur.go b/internal/goeland/fetch/imgur.go index ca4c6d0..f0241b2 100644 --- a/internal/goeland/fetch/imgur.go +++ b/internal/goeland/fetch/imgur.go @@ -2,6 +2,7 @@ package fetch import ( "encoding/json" + "fmt" "io/ioutil" "net/http" "time" @@ -81,6 +82,7 @@ func fetchImgurTag(source *goeland.Source, tag string, sort string) error { entry.URL = item.Link source.Entries = append(source.Entries, entry) } - source.Title = "Imgur pictures for tag #" + tag + source.Title = fmt.Sprintf("Imgur pictures for tag #%s", tag) + source.URL = fmt.Sprintf("https://imgur.com/t/%s", tag) return nil } diff --git a/internal/goeland/filters/filter.go b/internal/goeland/filters/filter.go index 10ec32c..bd3c3dc 100644 --- a/internal/goeland/filters/filter.go +++ b/internal/goeland/filters/filter.go @@ -55,6 +55,7 @@ var filters = map[string]filter{ "untrack": {"Removes feedburner pixel tracking", filterUntrack}, "reddit": {"Better formatting for reddit rss", filterReddit}, "sanitize": {"Sanitize the content of entries (to be used in case of --unsafe-no-sanitize-filter flag)", filterSanitize}, + "toc": {"Create a table of content entry for all the entries", filterToc}, } func GetFiltersHelp() string { @@ -244,6 +245,31 @@ func filterEmbedImage(source *goeland.Source, params *filterParams) { } } +func filterToc(source *goeland.Source, params *filterParams) { + toc := goeland.Entry{} + args := params.args + if len(args) > 0 && strings.ToLower(args[0]) == "nameastitle" { + toc.Title = fmt.Sprintf(`%s`, source.URL, source.Title) + } else { + toc.Title = fmt.Sprintf("Table of Content for %s", source.Title) + } + content := "" + h := sha256.New() + h.Write([]byte(content)) + toc.UID = fmt.Sprintf("%x", h.Sum(nil)) + toc.Date = time.Now() + toc.Content = content + source.Entries = append([]goeland.Entry{toc}, source.Entries...) +} + // FilterSource filters a source according to the config func FilterSource(source *goeland.Source, config config.Provider) { log.Infof("Retrieved %v feeds for source %v", len(source.Entries), source.Name) diff --git a/internal/goeland/i18n/messages.go b/internal/goeland/i18n/messages.go index a67a1b0..0d63924 100644 --- a/internal/goeland/i18n/messages.go +++ b/internal/goeland/i18n/messages.go @@ -9,4 +9,9 @@ func init() { message.SetString(language.BritishEnglish, "Digest for %s", "Digest for %s") message.SetString(language.AmericanEnglish, "Digest for %s", "Digest for %s") message.SetString(language.French, "Digest for %s", "Abrégé de %s") + + message.SetString(language.BritishEnglish, "Imgur pictures for tag #%s", "Imgur pictures for tag #%s") + message.SetString(language.AmericanEnglish, "Imgur pictures for tag #%s", "Imgur pictures for tag #%s") + message.SetString(language.French, "Imgur pictures for tag #%s", "Images Imgur pour le tag#%s") + } diff --git a/internal/goeland/source.go b/internal/goeland/source.go index 028240f..60dac59 100644 --- a/internal/goeland/source.go +++ b/internal/goeland/source.go @@ -19,5 +19,6 @@ type Entry struct { type Source struct { Name string Title string + URL string Entries []Entry }