| 1 | # | ||||||||||||||||||||||||||||||||||
| 2 | # This file is part of WebDyne. | ||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||
| 4 | # This software is copyright (c) 2026 by Andrew Speer <andrew.speer@isolutions.com.au>. | ||||||||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||||||||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||
| 9 | # Full license text is available at: | ||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||
| 11 | # <http://dev.perl.org/licenses/> | ||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||
| 13 | package WebDyne::Constant; | ||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||
| 16 | # Pragma | ||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||
| 18 | 62 | ▶ | use strict qw(vars); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 19 | 62 | ▶ | use vars qw($VERSION %Constant %Package); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 62 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 62 | ▶ | no warnings qw(uninitialized redefine); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||
| 24 | # External modules | ||||||||||||||||||||||||||||||||||
| 25 | # | ||||||||||||||||||||||||||||||||||
| 26 | 62 | ▶ | use WebDyne::Util; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 27 | 62 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 28 | 62 | ▶ | use File::Basename qw(dirname); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 29 | 62 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 30 | 62 | $Data::Dumper::Indent=1; | |||||||||||||||||||||||||||||||||
| 31 | 62 | require Opcode; | |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||
| 34 | # Version information | ||||||||||||||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||||||||||||||
| 36 | 62 | $VERSION='3.029'; | |||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||
| 39 | # Get mod_perl version taking intio account legacy strings. Clear $@ after evals | ||||||||||||||||||||||||||||||||||
| 40 | # | ||||||||||||||||||||||||||||||||||
| 41 | 62 | ▶ | eval {require mod_perl2 if (defined($ENV{'MOD_PERL_API_VERSION'}) && ($ENV{'MOD_PERL_API_VERSION'} == 2))} || | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
MC/DC0%0/2
defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
defined $ENV{"MOD_PERL_API_VERSION"}
$ENV{"MOD_PERL_API_VERSION"} == 2
Truth table33%1/3
A and B
A= defined $ENV{"MOD_PERL_API_VERSION"}B= $ENV{"MOD_PERL_API_VERSION"} == 2
| |||||||||||||||||||||||||||||||||||
| 42 | 62 | ▶ | eval {require Apache2 if (defined($ENV{'MOD_PERL'}) && ($ENV{'MOD_PERL'}=~/1.99/))} || | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
MC/DC0%0/2
defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
defined $ENV{"MOD_PERL"}
$ENV{"MOD_PERL"} =~ /1.99/
Truth table33%1/3
A and B
A= defined $ENV{"MOD_PERL"}B= $ENV{"MOD_PERL"} =~ /1.99/
| |||||||||||||||||||||||||||||||||||
| 43 | 62 | ▶ | eval {require mod_perl if $ENV{'MOD_PERL'}}; | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
eval {
do {
require mod_perl2 if defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
}
} or eval {
do {
require Apache2 if defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
}
}
MC/DC0%0/2
eval {
do {
require mod_perl2 if defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
}
} or eval {
do {
require Apache2 if defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
}
}
eval {
do {
require mod_perl2 if defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
}
}
eval {
do {
require Apache2 if defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
}
}
Truth table33%1/3
A or B
A= eval {
do {
require mod_perl2 if defined $ENV{"MOD_PERL_API_VERSION"} and $ENV{"MOD_PERL_API_VERSION"} == 2
}
}B= eval {
do {
require Apache2 if defined $ENV{"MOD_PERL"} and $ENV{"MOD_PERL"} =~ /1.99/
}
}
| |||||||||||||||||||||||||||||||||||
| 44 | 62 | ▶ | eval {} if $@; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 45 | 62 | ▶ | my $MP_version=$mod_perl::VERSION || $mod_perl2::VERSION || $ENV{MOD_PERL_API_VERSION}; | ||||||||||||||||||||||||||||||||
|
Condition33%2/6
$mod_perl::VERSION || $mod_perl2::VERSION || $ENV{'MOD_PERL_API_VERSION'}
$mod_perl::VERSION or $mod_perl2::VERSION
MC/DC0%0/3
$mod_perl::VERSION || $mod_perl2::VERSION || $ENV{'MOD_PERL_API_VERSION'}
$mod_perl::VERSION
$mod_perl2::VERSION
$ENV{'MOD_PERL_API_VERSION'}
Truth table25%1/4
A or B || C
A= $mod_perl::VERSIONB= $mod_perl2::VERSIONC= $ENV{'MOD_PERL_API_VERSION'}
| |||||||||||||||||||||||||||||||||||
| 46 | 62 | ▶ | my $MP2=(defined($MP_version) && ($MP_version > 1.99)) ? 1 : 0; | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $MP_version and $MP_version > "1.99"
MC/DC0%0/2
defined $MP_version and $MP_version > "1.99"
defined $MP_version
$MP_version > "1.99"
Truth table33%1/3
A and B
A= defined $MP_versionB= $MP_version > "1.99"
| |||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||
| 49 | # Temp location to hold vars we propagate into multiple constants below. | ||||||||||||||||||||||||||||||||||
| 50 | # | ||||||||||||||||||||||||||||||||||
| 51 | 62 | my %constant_temp; | |||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||
| 54 | # Hash of constants | ||||||||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||||||||
| 56 | %Constant=( | ||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||
| 59 | # Array structure index abstraction. Do not change or bad | ||||||||||||||||||||||||||||||||||
| 60 | # things will happen. | ||||||||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||||||||
| 62 | WEBDYNE_NODE_NAME_IX => 0, | ||||||||||||||||||||||||||||||||||
| 63 | WEBDYNE_NODE_ATTR_IX => 1, | ||||||||||||||||||||||||||||||||||
| 64 | WEBDYNE_NODE_CHLD_IX => 2, | ||||||||||||||||||||||||||||||||||
| 65 | WEBDYNE_NODE_SBST_IX => 3, | ||||||||||||||||||||||||||||||||||
| 66 | WEBDYNE_NODE_LINE_IX => 4, | ||||||||||||||||||||||||||||||||||
| 67 | WEBDYNE_NODE_LINE_TAG_END_IX => 5, | ||||||||||||||||||||||||||||||||||
| 68 | WEBDYNE_NODE_SRCE_IX => 6, | ||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||
| 71 | # Container structure | ||||||||||||||||||||||||||||||||||
| 72 | # | ||||||||||||||||||||||||||||||||||
| 73 | WEBDYNE_CONTAINER_META_IX => 0, | ||||||||||||||||||||||||||||||||||
| 74 | WEBDYNE_CONTAINER_DATA_IX => 1, | ||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||
| 77 | # Where compiled scripts are stored. Scripts are stored in | ||||||||||||||||||||||||||||||||||
| 78 | # here with a the inode of the source file as the cache | ||||||||||||||||||||||||||||||||||
| 79 | # file name. | ||||||||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||||||||
| 81 | WEBDYNE_CACHE_DN => &cache_dn, | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||
| 84 | # Empty cache files at startup ? Default is yes (psp files wil be | ||||||||||||||||||||||||||||||||||
| 85 | # recompiled again after a server restart) | ||||||||||||||||||||||||||||||||||
| 86 | # | ||||||||||||||||||||||||||||||||||
| 87 | WEBDYNE_STARTUP_CACHE_FLUSH => 1, | ||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | # How often to check cache for excess entries, clean to | ||||||||||||||||||||||||||||||||||
| 91 | # low_water if > high_water entries, based on last used | ||||||||||||||||||||||||||||||||||
| 92 | # time or frequency. | ||||||||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||||||||
| 94 | # clean_method 0 = clean based on last used time (oldest | ||||||||||||||||||||||||||||||||||
| 95 | # get cleaned) | ||||||||||||||||||||||||||||||||||
| 96 | # | ||||||||||||||||||||||||||||||||||
| 97 | # clean_method 1 = clean based on frequency of use (least | ||||||||||||||||||||||||||||||||||
| 98 | # used get cleaned) | ||||||||||||||||||||||||||||||||||
| 99 | # | ||||||||||||||||||||||||||||||||||
| 100 | WEBDYNE_CACHE_CHECK_FREQ => 256, | ||||||||||||||||||||||||||||||||||
| 101 | WEBDYNE_CACHE_HIGH_WATER => 64, | ||||||||||||||||||||||||||||||||||
| 102 | WEBDYNE_CACHE_LOW_WATER => 32, | ||||||||||||||||||||||||||||||||||
| 103 | WEBDYNE_CACHE_CLEAN_METHOD => 1, | ||||||||||||||||||||||||||||||||||
| 104 | WEBDYNE_CACHE_STAT_TTL => 0, | ||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||
| 107 | # Type of eval code to run - use Safe module, or direct. Direct | ||||||||||||||||||||||||||||||||||
| 108 | # is default, but may allow subversion of code | ||||||||||||||||||||||||||||||||||
| 109 | # | ||||||||||||||||||||||||||||||||||
| 110 | # 1 = Safe # Not tested much - don't assume it is really safe ! | ||||||||||||||||||||||||||||||||||
| 111 | # 0 = Direct (UnSafe) | ||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||
| 113 | WEBDYNE_EVAL_SAFE => 0, | ||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||
| 116 | # Prefix eval code with strict pragma. Can be undef'd to remove | ||||||||||||||||||||||||||||||||||
| 117 | # this behaviour, or altered to suit local taste | ||||||||||||||||||||||||||||||||||
| 118 | # | ||||||||||||||||||||||||||||||||||
| 119 | WEBDYNE_EVAL_USE_STRICT => 'use strict qw(vars)', | ||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||
| 122 | # Anything to prepend after use strict | ||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||
| 124 | WEBDYNE_EVAL_PREPEND => '', | ||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||
| 127 | # Global opcode set, only these opcodes can be used if using a | ||||||||||||||||||||||||||||||||||
| 128 | # safe eval type. Uncomment the full_opset line if you want to | ||||||||||||||||||||||||||||||||||
| 129 | # be able to use all perl opcodes. Ignored if using direct eval | ||||||||||||||||||||||||||||||||||
| 130 | # | ||||||||||||||||||||||||||||||||||
| 131 | #WEBDYNE_EVAL_SAFE_OPCODE_AR => [&Opcode::full_opset()], | ||||||||||||||||||||||||||||||||||
| 132 | #WEBDYNE_EVAL_SAFE_OPCODE_AR => [&Opcode::opset(':default')], | ||||||||||||||||||||||||||||||||||
| 133 | WEBDYNE_EVAL_SAFE_OPCODE_AR => [':default'], | ||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||
| 136 | # Use strict var checking, eg will check that a when ${varname} param | ||||||||||||||||||||||||||||||||||
| 137 | # exists with a HTML page that the calling perl code (a) supplies a | ||||||||||||||||||||||||||||||||||
| 138 | # "varname" hash parm, and (b) that param is not undef | ||||||||||||||||||||||||||||||||||
| 139 | # | ||||||||||||||||||||||||||||||||||
| 140 | WEBDYNE_STRICT_VARS => 1, | ||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||
| 143 | # When a perl method loaded by a user calls another method within | ||||||||||||||||||||||||||||||||||
| 144 | # that just-loaded package (eg sub foo { shift()->bar() }), the | ||||||||||||||||||||||||||||||||||
| 145 | # WebDyne AUTOLOAD method gets called to work out where "bar" is, | ||||||||||||||||||||||||||||||||||
| 146 | # as it is not in the WebDyne ISA stack. | ||||||||||||||||||||||||||||||||||
| 147 | # | ||||||||||||||||||||||||||||||||||
| 148 | # By default, this gets done every time the routine is called, | ||||||||||||||||||||||||||||||||||
| 149 | # which can add up when done many times. By setting the var below | ||||||||||||||||||||||||||||||||||
| 150 | # to 1, the AUTOLOAD method will pollute the WebDyne class with | ||||||||||||||||||||||||||||||||||
| 151 | # a code ref to the method in question, saving a run through | ||||||||||||||||||||||||||||||||||
| 152 | # AUTOLOAD if it is ever called again. The downside - it is | ||||||||||||||||||||||||||||||||||
| 153 | # forever, and if your module has a method of the same name as | ||||||||||||||||||||||||||||||||||
| 154 | # one in the WebDyne class, it will clobber the WebDyne one, probably | ||||||||||||||||||||||||||||||||||
| 155 | # bringing the whole lot crashing down around your ears. | ||||||||||||||||||||||||||||||||||
| 156 | # | ||||||||||||||||||||||||||||||||||
| 157 | # The upside. A speedup of about 10% on modules that use AUTOLOAD | ||||||||||||||||||||||||||||||||||
| 158 | # heavily | ||||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||||
| 160 | WEBDYNE_AUTOLOAD_POLLUTE => 0, | ||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||
| 163 | # Dump flag. Set to 1 if you want the <dump> tag to display the | ||||||||||||||||||||||||||||||||||
| 164 | # current CGI status | ||||||||||||||||||||||||||||||||||
| 165 | # | ||||||||||||||||||||||||||||||||||
| 166 | WEBDYNE_DUMP_FLAG => 0, | ||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | # Encoding | ||||||||||||||||||||||||||||||||||
| 170 | # | ||||||||||||||||||||||||||||||||||
| 171 | WEBDYNE_HTML_CHARSET => do { | ||||||||||||||||||||||||||||||||||
| 172 | 62 | $constant_temp{'webdyne_html_charset'}='UTF-8' | |||||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | # Content-type for text/html. Combined with charset to produce Content-type header | ||||||||||||||||||||||||||||||||||
| 177 | # | ||||||||||||||||||||||||||||||||||
| 178 | WEBDYNE_CONTENT_TYPE_HTML => do { | ||||||||||||||||||||||||||||||||||
| 179 | 62 | $constant_temp{'webdyne_content_type_html'}='text/html' | |||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||
| 181 | WEBDYNE_CONTENT_TYPE_HTML_ENCODED => do { | ||||||||||||||||||||||||||||||||||
| 182 | 62 | $constant_temp{'webdyne_content_type_html_encoded'}=sprintf('%s; charset=%s', @constant_temp{qw(webdyne_content_type_html webdyne_html_charset)}) | |||||||||||||||||||||||||||||||||
| 183 | }, | ||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||
| 186 | # Content-type for text/plain. As above | ||||||||||||||||||||||||||||||||||
| 187 | # | ||||||||||||||||||||||||||||||||||
| 188 | WEBDYNE_CONTENT_TYPE_TEXT => do { | ||||||||||||||||||||||||||||||||||
| 189 | 62 | $constant_temp{'webdyne_content_type_text'}='text/plain' | |||||||||||||||||||||||||||||||||
| 190 | }, | ||||||||||||||||||||||||||||||||||
| 191 | WEBDYNE_CONTENT_TYPE_TEXT_ENCODED => | ||||||||||||||||||||||||||||||||||
| 192 | sprintf('%s; charset=%s', @constant_temp{qw(webdyne_content_type_text webdyne_html_charset)}), | ||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||
| 195 | # And JSON | ||||||||||||||||||||||||||||||||||
| 196 | # | ||||||||||||||||||||||||||||||||||
| 197 | WEBDYNE_CONTENT_TYPE_JSON => do { | ||||||||||||||||||||||||||||||||||
| 198 | 62 | $constant_temp{'webdyne_content_type_json'}='application/json' | |||||||||||||||||||||||||||||||||
| 199 | }, | ||||||||||||||||||||||||||||||||||
| 200 | WEBDYNE_CONTENT_TYPE_JSON_ENCODED => | ||||||||||||||||||||||||||||||||||
| 201 | sprintf('%s; charset=%s', @constant_temp{qw(webdyne_content_type_json webdyne_html_charset)}), | ||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||
| 204 | # Script types which are executable so we won't subst strings in them | ||||||||||||||||||||||||||||||||||
| 205 | # | ||||||||||||||||||||||||||||||||||
| 206 | 186 | WEBDYNE_SCRIPT_TYPE_EXECUTABLE_HR => { map { $_=>1 } qw( | |||||||||||||||||||||||||||||||||
| 207 | text/javascript | ||||||||||||||||||||||||||||||||||
| 208 | application/javascript | ||||||||||||||||||||||||||||||||||
| 209 | module | ||||||||||||||||||||||||||||||||||
| 210 | )}, | ||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||
| 213 | # DTD to use when generating HTML | ||||||||||||||||||||||||||||||||||
| 214 | # | ||||||||||||||||||||||||||||||||||
| 215 | WEBDYNE_DTD => '<!DOCTYPE html>', | ||||||||||||||||||||||||||||||||||
| 216 | WEBDYNE_META => { | ||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||
| 218 | # Set to 'chareset=UTF-8' => undef to get result we want | ||||||||||||||||||||||||||||||||||
| 219 | 'charset='.$constant_temp{'webdyne_html_charset'} => undef, | ||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||
| 221 | # Set viewport by default | ||||||||||||||||||||||||||||||||||
| 222 | 'viewport' => 'width=device-width, initial-scale=1.0' | ||||||||||||||||||||||||||||||||||
| 223 | }, | ||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | # Include a Content-Type meta tag ? | ||||||||||||||||||||||||||||||||||
| 227 | # | ||||||||||||||||||||||||||||||||||
| 228 | WEBDYNE_CONTENT_TYPE_HTML_META => 0, | ||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||
| 231 | # Default <html> tag paramaters, eg { lang =>'en-US' } | ||||||||||||||||||||||||||||||||||
| 232 | # | ||||||||||||||||||||||||||||||||||
| 233 | WEBDYNE_HTML_PARAM => {lang => 'en' }, | ||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||
| 236 | # Default params for <start_html> tag | ||||||||||||||||||||||||||||||||||
| 237 | # | ||||||||||||||||||||||||||||||||||
| 238 | # E.g. WEBDYNE_START_HTML_PARAM => { include_style=>['foo.css', 'bar.css'] }, | ||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||||||||
| 241 | WEBDYNE_START_HTML_PARAM => {}, | ||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||
| 244 | # Make include/other sections in start_html tag static, i.e. load them at compile | ||||||||||||||||||||||||||||||||||
| 245 | # time and they never change. Make undef to force re-include every page load | ||||||||||||||||||||||||||||||||||
| 246 | # | ||||||||||||||||||||||||||||||||||
| 247 | WEBDYNE_START_HTML_PARAM_STATIC => 1, | ||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||
| 250 | # Shortcut attributes for start_html. Use with convention <start_html pico title="My Title"> to use | ||||||||||||||||||||||||||||||||||
| 251 | # | ||||||||||||||||||||||||||||||||||
| 252 | WEBDYNE_START_HTML_SHORTCUT_HR => { | ||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||
| 254 | pico => { style => 'https://cdn.jsdelivr.net/npm/@picocss/pico@latest/css/pico.min.css' }, | ||||||||||||||||||||||||||||||||||
| 255 | htmx => { script => 'https://cdn.jsdelivr.net/npm/htmx.org@latest/dist/htmx.min.js' }, | ||||||||||||||||||||||||||||||||||
| 256 | htmx_sse => { script => 'https://cdn.jsdelivr.net/npm/htmx-ext-sse@latest/sse.js' }, | ||||||||||||||||||||||||||||||||||
| 257 | alpine => { script => 'https://cdn.jsdelivr.net/npm/alpinejs@latest/dist/cdn.min.js#defer' } | ||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||
| 259 | # Commented out for now, left as syntax examples | ||||||||||||||||||||||||||||||||||
| 260 | # | ||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||
| 262 | #bootstrap => { | ||||||||||||||||||||||||||||||||||
| 263 | # style => 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css', | ||||||||||||||||||||||||||||||||||
| 264 | # script => 'https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js' | ||||||||||||||||||||||||||||||||||
| 265 | #}, | ||||||||||||||||||||||||||||||||||
| 266 | #tailwind => { style => 'https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4' }, | ||||||||||||||||||||||||||||||||||
| 267 | #alpine_ajax => { script => [ | ||||||||||||||||||||||||||||||||||
| 268 | # 'https://cdn.jsdelivr.net/npm/@imacrayon/alpine-ajax@0.12.6/dist/cdn.min.js#defer', | ||||||||||||||||||||||||||||||||||
| 269 | # 'https://cdn.jsdelivr.net/npm/alpinejs@3.14.1/dist/cdn.min.js#defer' | ||||||||||||||||||||||||||||||||||
| 270 | #]} | ||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||
| 272 | }, | ||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||
| 275 | # Anything that should be added in <head> section. Will be inserted verbatim before | ||||||||||||||||||||||||||||||||||
| 276 | # </head>. No interpolation or variables, simple text string only. Useful for setting | ||||||||||||||||||||||||||||||||||
| 277 | # global stylesheet, e.g. | ||||||||||||||||||||||||||||||||||
| 278 | # | ||||||||||||||||||||||||||||||||||
| 279 | # WEBDYNE_HEAD_INSERT => '<link href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css" rel="stylesheet">' | ||||||||||||||||||||||||||||||||||
| 280 | # | ||||||||||||||||||||||||||||||||||
| 281 | # Will be added to all <head> sections universally. Default is to inline webdyne.css so don't need to | ||||||||||||||||||||||||||||||||||
| 282 | # worry about where docroot is, enabling static file load etc. Just null out with | ||||||||||||||||||||||||||||||||||
| 283 | # | ||||||||||||||||||||||||||||||||||
| 284 | # WEBDYNE_HEAD_INSERT => undef, | ||||||||||||||||||||||||||||||||||
| 285 | # | ||||||||||||||||||||||||||||||||||
| 286 | # To disable. | ||||||||||||||||||||||||||||||||||
| 287 | # | ||||||||||||||||||||||||||||||||||
| 288 | WEBDYNE_HEAD_INSERT => sprintf('<style>%s</style>', do { | ||||||||||||||||||||||||||||||||||
| 289 | 62 | local $/; | |||||||||||||||||||||||||||||||||
| 290 | 62 | my $style_fn=&fullpath('webdyne.css'); | |||||||||||||||||||||||||||||||||
| 291 | 62 | ▶ | open my $fh, '<', $style_fn | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 292 | or die sprintf('unable to read default stylesheet %s: %s', $style_fn, $!); | ||||||||||||||||||||||||||||||||||
| 293 | 62 | <$fh>; | |||||||||||||||||||||||||||||||||
| 294 | }), | ||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||
| 297 | # Ignore ignorable whitespace in compile. Play around with these settings if | ||||||||||||||||||||||||||||||||||
| 298 | # you don't like the formatting of the compiled HTML. See HTML::TreeBuilder | ||||||||||||||||||||||||||||||||||
| 299 | # man page for details here | ||||||||||||||||||||||||||||||||||
| 300 | # | ||||||||||||||||||||||||||||||||||
| 301 | WEBDYNE_COMPILE_IGNORE_WHITESPACE => 1, | ||||||||||||||||||||||||||||||||||
| 302 | WEBDYNE_COMPILE_NO_SPACE_COMPACTING => 0, | ||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||
| 305 | # Other Compile settings | ||||||||||||||||||||||||||||||||||
| 306 | # | ||||||||||||||||||||||||||||||||||
| 307 | WEBDYNE_COMPILE_P_STRICT => 1, | ||||||||||||||||||||||||||||||||||
| 308 | WEBDYNE_COMPILE_IMPLICIT_BODY_P_TAG => 1, | ||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||
| 311 | # Store and render comments ? | ||||||||||||||||||||||||||||||||||
| 312 | # | ||||||||||||||||||||||||||||||||||
| 313 | WEBDYNE_STORE_COMMENTS => 1, | ||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||
| 316 | # Send no-cache headers ? | ||||||||||||||||||||||||||||||||||
| 317 | # | ||||||||||||||||||||||||||||||||||
| 318 | WEBDYNE_NO_CACHE => 1, | ||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||
| 321 | # Render blocks outside of perl code | ||||||||||||||||||||||||||||||||||
| 322 | # | ||||||||||||||||||||||||||||||||||
| 323 | #WEBDYNE_DELAYED_BLOCK_RENDER => 1, | ||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||
| 326 | # Are warnings fatal ? | ||||||||||||||||||||||||||||||||||
| 327 | # | ||||||||||||||||||||||||||||||||||
| 328 | WEBDYNE_WARNINGS_FATAL => 0, | ||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||
| 331 | # CGI disable uploads default, max post size default | ||||||||||||||||||||||||||||||||||
| 332 | # | ||||||||||||||||||||||||||||||||||
| 333 | WEBDYNE_CGI_DISABLE_UPLOADS => 0, | ||||||||||||||||||||||||||||||||||
| 334 | WEBDYNE_CGI_POST_MAX => (512*1024), #512Kb | ||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||
| 337 | # Expand CGI parameters found in CGI values, e.g. button with submit=1&name=2 will get those | ||||||||||||||||||||||||||||||||||
| 338 | # CGI params set. | ||||||||||||||||||||||||||||||||||
| 339 | # | ||||||||||||||||||||||||||||||||||
| 340 | WEBDYNE_CGI_PARAM_EXPAND => 1, | ||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||
| 343 | # Escape CGI form fields and generated HTML attributes ? | ||||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||||
| 345 | WEBDYNE_CGI_AUTOESCAPE => 1, | ||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||
| 348 | # Error handling. Use text errors rather than HTML ? | ||||||||||||||||||||||||||||||||||
| 349 | # | ||||||||||||||||||||||||||||||||||
| 350 | WEBDYNE_ERROR_TEXT => 0, | ||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||
| 353 | # Show errors ? Extended shows additional information with granularity as per following | ||||||||||||||||||||||||||||||||||
| 354 | # section. | ||||||||||||||||||||||||||||||||||
| 355 | # | ||||||||||||||||||||||||||||||||||
| 356 | WEBDYNE_ERROR_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 357 | WEBDYNE_ERROR_SHOW_EXTENDED => 0, | ||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||
| 360 | # Show error, source file context, number of lines pre and post. Only applicable | ||||||||||||||||||||||||||||||||||
| 361 | # for extended + HTML error output. | ||||||||||||||||||||||||||||||||||
| 362 | # | ||||||||||||||||||||||||||||||||||
| 363 | WEBDYNE_ERROR_SOURCE_CONTEXT_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 364 | WEBDYNE_ERROR_SOURCE_CONTEXT_LINES_PRE => 4, | ||||||||||||||||||||||||||||||||||
| 365 | WEBDYNE_ERROR_SOURCE_CONTEXT_LINES_POST => 4, | ||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||
| 367 | # Max length of source line to show in ouput. 0 for unlimited. | ||||||||||||||||||||||||||||||||||
| 368 | WEBDYNE_ERROR_SOURCE_CONTEXT_LINE_FRAGMENT_MAX => 80, | ||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||
| 370 | # Show filename (FULL for full filesystem path) | ||||||||||||||||||||||||||||||||||
| 371 | WEBDYNE_ERROR_SOURCE_FILENAME_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 372 | WEBDYNE_ERROR_SOURCE_FILENAME_FULL => 0, | ||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||
| 374 | # Show backtrace, show full or brief backtrace | ||||||||||||||||||||||||||||||||||
| 375 | WEBDYNE_ERROR_BACKTRACE_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 376 | WEBDYNE_ERROR_BACKTRACE_SHORT => 0, | ||||||||||||||||||||||||||||||||||
| 377 | # Skip (eval) and __ANON__ methods unless set to 1 | ||||||||||||||||||||||||||||||||||
| 378 | WEBDYNE_ERROR_BACKTRACE_FULL => 0, | ||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||
| 380 | # Show eval trace. Uses SOURCE_CONTEXT_LINES to determine number of lines to show | ||||||||||||||||||||||||||||||||||
| 381 | WEBDYNE_ERROR_EVAL_CONTEXT_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||
| 383 | # CGI and other info | ||||||||||||||||||||||||||||||||||
| 384 | WEBDYNE_ERROR_CGI_PARAM_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 385 | WEBDYNE_ERROR_ENV_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 386 | WEBDYNE_ERROR_WEBDYNE_CONSTANT_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||
| 388 | # URI and version | ||||||||||||||||||||||||||||||||||
| 389 | WEBDYNE_ERROR_URI_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 390 | WEBDYNE_ERROR_VERSION_SHOW => 1, | ||||||||||||||||||||||||||||||||||
| 391 | WEBDYNE_ERROR_INTERNAL_SHOW => 0, | ||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||
| 393 | # Internal indexes for error eval handler array | ||||||||||||||||||||||||||||||||||
| 394 | # | ||||||||||||||||||||||||||||||||||
| 395 | #WEBDYNE_ERROR_EVAL_TEXT_IX => 0, | ||||||||||||||||||||||||||||||||||
| 396 | #WEBDYNE_ERROR_EVAL_EMBEDDED_IX => 1, | ||||||||||||||||||||||||||||||||||
| 397 | #WEBDYNE_ERROR_EVAL_LINE_NO_IX => 2, | ||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||
| 400 | # Alternate error message if WEBDYNE_ERROR_SHOW disabled | ||||||||||||||||||||||||||||||||||
| 401 | # | ||||||||||||||||||||||||||||||||||
| 402 | WEBDYNE_ERROR_SHOW_ALTERNATE => | ||||||||||||||||||||||||||||||||||
| 403 | 'error display disabled - enable WEBDYNE_ERROR_SHOW to show errors, or review web server error log.', | ||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||
| 405 | # Default title | ||||||||||||||||||||||||||||||||||
| 406 | # | ||||||||||||||||||||||||||||||||||
| 407 | WEBDYNE_HTML_DEFAULT_TITLE => 'Untitled Document', | ||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||
| 410 | # HTML Tiny mode, XML or HTML | ||||||||||||||||||||||||||||||||||
| 411 | # | ||||||||||||||||||||||||||||||||||
| 412 | WEBDYNE_HTML_TINY_MODE => 'html', | ||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||
| 415 | # Development mode - recompile loaded modules | ||||||||||||||||||||||||||||||||||
| 416 | # | ||||||||||||||||||||||||||||||||||
| 417 | WEBDYNE_RELOAD => 0, | ||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||
| 420 | # Use JSON canonical. pretty mode ? | ||||||||||||||||||||||||||||||||||
| 421 | # | ||||||||||||||||||||||||||||||||||
| 422 | WEBDYNE_JSON_CANONICAL => 1, | ||||||||||||||||||||||||||||||||||
| 423 | WEBDYNE_JSON_PRETTY => 0, | ||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||
| 426 | # Enable the API mode ? | ||||||||||||||||||||||||||||||||||
| 427 | # | ||||||||||||||||||||||||||||||||||
| 428 | WEBDYNE_API_ENABLE => 1, | ||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||
| 431 | # Enable Alpine/Vue hack | ||||||||||||||||||||||||||||||||||
| 432 | # | ||||||||||||||||||||||||||||||||||
| 433 | WEBDYNE_ALPINE_VUE_ATTRIBUTE_HACK_ENABLE => 'x-on', | ||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||
| 436 | # Request headers for HTMX and Alpine Ajax | ||||||||||||||||||||||||||||||||||
| 437 | # | ||||||||||||||||||||||||||||||||||
| 438 | 248 | WEBDYNE_HTTP_HEADER_AJAX_HR => { map { $_=> 1} @{$_=[qw( | |||||||||||||||||||||||||||||||||
| 439 | hx-request | ||||||||||||||||||||||||||||||||||
| 440 | x-alpine-request | ||||||||||||||||||||||||||||||||||
| 441 | Hx-Request | ||||||||||||||||||||||||||||||||||
| 442 | X-Alpine-Request | ||||||||||||||||||||||||||||||||||
| 443 | )]}}, | ||||||||||||||||||||||||||||||||||
| 444 | WEBDYNE_HTTP_HEADER_AJAX_AR => $_, | ||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||
| 447 | # Force run of <htmx> tag even if no hx-request header | ||||||||||||||||||||||||||||||||||
| 448 | # | ||||||||||||||||||||||||||||||||||
| 449 | WEBDYNE_HTMX_FORCE => 0, | ||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||
| 452 | # Headers | ||||||||||||||||||||||||||||||||||
| 453 | # | ||||||||||||||||||||||||||||||||||
| 454 | WEBDYNE_HTTP_HEADER => { | ||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||
| 456 | #'Content-Type' => sprintf('%s; charset=%s', @constant_temp{qw(webdyne_content_type_html webdyne_html_charset)}), | ||||||||||||||||||||||||||||||||||
| 457 | 'Content-Type' => $constant_temp{'webdyne_content_type_html_encoded'}, | ||||||||||||||||||||||||||||||||||
| 458 | 'Cache-Control' => 'no-cache, no-store, must-revalidate', | ||||||||||||||||||||||||||||||||||
| 459 | 'Pragma' => 'no-cache', | ||||||||||||||||||||||||||||||||||
| 460 | 'Expires' => '0', | ||||||||||||||||||||||||||||||||||
| 461 | 'X-Content-Type-Options' => 'nosniff', | ||||||||||||||||||||||||||||||||||
| 462 | 'X-Frame-Options' => 'SAMEORIGIN' | ||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||
| 464 | # Set other options here, e.g. | ||||||||||||||||||||||||||||||||||
| 465 | # | ||||||||||||||||||||||||||||||||||
| 466 | #'Strict-Transport-Security' => 'max-age=31536000; includeSubDomains; preload', | ||||||||||||||||||||||||||||||||||
| 467 | #'Content-Security-Policy' => "default-src 'self'; style-src 'self' https://cdn.jsdelivr.net https://fonts.googleapis.com/ 'unsafe-inline'; font-src https://fonts.gstatic.com", | ||||||||||||||||||||||||||||||||||
| 468 | #'Referrer-Policy' => 'strict-origin-when-cross-origin', | ||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||
| 470 | }, | ||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||
| 473 | # Webdyne PSGI serves static files ? | ||||||||||||||||||||||||||||||||||
| 474 | # | ||||||||||||||||||||||||||||||||||
| 475 | #WEBDYNE_PSGI_STATIC => 1, | ||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||
| 478 | # WebDyne default extension and length, used in susbtr as faster than regex. Update - too slow, retiring and going to fixed | ||||||||||||||||||||||||||||||||||
| 479 | # string .psp extension | ||||||||||||||||||||||||||||||||||
| 480 | # | ||||||||||||||||||||||||||||||||||
| 481 | WEBDYNE_PSP_EXT => ($constant_temp{'webdyne_psp_ext'}='.psp'), | ||||||||||||||||||||||||||||||||||
| 482 | WEBDYNE_PSP_EXT_RE => qr/\Q$constant_temp{'webdyne_psp_ext'}\E$/, | ||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||
| 485 | # Very minimal MIME type hash used by lookup_file function | ||||||||||||||||||||||||||||||||||
| 486 | # | ||||||||||||||||||||||||||||||||||
| 487 | WEBDYNE_MIME_TYPE_HR => { | ||||||||||||||||||||||||||||||||||
| 488 | 'html' => 'text/html', | ||||||||||||||||||||||||||||||||||
| 489 | 'htm' => 'text/html', | ||||||||||||||||||||||||||||||||||
| 490 | 'txt' => 'text/plain', | ||||||||||||||||||||||||||||||||||
| 491 | 'jpg' => 'image/jpeg', | ||||||||||||||||||||||||||||||||||
| 492 | 'jpeg' => 'image/jpeg', | ||||||||||||||||||||||||||||||||||
| 493 | 'png' => 'image/png', | ||||||||||||||||||||||||||||||||||
| 494 | 'gif' => 'image/gif', | ||||||||||||||||||||||||||||||||||
| 495 | 'css' => 'text/css', | ||||||||||||||||||||||||||||||||||
| 496 | 'js' => 'application/javascript', | ||||||||||||||||||||||||||||||||||
| 497 | 'json' => 'application/json', | ||||||||||||||||||||||||||||||||||
| 498 | 'pdf' => 'application/pdf', | ||||||||||||||||||||||||||||||||||
| 499 | 'svg' => 'image/svg+xml', | ||||||||||||||||||||||||||||||||||
| 500 | 'yml' => 'application/x-yaml', | ||||||||||||||||||||||||||||||||||
| 501 | 'yaml' => 'application/x-yaml', | ||||||||||||||||||||||||||||||||||
| 502 | 'xml' => 'application/xml', | ||||||||||||||||||||||||||||||||||
| 503 | 'toml' => 'application/toml', | ||||||||||||||||||||||||||||||||||
| 504 | 'md' => 'text/markdown' | ||||||||||||||||||||||||||||||||||
| 505 | }, | ||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||
| 508 | # Other file extenstions the PSGI indexer is allowed to open | ||||||||||||||||||||||||||||||||||
| 509 | # | ||||||||||||||||||||||||||||||||||
| 510 | 186 | WEBDYNE_INDEX_EXT_ALLOWED_HR => { map {$_=>1} qw( | |||||||||||||||||||||||||||||||||
| 511 | psp | ||||||||||||||||||||||||||||||||||
| 512 | pm | ||||||||||||||||||||||||||||||||||
| 513 | pl | ||||||||||||||||||||||||||||||||||
| 514 | )}, | ||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||
| 517 | # Allow the bundled indexer to display file source ? | ||||||||||||||||||||||||||||||||||
| 518 | # | ||||||||||||||||||||||||||||||||||
| 519 | WEBDYNE_INDEX_SOURCE_ENABLE => 0, | ||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||
| 522 | # And raw file names. Should be regexp, todo | ||||||||||||||||||||||||||||||||||
| 523 | # | ||||||||||||||||||||||||||||||||||
| 524 | 372 | ▶ | WEBDYNE_INDEX_FN_ALLOWED_HR => { map {$_=>1} qw( | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 525 | LICENSE | ||||||||||||||||||||||||||||||||||
| 526 | MANIFEST | ||||||||||||||||||||||||||||||||||
| 527 | Makefile | ||||||||||||||||||||||||||||||||||
| 528 | cpanfile | ||||||||||||||||||||||||||||||||||
| 529 | cpanfile.snapshot | ||||||||||||||||||||||||||||||||||
| 530 | Dockerfile | ||||||||||||||||||||||||||||||||||
| 531 | )}, | ||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||
| 534 | # Dir_config can be loaded from here if not in Apache | ||||||||||||||||||||||||||||||||||
| 535 | # | ||||||||||||||||||||||||||||||||||
| 536 | WEBDYNE_DIR_CONFIG => undef, | ||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||
| 539 | # Dir_config can be loaded from each directory via webdyne.conf.pl | ||||||||||||||||||||||||||||||||||
| 540 | # if desired, only under Plack at the moment | ||||||||||||||||||||||||||||||||||
| 541 | # | ||||||||||||||||||||||||||||||||||
| 542 | WEBDYNE_DIR_CONFIG_CWD_LOAD => 1, | ||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||
| 545 | # Local constant path names. Used as marker only, updated dynamically | ||||||||||||||||||||||||||||||||||
| 546 | # by &local_constant_load; | ||||||||||||||||||||||||||||||||||
| 547 | # | ||||||||||||||||||||||||||||||||||
| 548 | WEBDYNE_CONF_HR => undef, | ||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||
| 551 | # Config file name | ||||||||||||||||||||||||||||||||||
| 552 | # | ||||||||||||||||||||||||||||||||||
| 553 | WEBDYNE_CONF_FN => 'webdyne.conf.pl', | ||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||
| 556 | # Tidy output ? Will require HTML::Tidy5 and all dependencies to be installed | ||||||||||||||||||||||||||||||||||
| 557 | # | ||||||||||||||||||||||||||||||||||
| 558 | WEBDYNE_HTML_TIDY => 0, | ||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||
| 561 | # HTML::Tidy5 config | ||||||||||||||||||||||||||||||||||
| 562 | # | ||||||||||||||||||||||||||||||||||
| 563 | WEBDYNE_HTML_TIDY_CONFIG_HR => { | ||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||
| 565 | 'indent' => 0, # enable indentation | ||||||||||||||||||||||||||||||||||
| 566 | 'indent-spaces' => 2, # 2 spaces per indent level | ||||||||||||||||||||||||||||||||||
| 567 | 'wrap' => 0, # don't wrap lines | ||||||||||||||||||||||||||||||||||
| 568 | 'tidy-mark' => 'no', # don't add a tidy comment | ||||||||||||||||||||||||||||||||||
| 569 | 'clean' => 'no', # don't clean embedded styles | ||||||||||||||||||||||||||||||||||
| 570 | 'drop-empty-elements' => 'no', # don't remove empty elements | ||||||||||||||||||||||||||||||||||
| 571 | 'hide-comments' => 'no', # keep HTML comments | ||||||||||||||||||||||||||||||||||
| 572 | 'fix-uri' => 'no', # don't alter URIs | ||||||||||||||||||||||||||||||||||
| 573 | 'output-html' => 'yes', # output as HTML | ||||||||||||||||||||||||||||||||||
| 574 | 'show-warnings' => 'no', # suppress warnings | ||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||
| 576 | }, | ||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||
| 579 | # Add some linefeeds via "\n" to output | ||||||||||||||||||||||||||||||||||
| 580 | # | ||||||||||||||||||||||||||||||||||
| 581 | WEBDYNE_HTML_NEWLINE => 0, | ||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||
| 584 | # PAGI loaded ? | ||||||||||||||||||||||||||||||||||
| 585 | # | ||||||||||||||||||||||||||||||||||
| 586 | WEBDYNE_PAGI => $INC{'WebDyne/PAGI.pm'} ? 1 : 0, | ||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||
| 589 | # PSGI loaded ? | ||||||||||||||||||||||||||||||||||
| 590 | # | ||||||||||||||||||||||||||||||||||
| 591 | 62 | WEBDYNE_PSGI => $INC{'WebDyne/PSGI.pm'} ? 1 : 0, | |||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||
| 594 | # Indexer and test, style files | ||||||||||||||||||||||||||||||||||
| 595 | # | ||||||||||||||||||||||||||||||||||
| 596 | WEBDYNE_DEFAULT_TEST_FN => &fullpath('time.psp'), | ||||||||||||||||||||||||||||||||||
| 597 | WEBDYNE_DEFAULT_INDEX_FN => &fullpath('index.psp'), | ||||||||||||||||||||||||||||||||||
| 598 | WEBDYNE_DEFAULT_STYLE_FN => &fullpath('webdyne.css'), | ||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||
| 601 | # Mod_perl level. Do not change unless you know what you are | ||||||||||||||||||||||||||||||||||
| 602 | # doing. | ||||||||||||||||||||||||||||||||||
| 603 | # | ||||||||||||||||||||||||||||||||||
| 604 | MP2 => $MP2, | ||||||||||||||||||||||||||||||||||
| 605 | MOD_PERL => $MP_version, | ||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||
| 608 | ); | ||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||
| 611 | 248 | ▶ | sub fullpath { | ||||||||||||||||||||||||||||||||
|
Subroutine
fullpath: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||
| 614 | # Test file to use if no DOCUMENT_ROOT found | ||||||||||||||||||||||||||||||||||
| 615 | # | ||||||||||||||||||||||||||||||||||
| 616 | 248 | my ($fn, $dn)=@_; | |||||||||||||||||||||||||||||||||
| 617 | 248 | ▶ | $dn ||= dirname(__FILE__); | ||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dn ||= dirname(__FILE__)
MC/DC0%0/2
$dn ||= dirname(__FILE__)
$dn
dirname(__FILE__)
Truth table33%1/3
A ||= B
A= $dnB= dirname(__FILE__)
| |||||||||||||||||||||||||||||||||||
| 618 | 248 | return File::Spec->rel2abs(File::Spec->catfile($dn, $fn)); | |||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||
| 623 | 360 | ▶ | sub local_constant_fn { | ||||||||||||||||||||||||||||||||
|
Subroutine
local_constant_fn: called CC=7 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||
| 626 | # Where local constants reside | ||||||||||||||||||||||||||||||||||
| 627 | # | ||||||||||||||||||||||||||||||||||
| 628 | 360 | my @local_constant_fn; | |||||||||||||||||||||||||||||||||
| 629 | 360 | my $local_constant_fn=$Constant{'WEBDYNE_CONF_FN'}; | |||||||||||||||||||||||||||||||||
| 630 | 360 | ▶ | if ($^O=~/MSWin[32|64]/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | my $dn=$ENV{'WEBDYNE_HOME'} || $ENV{'WEBDYNE'} || $ENV{'WINDIR'}; | ||||||||||||||||||||||||||||||||
|
Condition0%0/6
$ENV{'WEBDYNE_HOME'} || $ENV{'WEBDYNE'} || $ENV{'WINDIR'}
$ENV{"WEBDYNE_HOME"} or $ENV{"WEBDYNE"}
MC/DC0%0/3
$ENV{'WEBDYNE_HOME'} || $ENV{'WEBDYNE'} || $ENV{'WINDIR'}
$ENV{"WEBDYNE_HOME"}
$ENV{"WEBDYNE"}
$ENV{'WINDIR'}
Truth table0%0/4
A or B || C
A= $ENV{"WEBDYNE_HOME"}B= $ENV{"WEBDYNE"}C= $ENV{'WINDIR'}
| |||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | push @local_constant_fn, (exists $ENV{'WEBDYNE_CONF'} ? $ENV{'WEBDYNE_CONF'} : | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 633 | File::Spec->catfile($dn, $local_constant_fn)) | ||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||
| 635 | else { | ||||||||||||||||||||||||||||||||||
| 636 | 360 | ▶ | push @local_constant_fn, ($ENV{'WEBDYNE_CONF'} || | ||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ENV{'WEBDYNE_CONF'} || 'File::Spec'->catfile('File::Spec'->rootdir, 'etc', $local_constant_fn)
MC/DC0%0/2
$ENV{'WEBDYNE_CONF'} || 'File::Spec'->catfile('File::Spec'->rootdir, 'etc', $local_constant_fn)
$ENV{'WEBDYNE_CONF'}
'File::Spec'->catfile('File::Spec'->rootdir, 'etc', $local_constant_fn)
Truth table66%2/3
A || B
A= $ENV{'WEBDYNE_CONF'}B= 'File::Spec'->catfile('File::Spec'->rootdir, 'etc', $local_constant_fn)
| |||||||||||||||||||||||||||||||||||
| 637 | File::Spec->catfile( | ||||||||||||||||||||||||||||||||||
| 638 | File::Spec->rootdir(), 'etc', $local_constant_fn | ||||||||||||||||||||||||||||||||||
| 639 | )) | ||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||
| 641 | 360 | ▶ | unless ($ENV{'WEBDYNE_CONF'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 642 | 58 | ▶ | push @local_constant_fn, (my ($fn)=glob(sprintf('~/.%s', $local_constant_fn))); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 643 | 226 | 0 && debug("push fn: $fn onto local_constant_fn: %s, env: %s", Dumper(\@local_constant_fn, \%ENV)); | |||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||
| 645 | 360 | 0 && debug('local_constant_fn: %s, env: %s', Dumper(\@local_constant_fn, \%ENV)); | |||||||||||||||||||||||||||||||||
| 646 | 360 | return \@local_constant_fn; | |||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||
| 651 | 62 | ▶ | sub cache_dn { | ||||||||||||||||||||||||||||||||
|
Subroutine
cache_dn: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||
| 654 | # Where the cache directory should be located | ||||||||||||||||||||||||||||||||||
| 655 | # | ||||||||||||||||||||||||||||||||||
| 656 | 62 | my $cache_dn; | |||||||||||||||||||||||||||||||||
| 657 | 62 | ▶ | if ($ENV{'PAR_TEMP'}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 658 | 0 | $cache_dn=$ENV{'PAR_TEMP'} | |||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||
| 662 | # Used to set like this - now leave the installer to | ||||||||||||||||||||||||||||||||||
| 663 | # find and set an appropriate location | ||||||||||||||||||||||||||||||||||
| 664 | # | ||||||||||||||||||||||||||||||||||
| 665 | #else { | ||||||||||||||||||||||||||||||||||
| 666 | #require File::Temp; | ||||||||||||||||||||||||||||||||||
| 667 | #$cache_dn=&File::Temp::tempdir( CLEANUP=> 1 ); | ||||||||||||||||||||||||||||||||||
| 668 | #} | ||||||||||||||||||||||||||||||||||
| 669 | #elsif ($prefix) { | ||||||||||||||||||||||||||||||||||
| 670 | # $cache_dn=File::Spec->catdir($prefix, 'cache'); | ||||||||||||||||||||||||||||||||||
| 671 | #} | ||||||||||||||||||||||||||||||||||
| 672 | #elsif ($^O=~/MSWin[32|64]/) { | ||||||||||||||||||||||||||||||||||
| 673 | # $cache_dn=File::Spec->catdir($ENV{'SYSTEMROOT'}, qw(TEMP webdyne)) | ||||||||||||||||||||||||||||||||||
| 674 | #} | ||||||||||||||||||||||||||||||||||
| 675 | #else { | ||||||||||||||||||||||||||||||||||
| 676 | # $cache_dn=File::Spec->catdir( | ||||||||||||||||||||||||||||||||||
| 677 | # File::Spec->rootdir(), qw(var cache webdyne)); | ||||||||||||||||||||||||||||||||||
| 678 | #} | ||||||||||||||||||||||||||||||||||
| 679 | 62 | return $cache_dn | |||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||
| 684 | 0 | ▶ | sub hashref { | ||||||||||||||||||||||||||||||||
|
Subroutine
hashref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||
| 686 | 0 | my $class=shift(); | |||||||||||||||||||||||||||||||||
| 687 | 0 | return \%{"${class}::Constant"}; | |||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||
| 689 | } | ||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||
| 693 | 358 | ▶ | sub local_constant_load { | ||||||||||||||||||||||||||||||||
|
Subroutine
local_constant_load: called CC=9 SCAR=24.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||
| 696 | # Load constants from override files. | ||||||||||||||||||||||||||||||||||
| 697 | # | ||||||||||||||||||||||||||||||||||
| 698 | 358 | my ($class, $local_constant_fn)=@_; | |||||||||||||||||||||||||||||||||
| 699 | 358 | 0 && debug("class: $class, local_constant_fn: $local_constant_fn"); | |||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||
| 702 | # Var to hold hash ref we load | ||||||||||||||||||||||||||||||||||
| 703 | # | ||||||||||||||||||||||||||||||||||
| 704 | 358 | my $constant_hr; | |||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||
| 707 | # Now load, making sure we don't reload already loaded file - with bonus of creating | ||||||||||||||||||||||||||||||||||
| 708 | # var that tracks/shows loaded files - WEBDYNE_CONF_HR | ||||||||||||||||||||||||||||||||||
| 709 | # | ||||||||||||||||||||||||||||||||||
| 710 | 358 | 0 && debug("attempt load local_constant_fn: $local_constant_fn"); | |||||||||||||||||||||||||||||||||
| 711 | 358 | ▶ | if (-f $local_constant_fn && !$Constant{'WEBDYNE_CONF_HR'}{$local_constant_fn}++) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
-f $local_constant_fn and not $WebDyne::Constant::Constant{"WEBDYNE_CONF_HR"}{$local_constant_fn}++
MC/DC50%1/2
-f $local_constant_fn and not $WebDyne::Constant::Constant{"WEBDYNE_CONF_HR"}{$local_constant_fn}++
-f $local_constant_fn
not $WebDyne::Constant::Constant{"WEBDYNE_CONF_HR"}{$local_constant_fn}++
Truth table66%2/3
A and not(B)
A= -f $local_constant_fnB= not $WebDyne::Constant::Constant{"WEBDYNE_CONF_HR"}{$local_constant_fn}++
| |||||||||||||||||||||||||||||||||||
| 712 | #if (-f $local_constant_fn && !$Package{'file'}{$local_constant_fn}++) { | ||||||||||||||||||||||||||||||||||
| 713 | 5 | 0 && debug("file exists, about to load from: $local_constant_fn (%s)", File::Spec->rel2abs($local_constant_fn)); | |||||||||||||||||||||||||||||||||
| 714 | 5 | $Constant{'WEBDYNE_CONF_HR'}{$local_constant_fn}++; | |||||||||||||||||||||||||||||||||
| 715 | 5 | ▶ | $constant_hr=do(File::Spec->rel2abs($local_constant_fn)) || | ||||||||||||||||||||||||||||||||
|
Condition50%1/2
do 'File::Spec'->rel2abs($local_constant_fn) || warn("unable to read local constant file, $!")
MC/DC0%0/1
do 'File::Spec'->rel2abs($local_constant_fn) || warn("unable to read local constant file, $!")
do 'File::Spec'->rel2abs($local_constant_fn)
Truth table50%1/2
A
A= do 'File::Spec'->rel2abs($local_constant_fn)
| |||||||||||||||||||||||||||||||||||
| 716 | warn("unable to read local constant file, $!"); | ||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||
| 720 | # Now from environment vars - override anything in config file | ||||||||||||||||||||||||||||||||||
| 721 | # | ||||||||||||||||||||||||||||||||||
| 722 | 358 | my %constant_class=%{"${class}::Constant"}; | |||||||||||||||||||||||||||||||||
| 723 | 358 | foreach my $key (keys %constant_class) { | |||||||||||||||||||||||||||||||||
| 724 | 32230 | ▶ | if (defined $ENV{$key}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 725 | 53 | my $val=$ENV{$key}; | |||||||||||||||||||||||||||||||||
| 726 | 53 | 0 && debug("using environment value $val for key: $key"); | |||||||||||||||||||||||||||||||||
| 727 | 53 | $constant_hr->{$class}{$key}=$val; | |||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||
| 732 | # Load up Apache config - only if running under mod_perl | ||||||||||||||||||||||||||||||||||
| 733 | # | ||||||||||||||||||||||||||||||||||
| 734 | 358 | ▶ | if (my $server_or=&server_or()) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 735 | 0 | my $table_or=$server_or->dir_config(); | |||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | while (my ($key, $val)=each %{$table_or}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 737 | 0 | 0 && debug("installing value $val for Apache directive: $key"); | |||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | $constant_hr->{$class}{$key}=$val if exists $constant_class{$key} | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||
| 743 | # Done - return constant hash ref | ||||||||||||||||||||||||||||||||||
| 744 | # | ||||||||||||||||||||||||||||||||||
| 745 | 358 | return $constant_hr; | |||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||||||||
| 750 | 358 | ▶ | sub server_or { | ||||||||||||||||||||||||||||||||
|
Subroutine
server_or: called CC=6 SCAR=30.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||
| 753 | # Get the apache server object if available | ||||||||||||||||||||||||||||||||||
| 754 | # | ||||||||||||||||||||||||||||||||||
| 755 | 358 | ▶ | unless (exists($Package{'server_or'})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||
| 758 | # Var to hold any server object found | ||||||||||||||||||||||||||||||||||
| 759 | # | ||||||||||||||||||||||||||||||||||
| 760 | 62 | my $server_or; | |||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||
| 763 | # Only do checks if running under mod_perl | ||||||||||||||||||||||||||||||||||
| 764 | # | ||||||||||||||||||||||||||||||||||
| 765 | 62 | ▶ | if ($MP_version) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||
| 768 | # Ignore die's for the moment so don't get caught by error handler | ||||||||||||||||||||||||||||||||||
| 769 | # | ||||||||||||||||||||||||||||||||||
| 770 | 0 | 0 && debug("detected mod_perl version $MP_version - loading Apache directives"); | |||||||||||||||||||||||||||||||||
| 771 | 0 | local $SIG{'__DIE__'}=undef; | |||||||||||||||||||||||||||||||||
| 772 | 0 | my $server_or; | |||||||||||||||||||||||||||||||||
| 773 | 0 | eval { | |||||||||||||||||||||||||||||||||
| 774 | # Modern mod_perl 2 | ||||||||||||||||||||||||||||||||||
| 775 | 0 | require Apache2::ServerUtil; | |||||||||||||||||||||||||||||||||
| 776 | 0 | require APR::Table; | |||||||||||||||||||||||||||||||||
| 777 | 0 | $server_or=Apache2::ServerUtil->server(); | |||||||||||||||||||||||||||||||||
| 778 | }; | ||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | $@ && eval { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||
| 781 | # Interim mod_perl 1.99x | ||||||||||||||||||||||||||||||||||
| 782 | 0 | require Apache::ServerUtil; | |||||||||||||||||||||||||||||||||
| 783 | 0 | require APR::Table; | |||||||||||||||||||||||||||||||||
| 784 | 0 | $server_or=Apache::ServerUtil->server(); | |||||||||||||||||||||||||||||||||
| 785 | }; | ||||||||||||||||||||||||||||||||||
| 786 | 0 | ▶ | $@ && eval { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||
| 788 | # mod_perl 1x ? | ||||||||||||||||||||||||||||||||||
| 789 | 0 | require Apache::Table; | |||||||||||||||||||||||||||||||||
| 790 | 0 | $server_or=Apache->server(); | |||||||||||||||||||||||||||||||||
| 791 | }; | ||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||
| 793 | # Clear any eval errors, set via dir_config now (overrides env) | ||||||||||||||||||||||||||||||||||
| 794 | # | ||||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | $@ && do { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 796 | 0 | eval {undef}; errclr() | |||||||||||||||||||||||||||||||||
| 797 | }; | ||||||||||||||||||||||||||||||||||
| 798 | 0 | 0 && debug("loaded server_or: $server_or"); | |||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||
| 801 | else { | ||||||||||||||||||||||||||||||||||
| 802 | 62 | 0 && debug('skip server_or load, not running under mod_perl'); | |||||||||||||||||||||||||||||||||
| 803 | } | ||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||
| 806 | # Save away so don't have to do this again | ||||||||||||||||||||||||||||||||||
| 807 | # | ||||||||||||||||||||||||||||||||||
| 808 | 62 | $Package{'server_or'}=$server_or; | |||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||
| 813 | # Return it | ||||||||||||||||||||||||||||||||||
| 814 | # | ||||||||||||||||||||||||||||||||||
| 815 | 358 | return $Package{'server_or'}; | |||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||
| 817 | } | ||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||
| 820 | 360 | ▶ | sub import { | ||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=19 SCAR=30.1
| |||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||
| 823 | # Get caller | ||||||||||||||||||||||||||||||||||
| 824 | # | ||||||||||||||||||||||||||||||||||
| 825 | 360 | my ($class, $local_constant_fn)=@_; | |||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||
| 828 | # Check for dump flag, reserved word | ||||||||||||||||||||||||||||||||||
| 829 | # | ||||||||||||||||||||||||||||||||||
| 830 | 360 | my $dump_fg; | |||||||||||||||||||||||||||||||||
| 831 | 360 | ▶ | if (($local_constant_fn ||= '') eq 'dump') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$local_constant_fn ||= ""
MC/DC100%1/1
$local_constant_fn ||= ""
$local_constant_fn
Truth table100%2/2
A
A= $local_constant_fn
| |||||||||||||||||||||||||||||||||||
| 832 | # Dump all constants | ||||||||||||||||||||||||||||||||||
| 833 | 0 | $dump_fg++; | |||||||||||||||||||||||||||||||||
| 834 | 0 | $local_constant_fn=undef; | |||||||||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||||||||
| 836 | ▶ | elsif ($dump_fg=exists($Constant{$local_constant_fn}) ? $local_constant_fn : undef) { | |||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 837 | # Dump one constant value | ||||||||||||||||||||||||||||||||||
| 838 | # | ||||||||||||||||||||||||||||||||||
| 839 | 0 | $local_constant_fn=undef; | |||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||
| 844 | # Get array of local files also | ||||||||||||||||||||||||||||||||||
| 845 | # | ||||||||||||||||||||||||||||||||||
| 846 | 360 | my $local_constant_fn_ar=&local_constant_fn(); | |||||||||||||||||||||||||||||||||
| 847 | 360 | 0 && debug("local_constant_fn_ar: %s", Dumper($local_constant_fn_ar)); | |||||||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||
| 850 | # Load files if neccessary, get hash of constants to be applied | ||||||||||||||||||||||||||||||||||
| 851 | # | ||||||||||||||||||||||||||||||||||
| 852 | 360 | my @class_constant_hr; | |||||||||||||||||||||||||||||||||
| 853 | 360 | foreach my $fn (grep {$_} (@{$local_constant_fn_ar}, $local_constant_fn)) { | |||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||
| 856 | # Don't process twice | ||||||||||||||||||||||||||||||||||
| 857 | # | ||||||||||||||||||||||||||||||||||
| 858 | 587 | ▶ | my $fn_hr=$Package{'import'}{$fn} ||= do { | ||||||||||||||||||||||||||||||||
|
Condition100%3/3
$WebDyne::Constant::Package{"import"}{$fn} ||= do {
'???';
&local_constant_load($class, $fn)
}
MC/DC100%2/2
$WebDyne::Constant::Package{"import"}{$fn} ||= do {
'???';
&local_constant_load($class, $fn)
}
$WebDyne::Constant::Package{"import"}{$fn}
do {
'???';
&local_constant_load($class, $fn)
}
Truth table100%3/3
A ||= B
A= $WebDyne::Constant::Package{"import"}{$fn}B= do {
'???';
&local_constant_load($class, $fn)
}
| |||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||
| 860 | # Need to load in file, haven't seen it yet/ | ||||||||||||||||||||||||||||||||||
| 861 | # | ||||||||||||||||||||||||||||||||||
| 862 | 358 | 0 && debug("loading file: $fn"); | |||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||
| 865 | # If here need to read hash ref in from file | ||||||||||||||||||||||||||||||||||
| 866 | # | ||||||||||||||||||||||||||||||||||
| 867 | 358 | &local_constant_load($class, $fn); | |||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||
| 869 | }; | ||||||||||||||||||||||||||||||||||
| 870 | 587 | 0 && debug("local_constant_load hr: $fn_hr, %s", Dumper($fn_hr)); | |||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||
| 873 | # Any constants for this class into array for loading | ||||||||||||||||||||||||||||||||||
| 874 | # | ||||||||||||||||||||||||||||||||||
| 875 | 587 | ▶ | if (my $class_constant_hr=$fn_hr->{$class}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||
| 878 | # Yes, save for later processing | ||||||||||||||||||||||||||||||||||
| 879 | # | ||||||||||||||||||||||||||||||||||
| 880 | 213 | 0 && debug("adding class_constant_hr: $class_constant_hr for processing, %s", Dumper($class_constant_hr)); | |||||||||||||||||||||||||||||||||
| 881 | 213 | push @class_constant_hr, $class_constant_hr; | |||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||
| 884 | else { | ||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||
| 886 | 374 | 0 && debug("skip $fn, no class: $class component in hash ref"); | |||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||
| 893 | # Debug what we have | ||||||||||||||||||||||||||||||||||
| 894 | # | ||||||||||||||||||||||||||||||||||
| 895 | 360 | 0 && debug('class_constant_hr: %s', Dumper(\@class_constant_hr)); | |||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||
| 898 | # Get hash ref of Constants file from class calling us - calling | ||||||||||||||||||||||||||||||||||
| 899 | # module needs to declare a %Class:Name::Constant variable in | ||||||||||||||||||||||||||||||||||
| 900 | # global space. | ||||||||||||||||||||||||||||||||||
| 901 | # | ||||||||||||||||||||||||||||||||||
| 902 | 360 | my $class_constant_hr=\%{"${class}::Constant"}; | |||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||
| 905 | # We want to load variable into namespace. Get the parent class and who is | ||||||||||||||||||||||||||||||||||
| 906 | # calling us/ | ||||||||||||||||||||||||||||||||||
| 907 | # | ||||||||||||||||||||||||||||||||||
| 908 | 360 | (my $class_parent=$class)=~s/::Constant$//; | |||||||||||||||||||||||||||||||||
| 909 | 360 | my $caller = caller(0); | |||||||||||||||||||||||||||||||||
| 910 | 360 | 0 && debug("caller: $caller"); | |||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||
| 913 | # Remember caller | ||||||||||||||||||||||||||||||||||
| 914 | # | ||||||||||||||||||||||||||||||||||
| 915 | 360 | $Package{'caller'}{$class}{$caller}++; | |||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||
| 918 | # Now start iterating over and loading | ||||||||||||||||||||||||||||||||||
| 919 | # | ||||||||||||||||||||||||||||||||||
| 920 | 360 | foreach $caller (keys %{$Package{'caller'}{$class}}) { | |||||||||||||||||||||||||||||||||
| 921 | 1258 | foreach my $constant_hr ($class_constant_hr, @class_constant_hr) { | |||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||
| 924 | # Now iterate across all callers and load vars into namespace. Turn off warnings as | ||||||||||||||||||||||||||||||||||
| 925 | # we may have to redefine some variables | ||||||||||||||||||||||||||||||||||
| 926 | # | ||||||||||||||||||||||||||||||||||
| 927 | 62 | ▶ | no warnings qw(once redefine); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 928 | 2122 | 0 && debug("importing for caller: $caller"); | |||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||
| 931 | # Don't load hash ref into caller if already done. This probably needs to be reworked .. | ||||||||||||||||||||||||||||||||||
| 932 | # | ||||||||||||||||||||||||||||||||||
| 933 | 2122 | if (0 && (my $var_test= (keys(%{$constant_hr}))[0])) { | |||||||||||||||||||||||||||||||||
| 934 | 0 && debug("picking var: $var_test as test, exists *{${caller}::${var_test}}: %s", defined(*{"${caller}::${var_test}"})); | ||||||||||||||||||||||||||||||||||
| 935 | if ($Package{'caller'}{$caller}{$constant_hr}++ && defined(*{"${caller}::${var_test}"})) { | ||||||||||||||||||||||||||||||||||
| 936 | 0 && debug("skip, already applied $constant_hr to caller: $caller"); | ||||||||||||||||||||||||||||||||||
| 937 | #next; | ||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||
| 939 | else { | ||||||||||||||||||||||||||||||||||
| 940 | 0 && debug('continue'); | ||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||
| 943 | else { | ||||||||||||||||||||||||||||||||||
| 944 | 2122 | 0 && debug('no test var found in constant_hr: %s', Dumper($constant_hr)); | |||||||||||||||||||||||||||||||||
| 945 | } | ||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||
| 948 | # Start iterating over all constants in class | ||||||||||||||||||||||||||||||||||
| 949 | # | ||||||||||||||||||||||||||||||||||
| 950 | 2122 | ▶ | while (my($k, $v)=each %{$class_constant_hr}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||
| 952 | # Override ? | ||||||||||||||||||||||||||||||||||
| 953 | # | ||||||||||||||||||||||||||||||||||
| 954 | #if (defined($constant_hr->{$k}) && ($constant_hr ne $class_constant_hr)) { | ||||||||||||||||||||||||||||||||||
| 955 | 208417 | ▶ | if (defined($constant_hr->{$k}) && ($constant_hr->{$k} ne $class_constant_hr->{$k})) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $constant_hr->{$k} and $constant_hr->{$k} ne $class_constant_hr->{$k}
MC/DC100%2/2
defined $constant_hr->{$k} and $constant_hr->{$k} ne $class_constant_hr->{$k}
defined $constant_hr->{$k}
$constant_hr->{$k} ne $class_constant_hr->{$k}
Truth table100%3/3
A and B
A= defined $constant_hr->{$k}B= $constant_hr->{$k} ne $class_constant_hr->{$k}
| |||||||||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||||||||
| 957 | # Yes | ||||||||||||||||||||||||||||||||||
| 958 | # | ||||||||||||||||||||||||||||||||||
| 959 | 38 | 0 && debug('override constant_hr: %s value: %s with file value: %s', $k, $v, $constant_hr->{$k}); | |||||||||||||||||||||||||||||||||
| 960 | 38 | $v=$class_constant_hr->{$k}=$constant_hr->{$k}; | |||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||||||||
| 963 | 208417 | 0 && debug("caller: $caller, class: $class set: $k=%s", defined($v) ? $v : q[]); | |||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||
| 966 | # Used to do just | ||||||||||||||||||||||||||||||||||
| 967 | # | ||||||||||||||||||||||||||||||||||
| 968 | # *{"${caller}::${k}"}=\$v; | ||||||||||||||||||||||||||||||||||
| 969 | # | ||||||||||||||||||||||||||||||||||
| 970 | # Make a bit more sophisticated so if the | ||||||||||||||||||||||||||||||||||
| 971 | # var is updated anywhere it is used all | ||||||||||||||||||||||||||||||||||
| 972 | # modules see + put a hash called Constant in | ||||||||||||||||||||||||||||||||||
| 973 | # the parent module so we don't have to do | ||||||||||||||||||||||||||||||||||
| 974 | # | ||||||||||||||||||||||||||||||||||
| 975 | # %WebDyne::Constant::Constant | ||||||||||||||||||||||||||||||||||
| 976 | # | ||||||||||||||||||||||||||||||||||
| 977 | # now just | ||||||||||||||||||||||||||||||||||
| 978 | # | ||||||||||||||||||||||||||||||||||
| 979 | # %WebDyne::Constant | ||||||||||||||||||||||||||||||||||
| 980 | # | ||||||||||||||||||||||||||||||||||
| 981 | 208417 | ▶ | if ($caller eq $class_parent) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 982 | 35499 | *{"${caller}::${k}"}=\$v; | |||||||||||||||||||||||||||||||||
| 983 | #*{"${caller}::Constant"}=$hr; # Pulled for moment, bit polluting without ability to ref constant scalars in hash values | ||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||
| 985 | else { | ||||||||||||||||||||||||||||||||||
| 986 | 172918 | ▶ | if (defined *{"${class_parent}::${k}"}) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 987 | 140800 | *{"${caller}::${k}"} = *{"${class_parent}::${k}"}; | |||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||
| 989 | else { | ||||||||||||||||||||||||||||||||||
| 990 | 32118 | *{"${caller}::${k}"} = \$v; | |||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||
| 992 | # Used to be this | ||||||||||||||||||||||||||||||||||
| 993 | #*{"${caller}::${k}"}=\${"${class_parent}::${k}"}; | ||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||
| 995 | #debug("caller: $caller, set:$k value:$v"); | ||||||||||||||||||||||||||||||||||
| 996 | #next if ref($v); # Not needed, stop Regexp conversion | ||||||||||||||||||||||||||||||||||
| 997 | 208417 | my $sub_body; | |||||||||||||||||||||||||||||||||
| 998 | 208417 | ▶ | if ($v=~/^\d+$/) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 999 | #debug("using sub() ${caller}::${k}=$v"); | ||||||||||||||||||||||||||||||||||
| 1000 | 130341 | $sub_body=$v; | |||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||
| 1002 | else { | ||||||||||||||||||||||||||||||||||
| 1003 | #debug("fall through, using sub() ${caller}::${k}=q($v)"); | ||||||||||||||||||||||||||||||||||
| 1004 | 78076 | $sub_body="q($v)"; | |||||||||||||||||||||||||||||||||
| 1005 | } | ||||||||||||||||||||||||||||||||||
| 1006 | |||||||||||||||||||||||||||||||||||
| 1007 | # Perl 5.14 and earlier warn unconditionally when a foldable | ||||||||||||||||||||||||||||||||||
| 1008 | # constant sub is redefined. Keep foldable constants on newer | ||||||||||||||||||||||||||||||||||
| 1009 | # Perl, but use perlsub's documented non-inlined form there. | ||||||||||||||||||||||||||||||||||
| 1010 | # | ||||||||||||||||||||||||||||||||||
| 1011 | 208417 | ▶ | *{"${caller}::${k}"}=eval( | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1012 | ($] < 5.016) | ||||||||||||||||||||||||||||||||||
| 1013 | ? "sub () { $sub_body if \$] }" | ||||||||||||||||||||||||||||||||||
| 1014 | : "sub () { $sub_body }" | ||||||||||||||||||||||||||||||||||
| 1015 | ); | ||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||
| 1022 | # Check if just dumping for view, or actually loading into caller | ||||||||||||||||||||||||||||||||||
| 1023 | # namespace | ||||||||||||||||||||||||||||||||||
| 1024 | # | ||||||||||||||||||||||||||||||||||
| 1025 | 360 | ▶ | if ($dump_fg) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||
| 1027 | # We just to want to see what they are | ||||||||||||||||||||||||||||||||||
| 1028 | # | ||||||||||||||||||||||||||||||||||
| 1029 | 0 | local $Data::Dumper::Indent=1; | |||||||||||||||||||||||||||||||||
| 1030 | 0 | local $Data::Dumper::Terse=1; | |||||||||||||||||||||||||||||||||
| 1031 | 0 | local $Data::Dumper::Sortkeys=1; | |||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | CORE::print exists($Constant{$dump_fg}) ? Dumper($class_constant_hr->{$dump_fg}) : Dumper($class_constant_hr); | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 1033 | 0 | exit 0; | |||||||||||||||||||||||||||||||||
| 1034 | } | ||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||
| 1036 | } | ||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||
| 1039 | 62 | 1; | |||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||||||||
| 1042 | __END__ | ||||||||||||||||||||||||||||||||||