From d0d8b15bbb06c4118f2f7973a8baf942adf005c8 Mon Sep 17 00:00:00 2001 From: makeworld Date: Wed, 18 Nov 2020 20:39:27 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20Autodetect=20all=20kinds=20of=20?= =?UTF-8?q?feeds?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NOTES.md | 3 --- config/config.go | 2 +- display/private.go | 13 +++++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NOTES.md b/NOTES.md index f79e8d9..65a43a6 100644 --- a/NOTES.md +++ b/NOTES.md @@ -1,11 +1,8 @@ # Notes ## Feeds (temp) -- Only options for "non-text" feed files is the download modal - there should be a feed modal before that one -- Auto feed detection fails on `ebc.li/atom.xml` - which is text - TODO: remove all logger lines - ## Issues - URL for each tab should not be stored as a string - in the current code there's lots of reparsing the URL diff --git a/config/config.go b/config/config.go index 8f783f2..8f988b6 100644 --- a/config/config.go +++ b/config/config.go @@ -230,7 +230,7 @@ func Init() error { viper.SetDefault("a-general.page_max_size", 2097152) viper.SetDefault("a-general.page_max_time", 10) viper.SetDefault("a-general.emoji_favicons", false) - viper.SetDefault("a-general.feeds_popup", true) + viper.SetDefault("a-general.feed_popup", true) viper.SetDefault("keybindings.shift_numbers", "!@#$%^&*()") viper.SetDefault("url-handlers.other", "off") viper.SetDefault("cache.max_size", 0) diff --git a/display/private.go b/display/private.go index ff41f91..6d06d69 100644 --- a/display/private.go +++ b/display/private.go @@ -5,9 +5,11 @@ import ( "errors" "fmt" "io" + "mime" "net" "net/url" "os/exec" + "path" "strconv" "strings" @@ -585,6 +587,17 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) { } // Status code 20, but not a document that can be displayed + + // First see if it's a feed, and ask the user about adding it if it is + filename := path.Base(parsed.Path) + mediatype, _, _ := mime.ParseMediaType(res.Meta) + feed, ok := feeds.GetFeed(mediatype, filename, res.Body) + if ok { + go addFeedDirect(u, feed, feeds.IsTracked(u)) + return ret("", false) + } + + // Otherwise offer download choices go dlChoice("That file could not be displayed. What would you like to do?", u, res) return ret("", false) }