By a little bit of blending newwriteups into Random Nodes, I created the following code which should prevent a node with an extremely long word in the title from causing an extra-wide nodelet bar.

[%
my @phrase = ("Nodes your grandma would have liked:",
  "After stirring Everything, these nodes rose to the top:",
  "Look at this mess the Death Borg made!",
  "Just another sprinking of indeterminacy",
  "The best nodes of all time:");

my $str;
$str.="<i>".$phrase[rand(int(@phrase))]."</i><br>";

foreach (1..12) {
  my $PN = getRandomNode;
  my $titleFix = $$PN{title};
  my $len = 24;
  my @words = split ' ', $titleFix;

  foreach (@words) {
    if(length($_) > $len) {
      $_ = substr($titleFix, 0, $len);
      $_ .= "...";
    }
  }  
  $titleFix = join ' ', @words;

  $str.= linkNode($PN, $titleFix)."<br>";
}
$str;

%]
Of course, I was severely tempted to add "Nodes edev doesn't want you to see:" to the possible flavor text for Random Nodes.

Log in or registerto write something here or to contact authors.