From: Will Budic Date: Fri, 17 Nov 2023 08:25:05 +0000 (+1100) Subject: . X-Git-Url: https://lifelog.hopto.org/gitweb/?a=commitdiff_plain;h=849209c7c9062b4c31c94a09c9cbd814345711e2;p=LifeLog.git . --- diff --git a/.gitignore b/.gitignore index 134ba1b..7e202d5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,10 +22,9 @@ cgisess_* tags */bck/* bck_* -dbLifeLog/current_theme lighttpd.conf dump_* *.rdf tree_*.cnf vscode_local_extensions/extensions.json - +dbLifeLog/current_theme diff --git a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm index afce2c1..7fe9625 100644 --- a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm +++ b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm @@ -26,34 +26,34 @@ sub new ($class, $plugin){ ### # Process config data to contain expected fields and data. ### -sub convert ($self, $parser, $property) { +sub convert ($self, $parser, $property) { my ($buffer,$title, $link, $body_attrs, $body_on_load, $give_me); my $cgi = CGI -> new(); - my $cgi_action = $cgi-> param('action'); - my $cgi_doc = $cgi-> param('doc'); + my $cgi_action = $cgi-> param('action'); + my $cgi_doc = $cgi-> param('doc'); my $tree = $parser-> anon($property); - die "Tree property '$property' is not available!" if(!$tree or ref($tree) ne 'CNFNode'); + die "Tree property '$property' is not available!" if(!$tree or ref($tree) ne 'CNFNode'); try{ - if (exists $parser->{'HTTP_HEADER'}){ + if (exists $parser->{'HTTP_HEADER'}){ $buffer .= $parser-> {'HTTP_HEADER'}; - }else{ + }else{ if(exists $parser -> collections()->{'%HTTP_HEADER'}){ my %http_hdr = $parser -> collection('%HTTP_HEADER'); $buffer = $cgi->header(%http_hdr); } } - if ($cgi_action and $cgi_action eq 'load'){ - $buffer .= $cgi->start_html(); my - $load = loadDocument($parser, $cgi_doc); + if ($cgi_action and $cgi_action eq 'load'){ + $buffer .= $cgi->start_html(); my + $load = loadDocument($self, $parser, $cgi_doc); if($load){ - $buffer .= $$load if $load; + $buffer .= $$load if $load; }else{ $buffer .= "Document is empty: $cgi_doc\n" - } + } }else{ $title = $tree -> {'Title'} if exists $tree->{'Title'}; $link = $tree -> {'HEADER'}; @@ -64,13 +64,13 @@ try{ if($link){ if(ref($link) eq 'CNFNode'){ my $arr = $link->find('CSS/@@'); - foreach (@$arr){ - push @hhshCSS, {-type => 'text/css', -src => $_->val()}; + foreach (@$arr){ + push @hhshCSS, {-type => 'text/css', -src => $_->val()}; } $arr = $link->find('JS/@@'); - foreach (@$arr){ - push @hhshJS, {-type => 'text/javascript', -src => $_->val()}; - } + foreach (@$arr){ + push @hhshJS, {-type => 'text/javascript', -src => $_->val()}; + } $arr = $link -> find('STYLE'); if(ref($arr) eq 'ARRAY'){ foreach (@$arr){ @@ -80,24 +80,24 @@ try{ } $arr = $link -> find('SCRIPT'); if(ref($arr) eq 'ARRAY'){ - foreach (@$arr){ + foreach (@$arr){ $give_me .= "\n\n" }}else{ $give_me .= "\n\n" } - } - delete $tree -> {'HEADER'}; - } + } + delete $tree -> {'HEADER'}; + } $buffer .= $cgi->start_html( -title => $title, -onload => $body_on_load, - # -BGCOLOR => $colBG, + # -BGCOLOR => $colBG, -style => \@hhshCSS, -script => \@hhshJS, -head=>$give_me, $body_attrs ); - foreach my $node($tree->nodes()){ + foreach my $node($tree->nodes()){ $buffer .= build($parser, $node) if $node; } $buffer .= $cgi->end_html(); @@ -108,23 +108,23 @@ try{ } } # -sub loadDocument($parser, $doc) { +sub loadDocument($self, $parser, $doc) { my $slurp = do { open my $fh, '<:encoding(UTF-8)', $doc or HTMLIndexProcessorPluginException->throw("Document not avaliable: $doc"); local $/; - <$fh>; + <$fh>; }; if($doc =~/\.md$/){ - require MarkdownPlugin; - my @r = @{MarkdownPlugin->new()->parse($slurp)}; + require MarkdownPlugin; + my @r = @{MarkdownPlugin->new($self)->parse($slurp)}; return $r[0]; } - return \$slurp + return \$slurp } ### # Builds the html version out of a CNFNode. -# CNFNode with specific tags here are converted also here, +# CNFNode with specific tags here are converted also here, # those that are out of the scope for normal standard HTML tags. # i.e. HTML doesn't have row and cell tags. Neither has meta links syntax. ### @@ -138,14 +138,14 @@ sub build { $bf .= "\t"x$tabs."\n"."\t"x$tabs."
"; foreach my $n($node->nodes()){ if($n->{'_'} ne '#'){ - my $b = build($parser, $n, $tabs+1); + my $b = build($parser, $n, $tabs+1); $bf .= "$b\n" if $b; } } if($node->{'#'}){ my $v = $node->val(); $v =~ s/\n\n+/\<\/br>\n/gs; - $bf .= "\t
\n\t

