* Updated Log->entry() to escape the finished string just prior to calling logger.

* Updated Template->get() to set the skin directory more cleanly.
* Updated Words->string() to check for a string with #!variable!x!# replacement keys and the 'variables' parameter wasn't passed and throws a useful error are returns '#!error!#'.
* Added top-right icons (see sources.txt for attributions).
* Created a new shared.html template file for shared templates, and added a template for the HTML header.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 8 years ago
parent e983f27de7
commit f948d7a762
  1. 5
      AN/Tools/Log.pm
  2. 17
      AN/Tools/Template.pm
  3. 21
      AN/Tools/Words.pm
  4. 1
      AN/an-tools.xml
  5. 22
      cgi-bin/home
  6. BIN
      html/skins/alteeve/images/anvil_icon.png
  7. BIN
      html/skins/alteeve/images/help_icon.png
  8. 15
      html/skins/alteeve/images/sources.txt
  9. BIN
      html/skins/alteeve/images/striker_icon.png
  10. BIN
      html/skins/alteeve/images/users_icon.png
  11. BIN
      html/skins/alteeve/images/users_icon_2.png
  12. 14
      html/skins/alteeve/main.css
  13. 36
      html/skins/alteeve/main.html
  14. 3
      html/skins/alteeve/main.js
  15. 10
      html/skins/alteeve/shared.html

