Not displaying the correct amount of characters. From the looks of it, we're still about 12 characters short of the maximum allowance under Twitter.

CommentFileSizeAuthor
#4 activitystream_node_245662.txt1.78 KBCraig Gardner

Comments

akalsey’s picture

The module just pulls in whatever is in Twitter's feed, but I can check it. What's your username on Twitter?

rastarr’s picture

Martin_Cooney is my username.

tayknight’s picture

Part of the problem is that {node_revisions}.title is varchar(128). A twitter post can be 140 characters, so title is getting trimmed. I'm not sure what should be done, but thought I'd point this out...

I've done something like this:
In my activitystream_twitter.module I've created a function (from http://www.lullabot.com/articles/trim_a_string_to_a_given_word_count, lullabot rules).

function activitystream_twitter_word_trim($string, $count, $ellipsis = FALSE){
  $words = explode(' ', $string);
  if (count($words) > $count){
    array_splice($words, $count);
    $string = implode(' ', $words);
    if (is_string($ellipsis)){
      $string .= $ellipsis;
    }
    elseif ($ellipsis){
      $string .= '...';
    }
  }
  return $string;
}

then I modified activitystream_twitter_streamapi and replaced

$tweet['title'] = preg_replace('/^'.$userid.' /', '', $tweet['title']);

with

$raw_title = preg_replace('/^'.$userid.' /', '', $tweet['title']);
$tweet['title'] = activitystream_twitter_word_trim($raw_title, 10, TRUE);

This trims the node title to 10 words and appends an ellipses (three dots, the html entity doens't work correctly in node title, like any other html).

Craig Gardner’s picture

Assigned: Unassigned » Craig Gardner
Status: Active » Needs review
StatusFileSize
new1.78 KB

Created a patch for the above comment, but also added an administration option to set the number of words to display. Set default to 10 as noted above.

akalsey’s picture

I'm not sure this is something I want to do. I'm not a bug fan of creating endless config options as they just tend to confuse the user.

However, a feature that adds an ellipsis if the title is longer than the imported text makes sense. Also changing the twitter display to use the node body instead of the title is probably in order.

akalsey’s picture

Status: Needs review » Closed (won't fix)