\n".$v."

\n\t
\n"; + $bf .= "\t
\n\t

\n".$v."

\n\t
\n"; } $bf .= "\t
\t\n" }elsif( $name eq 'row' || $name eq 'cell' ){ @@ -156,13 +156,13 @@ sub build { $bf .= "$b\n" if $b; } } - $bf .= $node->val()."\n" if $node->{'#'}; + $bf .= $node->val()."\n" if $node->{'#'}; $bf .= "\t"x$tabs."" }elsif( $name eq 'img' ){ $bf .= "\t\t\n"; }elsif($name eq 'list_images'){ my $paths = $node->{'@@'}; - foreach my $ndp (@$paths){ + foreach my $ndp (@$paths){ my $path = $ndp -> val(); my @ext = split(',',"jpg,jpeg,png,gif"); my $exp = " ".$path."/*.". join (" ".$path."/*.", @ext); @@ -175,22 +175,22 @@ sub build { $bf .= qq(\t
); $bf .= qq(\t
$fn
\n
\n); } - } + } }elsif($name eq '!'){ return "\n"; - + }elsif($node->{'*'}){ #Links are already captured, in future this might be needed as a relink from here for dynamic stuff? my $lval = $node->{'*'}; - if($name eq 'file_list_html'){ #Special case where html links are provided. + if($name eq 'file_list_html'){ #Special case where html links are provided. foreach(split(/\n/,$lval)){ $bf .= qq( [ $_ ] |) if $_ } $bf =~ s/\|$//g; }else{ #Generic included link value. #is there property data for it? - my $prop = $parser->data()->{$node->name()}; + my $prop = $parser->data()->{$node->name()}; #if not has it been passed as an page constance? - $prop = $parser -> {$node->name()} if !$prop; + $prop = $parser -> {$node->name()} if !$prop; if ( !$prop ) { if ( $parser->{STRICT} ) { die "Not found as property link -> " . $node->name()} else { warn "Not found as property link -> " . $node->name()} @@ -209,20 +209,20 @@ sub build { } else{ my $spaced = 1; - $bf .= "\t"x$tabs."<".$node->name().placeAttributes($node).">"; - foreach my $n($node->nodes()){ - my $b = build($parser, $n,$tabs+1); - if ($b){ + $bf .= "\t"x$tabs."<".$node->name().placeAttributes($node).">"; + foreach my $n($node->nodes()){ + my $b = build($parser, $n,$tabs+1); + if ($b){ if($b =~/\n/){ $bf =~ s/\n$//gs; $bf .= "\n$b\n" }else{ - $spaced=0; - $bf .= $b; + $spaced=0; + $bf .= $b; } - } + } } - + if ($node->{'#'}){ $bf .= $node->val(); $bf .= "name().">"; @@ -247,7 +247,7 @@ sub placeAttributes { if(@$_[0] ne '#' && @$_[0] ne '_'){ if(@$_[1]){ $ret .= " ".@$_[0]."=\"".@$_[1]."\""; - }else{ + }else{ $ret .= " ".@$_[0]." "; } }