@ -286,11 +286,14 @@ sub entry
key => $key, key => $key,
variables => $variables, variables => $variables,
}); });
$message =~ s/"/\\\"/gs;
#print $THIS_FILE." ".__LINE__."; [ Debug ] - message: [$message]\n"; #print $THIS_FILE." ".__LINE__."; [ Debug ] - message: [$message]\n";
$string .= $message; $string .= $message;
} }
# Clean up the string for bash
$string =~ s/"/\\\"/gs;
$string =~ s/\(/\\\(/gs;
# NOTE: This might become too expensive, in which case we may need to create a connection to journald # NOTE: This might become too expensive, in which case we may need to create a connection to journald
# that we can leave open during a run. # that we can leave open during a run.
my $shell_call = $an->data->{path}{exe}{logger}." --id --tag ".$tag." --priority ".$priority_string; my $shell_call = $an->data->{path}{exe}{logger}." --id --tag ".$tag." --priority ".$priority_string;

@ -112,8 +112,9 @@ sub get
my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $file = defined $parameter->{file} ? $parameter->{file} : "";
my $language = defined $parameter->{language} ? $parameter->{language} : $an->Words->language; my $language = defined $parameter->{language} ? $parameter->{language} : $an->Words->language;
my $name = defined $parameter->{name} ? $parameter->{name} : ""; my $name = defined $parameter->{name} ? $parameter->{name} : "";
my $skin = defined $parameter->{skin} ? $parameter->{skin} : ""; my $skin = defined $parameter->{skin} ? $parameter->{skin} : $an->Template->skin;
my $variables = defined $parameter->{variables} ? $parameter->{variables} : ""; my $variables = defined $parameter->{variables} ? $parameter->{variables} : "";
$skin = $an->data->{path}{directories}{skins}."/".$skin;
my $template = ""; my $template = "";
my $source = ""; my $source = "";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
@ -123,18 +124,6 @@ sub get
skin => $skin, skin => $skin,
}}); }});
# If the user passed the skin, prepend the skins directory. Otherwise use the active skin.
if (not $skin)
{
$skin = $an->data->{path}{directories}{skins}."/".$an->Template->skin;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { skin => $skin }});
}
else
{
$skin = $an->data->{path}{directories}{skins}."/".$skin;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { skin => $skin }});
}
my $error = 0; my $error = 0;
if (not $file) if (not $file)
{ {
@ -199,7 +188,7 @@ sub get
} }
} }
close $file_handle; close $file_handle;
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { source => $source }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { template => $template }});
# Now that I have the skin, inject my variables. We'll use Words->string() to do this for us. # Now that I have the skin, inject my variables. We'll use Words->string() to do this for us.
$template = $an->Words->string({ $template = $an->Words->string({

@ -412,6 +412,22 @@ sub string
my $loops = 0; my $loops = 0;
my $limit = $an->data->{defaults}{limits}{string_loops} =~ /^\d+$/ ? $an->data->{defaults}{limits}{string_loops} : 1000; my $limit = $an->data->{defaults}{limits}{string_loops} =~ /^\d+$/ ? $an->data->{defaults}{limits}{string_loops} : 1000;
# If the user didn't pass in any variables, then we're in trouble.
if (($string =~ /#!variable!(.+?)!#/s) && ((not $variables) or (ref($variables) ne "HASH")))
{
# Escape the variables before the sending the error
while ($string =~ /#!variable!(.+?)!#/s)
{
$string =~ s/#!variable!(.*?)!#/!!variable!$1!!/s;
# Die if I've looped too many times.
$loops++;
die "$THIS_FILE ".__LINE__."; Infinite loop detected while processing the string: [".$string."] from the key: [$key] in language: [$language], exiting.\n" if $loops > $limit;
}
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0042", variables => { string => $string }});
return("#!error!#");
}
# We set the 'loop' variable to '1' and check it at the end of each pass. This is done # We set the 'loop' variable to '1' and check it at the end of each pass. This is done
# because we might inject a string near the end that adds a replacement key to an # because we might inject a string near the end that adds a replacement key to an
# otherwise-processed string and we don't want to miss that. # otherwise-processed string and we don't want to miss that.
@ -472,6 +488,11 @@ sub string
$string =~ s/#!variable!\*!#/!#variable!*#!/; $string =~ s/#!variable!\*!#/!#variable!*#!/;
next; next;
} }
if ($variable eq "")
{
$string =~ s/#!variable!\*!#/!#variable!#!/;
next;
}
if (not defined $variables->{$variable}) if (not defined $variables->{$variable})
{ {

@ -61,6 +61,7 @@ It also has replacement variables: [#!variable!first!#] and [#!variable!second!#
<key name="log_0039"><![CDATA[[ Error ] - The module Storage->change_owner() was called without a 'target' parameter, or the parameter was empty.]]></key> <key name="log_0039"><![CDATA[[ Error ] - The module Storage->change_owner() was called without a 'target' parameter, or the parameter was empty.]]></key>
<key name="log_0040"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it already exists and 'overwrite' was not set. Aborting.]]></key> <key name="log_0040"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it already exists and 'overwrite' was not set. Aborting.]]></key>
<key name="log_0041"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it is not a full path. Aborting.]]></key> <key name="log_0041"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it is not a full path. Aborting.]]></key>
<key name="log_0042"><![CDATA[[ Error ] - The module Words->string() was asked to process the string: [#!variable!string!#] which has insertion variables, but nothing was passed to the 'variables' parameter.]]></key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. --> <!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<key name="t_0000">Test</key> <key name="t_0000">Test</key>

@ -12,10 +12,11 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
$running_directory =~ s/^\./$ENV{PWD}/; $running_directory =~ s/^\./$ENV{PWD}/;
} }
print "Content-type: text/html; charset=utf-8\n\n";
my $an = AN::Tools->new(); my $an = AN::Tools->new();
# Print the html headers, with a new line to break the header from the body.
print $an->Template->get({file => "shared.html", name => "http_headers"})."\n";
# Set the log level to 2 # Set the log level to 2
$an->Log->level(2); $an->Log->level(2);
@ -25,19 +26,20 @@ $an->Words->read({file => $an->data->{path}{directories}{'cgi-bin'}."/words.xml"
# Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete. # Turn off buffering so that the pinwheel will display while waiting for the SSH call(s) to complete.
$| = 1; $| = 1;
my $header = $an->Template->get({file => "main.html", name => "header", variables => { $an->data->{skin}{url} = $an->data->{path}{urls}{skins}."/".$an->Template->skin;
language => $an->Words->language, my $header = $an->Template->get({file => "main.html", name => "header", variables => { language => $an->Words->language }});
skin_url => $an->data->{path}{urls}{skins}."/".$an->Template->skin,
}});
my $footer = $an->Template->get({file => "main.html", name => "footer"});
my $network = get_network_details($an); my $network = get_network_details($an);
my $buttons = $an->Template->get({file => "main.html", name => "button_bar"});
my $footer = $an->Template->get({file => "main.html", name => "footer"});
# Display the page.
my $template = $an->Template->get({file => "main.html", name => "master", variables => { my $template = $an->Template->get({file => "main.html", name => "master", variables => {
header => $header, header => $header,
skin_url => $an->data->{path}{urls}{skins}."/".$an->Template->skin, skin_url => $an->data->{path}{urls}{skins}."/".$an->Template->skin,
left_top_bar => "&nbsp;", left_top_bar => "&nbsp;",
center_top_bar => "$network", center_top_bar => "&nbsp;",
right_top_bar => "&nbsp;", right_top_bar => "$buttons",
center_body => "&nbsp;", center_body => "$network",
left_bottom_bar => "&nbsp;", left_bottom_bar => "&nbsp;",
center_bottom_bar => "&nbsp;", center_bottom_bar => "&nbsp;",
right_bottom_bar => "&nbsp;", right_bottom_bar => "&nbsp;",

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

@ -1,3 +1,18 @@
From the gnome project; From the gnome project;
- network-wired-connected.png - network-wired-connected.png
- network-wired-disconnected.png - network-wired-disconnected.png
Anvil by Christopher T. Howlett from the Noun Project (https://thenounproject.com/term/anvil/90190/)
- anvil_icon.png
Anvil and Hammer by Ivana Milchanska from the Noun Project (https://thenounproject.com/term/anvil/226943/)
- striker_icon.png
Users by Edgar Vargas, US from the Noun Project (https://thenounproject.com/term/user/13635/)
- users_icon.png
User by Wilson Joseph from the Noun Project (https://thenounproject.com/term/user/43761/)
- users_icon_2.png
Question by Travis Avery from the Noun Project (https://thenounproject.com/term/question/587291/)
- help_icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@ -19,7 +19,7 @@ body {
.body_table { .body_table {
width: 90%; width: 90%;
border: 0.1em solid blue; /* border: 0.1em solid blue; */
margin: auto; margin: auto;
top: 0; top: 0;
position: absolute; position: absolute;
@ -31,12 +31,22 @@ table {
border-collapse: collapse; border-collapse: collapse;
} }
td { td {
border: 1px solid green; /* border: 1px solid green; */
padding: 0; padding: 0;
border-collapse: collapse; border-collapse: collapse;
} }
.logo { .logo {
border-top: 0.3em solid transparent;
border-left: 0.3em solid transparent;
border-right: 0.3em solid transparent;
height: 2.5em;
}
.top_icon {
border-top: 0.3em solid transparent;
border-left: 0.3em solid transparent;
border-right: 0.3em solid transparent;
height: 2.5em; height: 2.5em;
} }

@ -1,5 +1,21 @@
<!-- start button_bar --> <!-- start button_bar -->
<!--end button_bar --> <table id="button_bar">
<tr>
<td>
<img src="#!data!skin::url!#/images/striker_icon.png" class="logo">
</td>
<td>
<img src="#!data!skin::url!#/images/anvil_icon.png" class="top_icon">
</td>
<td>
<img src="#!data!skin::url!#/images/users_icon.png" class="top_icon">
</td>
<td>
<img src="#!data!skin::url!#/images/help_icon.png" class="top_icon">
</td>
</tr>
</table>
<!-- end button_bar -->
<!-- start footer --> <!-- start footer -->
<div onload="show_status()" class="footer"> <div onload="show_status()" class="footer">
@ -20,9 +36,9 @@
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" /> <title>#!string!brand_0001!# - #!string!brand_0003!#</title> <meta http-equiv="pragma" content="no-cache" /> <title>#!string!brand_0001!# - #!string!brand_0003!#</title>
<link rel="stylesheet" href="#!variable!skin_url!#/main.css" media="screen" /> <link rel="stylesheet" href="#!data!skin::url!#/main.css" media="screen" />
<script type="text/javascript" src="/jquery-latest.js"></script> <script type="text/javascript" src="/jquery-latest.js"></script>
<script type="text/javascript" src="#!variable!skin_url!#/main.js"></script> <script type="text/javascript" src="#!data!skin::url!#/main.js"></script>
</head> </head>
<!-- end header --> <!-- end header -->
@ -31,19 +47,19 @@
<body> <body>
<table class="body_table"> <table class="body_table">
<tr> <!-- <tr>
<td class="header" colspan="3"> <td class="header" colspan="3">
<img src="#!variable!skin_url!#/images/logo.png" class="logo"> <img src="#!data!skin::url!#/images/logo.png" class="logo">
</td> </td>
</tr> </tr>-->
<tr> <tr>
<td> <td class="header" width="5%">
#!variable!left_top_bar!# <img src="#!data!skin::url!#/images/logo.png" class="logo">
</td> </td>
<td> <td class="header" width="90%">
#!variable!center_top_bar!# #!variable!center_top_bar!#
</td> </td>
<td> <td class="header" width="5%" style="white-space: nowrap;">
#!variable!right_top_bar!# #!variable!right_top_bar!#
</td> </td>
</tr> </tr>

@ -1,3 +1,6 @@
// $.ajaxSetup({
// cache: false
// });
$(function() { $(function() {
var say_up = $('#network_link_state').data('up'); var say_up = $('#network_link_state').data('up');
var say_down = $('#network_link_state').data('down'); var say_down = $('#network_link_state').data('down');

@ -0,0 +1,10 @@
<!-- start http_headers -->
Content-type: text/html; charset=utf-8
<!-- end http_headers -->
<!-- start http_headers-no-cache -->
Content-type: text/html; charset=utf-8
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
<!-- end http_headers-no-cache -->
Loading…
Cancel
Save