Przeglądaj źródła

Wrap longer than 40 chars words.

Morten Brix Pedersen 23 lat temu
rodzic
commit
d342ce414e
2 zmienionych plików z 17 dodań i 4 usunięć
  1. 2 0
      docs/Changelog
  2. 15 4
      modules/Pisg/HTMLGenerator.pm

+ 2 - 0
docs/Changelog

@@ -2,6 +2,8 @@ pisg (x.xx)
    * Fixed an error in the mIRC6 format which caused pisg to abort on some
      lines.
    * mirc2egg script updated.
+   * The random line in "Most Active Nicks" now wraps words that are longer
+     than 40 characters. (thanks, glen)
 
 pisg (0.43) - Fri Nov, 22th 2002
    * Add "ShowOnlyTop" option which can be used if you only want to have stats

+ 15 - 4
modules/Pisg/HTMLGenerator.pm

@@ -418,16 +418,27 @@ sub _activenicks
         my $randomline;
         if (not defined $self->{stats}->{sayings}{$nick}) {
             if ($self->{stats}->{actions}{$nick}) {
-                $randomline = htmlentities($self->_format_line($self->{stats}->{actionlines}{$nick}));
+                $randomline = $self->_format_line($self->{stats}->{actionlines}{$nick});
             } else {
                 $randomline = "";
             }
         } else {
-            $randomline = htmlentities($self->{stats}->{sayings}{$nick});
+            $randomline = $self->{stats}->{sayings}{$nick};
         }
 
-        # Convert URLs and e-mail addys to links
-        $randomline = $self->_replace_links($randomline);
+        if ($randomline) {
+            # Wrap longer than 40 chars words. It will break long HTML
+            # links.
+            # TODO: put <br> after 40 ! or ? marks - IE bug
+            # TODO: respect long URLs (like merge spaces back in url?)
+            # glen, 29/11/2002
+            1 while $randomline =~ s/(\S{40})(\S+)/$1 $2/m;
+
+            $randomline = htmlentities($randomline);
+
+            # Convert URLs and e-mail addys to links
+            $randomline = $self->_replace_links($randomline);
+        }
 
         # Add a link to the nick if there is any
         if ($self->{users}->{userlinks}{$nick}) {