Option to programatically add special feeds (Social Plugin)

Development-related discussion, including bundled plugins
mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Option to programatically add special feeds (Social Plugin)

Postby mightycoco » 26 Mar 2013, 18:34

Hi,

I need some way to add a dynamically created feed in the special feeds category. (Like Fresh/Starred/Published/etc).

I'm writing a plugin with social features where users can add each other as friends and comment/share on articles. So I need to hook into the something like the classes/prefs/feeds.php->getfeedtree() and add a new dynamically created feed to the list. At least a feed into the tree and handle via routing the request.

I'm running against a wall here, because the commenting and friend request stuff is already working - you just don't see the shared articles from your friends.
This would bring back the good old Google Reader Social integration, whioch was remove by Google 2 years ago.

Thanks for any hints,
MC

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 26 Mar 2013, 18:56

Sorry but this will probably never happen. You can create a label or something.

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 27 Mar 2013, 02:19

Hi Fox,

thanks for the info even though this will make social sharing extremely hard.

I have looked into your label idea which looked pretty good at the beginning. However, sharing is not possible there, as labels are user-unique (added to ttrs_user_entries) and if 2 users do have a Label (with the same name) and an article ID is added in ttrs_user_labels2 to both label-IDs the article will only show up in the label of the user, who is the owner of the article.

One place, which restricts an article to one user is in classes/feeds.php where the SELECT is against the label_id + owner_id which is a bit of an overkill, as a label_id is always unique to one user...

