X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=blobdiff_plain;f=yarrg%2FCommodsWeb.pm;h=5e120039838271ed9f5ce8377c397b49974b62a1;hp=37bbfe7dcbcc2d878eb5a2d7016458b616358e35;hb=9c3c0cfe4257a1365c8d82ff6f9b7908a4eb74a1;hpb=f7c3c04f684b0e9cac4518beeece11853ef75109 diff --git a/yarrg/CommodsWeb.pm b/yarrg/CommodsWeb.pm index 37bbfe7..5e12003 100644 --- a/yarrg/CommodsWeb.pm +++ b/yarrg/CommodsWeb.pm @@ -50,8 +50,9 @@ BEGIN { @ISA = qw(Exporter); @EXPORT = qw(&dbw_connect &dbw_filename &ocean_list &sourcebasedir &to_json_shim &to_json_protecttags - &set_ctype_utf8 &webdatadir &printable + &set_ctype_utf8 &webdatadir &expected_error &dbw_lookup_string + &printable &tr_datarow &escerrq &prettyprint_age &meta_prettyprint_age); %EXPORT_TAGS = ( ); @@ -203,12 +204,31 @@ sub expected_error ($) { sub printable ($) { # printable($m) where $m is the Mason request object my ($m) = @_; my $a= scalar $m->caller_args(-1); - foreach my $t (qw(pdf ps html)) { + foreach my $t (qw(pdf ps html pdf2 ps2)) { return $t if $a->{"printable_$t"}; } return 0; } +sub tr_datarow ($$) { + my ($m, $lineno) = @_; + $lineno &= 1; + if (!printable($m)) { + $m->print(""); + } else { + $m->print(""); + } +} + +sub escerrq ($) { + return '"'.CGI::escapeHTML($_[0]).'"'; + # Prettier qotes as below are not in HTML 3.2: +# return '“'.CGI::escapeHTML($_[0]).'”'; +# return '‘'.CGI::escapeHTML($_[0]).'’'; +} + package CommodsWeb::ExpectedError; sub emsg ($) {