Skip to content

Commit

Permalink
Anonymize IPs that we do show using a color code.
Browse files Browse the repository at this point in the history
  • Loading branch information
kensanata committed Mar 17, 2018
1 parent b1ed5ac commit 46911eb
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
44 changes: 44 additions & 0 deletions css/wiki.css
Expand Up @@ -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;
Expand Down
17 changes: 14 additions & 3 deletions wiki.pl
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 46911eb

Please sign in to comment.