Line 781
if ($feed < -10) {
$label_feed = -11-$feed;
$result = db_query($this->link, "SELECT id FROM ttrss_labels2 WHERE
id = '$label_feed' AND owner_uid = " . $_SESSION['uid']);

I'll continue looking into available options, as I really think that social sharing of articles would be a big improvement to TTRSS (it would be one of the few applications which would offer such features!)

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 27 Mar 2013, 09:06

Yeah I see that this could be problematic, even if you create multiple user_entries & user_labels records for it, I'm not sure if it'll work.

I'll investigate adding special feeds, but this is deep inside tt-rss plumbing and could be pretty hard too, also I guess I screwed up with label base index (-10) so there's not much space left in there, about 5 feeds or so.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 27 Mar 2013, 09:41

Well, it looks like I managed to rebase labels below -10, I'll investigate adding special feeds later.

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 27 Mar 2013, 13:16

Sounds awsome! I'll look into the labels idea a bit further. Maybe this is something which could be incooperated, as well as having a "Social" label is pretty sexy though.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 27 Mar 2013, 16:17

This looks really unhealthy to work with, but I digress. Far from everything required is implemented, but it's something you can play around with.

https://github.com/gothfox/Tiny-Tiny-RS ... 1d0993ae0b

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 28 Mar 2013, 01:24

Hi fox,

looks like a good starting point - esp. the concept how vfeeds are observerd. However, I didn't get it working.
As soon as I enable your demo-plugin the page stops loading at 75% with an error creating the Tree

Code: Select all

Object {_attachPoints: Array[1], _attachEvents: Array[0], _connects: Array[0], _supportingWidgets: Array[0], id: "feedTree"…}
 ": error loading undefined children: " TypeError {}


The call to $host->add_feed returns 0 as a dummy_id. This may get compensated in the feed_to_pfeed_id which would result in -129 as a vfeed id.

I also found that in classes\feeds.php the code to call the hooked function never get's executed:

Code: Select all

if (!$cat_view && is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX) {

I try to figure out, why it doesn't get called, but it's pretty hard to write out debugging info to the console, without breaking the dojo stuff.

I'll continue investigating and give an update on that.

Thanks,
MC

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 28 Mar 2013, 08:40

You can also try opening backend.php?op=pref-feeds&method=getfeedtree&mode=2 to see the actual JSON tree that is being generated.

I dunno, the vfeed sample plugin worked for me. The feed id should be -129 and lower and appear in Special, yeah.

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 28 Mar 2013, 18:07

I just did a diff on the getfeedtree with and without example_vfeed. As expected the difference containes only the new vfeed (and correct formated):

Code: Select all

58   58                     {
59   59                         "id": "FEED:-6",
60   60                         "name": "Recently read",
61   61                         "unread": 0,
62   62                         "type": "feed",
63   63                         "error": "",
64   64                         "updated": "",
65   65                         "icon": "images/recently_read.png",
66   66                         "bare_id": -6
67      -                 },
68      -                 {
69      -                     "id": "FEED:-129",
70      -                     "bare_id": -129,
71      -                     "name": "Dummy feed",
72      -                     "checkbox": false,
73      -                     "error": "",
74      -                     "icon": "images/pub_set.svg",
75      -                     "param": "",
76      -                     "unread": 0,
77      -                     "type": "feed"
78   67                     }
79   68                 ],
80   69                 "name": "Special",
81   70                 "type": "category",
82   71                 "unread": 0,
83   72                 "bare_id": -1


If i comment out the line 140 in /pref/feed.php everything works (by omitting the vfeed)

Code: Select all

            foreach ($feeds as $feed) {
               $feed_id = PluginHost::pfeed_to_feed_id($feed['id']);

               $item = array();
               $item['id'] = 'FEED:' . $feed_id;
               $item['bare_id'] = (int)$feed_id;
               $item['name'] = $feed['title'];
               $item['checkbox'] = false;
               $item['error'] = '';
               $item['icon'] = $feed['icon'];

               $item['param'] = '';
               $item['unread'] = 0; //$feed['sender']->get_unread($feed['id']);
               $item['type'] = 'feed';

               //array_push($cat['items'], $item); // <--- Commented out to remove the vfeed from JSON output
            }


That's somehow extremely wired and might have something to do with my 1.7.5 installation. I'll test this on a new vanilla installation tonight.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 28 Mar 2013, 18:09

Wait, did you merge that to 1.7.5? I'm not sure if that'll work, you should be using trunk. You can create a separate dev instance for that, if you don't feel comfortable just using it.

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 28 Mar 2013, 18:33

I played a bit further.
pref/feeds.php

Code: Select all

129       $item['id'] = 'FEED:' . $feed_id;


If I replace this with a hard coded value between -6 and -10 it works!

Code: Select all

129       $item['id'] = 'FEED:-9';


I see in js/FeedTree still some hard-coded values of -10

Code: Select all

109      if (bare_id < -10) {
372               if (hide && unread == 0 && (bare_id > 0 || bare_id < -10 || !show_special)) {


I tried changing them to -128 but that didn't help. However, there still seems to be a problem somewhere with feeds < -10...

I'll dive deeper.

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby fox » 28 Mar 2013, 18:41

Dude, just update to trunk. The labels were rebased because of this issue.

mightycoco
Bear Rating Trainee
Bear Rating Trainee
Posts: 38
Joined: 23 Mar 2013, 20:46

Re: Option to programatically add special feeds (Social Plug

Postby mightycoco » 30 Mar 2013, 01:20

Beautiful. Works like a charm. I'll put the plugin on git within the next days. Maybe someone can beta test.

Features:
    Add registered users as friends
    Accept/Reject friend requests
    Comment on articles
    See in a VFeed your and your friends comments

Nice work an all that, fox!

User avatar
davidm
Plays it by ear
Posts: 115
Joined: 29 Mar 2012, 20:10
Contact:

Re: Option to programatically add special feeds (Social Plug

Postby davidm » 31 Mar 2013, 17:27

I just wanted to say that this can be great. And it would be greatest (and difficult in more than one aspect I guess) if you could link different tt-rss instances and get the social features across them. That could turn tt-rss into an infinitely scalable environment to build a network for collaborative news reading and filtering and publication... Any community project or organisation could use it to mine for content with as many people participating as desired. Could be an interesting evolution after this first version.


Return to “Development”

Who is online

Users browsing this forum: No registered users and 8 guests