Forums GobbleRSS

add "mark all read" button

Subscribe to add "mark all read" button 15 post(s), 2 voice(s)

 
Avatar barton 7 post(s)

I would like to add a “mark all read” button. Could you direct me to the file and area where this logic could go?

 
Avatar Guillaume Bo... Administrator 203 post(s)

The easiest way would be:

index.php: place a link somewhere to trigger that new action; <a onclick=”markAllRead()”>...

js/gob.js: add a new markAllRead() function that loops of all visible articles, and calls action(‘new’, ‘remove’ ...) for all articles ids:

// Note: numRows is a global var
for (var pos=0; pos<numRows; pos++) { var id = $F(‘id_’ + pos); action(‘new’,’remove’,id);
}

While not the most effective way to do this, it makes sure only the visible articles will be marked as read. So that if you’re reading only a specific feed for example, it marks all articles in this feed read, not all articles from all feeds…

 
Avatar barton 7 post(s)

Great I’ll try that and let you know if it works.

 
Avatar Guillaume Bo... Administrator 203 post(s)

And the ‘right’, more demanding way to implement this would be to:

- move to functions.inc.php, in a new function, the top on index.php where different options to select articles from GET & POST data is done; add an option to select a single article using a new GET parameter.

- reuse that function in action.php

- change the calls to action.php (all of them are in js/gob.js?) to use the new function, if needed (only needed if GET/POST parameters form index.php and action.php were in conflict)

- create a ‘mark all read’ link in index.php

- make that link call, in AJAX, action.php?action=remove&state=new and append to that URL the current page’s URL, so that clicking that mark all read link makes only the articles you are currently reading read (not new), not all unread articles.
You’ll also need to make that AJAX call a POST request when the current page has been requested using a POST, and include the current POST data in that request, so that ‘mark all read’ also works fine when viewing search results, or specifc articles by ID.

 
Avatar barton 7 post(s)

Just read your new post. I tried doing it the way you first suggested. I added a shortcut ‘x’ for “mark all read” and added a markAllRead() function. It looks like id_ needs to start at 1 not zero. With that modification it seems to work, though does not refresh the page automatically.

I don’t see any DELETE of items in the articles table so I guess it just gets bigger and bigger. I guess one could add a cron to delete old entries as one option.

All the object php stuff makes it pretty hard to follow the code and the prototype.php stuff is really complex.

 
Avatar Guillaume Bo... Administrator 203 post(s)

It indeed starts at 1, not 0.

There’s no delete. I never want to prune old articles myself, but it should be easy to implement a config option that would be checked when articles are fetched…

I currently have about 110k articles in my DB, and it’s still fast enough to be usable. Searches can sometimes take a little long, but otherwise, it seems to run find even with that much articles kept.

prototype.js is just a library I use. Their documentation is quite thorough, so if you want to see what a function does, the doc. is a better idea than trying to follow JS code! I almost never open that file myself.

 
Avatar barton 7 post(s)

I spent some time looking at the prototype docs on the web as well as examining the other helpers you are using (magpie, and snoopy) which are quite nice. I have made a few modifications to the code to handle errors like up or down etc at the end so the javascript does not just bail and send the user to an error page. I also added the number of unread items after the ‘article’ link on the subscription page as I like to know what is available. Are you interested in any of these modification? If so let me know.
Thanks for an interesting application and a number of utilities I can use for other projects.

 
Avatar Guillaume Bo... Administrator 203 post(s)

Sure. Just send me a zip file of all your files and I’ll diff with mine.
You can send to gobblerss a t pommepause com
Thanks.

 
Avatar barton 7 post(s)

I have also noticed that Google News articles don’t behave as one might expect when the ‘view original article’ is called. The href with the ‘currentLink’ id is not right. The real link is embedded in the article itself. I’ll take a look at fixing this—any ideas?

 
Avatar Guillaume Bo... Administrator 203 post(s)

The link that I use is, I think, the <link> tag of the <article> element. Never tried the Google News RSS but maybe they use some other kind of link tag…
If you can’t find the problem, just give a test URL here for the feed that doesn’t behave correctly and I’ll see what I can find.

 
Avatar barton 7 post(s)

For news.google.com the link to the actual site is after url= up to the next &. I added an ereg to find any news.google.com links and then got the link with a ereg_replace. The link line from google is below:

<link>http://news.google.com/news/url?sa=T&ct=us/0-0-0&fd=R&url=http://edition.cnn.com/2008/SHOWBIZ/Movies/01/23/heath.ledger.dead/%3Fimw%3DY%26iref%3Dmpstoryemail&cid=1126751895&ei=eqaXR-CZKpO4-QGIkLz2Bw</link>
 
Avatar Guillaume Bo... Administrator 203 post(s)

GobbleRSS uses the correct link; it’s just not the link you want to go to.
Google decided to link back to their news site in their own RSS new feed, I don’t intend to change that in GobbleRSS!

It’s pretty much the same way for all other RSS feeds; Gizmodo links to a Gizmodo page, which links back to the original website where the (tech) news originated from. It’s pretty much the same thing with Google News.

 
Avatar barton 7 post(s)

Actually it looks like the problem is the ereg in load_article.php that removes the second http://

if (ereg(‘http://.http://.’, $alink)) { $alink = ereg_replace(‘(http://.)http://.’, ”\\1”, $alink);
}

There may be other reasons for this logic that I don’t understand, but when removed it seems to fix the google problem and a coupled of others.

 
Avatar Guillaume Bo... Administrator 203 post(s)

Ah, ok. Thanks, I’ll fix that.

 
Avatar Guillaume Bo... Administrator 203 post(s)

It should be like this:
if (ereg(‘http://[\?]http://.’, $alink)) { $alink = ereg_replace(‘(http://[\?])http://.’, ”\\1”, $alink); }

It was added to fix some broken URLs that I got in the past; indeed, just removing it probably won’t affect you.

Forums GobbleRSS