• R/O
  • SSH
  • HTTPS

slashdotjp: Commit


Commit MetaInfo

Revision1109 (tree)
Time2009-04-06 17:37:42
Authortach

Log Message

  • Enable to select adding "rel=nofollow" to anchor or not using regex by
    constants "nofollow_exclude_regex"

Change Summary

Incremental Difference

--- slashjp/trunk/Slash/Utility/Data/Data.pm (revision 1108)
+++ slashjp/trunk/Slash/Utility/Data/Data.pm (revision 1109)
@@ -2547,10 +2547,20 @@
25472547
25482548 sub noFollow {
25492549 my($html) = @_;
2550- $html =~ s/(<a href=.+?)>/$1 rel="nofollow">/gis;
2550+ $html =~ s/(<a\s+(?:[^>]*?\s)?href=[^>]+?)>/&_noFollowStr($1)/geis;
25512551 return $html;
25522552 }
25532553
2554+sub _noFollowStr {
2555+ my($str) = @_;
2556+ next unless ($str =~ /href="?(.*?)(?:"|\s|$)/);
2557+ my $url = $1;
2558+ my $regex = getCurrentStatic('nofollow_exclude_regex');
2559+ if (!$regex || $url !~ $regex) {
2560+ $str .= ' rel="nofollow"';
2561+ }
2562+ return $str . '>';
2563+}
25542564
25552565
25562566 # DOCUMENT after we remove some of this in favor of
Show on old repository browser