Add in spell check for lex file and more format for LIST panel
This commit is contained in:
parent
a531307464
commit
031c1414ec
@ -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-05 11:55:00
|
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# heading : Network
|
# heading : Network
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
|
<div id="Letsencrypt-CHECKALLDOMAINS" class="partial Letsencrypt-CHECKALLDOMAINS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
|
<div id="Letsencrypt-CHECKALLENABLEDDOMAINS" class="partial Letsencrypt-CHECKALLENABLEDDOMAINS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<pre>
|
<pre>
|
||||||
%= dumper $lets_data
|
%= dumper $lets_data
|
||||||
%= dumper $c->stash('DomainList')
|
%# dumper $c->stash('DomainList')
|
||||||
</pre>
|
</pre>
|
||||||
% my $btn = l('lets_APPLY');
|
% my $btn = l('lets_APPLY');
|
||||||
%= form_for "Letsencryptd" => (method => 'POST') => begin
|
%= form_for "Letsencryptd" => (method => 'POST') => begin
|
||||||
@ -18,13 +18,11 @@
|
|||||||
%= hidden_field 'trt' => $lets_data->{trt}
|
%= hidden_field 'trt' => $lets_data->{trt}
|
||||||
%# Inputs etc in here.
|
%# Inputs etc in here.
|
||||||
|
|
||||||
%= link_to l('lets_CONFIG'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE' , class=>'link link2'
|
<div class="inline-buttons">
|
||||||
|
%= button_to l('lets_CONFIG'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE' , class=>'buttonlink link2'
|
||||||
|
%= button_to l('lets_CHECK_ALL_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE' , class=>'buttonlink link3'
|
||||||
%= link_to l('lets_CHECK_ALL_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE' , class=>'link link3'
|
%= button_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE' , class=>'buttonlink link4'
|
||||||
|
</div>
|
||||||
|
|
||||||
%= link_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE' , class=>'link link4'
|
|
||||||
|
|
||||||
|
|
||||||
<h2 class='subh2'><%=l('lets_IPs_for_this_Server')%></h2>
|
<h2 class='subh2'><%=l('lets_IPs_for_this_Server')%></h2>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
%#
|
%#
|
||||||
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
|
<div id="Letsencrypt-PARAMS" class="partial Letsencrypt-PARAMS">
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
*/
|
*/
|
||||||
.Letsencrypt-panel {}
|
.Letsencrypt-panel {}
|
||||||
.name {}
|
.name {}
|
||||||
.rout {}
|
.rout {}
|
||||||
.link2 {}
|
.butt2 {}
|
||||||
.link3 {}
|
.butt3 {}
|
||||||
.link4 {}
|
.butt4 {}
|
||||||
.subh2 {}
|
.subh2 {}
|
||||||
.read4 {}
|
.read4 {}
|
||||||
.read5 {}
|
.read5 {}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
%#
|
%#
|
||||||
% 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:
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
#
|
#
|
||||||
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 11:55:00
|
# Generated by SM2Gen version: SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-11-05 13:20:33
|
||||||
#
|
#
|
||||||
'lets_IS_IN_CERT' => 'IS IN CERT',
|
|
||||||
'lets_CONFIG' => 'Config',
|
|
||||||
'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
|
||||||
'lets_IPs_for_this_Server' => 'Ips for this Server',
|
|
||||||
'lets_Not_Before' => 'Not Before',
|
|
||||||
'lets_ACCEPT_TERMS_STATUS' => 'ACCEPT TERMS STATUS',
|
|
||||||
'lets_CHECK_ALL_DOMAINS' => 'CHECK ALL DOMAINS',
|
|
||||||
'lets_CONFIG_LETSENCRYPT' => 'CONFIG LETSENCRYPT',
|
|
||||||
'lets_CONFIGUREMODE_STATUS' => 'CONFIGUREMODE STATUS',
|
|
||||||
'lets_KEYSIZE_STATUS' => 'KEYSIZE STATUS',
|
|
||||||
'lets_Internet_IP' => 'Internet IP',
|
|
||||||
'lets_Manage_letsencrypt-config_settings:' => 'Manage letsencrypt-config settings:',
|
|
||||||
'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful',
|
|
||||||
'lets_Letsencrypt_certificate' => 'Letsencrypt certificate',
|
|
||||||
'lets_HOOKSCRIPT_STATUS' => 'HOOKSCRIPT STATUS',
|
|
||||||
'lets_Expiry' => 'Expiry',
|
|
||||||
'lets_API_STATUS' => 'API STATUS',
|
|
||||||
'lets_Back' => 'Back',
|
|
||||||
'lets_Check_all_enabled_domains' => 'Check all enabled domains',
|
|
||||||
'lets_Issuer' => 'Issuer',
|
'lets_Issuer' => 'Issuer',
|
||||||
'lets_LABEL_POINT' => 'LABEL POINT',
|
'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful',
|
||||||
'lets_Check_all_domains' => 'Check all domains',
|
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
|
||||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain',
|
'lets_Letsencrypt_certificate' => 'Letsencrypt certificate',
|
||||||
'lets_Internal_IP' => 'Internal IP',
|
|
||||||
'lets_APPLY' => 'Apply',
|
|
||||||
'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts',
|
|
||||||
'lets_Brief_description' => 'Brief description',
|
'lets_Brief_description' => 'Brief description',
|
||||||
'lets_HOSTOVERRIDE_STATUS' => 'HOSTOVERRIDE STATUS',
|
|
||||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain wihch is enabled',
|
|
||||||
'lets_Enabled_domains_check_result' => 'Enabled domains check result',
|
|
||||||
'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful',
|
|
||||||
'lets_Content' => 'Content',
|
'lets_Content' => 'Content',
|
||||||
'lets_LABEL_NAMESERVERS' => 'LABEL NAMESERVERS',
|
'lets_Check_all_enabled_domains' => 'Check all enabled domains',
|
||||||
|
'lets_Back' => 'Back',
|
||||||
|
'lets_IPs_for_this_Server' => 'is for this Server',
|
||||||
|
'lets_Save' => 'Save',
|
||||||
|
'lets_Manage_letsencrypt-config_settings:' => 'Manage letsencrypt-config settings',
|
||||||
'lets_External_Interface_IP' => 'External Interface IP',
|
'lets_External_Interface_IP' => 'External Interface IP',
|
||||||
'lets_All_domains_check_result' => 'All domains check result',
|
'lets_All_domains_check_result' => 'All domains check result',
|
||||||
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
|
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled',
|
||||||
'lets_Save' => 'Save',
|
'lets_Not_Before' => 'Not Before',
|
||||||
'lets_SERVICE_STATUS' => 'SERVICE STATUS',
|
'lets_CONFIG' => 'Config',
|
||||||
'lets_Current_certificate_details' => 'Current certificate details',
|
'lets_IS_IN_CERT' => 'Is In cart',
|
||||||
'lets_Configuration_for_Letsencrypt' => 'Configuration for Letsencrypt',
|
'lets_Check_all_domains' => 'Check all domains',
|
||||||
'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful',
|
'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status',
|
||||||
'lets_CHECK_ENABLED_DOMAINS' => 'CHECK ENABLED DOMAINS',
|
'lets_HOSTOVERRIDE_STATUS' => 'Hostoverride Status',
|
||||||
|
'lets_CONFIG_LETSENCRYPT' => 'confirm Letsencrypt',
|
||||||
|
'lets_Internet_IP' => 'Internet IP',
|
||||||
|
'lets_LABEL_POINT' => 'Label Point',
|
||||||
|
'lets_CHECKALLDOMAINS_panel_action_was_successful' => 'CHECKALLDOMAINS panel action was successful',
|
||||||
|
'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts',
|
||||||
|
'lets_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||||
|
'lets_Expiry' => 'Expiry',
|
||||||
|
'lets_API_STATUS' => 'ape Status',
|
||||||
|
'lets_Internal_IP' => 'Internal IP',
|
||||||
|
'lets_SERVICE_STATUS' => 'Service Status',
|
||||||
|
'lets_LABEL_LECERT' => 'Label secret',
|
||||||
|
'lets_LIST_panel_action_was_successful' => 'LIST panel action was successful',
|
||||||
|
'lets_HOOKSCRIPT_STATUS' => 'Hookscript Status',
|
||||||
|
'lets_CONFIGUREMODE_STATUS' => 'Configuremode Status',
|
||||||
'lets_CHECK' => 'Check',
|
'lets_CHECK' => 'Check',
|
||||||
'lets_LABEL_LECERT' => 'LABEL LECERT',
|
'lets_KEYSIZE_STATUS' => 'Keysize Status',
|
||||||
|
'lets_Current_certificate_details' => 'Current certificate details',
|
||||||
|
'lets_CHECK_ENABLED_DOMAINS' => 'Check Enabled Domains',
|
||||||
|
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain',
|
||||||
|
'lets_APPLY' => 'Apply',
|
||||||
|
'lets_LABEL_NAMESERVERS' => 'Label timeservers',
|
||||||
|
'lets_Configuration_for_Letsencrypt' => 'Configuration for Letsencrypt',
|
||||||
|
'lets_CHECK_ALL_DOMAINS' => 'Check All Domains',
|
||||||
|
'lets_Enabled_domains_check_result' => 'Enabled domains check result',
|
||||||
|
@ -232,6 +232,13 @@
|
|||||||
%= link_to l('${title}'), '${structure:href}' , class=>'link link${type_serial}'
|
%= link_to l('${title}'), '${structure:href}' , class=>'link link${type_serial}'
|
||||||
]]>
|
]]>
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
<ButtonLink><![CDATA[
|
||||||
|
%= button_to l('${title}'), '${structure:href}' , class=>'buttonlink buttonlink${type_serial}'
|
||||||
|
]]>
|
||||||
|
</ButtonLink>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</root>
|
</root>
|
@ -13,18 +13,18 @@
|
|||||||
{
|
{
|
||||||
'Name': 'List',
|
'Name': 'List',
|
||||||
'route': 'LIST',
|
'route': 'LIST',
|
||||||
'Link2': {
|
'ButtonLink2': {
|
||||||
'Type': 'Link',
|
'Type': 'ButtonLink',
|
||||||
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE',
|
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE',
|
||||||
'title': 'CONFIG'
|
'title': 'CONFIG'
|
||||||
},
|
},
|
||||||
'Link3': {
|
'ButtonLink3': {
|
||||||
'Type': 'Link',
|
'Type': 'ButtonLink',
|
||||||
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE',
|
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE',
|
||||||
'title': 'CHECK_ALL_DOMAINS'
|
'title': 'CHECK_ALL_DOMAINS'
|
||||||
},
|
},
|
||||||
'Link4': {
|
'ButtonLink4': {
|
||||||
'Type': 'Link',
|
'Type': 'ButtonLink',
|
||||||
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE',
|
'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE',
|
||||||
'title': 'CHECK_ENABLED_DOMAINS'
|
'title': 'CHECK_ENABLED_DOMAINS'
|
||||||
},
|
},
|
||||||
|
49
sm2gen.py
49
sm2gen.py
@ -12,8 +12,7 @@ from pathlib import Path
|
|||||||
import traceback
|
import traceback
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
from spellchecker import SpellChecker
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# To Do
|
# To Do
|
||||||
@ -30,7 +29,41 @@ OPENAI_API_KEY = ""
|
|||||||
|
|
||||||
def example_function(**kwargs):
|
def example_function(**kwargs):
|
||||||
print(kwargs)
|
print(kwargs)
|
||||||
|
|
||||||
|
def spell_check_and_correct(text):
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Initialize the spell checker
|
||||||
|
spell = SpellChecker()
|
||||||
|
|
||||||
|
# Tokenize the text into words
|
||||||
|
words = text.split()
|
||||||
|
|
||||||
|
# Create a new list to store corrected words
|
||||||
|
corrected_words = []
|
||||||
|
|
||||||
|
for word in words:
|
||||||
|
# Skip words that are entirely uppercase
|
||||||
|
if word.isupper():
|
||||||
|
corrected_words.append(word)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Check if the word is correctly spelled
|
||||||
|
if word in spell:
|
||||||
|
# Word is correct, add the original word
|
||||||
|
corrected_words.append(word)
|
||||||
|
else:
|
||||||
|
# Word is misspelled, get the correction
|
||||||
|
correction = spell.correction(word)
|
||||||
|
# If a correction is found, use it; otherwise, keep the original word
|
||||||
|
corrected_words.append(correction if correction else word)
|
||||||
|
# Join the corrected words back into a single string
|
||||||
|
corrected_text = ' '.join(corrected_words)
|
||||||
|
except:
|
||||||
|
print(f"Spelling checker exception ({text})")
|
||||||
|
return text
|
||||||
|
return corrected_text
|
||||||
|
|
||||||
def python_to_perl_structure(data):
|
def python_to_perl_structure(data):
|
||||||
#print(data)
|
#print(data)
|
||||||
if data:
|
if data:
|
||||||
@ -301,7 +334,7 @@ def format_text(text):
|
|||||||
formatted_sentences.append(formatted_sentence)
|
formatted_sentences.append(formatted_sentence)
|
||||||
# Join the formatted sentences back together
|
# Join the formatted sentences back together
|
||||||
formatted_text = ". ".join(formatted_sentences).lstrip()
|
formatted_text = ". ".join(formatted_sentences).lstrip()
|
||||||
return formatted_text
|
return spell_check_and_correct(capitalize_words_if_all_caps(formatted_text))
|
||||||
|
|
||||||
|
|
||||||
def get_completion(prompt):
|
def get_completion(prompt):
|
||||||
@ -399,6 +432,14 @@ def convert_lex_to_dict(pairs_string):
|
|||||||
formatted_dict = [{"id": key, "text": value} for key, value in data_dict.items()]
|
formatted_dict = [{"id": key, "text": value} for key, value in data_dict.items()]
|
||||||
return formatted_dict
|
return formatted_dict
|
||||||
|
|
||||||
|
def capitalize_words_if_all_caps(s):
|
||||||
|
# Check if all characters in the string are uppercase or spaces
|
||||||
|
if s.replace(" ", "").isupper():
|
||||||
|
# Capitalize each word
|
||||||
|
return s.title()
|
||||||
|
else:
|
||||||
|
return s
|
||||||
|
|
||||||
def extract_input_fields(json_data, value_type):
|
def extract_input_fields(json_data, value_type):
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user