From a76ffda562cbfd8fb5ae83efd584f83403fb2123 Mon Sep 17 00:00:00 2001 From: Will Budic Date: Tue, 6 Jun 2023 06:23:57 +1000 Subject: [PATCH] Header response settings fixed for lighttpd. --- htdocs/{ => cgi-bin}/favicon.ico | Bin .../modules/HTMLIndexProcessorPlugin.pm | 34 +++++++++++------- .../cgi-bin/system/modules/MarkdownPlugin.pm | 1 + lighttpd.conf | 12 ++++--- 4 files changed, 29 insertions(+), 18 deletions(-) rename htdocs/{ => cgi-bin}/favicon.ico (100%) diff --git a/htdocs/favicon.ico b/htdocs/cgi-bin/favicon.ico similarity index 100% rename from htdocs/favicon.ico rename to htdocs/cgi-bin/favicon.ico diff --git a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm index 96c90dd..cc86a2b 100644 --- a/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm +++ b/htdocs/cgi-bin/system/modules/HTMLIndexProcessorPlugin.pm @@ -2,6 +2,7 @@ package HTMLIndexProcessorPlugin; use strict; use warnings; +no warnings qw(experimental::signatures); use Syntax::Keyword::Try; use Exception::Class ('HTMLIndexProcessorPluginException'); use feature qw(signatures); @@ -32,24 +33,31 @@ 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_doc = $cgi-> param('doc'); my $tree = $parser-> anon($property); die "Tree property '$property' is not available!" if(!$tree or ref($tree) ne 'CNFNode'); try{ - if ($cgi_action and $cgi_action eq 'load'){ - $buffer = $cgi->header(expires => "+0s", -charset => "UTF-8"); - $buffer .= $cgi->start_html(); - $buffer .= ${loadDocument($parser, $cgi_doc)} - }else{ - if (exists $parser->{'HTTP_HEADER'}){ - $buffer .= $parser-> {'HTTP_HEADER'}; - }else{ - if(exists $parser -> collections()->{'%HTTP_HEADER'}){ - my %http_hdr = $parser -> collection('%HTTP_HEADER'); - $buffer = $cgi->header(%http_hdr); - } + + + if (exists $parser->{'HTTP_HEADER'}){ + $buffer .= $parser-> {'HTTP_HEADER'}; + }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($load){ + $buffer .= $$load if $load; + }else{ + $buffer .= "Document is empty: $cgi_doc\n" + } + }else{ $title = $tree -> {'Title'} if exists $tree->{'Title'}; $link = $tree -> {'HEADER'}; $body_attrs = $tree -> {'Body'} if exists $tree -> {'Body'}; diff --git a/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm b/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm index f1da337..b196eff 100644 --- a/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm +++ b/htdocs/cgi-bin/system/modules/MarkdownPlugin.pm @@ -2,6 +2,7 @@ package MarkdownPlugin; use strict; use warnings; +no warnings qw(experimental::signatures); use Syntax::Keyword::Try; use Exception::Class ('MarkdownPluginException'); use feature qw(signatures); diff --git a/lighttpd.conf b/lighttpd.conf index a9ee492..1ecdd2a 100644 --- a/lighttpd.conf +++ b/lighttpd.conf @@ -1,13 +1,15 @@ server.document-root = "/home/will/dev/LifeLog/htdocs/cgi-bin" - +dir-listing.activate = "enable" server.port = 80 mimetype.assign = ( ".html" => "text/html", + ".md" => "text/plain", ".txt" => "text/plain", ".jpg" => "image/jpeg", ".gif" => "image/gif", ".png" => "image/png", + ".ico" => "image/ico", ".svg" => "image/svg+xml", ".css" => "text/css", ".js" => "text/javascript" @@ -29,21 +31,21 @@ server.modules = ( index-file.names = ( "index.html" ) -server.breakagelog = "/home/will/dev/LifeLog/dbLifeLog/lighttpd_server.log" -cgi.assign = ( ".pl" => "/usr/local/bin/perl", ".cgi" => "/usr/local/bin/perl" ) +server.breakagelog = "/home/will/dev/LifeLog/lighttpd_server.log" +cgi.assign = ( ".pl" => "/usr/bin/perl", ".cgi" => "/usr/bin/perl" ) cgi.x-sendfile = "disable" $SERVER["socket"] == ":443" { # -#ssl.engine = "disable" +ssl.engine = "enable" ## Selfsigned SSL Certificate location created with openssl req -x509 -newkey rsa:4096 -sha256 ...etc... #https://www.interserver.net/tips/kb/how-to-configure-ssl-in-lighttpd/ ssl.pemfile = "/home/will/dev/nomad.pem" server.name = "nomad.net" - } # Create soft link in cgi-bin: to desired static pages directory. # with i.e: ln -s /home/will/dev/LifeLog/htdocs/ static $HTTP["url"] =~ "^/static($|/)" { server.dir-listing = "enable" } +$HTTP["url"] =~ "^docs($|/)" { server.dir-listing = "enable" } \ No newline at end of file -- 2.34.1