From 6870aff511fd6570ab5537c8de4bb7955aed8809 Mon Sep 17 00:00:00 2001
From: Brian Read
Date: Tue, 5 Nov 2024 18:31:24 +0000
Subject: [PATCH] Update custom generation for select, checkbox, textare, and
expand Xml templates for other input types
---
Targets/Letsencrypt/Letsencrypt-Custom.pm | 18 ++++++++
Targets/Letsencrypt/_lets_LIST.html.ep | 2 +-
Templates/html_controls.html.ep.xml | 42 ++++++++++++------
Templates/partial.html.ep.tem | 3 ++
html/letsencrypt-list.html | 5 ++-
json5/Letsencrypt.json5 | 9 ++--
sm2gen.py | 54 +++++++++++------------
7 files changed, 87 insertions(+), 46 deletions(-)
diff --git a/Targets/Letsencrypt/Letsencrypt-Custom.pm b/Targets/Letsencrypt/Letsencrypt-Custom.pm
index cfdad6e..854dcfa 100644
--- a/Targets/Letsencrypt/Letsencrypt-Custom.pm
+++ b/Targets/Letsencrypt/Letsencrypt-Custom.pm
@@ -82,6 +82,20 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
'Data1'=>'Data for PARAMS', #Example
# fields from Inputs in PARAMS $fields['PARAMS']
+ 'status'=>'status contents',
+
+ 'hookScript'=>'hookScript contents',
+
+ 'hostOverride'=>'hostOverride contents',
+
+ 'ACCEPT_TERMS'=>'ACCEPT_TERMS contents',
+
+ 'API'=>'API contents',
+
+ 'keysize'=>'keysize contents',
+
+ 'configure'=>'configure contents',
+
);
return %ret;
@@ -94,6 +108,8 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
'Data1'=>'Data for CHECKALLDOMAINS', #Example
# fields from Inputs in CHECKALLDOMAINS $fields['CHECKALLDOMAINS']
+ 'AllDomainsCheck'=>'AllDomainsCheck contents',
+
);
return %ret;
@@ -106,6 +122,8 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
'Data1'=>'Data for CHECKALLENABLEDDOMAINS', #Example
# fields from Inputs in CHECKALLENABLEDDOMAINS $fields['CHECKALLENABLEDDOMAINS']
+ 'EnabledDomainsCheck'=>'EnabledDomainsCheck contents',
+
);
return %ret;
diff --git a/Targets/Letsencrypt/_lets_LIST.html.ep b/Targets/Letsencrypt/_lets_LIST.html.ep
index c964c76..efd2da6 100644
--- a/Targets/Letsencrypt/_lets_LIST.html.ep
+++ b/Targets/Letsencrypt/_lets_LIST.html.ep
@@ -8,7 +8,7 @@
};
- %= dumper $lets_data
+ %# dumper $lets_data
%# dumper $c->stash('DomainList')
% my $btn = l('lets_APPLY');
diff --git a/Templates/html_controls.html.ep.xml b/Templates/html_controls.html.ep.xml
index bee5512..926f949 100644
--- a/Templates/html_controls.html.ep.xml
+++ b/Templates/html_controls.html.ep.xml
@@ -80,7 +80,8 @@
%=l('${prefix}_${Label}')
%=Search field
- %=search_field , class => 'searc${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=search_field '${Name}' , class => 'searc${type_serial}'
span>
]]>
@@ -89,7 +90,8 @@
%=l('${Label}')
- %=URL_field , class => 'url${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=URL_field '${Name}' , class => 'url${type_serial}'
span>
]]>
@@ -98,7 +100,8 @@
%=l('${Label}')
- %=tel_field, class => 'tel${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=tel_field '${Name}', class => 'tel${type_serial}'
span>
]]>
@@ -107,7 +110,8 @@
%=l('${Label}')
- %=email_field, class => 'emai${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=email_field '${Name}', class => 'emai${type_serial}'
span>
]]>
@@ -116,7 +120,8 @@
%=l('${Label}')
- %=password_field, class => 'pass${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=password_field '${Name}', class => 'pass${type_serial}'
span>
]]>
@@ -125,7 +130,8 @@
%=l('${Label}')
- %=timedate_field, class => 'time${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=timedate_field '${Name}', class => 'time${type_serial}'
span>
]]>
@@ -134,7 +140,8 @@
%=l('${Label}')
- %=week_field, class => 'week${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=week_field '${Name}', class => 'week${type_serial}'
span>
]]>
@@ -143,7 +150,8 @@
%=l('${Label}')
- %=month_field, class => 'mont${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=month_field '${Name}', class => 'mont${type_serial}'
span>
]]>
@@ -152,7 +160,8 @@
%=l('${Label}')
- %=range_field, class => 'rang${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=range_field '${Name}', class => 'rang${type_serial}'
span>
]]>
@@ -161,7 +170,8 @@
%=l('${Label}')
- %=radio_field, class => 'radi${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=radio_field '${Name}', class => 'radi${type_serial}'
span>
]]>
@@ -170,7 +180,8 @@
%=l('${Label}')
- %=number_field, class => 'numb${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=number_field '${Name}', class => 'numb${type_serial}'
span>
]]>
@@ -179,7 +190,8 @@
%=l('${Label}')
- %=file_field, class => 'file${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=file_field '${Name}', class => 'file${type_serial}'
span>
]]>
@@ -188,7 +200,8 @@
%=l('${Label}')
- %=color_field, class => 'colo${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=color_field '${Name}', class => 'colo${type_serial}'
span>
]]>
@@ -197,7 +210,8 @@
%=l('${Label}')
- %=checkbox_field, class => 'chec${type_serial}'
+ % param '${Name}' => $$${prefix}_data->{${Name}} unless param '${Name}';
+ %=checkbox_field '${Name}', class => 'chec${type_serial}'
span>
]]>
diff --git a/Templates/partial.html.ep.tem b/Templates/partial.html.ep.tem
index 5f9d3ea..4c0b13b 100644
--- a/Templates/partial.html.ep.tem
+++ b/Templates/partial.html.ep.tem
@@ -7,6 +7,9 @@
SelectInput();
};
+
+%= dumper $$${prefix}_data
+
% my $btn = l('APPLY');
%= form_for "${PackageName}d" => (method => 'POST') => begin
diff --git a/html/letsencrypt-list.html b/html/letsencrypt-list.html
index f91d794..13bb04f 100644
--- a/html/letsencrypt-list.html
+++ b/html/letsencrypt-list.html
@@ -33,7 +33,10 @@
href="letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE">CHECK_ALL_DOMAINS
CHECK_ENABLED_DOMAINS
- > Issuer: /C=--/ST=----/L=Ottawa/O=XYZ Corporation/OU=Main/CN=sme11.thereadclan.me.uk/emailAddress=admin@thereadclan.me.uk
Expiry: 2025-10-03T02:09:03Z
Not Before: 2024-10-03T02:09:03Z
>
+
+ > Issuer: /C=--/ST=----/L=Ottawa/O=XYZ Corporation/OU=Main/CN=sme11.thereadclan.me.uk/emailAddress=admin@thereadclan.me.uk
+
Expiry: 2025-10-03T02:09:03Z
+
Not Before: 2024-10-03T02:09:03Z
>
CURRENT_LIST_OF_DOMAINS
diff --git a/json5/Letsencrypt.json5 b/json5/Letsencrypt.json5
index d1873d0..192fb47 100644
--- a/json5/Letsencrypt.json5
+++ b/json5/Letsencrypt.json5
@@ -7,7 +7,7 @@
'MenuHeading': 'Network',
'MenuDescription': 'Letsencrypt certificate',
'MenuNavigation': '6000 6600',
- 'firstPanel': 'LIST',
+ 'firstPanel': 'PARAMS',
'signalEvent': 'smeserver-letsencrypt-update',
'html': [
{
@@ -96,7 +96,6 @@
{
'Name': 'params',
'route': 'PARAMS',
- 'Header': 'Configuration for Letsencrypt',
'SubHeader': 'Manage letsencrypt-config settings:',
'Paragraph1': 'CONFIG_LETSENCRYPT',
'Input1': {
@@ -234,7 +233,11 @@
'Value': 'Save',
'Name': 'Next',
'Label': null
- }
+ },
+ 'Input10': {
+ 'Type': 'Submit',
+ 'Value': 'Back',
+ }
},
{ 'Name':'CheckAllDomains',
'route':'CHECKALLDOMAINS',
diff --git a/sm2gen.py b/sm2gen.py
index 6b350c9..6648868 100644
--- a/sm2gen.py
+++ b/sm2gen.py
@@ -31,7 +31,6 @@ def example_function(**kwargs):
print(kwargs)
def spell_check_and_correct(text):
-
try:
# Initialize the spell checker
spell = SpellChecker()
@@ -441,34 +440,35 @@ def capitalize_words_if_all_caps(s):
return s
def extract_input_fields(json_data, value_type):
- result = {}
+ result = {}
+ # Pattern to identify and strip the specified value type and surrounding brackets
+ pattern = re.compile(rf"{value_type}\((.*?)\)")
- # Pattern to identify and strip the specified value type and surrounding brackets
- pattern = re.compile(rf"{value_type}\((.*?)\)")
+ # Iterate over each panel in the 'html' array
+ for panel in json_data['html']:
+ panel_name = panel['route']
+ # Initialize an empty list for each panel
+ result[panel_name] = []
- # Iterate over each panel in the 'html' array
- for panel in json_data['html']:
- panel_name = panel['route']
- # Initialize an empty list for each panel
- result[panel_name] = []
-
- # Iterate over each item in the panel
- for key, value in panel.items():
- if key.startswith('Input') and isinstance(value, dict):
- if value.get('Type').lower() in ['readonlytext', 'text']:
- input_value = value.get('Value', '')
- # Match and extract the value without the value_type and parentheses
- match = pattern.search(input_value)
- if match:
- # Extract the inner content of the matching pattern
- clean_value = match.group(1)
- # Take out any double quotes
- clean_value = clean_value.replace('"','')
- # Add the clean value to the list for the current panel
- result[panel_name].append(clean_value)
-
- # Note: Empty lists are not removed, so all panels will be present in the result
- return result
+ # Iterate over each item in the panel
+ for key, value in panel.items():
+ if key.startswith('Input') and isinstance(value, dict):
+ if value.get('Type').lower() in ['readonlytext', 'text', 'select','checkbox','textarea']:
+# input_value = value.get('Value', '')
+ input_name = value.get('Name', '')
+ print(input_name)
+ # # Match and extract the value without the value_type and parentheses
+ # match = pattern.search(input_value)
+ # if match:
+ # # Extract the inner content of the matching pattern
+ # clean_value = match.group(1)
+ # # Take out any double quotes
+ # clean_value = clean_value.replace('"','')
+ # # Add the clean value to the list for the current panel
+ # result[panel_name].append(clean_value)
+ result[panel_name].append(input_name)
+ # Note: Empty lists are not removed, so all panels will be present in the result
+ return result
if __name__ == "__main__":