Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Topic started by: wk38 on May 22, 2007, 07:41:36 PM

Title: Forum Spy
Post by: wk38 on May 22, 2007, 07:41:36 PM
This is kind of cool. Would be fun to have something like this for SMF.

http://www.rcgroups.com/forums/announcement.php?f=128
Title: Re: Forum Spy
Post by: littlefeather on May 22, 2007, 08:06:52 PM
that is very cool... it would be nice if this could be put in mod or feature requests, because this is something I would definitely put in my forums
Title: Re: Forum Spy
Post by: H on May 23, 2007, 05:33:35 PM
As a mod maybe.

IMO it is rather useless as most boards are small so it would basically be a static list anyway :P
Title: Re: Forum Spy
Post by: SlammedDime on May 23, 2007, 10:41:05 PM
I don't think it would be terribly difficult to code... most of it is Javascript based on RSS feeds... and since SMF already has RSS feeds, and the Javascript could probably be easily modified from that.............

Maybe in a few weeks if I'm looking for something to have some fun with :)
Title: Re: Forum Spy
Post by: khoking on May 23, 2007, 11:05:58 PM
That is very cool for a forum with lots of posts on every second or minute...mine not yet reach that stage...but still I would like to have this mod. :P

No, don't name the mod as SPY as it doesn't sound "safe" to members...
Title: Re: Forum Spy
Post by: Daniel15 on May 24, 2007, 03:11:44 AM
This looks quite interesting, I'll see if I can code up something similar (as usual, no promises!).
Basically, it checks an XML feed every 15 seconds, for any new posts. If there's some new posts, they're added to the table (one entry each second, so people don't get overwhelmed with posts flooding in :P). As SMF already has an XML feed inbuilt, this would be almost entirely client-side.

Title: Re: Forum Spy
Post by: Rudolf on May 24, 2007, 03:18:53 AM
Daniel, if you do write something like this, make sure to add a setting for the update frequency. Since this is ajax, you can even add a way to shape the frequency based on the server load, dynamically. The higher the load the slower the update time.
Without this feature this would make the servers to crawl even on the small-medium forums - if the users start to use it.

Hints: What happens when the number of returned topics is greater then 15 sec. The script is still loading up the topics in the table and a new request will be made. This would cause some parallel insertions, a total mess. Therefore, you need to write your script to don't send an update request only when the "cache" is empty.

Two, I haven't looked at the other script to see how it handles the topic queue, but topics that go over the bottom of the table should be removed from the page. Think DOM. ;)

That's it for now.
Title: Re: Forum Spy
Post by: Daniel15 on May 24, 2007, 04:39:53 AM
QuoteHints: What happens when the number of returned topics is greater then 15 sec. The script is still loading up the topics in the table and a new request will be made. This would cause some parallel insertions, a total mess.
I think it uses a queue - When a new request is made, all the new posts are pushed to the end of the queue.
I haven't looked through that code properly yet, but I may use it as inspiration (I never copy-and-paste code from someone else, I just use their code as inspiration for my own :)). I saw that they're using a JavaScript library (Prototype.js, I think... I'd personally use Scriptaculous or mootools :))
Title: Re: Forum Spy
Post by: Harro on May 24, 2007, 04:49:40 AM
Also take a look at jQuery.
http://jquery.com
http://visualjquery.com

That's a javascript library i've been using lately.
Kinda like it :)
Title: Re: Forum Spy
Post by: Daniel15 on May 26, 2007, 03:02:12 AM
OK, to see what I've done so far, take a look at http://rpl.dev.dansoftaustralia.net/smf/index.php?action=recentlive. It initially loads the latest 5 posts into the list, and then checks every 10 seconds for new ones. Open that page in a new browser window/tab, and then make a new topic (you may login with the username and password of "test"). After a few seconds, you'll see your new post appear in the list :).
You can get the code from its SVN repository (http://dev.dansoftaustralia.net/scm/?group_id=23), but there's no guarantees it will work for you (and I'm not giving any support yet). If you have any suggestions, please tell me :D

QuoteThat's a javascript library i've been using lately.
Kinda like it
Looks nice, I may consider using it.
The only libraries I'm familiar with at the moment are Scriptaculous (which uses Prototype.js) and mootools. I love mootools because it's so lightweight (5 - 40 KB packed, depending on the options you choose when downloading it).
Title: Re: Forum Spy
Post by: Tanks on May 26, 2007, 05:54:26 AM
It gives me an error in IE7 when i try to see you demo !
Title: Re: Forum Spy
Post by: Daniel15 on May 26, 2007, 07:52:15 AM
Quote from: Tanks on May 26, 2007, 05:54:26 AM
It gives me an error in IE7 when i try to see you demo !
What errors are you getting?
Sorry, I could not test it in IE7, as I do not have Windows installed at the moment (I use Linux).
Title: Re: Forum Spy
Post by: Dannii on May 26, 2007, 08:40:31 AM
base2 is my library of choice ;)
Are you doing this poll based, or Comet (http://en.wikipedia.org/wiki/Comet_%28programming%29) based?
Title: Re: Forum Spy
Post by: Daniel15 on May 26, 2007, 10:48:12 AM
Currently, it's poll-based. I'd probably have problems with timeouts and such if I tried to make it Comet-based ;).
Title: Re: Forum Spy
Post by: karlbenson on May 26, 2007, 11:21:15 AM
yes daniel, I get the error too on IE7

