Skip to content
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

Make extra backends works more easily #220

Merged
merged 1 commit into from
May 31, 2017
Merged

Make extra backends works more easily #220

merged 1 commit into from
May 31, 2017

Conversation

fasheng
Copy link
Contributor

@fasheng fasheng commented May 20, 2017

With the new added elfeed-update-function, elfeed-tag-hooks and
elfeed-untag-hooks, it will be more easily to support extra elfeed
backends.

The ownCloud News in elfeed-backends works well now, you could have a try with the 10 minutes tutorial in README:
https://github.com/fasheng/elfeed-backends

BTW: what do you think about the design in this patch, any advice?

@skeeto
Copy link
Owner

skeeto commented May 20, 2017 via email

@fasheng
Copy link
Contributor Author

fasheng commented May 21, 2017

Thanks for your advice, sir. It's really helpful.

I push another comments now, so you can easily see the changes. All the comments will be merged to one at end.

The elfeed-is-status-error was moved to elfeed.el now and used in elfeed-update-feed, but I prefer don't let argument use-curl as optional and even default value to elfeed-use-curl. For example in elfeed-update-feed, the local variable use-curl wrap the value from global efeed-use-curl, looks there's no reason to use elfeed-use-curl again to change the following logical in elfeed-is-status-error.

And thanks for showing run-at-time for me, I really don't use it before and it's so cool. I read the doc and found that it will not solve the merging multiple tag/untag actions to only one problem which will prevent calling multiple curl processes when user change tags for large number of entries at one time, at least could not solve it directly. So I follow the advice add new function elfeed-tag/untag-multi which accept entries as argument and map original elfeed-tag/untag to it, and adjust the code in elfeed-search.el, things just looks better. If you think elfeed-tag and elfeed-tag-multi should be merged to one, I'd like to do the work and update the rest code, too.

About elfeed-update-function, I really have no good idea. Looks elfeed should provide a full implemtation to support extra backend, but I don't know how to begin it so just add elfeed-update-function to allow user use another method to fetch entries. And the changes in elfeed-search is just to skip call the original update operation like elfeed-update-feed if user customized another one. So any idea, sir?

@fasheng
Copy link
Contributor Author

fasheng commented May 21, 2017

How about just drop changes about elfeed-update-function, then elfeed-backends will define advice for it.Tthis will works well mostly, too.

@skeeto
Copy link
Owner

skeeto commented May 22, 2017 via email

@fasheng
Copy link
Contributor Author

fasheng commented May 23, 2017

Cool argument style, I just didn't thought it before, the code updated now.

Maybe I mistake the source and backend. Anyway, for example ownCloud News, I just want make such remote source works like this:

  1. Fetch and parse articles from remote, and just save them in the original elfeed database because the parsed entries format are same with others besides they own a special metadata to determine who fetched them like (:source ocnews)
  2. Remember necessary configuration like the last modified timestamp. I thinks make the remote source act as a mock feed item and save them in the metadata is just fine
  3. Keep the basic features with the help of tags, for example sync unread/starred stats with remote

So looks it's no necessary to replace the database backend at all, and the visit method is in the same, too. And another point is that the remote souce dispatch fetch all and fetch special feeds is a little different. If we define a owncloud-method, it should looks like this:

(defvar elfeed-default-methods
  (:update-all #'elfeed-update-all
   :update-feed #'elfeed-update-feed
   :tag #'elfeed-tag
   :untag #'elfee-untag
   ...))

(defvar elfeed-owncloud-methods
  (:update-all #'elfeed-owncloud-update-all
   :update-feed #'elfeed-owncloud-update-feed
   :tag #'elfeed-owncloud-tag
   :untag #'elfeed-owncloud-untag
   ...))

The new code will be implemented soon.

@fasheng
Copy link
Contributor Author

fasheng commented May 23, 2017

Hi sir, the new code updated now, how about this time? The changes are:

  1. :pre-tag/untag were used instead of :tag/untag because the extend source may don't want to override the elfeed-tag/untag like :update-all and :update-feed did, they just append some alternate operations. And elfeed-tag/untag-hooks were left along, too, but I believe they will be useful for others, later.
  2. the split package was renamed to elfeed-sources

elfeed-methods styles:

(defvar elfeed-default-methods
  '(:update-all #'elfeed-update-all
    :update-feed #'elfeed-update-feed))
(defvar elfeed-sources-ocnews-methods
  '(:update-all 'elfeed-sources-ocnews-update-all
    :update-feed 'elfeed-sources-ocnews-update-feed
    :pre-tag 'elfeed-sources-ocnews-pre-tag
    :pre-untag 'elfeed-sources-ocnews-pre-untag))

BTW: wish the style seems not strange for you, otherwise I really do not have a better way 😭

Make elfeed-tag/untag support entry or entry list.

Add elfeed-is-status-error helper function.
@fasheng
Copy link
Contributor Author

fasheng commented May 31, 2017

Hi sir, looks the source/backend interface design not so clearly. How about merge the elfeed-tag/untag-hooks firstly? And elfeed-sources will works fine with it :)

The commts were rebased, the old code keeps here:
https://github.com/fasheng/elfeed/tree/old/make-extra-backends-easily

@skeeto skeeto merged commit f3eaa74 into skeeto:master May 31, 2017
@skeeto
Copy link
Owner

skeeto commented Jun 1, 2017 via email

@fasheng
Copy link
Contributor Author

fasheng commented Jun 1, 2017

Sorry not describe it clearly before, my English is not very well..

  1. ownCloud News actually is a collection of feed urls, and it owns update and update-feed methods, too. So just define it as a feed with special protocol is not fine. In fact, if ownCloud was enabled, the origin local feed urls should be disabled.

  2. Yes, some self-host RSS reader like Tiny Tiny RSS support tags itself, but mostly not. So the tags here were only used to check/sync unread/starred stats with remote. And it will not affect database storage locally, that's why I use :pretag instead of :tag. Of course, we could use :tag symbol, but all the elfeed-tag related code need be hacked, too. I'm afraid this will make the code messy.

And really sorry that didn't point the code was inspired by newsbeuter before, which is a terminal RSS reader that already support ownCloud, Tiny Tiny RSS and Newsblur so far. Here is the abstract interfaces it used:
https://github.com/akrennmair/newsbeuter/blob/master/include/remote_api.h

Now my goal is to continue the work in the separate package with help of hooks and advices, just like elfeed-org did. Once the new interface designed, I'd like to update the code then and it should be a easy work.

@skeeto
Copy link
Owner

skeeto commented Jun 6, 2017 via email

@fasheng
Copy link
Contributor Author

fasheng commented Jun 6, 2017

Well, this could work, but will fetch each feed one time just like newsbeuter did, and the problem is if there are hundreds of feeds in remote and the user must send hundreds of requests, too. In fact, the self-hosting feed readers always provide API to fetch all articles in one request. That's why I point out to separate update-all and update-feed in different abstract methods before.

And if will be a little strange for user if we put "ownCloud://url" in elfeed-feeds and store the auth info in another variable..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants