Permalink
Browse files

Anonymize IPs that we do show using a color code.

  • Loading branch information...
kensanata committed Mar 17, 2018
1 parent b1ed5ac commit 46911eb14eb99a7caa355659c53786d25305e3b9
Showing with 58 additions and 3 deletions.
  1. +44 −0 css/wiki.css
  2. +14 −3 wiki.pl
@@ -172,6 +172,50 @@ span.bar a {
padding: 1ex 0;
}
.red {
background: red;
color: red;
}
.orange {
background: orange;
color: orange;
}
.yellow {
background: yellow;
color: yellow;
}
.green {
background: green;
color: green;
}
.blue {
background: blue;
color: blue;
}
.indigo {
background: indigo;
color: indigo;
}
.violet {
background: violet;
color: violet;
}
.white {
background: white;
color: white;
}
.ip-code {
border: 1px solid #666;
}
hr {
border: none;
color: black;
17 wiki.pl
@@ -35,6 +35,7 @@ package OddMuse;
no warnings 'numeric';
no warnings 'uninitialized';
use utf8; # in case anybody ever adds UTF8 characters to the source
use B;
use CGI qw/-utf8/;
use CGI::Carp qw(fatalsToBrowser);
use File::Glob ':glob';
@@ -2195,6 +2196,17 @@ sub ScriptLinkDiff {
return ScriptLink($action, $text, 'diff');
}
sub ColorCode {
my ($str) = @_;
my $num = unpack("L",B::hash($str)); # 32-bit integer
my $code = sprintf("%o", $num); # octal is 0-7
my @indexes = split(//, substr($code, 0, 4)); # four numbers
my @colors = qw/red orange yellow green blue indigo violet white/;
return $q->span({-class => 'ip-code', -title => T('Anonymous')},
join('', map { $q->span({-class => $colors[$_]}, $_) }
@indexes));
}
sub GetAuthor {
my ($username) = @_;
return $username if $username;
@@ -2209,12 +2221,11 @@ sub GetAuthorLink {
$username = ''; # Just pretend it isn't there.
}
if ($username and $RecentLink) {
return ScriptLink(UrlEncode($username), $name, 'author', undef, $host);
return ScriptLink(UrlEncode($username), $name, 'author');
} elsif ($username) {
return $q->span({-class=>'author'}, $name);
}
# FIXME add funny little image to visuall group by $host
return T('Anonymous');
return ColorCode($host);
}
sub GetHistoryLink {

0 comments on commit 46911eb

Please sign in to comment.