(http://img329.imageshack.us/img329/237/ie7errorwk3.gif)

Works fine in Firefox for me!
Title: Re: Forum Spy
Post by: Daniel15 on May 26, 2007, 11:59:12 AM
OK, I'll take a look at it when I have access to a Windows PC :).
Title: Re: Forum Spy
Post by: metallica48423 on May 26, 2007, 08:39:27 PM
i get no error, using firefox, on a windows based PC

another IE7 glitch :P

This mod is awesome, awesome work daniel15!
Title: Re: Forum Spy
Post by: Daniel15 on May 26, 2007, 10:24:38 PM
Quote from: karlbenson on May 26, 2007, 11:21:15 AM
yes daniel, I get the error too on IE7

(http://img329.imageshack.us/img329/237/ie7errorwk3.gif)

Works fine in Firefox for me!
Was that the full error message? Line 42 on the page itself is unrelated, and line 42 in rpl.js is blank :o.
I'll install my copy of Windows XP into a virtual machine later, download IE7, and see what I can do to fix it ;)

QuoteThis mod is awesome, awesome work daniel15!
Thanks :D

As usual, I'll only release it once I've finished with it, and have time to... This may not be for a while (mid-year exams coming soon!)
Title: Re: Forum Spy
Post by: Dannii on May 27, 2007, 03:48:31 AM
Quote from: Daniel15 on May 26, 2007, 10:48:12 AM
Currently, it's poll-based. I'd probably have problems with timeouts and such if I tried to make it Comet-based ;).
Apache sucks for Comet too. Polls can work okay, just make sure the footprint is low ;)
Title: Re: Forum Spy
Post by: Daniel15 on May 27, 2007, 04:27:24 AM
Quote from: eldʌkaː on May 27, 2007, 03:48:31 AM
Quote from: Daniel15 on May 26, 2007, 10:48:12 AM
Currently, it's poll-based. I'd probably have problems with timeouts and such if I tried to make it Comet-based ;).
Apache sucks for Comet too. Polls can work okay, just make sure the footprint is low ;)
Yeah, I'm working on that. Currently it just grabs the XML feed with the 5 latest posts, which is really not needed (and wastes a little bandwidth). I'm going to modify the XML functions to accept a message ID (like ?action=.xml;last_msg=12), and only all messages newer than this are returned. This would make the footprint really small :)
Title: Re: Forum Spy
Post by: Dannii on May 27, 2007, 04:56:16 AM
Small = 0 bytes IMO :P
Title: Re: Forum Spy
Post by: karlbenson on May 27, 2007, 10:17:15 AM
The error was the full error message that I get in IE7.
Title: Re: Forum Spy
Post by: Daniel15 on May 28, 2007, 02:23:05 AM
Quote from: eldʌkaː on May 27, 2007, 04:56:16 AM
Small = 0 bytes IMO :P
The root element is still needed in order to be a valid XML response ;).
A bare-minimum (empty) response would be:

