contrib/css/216dark.css | 20 ++++++++++++++++++++ lib/PublicInbox/UserContent.pm | 20 ++++++++++++++++++++ lib/PublicInbox/ViewVCS.pm | 15 ++++++++++++++- diff --git a/contrib/css/216dark.css b/contrib/css/216dark.css index 2fd85d0815fef6ae4ac8dfec2131ca2c1d437159..35ef7aa5a7fef1f76b05164c57f604519b11f37e 100644 --- a/contrib/css/216dark.css +++ b/contrib/css/216dark.css @@ -24,3 +24,23 @@ *.add { color:#0ff } *.del { color:#f0f } *.head { color:#fff } *.hunk { color:#c93 } + +/* + * highlight 3.x colors (tested 3.18) + * this doesn't use most of the colors available (I find too many + * colors overwhelming). So the #ccc default is commented out. + */ +.hl.num { color:#f30 } +.hl.esc { color:#f0f } +.hl.str { color:#f30 } +.hl.pps { color:#f30 } +/* .hl.slc { color:#ccc } */ +.hl.com { color:#09f } +.hl.ppc { color:#f0f } +/* .hl.opt { color:#ccc } */ +/* .hl.ipl { color:#ccc } */ +/* .hl.lin { color:#ccc } */ +.hl.kwa { color:#ff0 } +.hl.kwb { color:#0ff } +.hl.kwc { color:#ff0 } +/* .hl.kwd { color:#ccc } */ diff --git a/lib/PublicInbox/UserContent.pm b/lib/PublicInbox/UserContent.pm index b34ebf91b0caa9649bdf071180bd69fea5049126..514cd952c6d2f0e3f0b67963557805e7ac4053de 100644 --- a/lib/PublicInbox/UserContent.pm +++ b/lib/PublicInbox/UserContent.pm @@ -36,6 +36,26 @@ *.add { color:#0ff } *.del { color:#f0f } *.head { color:#fff } *.hunk { color:#c93 } + + /* + * highlight 3.x colors (tested 3.18) + * this doesn't use most of the colors available (I find too many + * colors overwhelming). So the #ccc default is commented out. + */ + .hl.num { color:#f30 } + .hl.esc { color:#f0f } + .hl.str { color:#f30 } + .hl.pps { color:#f30 } + /* .hl.slc { color:#ccc } */ + .hl.com { color:#09f } + .hl.ppc { color:#f0f } + /* .hl.opt { color:#ccc } */ + /* .hl.ipl { color:#ccc } */ + /* .hl.lin { color:#ccc } */ + .hl.kwa { color:#ff0 } + .hl.kwb { color:#0ff } + .hl.kwc { color:#ff0 } + /* .hl.kwd { color:#ccc } */ _ } # end of auto-updated sub diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm index 5de37ee6afba06b28c94499db2a69d8354e1d166..a8aa0b61e2934b96b3fd4eff8fdba151017a074d 100644 --- a/lib/PublicInbox/ViewVCS.pm +++ b/lib/PublicInbox/ViewVCS.pm @@ -21,6 +21,11 @@ use PublicInbox::SolverGit; use PublicInbox::WwwStream; use PublicInbox::Linkify; use PublicInbox::Hval qw(ascii_html to_filename); +my $hl = eval { + require PublicInbox::HlMod; + PublicInbox::HlMod->new; +}; + my %QP_MAP = ( A => 'oid_a', B => 'oid_b', a => 'path_a', b => 'path_b' ); my $max_size = 1024 * 1024; # TODO: configurable my $enc_utf8 = find_encoding('UTF-8'); @@ -88,6 +93,14 @@ $$blob = $enc_utf8->decode($$blob); my $nl = ($$blob =~ tr/\n/\n/); my $pad = length($nl); + $l->linkify_1($$blob); + my $ok = $hl->do_hl($blob, $path) if $hl; + if ($ok) { + $blob = $ok; + } else { + $$blob = ascii_html($$blob); + } + # using some of the same CSS class names and ids as cgit $log = "
$oid $type $size bytes $raw_link" . "
|