From 1c70fceb70a9fef59c9f96c345aef3110ded2963 Mon Sep 17 00:00:00 2001 From: Digimer Date: Thu, 27 Dec 2018 01:14:09 -0400 Subject: [PATCH] * Fixed a minor bug in Template->get() where a bad template name being passed would call Words->string() without proper arguments and generate error messages. * Fixed a bad template name in main.html. Signed-off-by: Digimer --- Anvil/Tools/Template.pm | 15 ++++++++++----- Anvil/Tools/Words.pm | 6 +++--- cgi-bin/striker | 29 +++++++++++++++-------------- html/skins/alteeve/main.html | 10 +++++----- 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/Anvil/Tools/Template.pm b/Anvil/Tools/Template.pm index e65de25c..12693105 100755 --- a/Anvil/Tools/Template.pm +++ b/Anvil/Tools/Template.pm @@ -227,12 +227,17 @@ sub get } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }}); + # Insert variables if I found something. # Now that I have the skin, inject my variables. We'll use Words->string() to do this for us. - $template = $anvil->Words->string({ - debug => $debug, - string => $template, - variables => $variables, - }); + if (($template_found) && ($template)) + { + $template = $anvil->Words->string({ + debug => $debug, + string => $template, + variables => $variables, + }); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { template => $template }}); + } # If we failed to read the template, then load an error message. $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { diff --git a/Anvil/Tools/Words.pm b/Anvil/Tools/Words.pm index 37ad9264..93db5c28 100755 --- a/Anvil/Tools/Words.pm +++ b/Anvil/Tools/Words.pm @@ -207,7 +207,7 @@ sub key } } - if ($string eq "#!not_found!#") + if ($string eq "#!not_found!") { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => "[ Error ] - Failed to find the string key: [".$key."]!!"}); } @@ -480,7 +480,7 @@ Parameters; This is the specific file to read the string from. It should generally not be needed as string keys should not be reused. However, if it happens, this is a way to specify which file's version you want. -=head3 key (required) +=head3 key (optional, required without 'string' set) This is the key to return the string for. @@ -492,7 +492,7 @@ This is the ISO code for the language you wish to read the string from. For exam When no language is passed, 'C<< defaults::languages::output >>' is used. -=head3 string (optional) +=head3 string (optional, required if no 'key') If this is passed, it is treated as a raw string that needs variables inserted. When this is used, the 'C<< key >>' parameter is ignored. diff --git a/cgi-bin/striker b/cgi-bin/striker index 7cb309dd..15f7ade6 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -1045,7 +1045,7 @@ sub configure_striker { # Sanity check step1. my $sane = sanity_check_step1($anvil); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sane => $sane }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { sane => $sane }}); if ($sane) { # Step 1 was sane, show step 2. @@ -1061,7 +1061,7 @@ sub configure_striker { # Sanity check step1. my $sane = sanity_check_step2($anvil); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { sane => $sane }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { sane => $sane }}); if ($sane) { # Step 2 was sane, show step 3. @@ -1087,7 +1087,7 @@ sub configure_striker job_description => "job_0002", job_progress => 0, }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { job_uuid => $job_uuid }}); # Set maintenance mode. $anvil->System->maintenance_mode({set => 1}); @@ -1700,7 +1700,6 @@ ORDER BY class => $dns_class, extra => "", }}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { say_dns => $say_dns }}); # Which interface gets the route? my $default_dg_iface = defined $anvil->data->{cgi}{dg_iface}{value} ? $anvil->data->{cgi}{dg_iface}{value} : "ifn_link1"; @@ -1711,14 +1710,16 @@ ORDER BY selected => $default_dg_iface, class => $anvil->data->{cgi}{dg_iface}{alert} ? "input_alert" : "input_clear", }); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { dg_iface_select => $dg_iface_select }}); - my $dg_iface_class = $anvil->data->{cgi}{dg_iface}{alert} ? "input_alert" : "input_clear"; - my $say_dg_iface = $anvil->Template->get({debug => 1, file => "main.html", name => "input_select_form", variables => { - field => "#!string!striker_0039!#", - description => "#!string!striker_0040!#", - 'select' => "", - }}); + ### NOTE: I'll likely want this for choosing which interface to use as the default gateway when 2+ + ### IFNs are used. +# my $dg_iface_class = $anvil->data->{cgi}{dg_iface}{alert} ? "input_alert" : "input_clear"; +# my $say_dg_iface = $anvil->Template->get({file => "main.html", name => "input_select_form", variables => { +# field => "#!string!striker_0039!#", +# description => "#!string!striker_0040!#", +# 'select' => "", +# }}); +# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { say_dg_iface => $say_dg_iface }}); # Hostname my $say_default_hostname = $anvil->data->{cgi}{prefix}{value}."-striker0".$anvil->data->{cgi}{sequence}{value}.".".$anvil->data->{cgi}{domain}{value}; @@ -2557,7 +2558,7 @@ sub get_network_details speed => $data->{interface}{$interface}{speed}, 'state' => $data->{interface}{$interface}{'state'}, }; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "interfaces::${interface}::bond" => $anvil->data->{interfaces}{$interface}{bond}, "interfaces::${interface}::bridge" => $anvil->data->{interfaces}{$interface}{bridge}, "interfaces::${interface}::duplex" => $anvil->data->{interfaces}{$interface}{duplex}, @@ -2610,7 +2611,7 @@ sub get_network_details { foreach my $address (sort {$a cmp $b} keys %{$data->{ip}}) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { address => $address }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { address => $address }}); $anvil->data->{ip}{$address} = { on => $data->{ip}{$address}{on}, subnet => $data->{ip}{$address}{subnet}, @@ -2618,7 +2619,7 @@ sub get_network_details default_gateway => $data->{ip}{$address}{default_gateway}, dns => $data->{ip}{$address}{dns}, }; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "ip::${address}::on" => $anvil->data->{ip}{$address}{on}, "ip::${address}::subnet" => $anvil->data->{ip}{$address}{subnet}, "ip::${address}::gateway" => $anvil->data->{ip}{$address}{gateway}, diff --git a/html/skins/alteeve/main.html b/html/skins/alteeve/main.html index 73ec92d6..a28dcbd8 100644 --- a/html/skins/alteeve/main.html +++ b/html/skins/alteeve/main.html @@ -118,6 +118,11 @@ + + #!variable!description!#
+ #!variable!options!# + + #!variable!description!#
@@ -194,11 +199,6 @@ - - #!variable!description!#
- #!variable!options!# - -