<?xml version="1.0" encoding="UTF-8"?>
<smf:xml-feed xmlns:smf="http://www.simplemachines.org/" xmlns="http://www.simplemachines.org/xml/recent">
</smf:xml-feed>
Title: Re: Forum Spy
Post by: Dannii on May 28, 2007, 04:20:29 AM
It doesn't need to be xml though. The xml header is basically useless too.
Title: Re: Forum Spy
Post by: Daniel15 on May 28, 2007, 05:52:25 AM
Quote from: eldʌkaː on May 28, 2007, 04:20:29 AM
It doesn't need to be xml though. The xml header is basically useless too.
Because I'm processing the result via the browser's XML parser, I'm thinking that the parser might choke if it's not XML (I'd have to check this). I suppose I could always check to see if the result is blank, and if so, don't parse it as XML.
And the XML header is needed on all XML files, I think?
Title: Re: Forum Spy
Post by: Dannii on May 28, 2007, 06:04:31 AM
The xml header isn't needed. I'd recommend JSON anyway. Your library should have a secure parser.
Title: Re: Forum Spy
Post by: Daniel15 on May 28, 2007, 07:44:45 AM
Quote from: eldʌkaː on May 28, 2007, 06:04:31 AM
The xml header isn't needed. I'd recommend JSON anyway. Your library should have a secure parser.
Yes, the library I'm using has a JSON parser.
I'm still going to use XML because it's (XML output) inbuilt to SMF. This is designed as a simple addon to SMF, not a full-blown thing.
Title: Re: Forum Spy
Post by: Dannii on May 28, 2007, 08:49:32 AM
Are you just using the normal xml feed? I thought you were making a new one. Use the xml parser then :)
Title: Re: Forum Spy
Post by: Daniel15 on May 29, 2007, 04:38:29 AM
Quote from: eldʌkaː on May 28, 2007, 08:49:32 AM
Are you just using the normal xml feed? I thought you were making a new one. Use the xml parser then :)
Yeah, just the normal XML feed... That's why I did not want to modify it that much.
The current version requires almost no modifications to SMF (except for index.php, to add the "recentlive" action). I'm going to modify the XML feed to optimise it a bit, but that will be very small (as I mentioned above, allow a "last msg id" parameter, and only return posts newer than this).
Title: Re: Forum Spy
Post by: Daniel15 on May 29, 2007, 07:05:55 AM
It looks like the error in IE is occuring because it doesn't properly support the getElementsByTagName method on an XMLResponse object. I'll try investigate how to fix this, although I'm not too good with JavaScript, so I'm really not sure how to approach it.
Title: Re: Forum Spy
Post by: karlbenson on May 29, 2007, 02:27:14 PM
I'm not too good at it either.

But a google search suggests that
http://dev.jquery.com/ticket/750

maybe useful to you.
Title: Re: Forum Spy
Post by: Paracelsus on June 26, 2008, 10:04:33 AM
bumping this thread, since this is a longtime awaited feature for SMF... perhaps this would be better in coding discussion ;)
Title: Re: Forum Spy
Post by: SlammedDime on June 26, 2008, 02:05:38 PM
I already have this in the works.  Alundra wanted something like this, only with a better name.  Stay tuned...
Title: Re: Forum Spy
Post by: digit on August 29, 2009, 03:16:50 PM
 :P

Did this become the Ajax Recent Topic mod?

http://custom.simplemachines.org/mods/index.php?mod=1284

8)

BTW - I found this by searching for "json"

It would be very cool to be able to write json files on the fly to do stats charts, using this.....

http://teethgrinder.co.uk/open-flash-chart-2/tutorial-4.php



Title: Re: Forum Spy
Post by: iMav on July 19, 2012, 01:27:20 PM
This would be awesome to have.  One of the things my members are complaining about since the painful (but necessary) migration from vB.
Title: Re: Forum Spy
Post by: emanuele on July 19, 2012, 02:49:51 PM
There is a link to a mod just above your post... :P

BTW: welcome to sm.org iMav! ;)