From 28151a28db84c6d6018232f36c0003ecd562b3f0 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 18 Oct 2009 17:57:40 +0000 Subject: [PATCH] common include for setup and stylesheet output --- base.css | 6 ------ cc.plp | 19 +++---------------- charset.plp | 13 +++---------- circus.css | 3 +++ common.inc.plp | 21 +++++++++++++++++++++ dark.css | 3 +++ digraphs.plp | 20 +++----------------- index.plp | 14 ++++---------- light.css | 3 +++ mono.css | 3 +++ mplayer.plp | 27 ++++++++------------------- mutt.plp | 27 ++++++++------------------- nethack.plp | 25 +++++++------------------ readline.plp | 25 +++++++------------------ red.css | 2 ++ source.plp | 18 +++--------------- termcol.plp | 14 ++++---------- terse.css | 2 ++ unicode.plp | 20 +++----------------- vim.plp | 25 +++++++------------------ vimperator.plp | 27 ++++++++------------------- 21 files changed, 105 insertions(+), 212 deletions(-) create mode 100644 common.inc.plp create mode 100644 light.css diff --git a/base.css b/base.css index b566045..5958ced 100644 --- a/base.css +++ b/base.css @@ -1,9 +1,3 @@ -/* media features */ - -@import url(terse.css) all and (max-width: 80em); - -@import url(mono.css) all and (monochrome); - /* general */ body { diff --git a/cc.plp b/cc.plp index afd10ed..8473241 100644 --- a/cc.plp +++ b/cc.plp @@ -1,12 +1,5 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; - -our $VERSION = 'v1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -15,13 +8,7 @@ $header{content_type} = 'text/html; charset=utf-8'; country code cheat sheet -<: - my %styles = map {$_ => $_} qw(dark mono red); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_ - ) for keys %styles; -:> +<:= stylesheet(qw'light dark mono red') :> diff --git a/charset.plp b/charset.plp index 73f9377..29e7e23 100644 --- a/charset.plp +++ b/charset.plp @@ -1,12 +1,5 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; - -our $VERSION = 'v1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -15,7 +8,7 @@ $header{content_type} = 'text/html; charset=utf-8'; charset cheat sheet - +<:= stylesheet(qw'light') :> diff --git a/circus.css b/circus.css index a6e77b7..fef9ef2 100644 --- a/circus.css +++ b/circus.css @@ -1,3 +1,6 @@ +@import url(base.css); +@import url(terse.css) all and (max-width: 80em); + .pm {background: #8F8} /* motion */ .po {background: #BF6} /* window */ .co {background: #FF6} /* command */ diff --git a/common.inc.plp b/common.inc.plp new file mode 100644 index 0000000..576e39c --- /dev/null +++ b/common.inc.plp @@ -0,0 +1,21 @@ +<: +use utf8; +use strict; +use warnings; +no warnings 'qw'; # you know what you doing +no warnings 'uninitialized'; # save some useless checks for more legible code +use open IO => ':utf8'; + +our $style; + +$header{content_type} = 'text/html; charset=utf-8'; + +sub stylesheet { + my %styles = map {$_ => $_} @_; + $style = exists $get{style} && $styles{$get{style}} || $_[0]; + return join "\n", map { sprintf( + '', + $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_ + ) } @_; +} + diff --git a/dark.css b/dark.css index 878c560..aa3c7d0 100644 --- a/dark.css +++ b/dark.css @@ -1,3 +1,6 @@ +@import url(base.css); +@import url(terse.css) all and (max-width: 80em); + body { background: #000; color: #CCC; diff --git a/digraphs.plp b/digraphs.plp index d44a7fa..5192c25 100644 --- a/digraphs.plp +++ b/digraphs.plp @@ -1,13 +1,5 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # to quote or not to quote, that is the question -use open IO => ':utf8'; - -our $VERSION = 'v1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -16,13 +8,7 @@ $header{content_type} = 'text/html; charset=utf-8'; digraph cheat sheet -<: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; -:> +<:= stylesheet(qw'light') :> diff --git a/index.plp b/index.plp index 2118612..096a6b5 100644 --- a/index.plp +++ b/index.plp @@ -1,11 +1,5 @@ -<: -use utf8; -use strict; -use warnings; - -our $VERSION = 'v1.0'; - -$header{content_type} = "text/html; charset=utf-8"; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -13,8 +7,8 @@ $header{content_type} = "text/html; charset=utf-8"; -vi cheat sheet - +cheat sheets +<:= stylesheet(qw'light dark') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> diff --git a/mutt.plp b/mutt.plp index 22dcf3b..cd90e86 100644 --- a/mutt.plp +++ b/mutt.plp @@ -1,34 +1,23 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # you know what you doing -no warnings 'uninitialized'; # save some useless checks for more legible code - -use Shiar_Sheet::KeySigns qw(%sign); +<(common.inc.plp)><: + use Shiar_Sheet::KeySigns qw(%sign); -our $VERSION = 'v1.0'; + our $VERSION = 'v1.0'; -$header{content_type} = "text/html; charset=$sign{charset}"; + $header{content_type} = "text/html; charset=$sign{charset}"; :> -mutt cheat sheet - +mutt cheat sheet +<:= stylesheet(qw'light dark circus mono red terse') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> diff --git a/nethack.plp b/nethack.plp index 8e5ffa6..c10c70c 100644 --- a/nethack.plp +++ b/nethack.plp @@ -1,15 +1,9 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # you know what you doing -no warnings 'uninitialized'; # save some useless checks for more legible code - -use Shiar_Sheet::KeySigns qw(%sign); +<(common.inc.plp)><: + use Shiar_Sheet::KeySigns qw(%sign); -our $VERSION = 'v1.0'; + our $VERSION = 'v1.0'; -$header{content_type} = "text/html; charset=$sign{charset}"; + $header{content_type} = "text/html; charset=$sign{charset}"; :> @@ -18,17 +12,12 @@ $header{content_type} = "text/html; charset=$sign{charset}"; nethack cheat sheet - +<:= stylesheet(qw'light dark circus mono red terse') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> diff --git a/readline.plp b/readline.plp index 8142162..e1e3f10 100644 --- a/readline.plp +++ b/readline.plp @@ -1,15 +1,9 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # you know what you doing -no warnings 'uninitialized'; # save some useless checks for more legible code - -use Shiar_Sheet::KeySigns qw(%sign); # dependant on $get{ascii} +<(common.inc.plp)><: + use Shiar_Sheet::KeySigns qw(%sign); # dependant on $get{ascii} -our $VERSION = 'v1.0'; + our $VERSION = 'v1.0'; -$header{content_type} = "text/html; charset=$sign{charset}"; + $header{content_type} = "text/html; charset=$sign{charset}"; :> @@ -18,17 +12,12 @@ $header{content_type} = "text/html; charset=$sign{charset}"; readline cheat sheet - +<:= stylesheet(qw'light dark circus mono red terse') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> diff --git a/red.css b/red.css index 5f9c06c..d1e1060 100644 --- a/red.css +++ b/red.css @@ -1,3 +1,5 @@ +@import url(base.css); + body { background: #000; color: #CCC; diff --git a/source.plp b/source.plp index 5359dbe..d874979 100644 --- a/source.plp +++ b/source.plp @@ -1,11 +1,5 @@ -<: -use utf8; -use strict; -use warnings; - -our $VERSION = 'v1.0'; - -$header{content_type} = "text/html; charset=utf-8"; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -14,13 +8,7 @@ $header{content_type} = "text/html; charset=utf-8"; sheet page source code -<: - my %styles = map {$_ => $_} qw(dark mono red); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_ - ) for keys %styles; -:> +<:= stylesheet(qw'light dark mono red') :> diff --git a/termcol.plp b/termcol.plp index 9e9ad19..321ea63 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,13 +1,7 @@ -<: -use utf8; -use strict; -use warnings; -use open IO => ':utf8'; -use List::Util 'min'; - -our $VERSION = 'v1.0'; +<(common.inc.plp)><: + use List::Util 'min'; -$header{content_type} = 'text/html; charset=utf-8'; + our $VERSION = 'v1.0'; :> @@ -16,7 +10,7 @@ $header{content_type} = 'text/html; charset=utf-8'; terminal colour cheat sheet - +<:= stylesheet(qw'light') :> diff --git a/terse.css b/terse.css index 502bb5f..b286da6 100644 --- a/terse.css +++ b/terse.css @@ -1,3 +1,5 @@ +@import url(base.css); + body ul.keys li { position: relative; /* hides overflow */ width: 4.5em; diff --git a/unicode.plp b/unicode.plp index 7207b03..ac63170 100644 --- a/unicode.plp +++ b/unicode.plp @@ -1,13 +1,5 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # that's not a comment, it's a NUMBER SIGN -use open IO => ':utf8'; - -our $VERSION = 'v1.0'; - -$header{content_type} = 'text/html; charset=utf-8'; +<(common.inc.plp)><: + our $VERSION = 'v1.0'; :> @@ -16,13 +8,7 @@ $header{content_type} = 'text/html; charset=utf-8'; digraph cheat sheet -<: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; -:> +<:= stylesheet(qw'light dark') :> diff --git a/vim.plp b/vim.plp index 8c666e9..cd855bf 100644 --- a/vim.plp +++ b/vim.plp @@ -1,15 +1,9 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # you know what you doing -no warnings 'uninitialized'; # save some useless checks for more legible code - -use Shiar_Sheet::KeySigns qw(%sign); # dependant on $get{ascii} +<(common.inc.plp)><: + use Shiar_Sheet::KeySigns qw(%sign); # dependant on $get{ascii} -our $VERSION = 'v1.2'; + our $VERSION = 'v1.2'; -$header{content_type} = "text/html; charset=$sign{charset}"; + $header{content_type} = "text/html; charset=$sign{charset}"; :> @@ -18,17 +12,12 @@ $header{content_type} = "text/html; charset=$sign{charset}"; vi cheat sheet - +<:= stylesheet(qw'light dark circus mono red terse') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> diff --git a/vimperator.plp b/vimperator.plp index fe1080b..3bc4d3b 100644 --- a/vimperator.plp +++ b/vimperator.plp @@ -1,34 +1,23 @@ -<: -use utf8; -use strict; -use warnings; -no warnings 'qw'; # you know what you doing -no warnings 'uninitialized'; # save some useless checks for more legible code - -use Shiar_Sheet::KeySigns qw(%sign); +<(common.inc.plp)><: + use Shiar_Sheet::KeySigns qw(%sign); -our $VERSION = 'v1.0'; + our $VERSION = 'v1.0'; -$header{content_type} = "text/html; charset=$sign{charset}"; + $header{content_type} = "text/html; charset=$sign{charset}"; :> -vimperator cheat sheet - +vimperator cheat sheet +<:= stylesheet(qw'light dark circus mono red terse') :> <: - my %styles = map {$_ => $_} qw(dark circus mono red terse); - our $style = exists $get{style} && $styles{$get{style}} || 'light'; - printf(qq{\n}, - $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "$_.css", $_ - ) for keys %styles; - our $showkeys = exists $get{keys} && $get{keys} ne '0'; - print "\n".'' unless $showkeys; + print "\n".'' + unless $showkeys; print "\n".'' if $showkeys and $get{keys} eq 'ghost'; :> -- 2.30.0