MD5: Restyled the response to match other IAs.

master
gdrooid 2014-06-24 22:22:10 +02:00
parent 43dde6ac8b
commit 583b3045fb
3 changed files with 20 additions and 4 deletions

View File

@ -19,6 +19,17 @@ category 'transformations';
triggers start => 'md5', 'md5sum';
my $css = share('style.css')->slurp;
sub html_output {
my $md5 = shift;
return "<style type='text/css'>$css</style>"
."<div class='zci--md5'>"
."<span class='text--secondary'>Md5:</span>"
."<span class='text--primary'> $md5</span>"
."</div>";
}
handle remainder => sub {
# Exit unless a string is found after the mode (if any)
if (/^(hex|base64|)\s*(.*)$/i) {
@ -38,7 +49,7 @@ handle remainder => sub {
# Defaults to hex encoding when no other mode was selected.
$str = md5_hex (encode "utf8", $str);
}
return qq(Md5: $str);
return $str, html => html_output $str;
}
return;
};

View File

@ -0,0 +1,5 @@
.zci--answer .zci--md5 {
font-size: 1.5em;
font-weight: 300;
padding: .25em auto;
}

View File

@ -12,9 +12,9 @@ ddg_goodie_test(
[qw(
DDG::Goodie::MD5
)],
'md5 digest this!' => test_zci('Md5: 3838c8fb10a114e6d21203359ef147ad'),
'md5 hex gimme the hex digest' => test_zci('Md5: 0ce78eeb15abe053207d79f9b8e5cbab'),
'md5sum base64 gimme the digest encoded in base64' => test_zci('Md5: INa7hD+ZcscImFVGHvnuvQ'),
'md5 digest this!' => test_zci('3838c8fb10a114e6d21203359ef147ad', html=>qr/.*/),
'md5 hex gimme the hex digest' => test_zci('0ce78eeb15abe053207d79f9b8e5cbab', html=>qr/.*/),
'md5sum base64 gimme the digest encoded in base64' => test_zci('INa7hD+ZcscImFVGHvnuvQ', html=>qr/.*/),
);
done_testing;