Finally crack the routing problem - html entities not allowed in mojo routing

This commit is contained in:
Brian Read 2024-11-13 16:45:14 +00:00
parent ece4f2f6f5
commit 1a78388e95
8 changed files with 68 additions and 61 deletions

View File

@ -6,10 +6,10 @@
# and provison of the control data for table(s) # and provison of the control data for table(s)
# #
use esmith::util; use esmith::util;
use esmith::ConfigDB;
use esmith::HostsDB; use esmith::HostsDB;
use esmith::AccountsDB; use esmith::AccountsDB;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB; use esmith::DomainsDB;
#use Net::SSLeay; #use Net::SSLeay;
@ -81,14 +81,14 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my %ret = ( my %ret = (
'Data1'=>'Data for PARAMS', #Example 'Data1'=>'Data for PARAMS', #Example
# fields from Inputs in PARAMS $fields['PARAMS'] # fields from Inputs in PARAMS $fields['PARAMS']
'status'=>get_prop('letsencrypt', 'status', 'disabled', 'status'=>$cdb->get_prop('letsencrypt', 'status', 'disabled'),
'hookScript'=>get_prop('letsencrypt', 'hookScript', 'disabled'), 'hookScript'=>$cdb->get_prop('letsencrypt', 'hookScript', 'disabled'),
'hostOverride'=>get_prop('letsencrypt', 'hostOverride', 'disabled'), 'hostOverride'=>$cdb->get_prop('letsencrypt', 'hostOverride', 'disabled'),
'ACCEPT_TERMS'=>get_prop('letsencrypt', 'ACCEPT_TERMS', ''), 'ACCEPT_TERMS'=>$cdb->get_prop('letsencrypt', 'ACCEPT_TERMS', ''),
'API'=>get_prop('letsencrypt', 'API', '2'), 'API'=>$cdb->get_prop('letsencrypt', 'API', '2'),
'keysize'=>get_prop('letsencrypt', 'keysize', '4096'), 'keysize'=>$cdb->get_prop('letsencrypt', 'keysize', '4096'),
'configure'=>get_prop('letsencrypt', 'configure', 'none' ), 'configure'=>$cdb->get_prop('letsencrypt', 'configure', 'none' ),
'Email'=>get_prop('letsencrypt', 'email') 'Email'=>$cdb->get_prop('letsencrypt', 'email')
); );
return %ret; return %ret;
} }
@ -159,7 +159,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
# } # }
my @data = (); my @data = ();
my $check = $c->l('CHECK'); my $check = $c->l('Check Domain');
for ($ddb->domains) for ($ddb->domains)
{ {
@ -167,7 +167,9 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $le = $_->prop('letsencryptSSLcert') || 'disabled';#letsencrypt configure all my $le = $_->prop('letsencryptSSLcert') || 'disabled';#letsencrypt configure all
my $dname= $_->key; my $dname= $_->key;
my $isincert = "N"; my $isincert = "N";
my $check = $c->l('lets_CHECK'); my $link = $c->create_link("letsencryptd","CHECKONEDOMAIN","");
my $checklink = "<a href='".$link."&dom=".$_->key."'>".$check."</a>";
#my $checklink = "<a href=''>check</a>";
$isincert = "Y" if ( $dname ~~ @list); $isincert = "Y" if ( $dname ~~ @list);
# domain # domain
push @data, push @data,
@ -175,7 +177,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
$_->props, $_->props,
letsencryptSSLcert => $le, letsencryptSSLcert => $le,
isincert => $isincert, isincert => $isincert,
Check => $check, Check => $checklink,
Nameservers => $ns, Nameservers => $ns,
}; };
#and hosts #and hosts
@ -192,7 +194,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
Description=>$h->prop('ExternalIP')|| $h->prop('InternalIP')||"", Description=>$h->prop('ExternalIP')|| $h->prop('InternalIP')||"",
Content => $h->prop('HostType'), Content => $h->prop('HostType'),
isincert => $isincert, isincert => $isincert,
Check => $check, Check => "", #$checklink
Nameservers => $c->l($ns), Nameservers => $c->l($ns),
} }
} }
@ -284,7 +286,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
sub create_link{ sub create_link{
# WIP # WIP
my ($c,$route, $panel, $index) = shift; my ($c,$route, $panel, $index) = @_;
my $link = "$route?trt=$panel&Selected=$index"; my $link = "$route?trt=$panel&Selected=$index";
return $link; return $link;
} }

View File

