add "mark all read" button
|
|
I would like to add a “mark all read” button. Could you direct me to the file and area where this logic could go? |
|
|
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 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… |
|
|
Great I’ll try that and let you know if it works. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
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. |
|
|
Sure. Just send me a zip file of all your files and I’ll diff with mine. |
|
|
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? |
|
|
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… |
|
|
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> |
|
|
GobbleRSS uses the correct link; it’s just not the link you want to go to. 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. |
|
|
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. |
|
|
Ah, ok. Thanks, I’ll fix that. |
|
|
It should be like this: It was added to fix some broken URLs that I got in the past; indeed, just removing it probably won’t affect you. |