-
Notifications
You must be signed in to change notification settings - Fork 518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to find feed on site generated by Hugo #4136
Comments
@ned21 Can you (as a test) remove this line from the
I can add the direct
|
@stuartbreckenridge Thanks for getting back to me so quickly. I have removed the application/json line and confirm that feed detection now works correctly and I can add the feed. When you say the JSON isn't valid, is this a spec violation in what Congo produces? I can turn off the generation of index.json but there's a note saying the json is required for all theme components to work correctly so I'd need to test if I am using any of them. Is there a defined spec for json that Congo should be following? Or is this one of those ill-defined areas of web specification where clients need to be relaxed in what they accept and the only "fix" is to workaround this in NNW? |
To be clear, when I said the JSON isn't valid I meant in terms of the JSON feed spec, which is an alternative to RSS. It appears that your Hugo theme is generating another JSON file that NNW wants to treat as a feed. |
Thanks, that's exactly the thing. I could raise a bug with Congo but I suspect that they may point to this note from August 2020 and claim that there is no other MIME type for their usage?
Could NNW's preferences be adjusted to prefer feed+* over plain json? i.e. Change the order of looking for a valid feed to be:
That would, I think, maintain backwards compatibility but ensure people using application/json for non-feed purposes do not encounter issues? |
Looking at the code, I think the issue might be that while index.xml appears first, because the url doesn't contain rss it doesn't get the +5 score boost, and the second url contains the string json so it gets +6, leaping it ahead of index.xml, despite the ordering. |
@ned21 We aren't looking at the MIME type, only the URL specified. @brentsimmons The weak point in the feed finder process is that once we've extracted potential feeds and scored them, NNW only attempts to parse the feed with the best score. In the scenario above, both Feeds should be scored, and NNW should iterate over them all and stop at the first one that can be parsed. |
@brentsimmons Some quick-and-dirty fleshed out thinking (tested with https://jpanther.github.io/congo/ which has this issue): func createRSSFeed(for account: Account, url: URL, editedName: String?, container: Container, completion: @escaping (Result<Feed, Error>) -> Void) {
// We need to use a batch update here because we need to assign add the feed to the
// container before the name has been downloaded. This will put it in the sidebar
// with an Untitled name if we don't delay it being added to the sidebar.
BatchUpdate.shared.start()
refreshProgress.addToNumberOfTasksAndRemaining(1)
FeedFinder.find(url: url) { result in
switch result {
case .success(let feedSpecifiers):
let scoredFeeds = FeedSpecifier.scoredFeeds(in: feedSpecifiers)
self.logger.debug("Identified the following scored feeds: \(scoredFeeds.map { $0.urlString })")
var parsedFeed: ParsedFeed?
Task { @MainActor in
for feed in scoredFeeds {
self.logger.debug("Attempting to add feed: \(feed.urlString)")
guard let url = URL(string: feed.urlString) else {
continue
}
if account.hasFeed(withURL: feed.urlString) {
self.refreshProgress.completeTask()
BatchUpdate.shared.end()
completion(.failure(AccountError.createErrorAlreadySubscribed))
self.logger.debug("Account has feed with \(feed.urlString)")
return
}
if let parsed = try? await InitialFeedDownloader.download(url) {
parsedFeed = parsed
} else {
self.logger.error("Unable to add feed: \(feed.urlString)")
}
if let parsedFeed = parsedFeed {
let feed = account.createFeed(with: nil, url: url.absoluteString, feedID: url.absoluteString, homePageURL: nil)
feed.editedName = editedName
container.addFeed(feed)
account.update(feed, with: parsedFeed, {_ in
BatchUpdate.shared.end()
completion(.success(feed))
self.logger.debug("Successfully added feed: \(feed.url)")
})
self.refreshProgress.completeTask()
return
} else {
continue
}
}
self.refreshProgress.completeTask()
BatchUpdate.shared.end()
if parsedFeed == nil {
completion(.failure(AccountError.createErrorNotFound))
}
}
case .failure:
BatchUpdate.shared.end()
self.refreshProgress.completeTask()
completion(.failure(AccountError.createErrorNotFound))
}
}
} Then we see output like this:
Or with DF:
|
I see #3878 and #3534 reporting issues with relative URLs within feeds so I am wondering if there is a similar issue with locating feeds from HTML in Version 6.1.4 (6120)?
My site is generated using the Congo theme for Hugo and has this code in the header, but NNW is unable to detect the feed when given
https://www.toobusyto.org.uk/ctt/
as the input.Error message:
Feed not found. Can’t add a feed because no feed was found.
Having said that, I tried changing the second line to:
and it still doesn't work so my guess it's a relative URL issue is likely wrong.
(Thank you so much for making and maintaining this fantastic app!)
The text was updated successfully, but these errors were encountered: