On my site, the teaser length is the same as the post, and some posts can be fairly long. It turns out that the JavaScript variable "digg_bodytext" contains the teaser, and in the case of my site, the entire post. When the post is long, the JavaScript breaks.

I have not tested the boundary case that causes this to break. I just discovered it on my site and had to patch it quickly, so I have not done much investigation.

Here is the patch code for the diggthis.module file (around line 107)

From:

  $skin = variable_get('diggthis_button_skin', 'standard');
  $title = drupal_to_js($node->title);
  $teaser = strip_tags($node->teaser);
  if (strlen($teaser) > 400) {$teaser = substr($teaser, 0, 400);}
  $teaser = drupal_to_js($teaser);

To:

  $skin = variable_get('diggthis_button_skin', 'standard');
  $title = drupal_to_js($node->title);
  $teaser = strip_tags($node->teaser);
  if (strlen($teaser) > 400) {$teaser = substr($teaser, 0, 400);}
  $teaser = drupal_to_js($teaser);

The code is a quick fix. I should use a number other than 400, but I didn't know how to come up with something meaningful. This code needs to be reviewed before it's used in production sites (although I'm most definitely using it.) =)

cheers,
sebs

CommentFileSizeAuthor
#3 diggthis.module.5--1-4.patch913 bytesyaph

Comments

yaph’s picture

Assigned: Unassigned » yaph

Thanks for your patch sebs. I'll look at the Digg developer docs to check out whether there is a fixed limit.

Bence’s picture

Yes, there is a fixed limit. I experienced the same issue. The solution is that use teasers wich are shorter. However, the module should limit the text length and not allow this error.

Try to submit a story on Digg.com with the user interface. It says:
Title 60 characters left
Description 350 characters left

So most definately these are the limits.

I imagine that Javascript also breaks if your title is too long.

yaph’s picture

Priority: Critical » Minor
Status: Needs work » Needs review
StatusFileSize
new913 bytes

I cannot resolve the issue because there is a problem with a sticky cvs tag which has a release node pointing to it. I attached a patch you can use for Drupal 5. This is fixed in the release for Drupal 6.

yaph’s picture

Status: Needs review » Closed (fixed)
yaph’s picture

Fixed the bug in the DRUPAL-5--2 branch of the module.