From 45e0d269f66077174fe1e7bc8f3470d5c4140244 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Mon, 2 Oct 2023 19:35:33 +1100 Subject: [PATCH] imp %WEBAPP_SETTINGS --- htdocs/cgi-bin/index.cnf | 8 +++- .../modules/HTMLIndexProcessorPlugin.pm | 37 ++++++++++++++++++- htdocs/cgi-bin/wsrc/main.css | 11 +++--- htdocs/cgi-bin/wsrc/main_earth.css | 5 +-- htdocs/cgi-bin/wsrc/main_moon.css | 7 ++-- htdocs/cgi-bin/wsrc/main_sun.css | 9 ++--- 6 files changed, 58 insertions(+), 19 deletions(-) diff --git a/htdocs/cgi-bin/index.cnf b/htdocs/cgi-bin/index.cnf index acf16ab..a181e45 100644 --- a/htdocs/cgi-bin/index.cnf +++ b/htdocs/cgi-bin/index.cnf @@ -1,4 +1,10 @@ -!CNF2.8 +!CNF3.0 + +<<@<%WEBAPP_SETTINGS> + $LOG_PATH = ../../dbLifeLog/ + //We are reading only the css property, old way is the following hash, preserved as reminder. + $THEME = css => wsrc/main.css, colBG => #c8fff8, colSHDW => #9baec8 +>> <<@<%HTTP_HEADER> -charset = "UTF8" diff --git a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm index 909f273..f92cc76 100644 --- a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm +++ b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm @@ -34,6 +34,37 @@ sub convert ($self, $parser, $property) { my $tree = $parser-> anon($property); die "Tree property '$property' is not available!" if(!$tree or ref($tree) ne 'CNFNode'); try{ + #TODO 20231002 Move -> %WEBAPP_SETTINGS into utility. + my %THEME; + my %wsettings = $parser -> collection('%WEBAPP_SETTINGS'); + if(%wsettings){ + my $theme = $wsettings{THEME}; + my @els = split(/, /, $theme); + foreach (@els) { + my ($key,$val) = split(/\s*=>\s*/, $_); + $THEME{$key} = $val; + last if $key eq 'css' + } + my $theme_file = $wsettings{LOG_PATH}.'current_theme'; + $theme_file =~ /^\.\.\/\.\.\// if(-e $theme_file); + if(-e $theme_file){ + open my $fh, '<', $theme_file; + my $theme = <$fh>; + close($fh); + if($theme =~ m/standard/i){ + $THEME{css} = "wsrc/main.css" + }elsif($theme =~ m/moon/i){ + $THEME{css} = "wsrc/main_moon.css" + } + elsif($theme =~ m/sun/i){ + $THEME{css} = "wsrc/main_sun.css" + } + elsif($theme =~ m/earth/i){ + $THEME{css} = "wsrc/main_earth.css" + } + } + } + if (exists $parser->{'HTTP_HEADER'}){ $buffer .= $parser-> {'HTTP_HEADER'}; }else{ @@ -61,7 +92,11 @@ try{ if(ref($link) eq 'CNFNode'){ my $arr = $link->find('CSS/@@'); foreach (@$arr){ - push @hhshCSS, {-type => 'text/css', -src => $_->val()}; + if($THEME{css} && $_->val() =~ /main.css$/){ + push @hhshCSS, {-type => 'text/css', -src => $THEME{css}}; + }else{ + push @hhshCSS, {-type => 'text/css', -src => $_->val()}; + } } $arr = $link->find('JS/@@'); foreach (@$arr){ diff --git a/htdocs/cgi-bin/wsrc/main.css b/htdocs/cgi-bin/wsrc/main.css index fc00ad0..d87efa8 100644 --- a/htdocs/cgi-bin/wsrc/main.css +++ b/htdocs/cgi-bin/wsrc/main.css @@ -1,15 +1,16 @@ body{ font-family: Segoe UI,Helvetica,Bookman,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji; + font-size: 14px; margin: 0; padding:0; -} -.content { background-image: url('images/page-bck-std.png'); background-repeat: no-repeat; background-attachment: fixed; - margin: 0; - padding:0; - height: 100vh; + background-size: cover; +} +.content { + margin: 0; + padding:0; } p { font-family: Bookman; diff --git a/htdocs/cgi-bin/wsrc/main_earth.css b/htdocs/cgi-bin/wsrc/main_earth.css index 8c3a4a6..c976a5b 100644 --- a/htdocs/cgi-bin/wsrc/main_earth.css +++ b/htdocs/cgi-bin/wsrc/main_earth.css @@ -3,14 +3,13 @@ body{ font-size: 14px; margin: 0; padding:0; -} -.content { background-image: url('images/page-bck-earth.png'); background-repeat: no-repeat; background-attachment: fixed; +} +.content { margin: 0; padding:0; - height: 100vh; } p { font-family: Bookman; diff --git a/htdocs/cgi-bin/wsrc/main_moon.css b/htdocs/cgi-bin/wsrc/main_moon.css index 7815392..dc59314 100644 --- a/htdocs/cgi-bin/wsrc/main_moon.css +++ b/htdocs/cgi-bin/wsrc/main_moon.css @@ -1,17 +1,16 @@ body{ font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Bookman,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji; font-size: 14px; - background-image: url('images/page-bck-moon.png'); margin: 0; padding:0; -} -.content{ background-image: url('images/page-bck-moon.png'); background-repeat: no-repeat; background-attachment: fixed; + background-size: cover; +} +.content{ margin: 0; padding:0; - height: 100vh; } p { font-family: Bookman; diff --git a/htdocs/cgi-bin/wsrc/main_sun.css b/htdocs/cgi-bin/wsrc/main_sun.css index 8899bcb..26ffd56 100644 --- a/htdocs/cgi-bin/wsrc/main_sun.css +++ b/htdocs/cgi-bin/wsrc/main_sun.css @@ -4,17 +4,16 @@ body{ background-color: #FFD700; margin: 0; padding:0; -} -.content { - background-image: url('images/page-bck-sun.png'); background-repeat: no-repeat; background-attachment: fixed; + background-size: cover; +} +.content { margin: 0; padding:0; - height: 100vh; - } + p { font-family: Bookman; margin-left: 70px; -- 2.34.1