Hi,

I've created an additional Wordpress blog to start testing the EVB.

When I post the script in Wordpress's "Single.php" (which is responsible for the display of the full node) the EVB works fine: it will trail for a couple of seconds and then eventually display the EVB or "Add it".

HOWEVER, if we paste the EVB script in the main index template (so that each entry displays its own EVB), this is what happens: only the first (i.e. the latest) blog entry at the top of the blog will display the EVB or "Add it", but all the rest of the entries on the page will keep displaying the trailing blue circle chasing-its-own-tale indefinitely.

I think this bug is critical, because most blogs and even some news sites that I've seen will often choose to display multible "Digg this" per each entry on their front page.

CommentFileSizeAuthor
#17 wp-sphinnit.php_.txt5.33 KBunmicdrac

Comments

drupalina’s picture

Forgot to mention:

for Wordpress I deleted the entire 'http://blog.MyMomainName.com/THE_URL_OF_THE_PAGE_ON_THE_SITE' and instead pasted

<?php the_permalink() ?>

I don't know if this is relevant. because Wordpress seems to also have nother variable called <?php the_ID(); ?>
If anyone got this working for Wordpress, Blogger/Blogspot, MovableType etc, please write here.

PGiro’s picture

Yep, critical bug !

Can you try using the other button javascript and report on how that one goes ? Maybe there is an issue with the newer one that I haven't encountered yet (use button-old.js).
Also, please attach the wordpress template as you modified it and the HTML of the page with the multiple buttons that don't work

BTW, I suppose you are doing this on your own Wordpress installation and not wordpress.com which doesn't allow javascript ?

unmicdrac’s picture

<script type="text/javascript">
	url_site = "<?php echo get_permalink() ?>";
	</script>
	<script src="http://mysite.ro/sites/all/modules/drigg_external/js/button-old.js" type="text/javascript"></script>

This is the code I am using on wordpress with the old button which works. The new one does what drupalina said.

Would somebody be interested in a plugin for wordpress which inserts automatically the code required without any php files editing? Somebody is doing this for me and I can share it if you need it.

PGiro’s picture

unmicdra, thanks for the test. The old button is the one I have running on production for a hacked D5 site I have. Until I figure out what's broken with the other one, stay with that one.
Can one of you attach the HTML generated for the incriminated page ? Or send it to me if you're not live yet and don't want this to be public

PGiro’s picture

unmicdrac, please share your wordpress plugin. I would like to use it myself on a site.
Also, if you want, I can include it in the distribution of this module

PGiro’s picture

Title: Can't display more than one EVB on the same page » Can't display more than one EVB on the same page with button-new.js
Assigned: Unassigned » PGiro
Priority: Critical » Normal
drupalina’s picture

I posted this message yesterday, but then my XP crashed. Luckyly Firefox recovered it for me:

@PGiro - Hi, yes, I've installed my own wordpress 2.6 so as to test EVB with another Drupal_6x .dev site. And that's where I do the testing.

But frankly, the continget that my Drigg site is directed at, rarely have their own wordpress installed. They mostly use the free subdomain blogs from wordpress.com, which doesn't allow putting scripts in the sidebar widgets. I don't know much about how Wordpress.com works, but they ocasionally allow _some_ special plugin widgets that integrate with external services (like Del.icio.us or VodPod). But I have no clue as to what's the procedure in getting a new "widget" to appear for .wordpress.com users. Unmicdrac, any ideas?

Coming back to the original bug report. I've testing the button-old.js using Unmicdrac's code. And it worked perfectly! (although, I must admit, that if it takes this long to load each button, many webmasters will soon drop it - but that's another issue).

@unmicrac, thanks for the pointer and the code. It worked!
Most of my site users are not bloggers, and those who are, use .wordpress.com, livejournal.com and blogspot.com. In entire blogging group that my drigg site is designed for, there are only 2-3 people that I know of that have their own wordpress installed ( but there could be more in the future). I'd say if you share your wordpress plugin, that'll be very nice of you - especially for other Drigg users. Generally it would be nice if Drigg community would share more - I know that some have developed pretty nice extra features like Firefox addons and Facebook apps for instance, but we never hear from them :)

drupalina’s picture

PGiro, please enable your contact form so that I can send you an e-mail with direct URL , so that you can see the html

drupalina’s picture

Version: 6.x-1.x-dev » 6.x-1.1

I've just tested the new 6x-1.1, None of the buttons there seems to work. I had to bring in the button-old.js from Drigg forum's .zip file, in order to get it working according to unmicdrac's instructions.

Please include button-old.js in the official release for now.

unmicdrac’s picture

I will sure share the plugin, but first I have to test it a little to be sure it does what was supposed to do. And then I have to translate it to English, as now all is only in Romanian, my native language. So, please excuse me, if my English is not that great.

PGiro, if you think it would help people you can include it in the package of Drigg external, that's fine by me.

If all works well I'll attach it here on Monday or Tuesday, that depends on my free time, as I am not working in the online industry and I do have a job.

PGiro’s picture

@drupalina :
- I've enabled my personnal contact form.
- I know the old button is slowwwwwww, that's why I've been trying in my spare time to get another version working better.
- in version 1.1, I switched button.js to be the former button-old.js so that people use the working one by default until I fix the new one. I have just checked the package and indeed, using 1.1, you should use the "button.js" script
- which browser have you tested on ?

@unmicdrac : great ! Once we get everything working, we'll see if we can get wordpress to put it up on their site. (I doubt it but you never know!)

PGiro’s picture

Go drupalina's message and confirmed the issue with the button-new.js file. Unfortunatly, this seems to be due to a limitation by browser for security reasons. I hadn't run into it because I was testing on the same domain.

