Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Recent Posts Automatic Updater

Aloittaja Major Minor, syyskuu 12, 2013, 03:31:51 IP

« edellinen - seuraava »

Major Minor

If you go to: hxxp:kanyetothe.com/forum/ [nonactive] (created with SMF)

You'll see that they have a "Latest Posts" section in which they show the latest posts within the forum on the right sidebar.  But if you wait a few seconds, you will see that new posts fade in and appear automatically.  So when someone posts something new, the user doesn't have to refresh their browser to see more recent posts, instead the forum updates itself and the newest posts fade in and appear automatically.

I'm assuming there is no modifications available on this website for download that do the same thing, and it was most likely made with custom coding from scratch, right?  With that being said, how would one go about making an automatic recent posts updater that works like the website listed above? Any help / ideas / insight would truly be appreciated!  :)

All Colours Sam

Welcome. The annoying captcha goes a way after a few posts.

Is not really a real time thing, more likely a jQuery script that loads an RSS feed, post 5 of those links then waits a few seconds and then shows the rest.

You can do a search for those scripts, just do a search for "rss reader". SMF already provides an RSS feed for latest post IIRC.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Major Minor

Lainaus käyttäjältä: Suki - syyskuu 12, 2013, 03:38:06 IP
Welcome. The annoying captcha goes a way after a few posts.

Is not really a real time thing, more likely a jQuery script that loads an RSS feed, post 5 of those links then waits a few seconds and then shows the rest.

You can do a search for those scripts, just do a search for "rss reader". SMF already provides an RSS feed for latest post IIRC.
Thanks for the response! So you are saying that there are downloadable scripts within this website that would achieve the same idea / result as the website I listed, where the newest posts "appear" to be updating by themselves?  I searched "rss reader" and didn't really find anything that appeared to be too helpful... Maybe I'm not looking hard enough  :(

IchBin™

Not likely on this site. In google. Just search for ajax rss feed reader or something to that effect.
IchBin™        TinyPortal

Major Minor

Thanks guys... correct me if I am wrong but as far as I know, the script isn't literally retrieving the latest posts and then constantly posting new ones... It's just grabbing say 20 posts, but only displaying 10 posts and then the other 10 will fade in and "appear" over time? I'm not sure if that is how it works because the new posts that appear don't appear every say.. 5 seconds, the new posts appear at random times, sometimes even two or three at a time, much like the patterns of actual posts within the forum (sometimes there are 2 or 3 posts within 5 seconds, sometimes it will take 10 seconds for a new post to appear).  If anyone could explain the concept of how this works on their website, that'd be great.  Or maybe I have more reading to do...  :laugh:

All Colours Sam

It looks like a custom JavaScript, you can, of course build an ajax call and set it up to be callable every 5 seconds, not to difficult to achieve however it will kill your forum rather quickly since retrieving the latest post isn't s cheap query and calling an expensive query every 5 seconds for every user whos visiting your site is not going to be pretty.

On a closer look, it seems that they are indeed using an ajax event to retrieve the latest post.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Major Minor

Lainaus käyttäjältä: Suki - syyskuu 12, 2013, 08:21:56 IP
It looks like a custom JavaScript, you can, of course build an ajax call and set it up to be callable every 5 seconds, not to difficult to achieve however it will kill your forum rather quickly since retrieving the latest post isn't s cheap query and calling an expensive query every 5 seconds for every user whos visiting your site is not going to be pretty.

On a closer look, it seems that they are indeed using an ajax event to retrieve the latest post.
So using custom ajax to do this would kill the forum, but the website I linked uses ajax to do it??  :o

It must be two completely different codes / concepts, right?

emanuele

It *may*, everything is always relative.
It depends on the number of posts, on the activity on the forum, on the server.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Major Minor

#8
Lainaus käyttäjältä: emanuele - syyskuu 13, 2013, 05:13:15 AP
It *may*, everything is always relative.
It depends on the number of posts, on the activity on the forum, on the server.
posts within that forum are literally being posted every 2 seconds.. don't know if that helps at all but it should definitely give you a rough idea towards how active the forum is  :) one thing i also noticed is that the latest posts on the sidebar will only update for about 20 seconds, or 10 posts or so (sometimes less, sometimes more) and then it will stop updating... and also the odd time u go to the forum, the latest posts wont update at all even though there are new posts being posted within the forum.. this rarely happens though.

Major Minor

#9
I found the JavaScript file that I'm pretty sure serves as the whole recent posts automatic updater function... Here it is:

kanyetothe.com/_shared/push.js?v910

I'm not to familiar with JavaScript... Could anyone explain what is going on within this code and also if it is a code designed straight from scratch, or a downloadable plugin?

What do you guys think? 


edit: after looking at the script more, I'm not too sure if that is the recent posts updater script.... hmm

Major Minor

It appears that the file I previously linked has been changed... It still appears to be the same code, just now bunched together and a lot harder to read / decipher.  Oddly enough, the code was modified shortly after I posted a link to it on this forum... Maybe the creator of that website still visits this forum?  :o Probably just a coincidence...  ;D

But anyways, here is the original code before it was modified.. Again, I think this is the source for the automatic post updater and if anyone could confirm this for me or try to decipher what is going on within the code that would be great...

pastebin.com/ny8bRfwb

All Colours Sam

Oh well, they probably don't want to share their code? it doesn't really matter since 80% of people who use SMF won't be able to achieve what they have.

Anyway, they are using Meteor which itself uses Node.js which is a low-level framework to handle HTTP request.

Since Node.js doesn't have the same "restrictions" as PHP does, they can quite happily handle "live" requests using Node/Meteor.

Unless you have the same infraestructure as they or at the very low your own un-managed server, you cannot replicate the exact same functionality.

You can mimic the functionality in pure PHP but the result won't be the same since PHP wasn't wrote for handling live HTTP request, theres PHPreact which is awesome and I've played with it before but it needs some requirements such as having your own server or at least a VM.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Major Minor

Lainaus käyttäjältä: Suki - syyskuu 16, 2013, 03:14:21 IP
Oh well, they probably don't want to share their code? it doesn't really matter since 80% of people who use SMF won't be able to achieve what they have.

Anyway, they are using Meteor which itself uses Node.js which is a low-level framework to handle HTTP request.

Since Node.js doesn't have the same "restrictions" as PHP does, they can quite happily handle "live" requests using Node/Meteor.

Unless you have the same infraestructure as they or at the very low your own un-managed server, you cannot replicate the exact same functionality.

You can mimic the functionality in pure PHP but the result won't be the same since PHP wasn't wrote for handling live HTTP request, theres PHPreact which is awesome and I've played with it before but it needs some requirements such as having your own server or at least a VM.
Makes sense, thanks Suki!  :)