@ -1,6 +1,6 @@
package SrvMngr::Controller::Letsencrypt; package SrvMngr::Controller::Letsencrypt;
# #
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-06 11:09:38 # Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-13 16:29:07
# #
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# heading : Network # heading : Network
@ -35,7 +35,7 @@ use SrvMngr qw(theme_list init_session);
use Data::Dumper; use Data::Dumper;
use esmith::util; use esmith::util;
use esmith::HostsDB; use esmith::ConfigDB;
use esmith::AccountsDB; use esmith::AccountsDB;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::HostsDB; use esmith::HostsDB;
@ -70,7 +70,7 @@ sub main {
my $title = $c->l('lets_Letsencrypt_certificate'); my $title = $c->l('lets_Letsencrypt_certificate');
my $modul = ''; my $modul = '';
$lets_data{'trt'} = 'CHECKALLDOMAINS'; $lets_data{'trt'} = 'LIST';
#Load any DB entries into the <prefix>_data area so as they are preset in the form #Load any DB entries into the <prefix>_data area so as they are preset in the form
# which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE # which DB - this only really works if the initial panel is a PARAMS type panel and not a TABLE
@ -80,7 +80,7 @@ sub main {
#pickup any other contents needed and load them into hash shared with panel #pickup any other contents needed and load them into hash shared with panel
my %returned_hash; my %returned_hash;
# subroutine returns a hash directly # subroutine returns a hash directly
%returned_hash = get_data_for_panel_CHECKALLDOMAINS(); %returned_hash = get_data_for_panel_LIST();
# Copy each key-value pair from the returned hash to the prefix data hash # Copy each key-value pair from the returned hash to the prefix data hash
while (my ($key, $value) = each %returned_hash) { while (my ($key, $value) = each %returned_hash) {
$lets_data{$key} = $value; $lets_data{$key} = $value;
@ -138,12 +138,12 @@ sub do_update {
my $num_params = keys %params; my $num_params = keys %params;
#Params are available in the hash "params" - copy to the prefix_data hash #Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) { #while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$lets_data{$key} = $value; # $lets_data{$key} = $value;
} #}
# the value of trt will tell you which panel has returned # the value of trt will tell you which panel has returned
my $trt = $c->param('trt') || 'CHECKALLDOMAINS'; #hidden control on every form. my $trt = $c->param('trt') || 'LIST'; #hidden control on every form.
my $ret = 'ok'; my $ret = 'ok';
#Validate the parameters in a custom sub one for each panel (although only one of these will be executed) #Validate the parameters in a custom sub one for each panel (although only one of these will be executed)
@ -173,10 +173,10 @@ sub do_update {
$thispanel = 'CHECKALLENABLEDDOMAINS'; $thispanel = 'CHECKALLENABLEDDOMAINS';
} }
if ($trt eq 'CHECKONEDDOMAINS'){ if ($trt eq 'CHECKONEDDOMAIN'){
#Validate form parameters for panel CHECKONEDDOMAINS #Validate form parameters for panel CHECKONEDDOMAIN
$ret = $c->validate_CHECKONEDDOMAINS(\%lets_data); $ret = $c->validate_CHECKONEDDOMAIN(\%lets_data);
$thispanel = 'CHECKONEDDOMAINS'; $thispanel = 'CHECKONEDDOMAIN';
} }
@ -235,15 +235,15 @@ sub do_update {
} }
} }
if ($trt eq 'CHECKONEDDOMAINS'){ if ($trt eq 'CHECKONEDDOMAIN'){
#do whatever is required ... #do whatever is required ...
$ret = $c->perform_CHECKONEDDOMAINS(\%lets_data); $ret = $c->perform_CHECKONEDDOMAIN(\%lets_data);
if ($ret ne "ok") { if ($ret ne "ok") {
# return to the panel with error message # return to the panel with error message
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->render("letsencrypt"); $c->render("letsencrypt");
} else { } else {
$c->stash( success => $c->l('lets_CHECKONEDDOMAINS_panel_action_was_successful')); #A bit bland - edit it in the lex file $c->stash( success => $c->l('lets_CHECKONEDDOMAIN_panel_action_was_successful')); #A bit bland - edit it in the lex file
} }
} }
@ -256,7 +256,7 @@ sub do_update {
lets_data => \%lets_data lets_data => \%lets_data
); );
if ('none' eq 'none') { if ('none' eq 'none') {
$lets_data{'trt'} = 'CHECKALLDOMAINS'; $lets_data{'trt'} = 'LIST';
} else { } else {
$lets_data{'trt'} = 'none'; $lets_data{'trt'} = 'none';
} }
@ -292,12 +292,12 @@ sub do_display {
my $is_new_record = ($c->req->method() eq 'POST'); my $is_new_record = ($c->req->method() eq 'POST');
#Params are available in the hash "params" - copy to the prefix_data hash #Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) { #while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$lets_data{$key} = $value; # $lets_data{$key} = $value;
} #}
# the value of trt will tell you which panel has returned # the value of trt will tell you which panel has returned
my $trt = $c->param('trt') || 'CHECKALLDOMAINS'; #Indicates where to go now my $trt = $c->param('trt') || 'LIST'; #Indicates where to go now
# Now add in the params from the selected row from the table # Now add in the params from the selected row from the table
@ -323,9 +323,9 @@ sub do_display {
%selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'},$is_new_record); %selectedrow = $c->get_selected_CHECKALLENABLEDDOMAINS($lets_data{'Selected'},$is_new_record);
} }
if ($trt eq 'CHECKONEDDOMAINS'){ if ($trt eq 'CHECKONEDDOMAIN'){
#Validate form parameters for panel CHECKONEDDOMAINS #Validate form parameters for panel CHECKONEDDOMAIN
%selectedrow = $c->get_selected_CHECKONEDDOMAINS($lets_data{'Selected'},$is_new_record); %selectedrow = $c->get_selected_CHECKONEDDOMAIN($lets_data{'Selected'},$is_new_record);
} }
@ -382,11 +382,11 @@ sub do_display {
} }
} }
if ($trt eq 'CHECKONEDDOMAINS'){ if ($trt eq 'CHECKONEDDOMAIN'){
# pickup any other contents needed and load them into hash shared with panel # pickup any other contents needed and load them into hash shared with panel
my %returned_hash; my %returned_hash;
# subroutine returns a hash directly # subroutine returns a hash directly
%returned_hash = get_data_for_panel_CHECKONEDDOMAINS(); %returned_hash = get_data_for_panel_CHECKONEDDOMAIN();
# Copy each key-value pair from the returned hash to the prefix data hash # Copy each key-value pair from the returned hash to the prefix data hash
while (my ($key, $value) = each %returned_hash) { while (my ($key, $value) = each %returned_hash) {
$lets_data{$key} = $value; $lets_data{$key} = $value;

View File

@ -1,7 +1,7 @@
%# %#
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-06 10:28:31 %# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-13 16:37:25
%# %#
<div id="Letsencrypt-CHECKONEDDOMAINS" class="partial Letsencrypt-CHECKONEDDOMAINS"> <div id="Letsencrypt-CHECKONEDOMAIN" class="partial Letsencrypt-CHECKONEDOMAIN">
<script> <script>
window.onload = function() { window.onload = function() {
SelectInput(); SelectInput();
@ -25,15 +25,15 @@
<p><span class=label> <p><span class=label>
%=l('lets_Domains_name') %=l('lets_Domains_name')
</span><span class=data> </span><span class=data>
% param 'OneDomainsToCheck' => $lets_data->{OneDomainsToCheck} unless param 'OneDomainsToCheck'; % param 'OneDomainToCheck' => $lets_data->{OneDomainToCheck} unless param 'OneDomainToCheck';
%= text_field 'OneDomainsToCheck', size => '50', class => 'textinput OneDomainsToCheck' , pattern=>'.*' , placeholder=>'OneDomainsToCheck', Readonly=>'true' %= text_field 'OneDomainToCheck', size => '50', class => 'textinput OneDomainToCheck' , pattern=>'.*' , placeholder=>'OneDomainToCheck', Readonly=>'true'
<br></span></p> <br></span></p>
<span class=label> <span class=label>
%=l('lets_Enabled_domains_check_result') %=l('lets_One_domain_check_result')
</span><span class=data> </span><span class=data>
% param 'EnabledDomainsCheck' => $lets_data->{EnabledDomainsCheck} unless param 'EnabledDomainsCheck'; % param 'OneDomainsCheck' => $lets_data->{OneDomainsCheck} unless param 'OneDomainsCheck';
%= text_area 'EnabledDomainsCheck', cols=>40, rows=>10, Readonly=>'true' %= text_area 'OneDomainsCheck', cols=>40, rows=>10, Readonly=>'true'
</span><br> </span><br>
<span class='data'> <span class='data'>

View File

@ -21,6 +21,7 @@
<div class="inline-buttons"> <div class="inline-buttons">
%= link_to l('lets_CONFIG'), 'letsencryptd?trt=PARAMS' , class=>'link link2' %= link_to l('lets_CONFIG'), 'letsencryptd?trt=PARAMS' , class=>'link link2'
<a href="letsencryptd?trt=PARAMS" class=link link2><%= l('lets_CONFIG') %></a>
%= link_to l('lets_CHECK_ALL_DOMAINS'), 'letsencryptd?trt=CHECKALLDOMAINS' , class=>'link link3' %= link_to l('lets_CHECK_ALL_DOMAINS'), 'letsencryptd?trt=CHECKALLDOMAINS' , class=>'link link3'
%= link_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencryptd?trt=CHECKALLENABLEDDOMAINS' , class=>'link link4' %= link_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencryptd?trt=CHECKALLENABLEDDOMAINS' , class=>'link link4'
</div> </div>

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33 %# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-13 16:40:01
%# %#
% layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './'; % layout 'default', title => "Sme server 2 - Letsencrypt certificate", share_dir => './';
%# css specific to this panel: %# css specific to this panel:
@ -58,6 +58,10 @@
%= include 'partials/_lets_CHECKALLENABLEDDOMAINS' %= include 'partials/_lets_CHECKALLENABLEDDOMAINS'
%} %}
% if ($lets_data->{trt} eq "CHECKONEDOMAIN") {
%= include 'partials/_lets_CHECKONEDOMAIN'
%}
</div> </div>

View File

@ -35,7 +35,7 @@ use SrvMngr qw(theme_list init_session);
use Data::Dumper; use Data::Dumper;
use esmith::util; use esmith::util;
use esmith::HostsDB; use esmith::ConfigDB;
use esmith::AccountsDB; use esmith::AccountsDB;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::HostsDB; use esmith::HostsDB;
@ -140,9 +140,9 @@ sub do_update {
my $num_params = keys %params; my $num_params = keys %params;
#Params are available in the hash "params" - copy to the prefix_data hash #Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) { #while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$$${prefix}_data{$key} = $value; # $$${prefix}_data{$key} = $value;
} #}
# the value of trt will tell you which panel has returned # the value of trt will tell you which panel has returned
my $trt = $c->param('trt') || '${firstPanel}'; #hidden control on every form. my $trt = $c->param('trt') || '${firstPanel}'; #hidden control on every form.
@ -222,9 +222,9 @@ sub do_display {
my $is_new_record = ($c->req->method() eq 'POST'); my $is_new_record = ($c->req->method() eq 'POST');
#Params are available in the hash "params" - copy to the prefix_data hash #Params are available in the hash "params" - copy to the prefix_data hash
while (my ($key, $value) = each %{$c->req->params->to_hash}) { #while (my ($key, $value) = each %{$c->req->params->to_hash}) {
$$${prefix}_data{$key} = $value; # $$${prefix}_data{$key} = $value;
} #}
# the value of trt will tell you which panel has returned # the value of trt will tell you which panel has returned
my $trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now my $trt = $c->param('trt') || '${firstPanel}'; #Indicates where to go now

View File

@ -6,10 +6,10 @@
# and provison of the control data for table(s) # and provison of the control data for table(s)
# #
use esmith::util; use esmith::util;
use esmith::ConfigDB;
use esmith::HostsDB; use esmith::HostsDB;
use esmith::AccountsDB; use esmith::AccountsDB;
use esmith::NetworksDB; use esmith::NetworksDB;
use esmith::HostsDB;
use esmith::DomainsDB; use esmith::DomainsDB;

View File

@ -7,7 +7,7 @@
'MenuHeading': 'Network', 'MenuHeading': 'Network',
'MenuDescription': 'Letsencrypt certificate', 'MenuDescription': 'Letsencrypt certificate',
'MenuNavigation': '6000 6600', 'MenuNavigation': '6000 6600',
'firstPanel': 'CHECKALLDOMAINS', 'firstPanel': 'LIST',
'signalEvent': 'smeserver-letsencrypt-update', 'signalEvent': 'smeserver-letsencrypt-update',
'html': [ 'html': [
{ {
@ -15,17 +15,17 @@
'route': 'LIST', 'route': 'LIST',
'Link2': { 'Link2': {
'Type': 'Link', 'Type': 'Link',
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE', 'href': 'letsencryptd?trt=PARAMS',
'title': 'CONFIG' 'title': 'CONFIG'
}, },
'Link3': { 'Link3': {
'Type': 'Link', 'Type': 'Link',
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE', 'href': 'letsencryptd?trt=CHECKALLDOMAINS',
'title': 'CHECK_ALL_DOMAINS' 'title': 'CHECK_ALL_DOMAINS'
}, },
'Link4': { 'Link4': {
'Type': 'Link', 'Type': 'Link',
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE', 'href': 'letsencryptd?trt=CHECKENABLEDDOMAINS',
'title': 'CHECK_ENABLED_DOMAINS' 'title': 'CHECK_ENABLED_DOMAINS'
}, },
SubHeader2: 'IPs for this Server', SubHeader2: 'IPs for this Server',
@ -271,8 +271,8 @@
'Value': 'Back', 'Value': 'Back',
} }
}, },
{ 'Name':'CheckOneDomains', { 'Name':'CheckOneDomain',
'route':'CHECKONEDDOMAINS', 'route':'CHECKONEDOMAIN',
'Header': 'Check just one domain', 'Header': 'Check just one domain',
'SubHeader': 'Loop through checking the letsencrypt status for a specific domain', 'SubHeader': 'Loop through checking the letsencrypt status for a specific domain',
'Input1': { 'Input1': {