There doesn't seem to be a way to solve this so if I am able to speed up the button, it will be through other means.
Of course, the easiest way to speed it up is to let each javascript run as fast as it can but you will be hitting your server really hard on each page display with multiple buttons and I can't afford that..

PGiro’s picture

Here's another try on the new button which should minimize the slownes. Copy paste into your button-new.js file and use that script in your pages.

if(!window.DRIGG_EVB_i) { 
  //first time the button script is executed in the page
  function DRIGG_EVB_process_buttons() {
      DRIGG_EVB_j++;
      if (DRIGG_EVB_i==DRIGG_EVB_j)
       return;
       
      var full_url=base_url+'drigg_external/display_button?url='+escape(DRIGG_EVB_urls[DRIGG_EVB_j]);
      frames['DRIGG_EVB-'+DRIGG_EVB_j].location.href=full_url;
      window.setTimeout(DRIGG_EVB_process_buttons,1000);
  }
  var DRIGG_EVB_urls=[];
  var DRIGG_EVB_i=0;
  var DRIGG_EVB_j=-1;
  var base_url="http://your.site.com/";
  window.onload=DRIGG_EVB_process_buttons;
}
if (!window.url_site) 
  var url_site=""; 
  
DRIGG_EVB_urls[DRIGG_EVB_i]=url_site;
var div_id='DRIGG_EVB-'+DRIGG_EVB_i;
document.write('<iframe scrolling="no" allowTransparency="true" name="'+div_id+'" id="'+div_id+'" src="'+base_url+'sites/all/modules/drigg_external/loader.html" frameborder="0" style="border-color:gray;border-style:solid;border-width:0px;" scrolling="0" width="50" height="73"></iframe>');
DRIGG_EVB_i=DRIGG_EVB_i+1;
delete url_site;

If y'oure feeling brave, change window.setTimeout(DRIGG_EVB_process_buttons,1000); to DRIGG_EVB_process_buttons() and you'll get no throttling of calls to the server.
You can adjust the wait period between button loading by change 1000 (=1 second) to whatever you want.

Please report your findings

drupalina’s picture

Hi,

Just tested the new code for button-new.js. First of all, with this new code, the button-new.js as least works (as I said earlier, it didn't work before, so I had to switch to button-old.js)

Also, as a test, I replaced

window.setTimeout(DRIGG_EVB_process_buttons,1000);

with

window.setTimeout(DRIGG_EVB_process_buttons());

It didn't make all that much difference :( The loading still seems slow: 3 seconds for an index page where 2 EVBs are displayed, and 2 seconds for individual nodes where 1 EVB is displayed -- slow compared to other similar buttons from Digg, Yahoo, Mixx, Reddit etc, which serve millions of such buttons. Of course, one has to also remember that this is just _1_ button/score request from a test site that is on the _same_ server. What will happen if there are 20 or even 100 simultaneous requests for different scoops comming from different servers across the globe?

But here's a thought:what if it could be cached? I'm thinking out loud here (and I'm NOT a coder), but at least in theory, wouldn't it be much more efficient if these scores were passed to memcache every 3-5 minutes, and then the EVB can read the scores from the memcache and when voting, update the scores directly to the database. If that entry is not in the memcache, then "Add it!" will automatically display.
Another thought is to cache the images too (remove Etags and set expiry date to 2018 and make the images cache on end-user's local computer).

And a minor suggestion - I think that trailing blue circle is a nice touch, but in terms optical illusions, it actually adds to the "slowness" effect. Plus it's an extra request of an extra 1 file.

PGiro’s picture

You see, the thing is, yahoo can fine tune its button to the core whereas I had to provide a mechanism that works for all possible cases. Now it's time to optimize it on your installation :)
Here are some ideas:

1) In terms of performance, I believe the issue is not "getting the data in the database" but the fact that the IFRAME loading the vote button is itself making tens of HTTP requests for all the CSS & javascript. Since most of it is not needed, I was planning on replacing the print drupal_add_css() in the header with the actuall CSS & JS needed on my site. Another idea would be to inline the required CSS & javascript in the button template. That will get us closer to digg/yahoo/etc buttons.

2) Using setTimeout is also slowing things down because it creates a new javascript context so it's doing it as many times as there are buttons. Either remove setTimeout() alltogether [but I think that will be bad because it will slow down page loading] or change it to setInterval(DRIGG_EVB_process_buttons, 1000) and report back your results.

3) I was thinking the same thing about the loader, try removing the "src" attribute of the IFRAME in button-new.js

Sorry I can't post anything but I'm going to work now... Can you try these and report back ?

unmicdrac’s picture

Tried the new version, the hit on the server on half a second delay it's not that big. And I do not have a vps or dedicated server, but a small reseller account. And we know how full are webservers today on shared hosting, dont we? Now only a couple of folks are using it, will see when there will be a lot more.

About the plugin I was talking about, the guy who should be doing it dropped it on last minute, he told he was way to busy to take free work right now. I cant blame him. Anyways, I found a plugin for wordpress for Sphinn, I think I can manage to modify it for our needs. Just give me untill tomorrow.

unmicdrac’s picture

StatusFileSize
new5.33 KB

Attached is the plugin which I was telling you about. I adapted it after http://www.michellemacphearson.com/wordpress-plugin-sphinnit-button/ and works quite well on wordpress 2.6.3 and even on the new wordpress 2.7 beta 3. Modify lines 88 and 147 to suit your needs and then customize as you like. I have translated all of the user configuration in Romanian and of course left the link to the author. Should be really easy to make the changes for anyone who ever opened a php file and edited it.

PGiro’s picture

Status: Active » Closed (fixed)

I am closing ths thread as fixed and will poen a new thread on performance issues