It seems like that forum has a lot of "next level" coding going on within their website... It made me realize that I still have a lot more reading and learning to do  :laugh:

All Colours Sam

Well, it is not "next level" Node.js is just another alternative to build web applications, there is a huge fuss a round it because all the "cool kids" used to used it and rant about how PHP cannot compete with that.

It is actually pretty fun to work with its PHP counterpart: PHPreact but even PHPreact has to deal with the same limitations of PHP itself.

You can build an ajax call and retrieve the latest post every 5 seconds but it will take a toll on your server performance. Or you can use SSI.php to show pretty much the same block and it will be update on every page change or refresh.

Heres a nice article about PHP's limitations: http://software-gunslinger.tumblr.com/post/48215406921/php-is-meant-to-die-continued  read the first part first though.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

samborabora

Is there no mod or function built in that could fetch the posts and then simply be displayed in a sidebar with a little extra coding? I can't imagine how it would be THAT hard to just grab recent posts even few seconds and stick them in a widget?

All Colours Sam

Lainaus käyttäjältä: samborabora - syyskuu 16, 2013, 04:01:03 IP
Is there no mod or function built in that could fetch the posts and then simply be displayed in a sidebar with a little extra coding? I can't imagine how it would be THAT hard to just grab recent posts even few seconds and stick them in a widget?

It isn't difficult at all... most if not all portals do that.  Theres even a SSI.php function already built and ready to be used...

The problem arise when you have an ajax call to retrieve the latest post/topic every X seconds. If you have the infrastructure then go for it.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

samborabora

Okay, can you basically describe what it would involve to build or use an infrastructure to access the function? Is it a hosting feature or something one installs or codes?

margarett

Not really, it's just coding, really.

What Suki means as infrastructure is SERVER resources: a VPS or another kind of high-resources hosting because it will hammer your server like hell :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

LainaaOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

samborabora

Hows about Hawkhost's Standard plan, would that have what it takes? (Sorry, not sure if this constitutes as advertising or anything, but I'm not sure how else to reference my current providers plan?)

Arantor

Unlikely.

Consider what's actually going on with this... every single user on the site, guests included, is making a call to the website every few seconds, each of which requires thousands of lines of code to be executed. If you have 100 users, that's 100 requests every 5 seconds - averaging 20 requests per second, far far more than most shared servers can handle.

Heck even a VPS might struggle with that.
Holder of controversial views, all of which my own.


Advertisement: