X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FUserContent.pm;h=b63d061771015e47ea3e83d89b1e09c7cdbf99ed;hb=af0b0fb7a454470a32c452119d0392e0dedb3fe1;hp=df0429c38f759c08f56488beebb722c7fa2b88d4;hpb=cf439203c31836e4c48f632f902aa58db6924972;p=public-inbox.git diff --git a/lib/PublicInbox/UserContent.pm b/lib/PublicInbox/UserContent.pm index df0429c3..b63d0617 100644 --- a/lib/PublicInbox/UserContent.pm +++ b/lib/PublicInbox/UserContent.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2019 all contributors +# Copyright (C) 2019-2021 all contributors # License: AGPL-3.0+ # Self-updating module containing a sample CSS for client-side @@ -11,51 +11,56 @@ use warnings; sub CSS () { <<'_' /* + * CC0-1.0 * Dark color scheme using 216 web-safe colors, inspired * somewhat by the default color scheme in mutt. * It reduces eyestrain for me, and energy usage for all: * https://en.wikipedia.org/wiki/Light-on-dark_color_scheme */ - * { background:#000; color:#ccc } + * { background:#000 !important; color:#ccc !important } /* * Underlined links add visual noise which make them hard-to-read. * Use colors to make them stand out, instead. */ - a { color:#69f; text-decoration:none } - a:visited { color:#96f } + a:link { color:#69f !important; text-decoration:none !important } + a:visited { color:#96f !important } - /* quoted text gets a different color */ - *.q { color:#09f } + /* quoted text in emails gets a different color */ + *.q { color:#09f !important } /* - * these may be used with cgit, too + * these may be used with cgit , too. * (cgit uses
, public-inbox uses ) */ - *.add { color:#0ff } - *.del { color:#f0f } - *.head { color:#fff } - *.hunk { color:#c93 } + *.add { color:#0ff !important } /* diff post-image lines */ + *.del { color:#f0f !important } /* diff pre-image lines */ + *.head { color:#fff !important } /* diff header (metainformation) */ + *.hunk { color:#c93 !important } /* diff hunk-header */ /* - * 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. + * highlight 3.x colors (tested 3.18) for displaying blobs. + * This doesn't use most of the colors available, as I find too + * many colors overwhelming, so the default is commented out. */ - .hl.num { color:#f30 } /* number */ - .hl.esc { color:#f0f } /* escape character */ - .hl.str { color:#f30 } /* string */ - .hl.ppc { color:#f0f } /* preprocessor */ - .hl.pps { color:#f30 } /* preprocessor string */ - .hl.slc { color:#09f } /* single-line comment */ - .hl.com { color:#09f } - /* .hl.opt { color:#ccc } */ - /* .hl.ipl { color:#ccc } */ - /* .hl.lin { color:#ccc } */ - .hl.kwa { color:#ff0 } - .hl.kwb { color:#0f0 } - .hl.kwc { color:#ff0 } - /* .hl.kwd { color:#ccc } */ + .hl.num { color:#f30 !important } /* number */ + .hl.esc { color:#f0f !important } /* escape character */ + .hl.str { color:#f30 !important } /* string */ + .hl.ppc { color:#f0f !important } /* preprocessor */ + .hl.pps { color:#f30 !important } /* preprocessor string */ + .hl.slc { color:#09f !important } /* single-line comment */ + .hl.com { color:#09f !important } /* multi-line comment */ + /* .hl.opt { color:#ccc !important } */ /* operator */ + /* .hl.ipl { color:#ccc !important } */ /* interpolation */ + + /* keyword groups kw[a-z] */ + .hl.kwa { color:#ff0 !important } + .hl.kwb { color:#0f0 !important } + .hl.kwc { color:#ff0 !important } + /* .hl.kwd { color:#ccc !important } */ + + /* line-number (unused by public-inbox) */ + /* .hl.lin { color:#ccc !important } */ _ } # end of auto-updated sub @@ -84,15 +89,22 @@ sub sample ($$) { # usage: perl -I lib __FILE__ contrib/css/216dark.css # (See Makefile.PL) if (scalar(@ARGV) == 1 && -r __FILE__) { - use autodie; - open my $ro, '<', $ARGV[0]; - my $css = do { local $/; <$ro> }; + open my $ro, '<', $ARGV[0] or die $!; + my $css = do { local $/; <$ro> } or die $!; + + # indent one level: $css =~ s/^([ \t]*\S)/\t$1/smg; - open my $rw, '+<', __FILE__; - my $out = do { local $/; <$rw> }; + + # "!important" overrides whatever the BOFH sets: + $css =~ s/;/ !important;/sg; + $css =~ s/(\w) \}/$1 !important }/msg; + + open my $rw, '+<', __FILE__ or die $!; + my $out = do { local $/; <$rw> } or die $!; $out =~ s/^sub CSS.*^_\n\}/sub CSS () {\n\t<<'_'\n${css}_\n}/sm; seek $rw, 0, 0; - print $rw $out; + print $rw $out or die $!; + close $rw or die $!; } 1;