Add in spell check for lex file and more format for LIST panel
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
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
 | 
			
		||||
 
 | 
			
		||||
@@ -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">
 | 
			
		||||
  <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">
 | 
			
		||||
  <script>
 | 
			
		||||
 
 | 
			
		||||
@@ -9,7 +9,7 @@
 | 
			
		||||
  </script>
 | 
			
		||||
  <pre>
 | 
			
		||||
	%= dumper $lets_data
 | 
			
		||||
	%= dumper $c->stash('DomainList')
 | 
			
		||||
	%# dumper $c->stash('DomainList')
 | 
			
		||||
  </pre>
 | 
			
		||||
    % my $btn = l('lets_APPLY');
 | 
			
		||||
    %= form_for "Letsencryptd" => (method => 'POST') => begin
 | 
			
		||||
@@ -18,13 +18,11 @@
 | 
			
		||||
		%= hidden_field 'trt' => $lets_data->{trt}
 | 
			
		||||
		%# Inputs etc in here.
 | 
			
		||||
 | 
			
		||||
		%= link_to l('lets_CONFIG'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE' , class=>'link link2'
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
		%= link_to l('lets_CHECK_ALL_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE' , class=>'link link3'
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
		%= link_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE' , class=>'link link4'
 | 
			
		||||
		<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'
 | 
			
		||||
			%= button_to l('lets_CHECK_ENABLED_DOMAINS'), 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE' , class=>'buttonlink link4'
 | 
			
		||||
		</div>
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
		<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">
 | 
			
		||||
  <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 {}
 | 
			
		||||
.name {}
 | 
			
		||||
.rout {}
 | 
			
		||||
.link2 {}
 | 
			
		||||
.link3 {}
 | 
			
		||||
.link4 {}
 | 
			
		||||
.butt2 {}
 | 
			
		||||
.butt3 {}
 | 
			
		||||
.butt4 {}
 | 
			
		||||
.subh2 {}
 | 
			
		||||
.read4 {}
 | 
			
		||||
.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 => './';
 | 
			
		||||
%# 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_LABEL_POINT' => 'LABEL POINT',
 | 
			
		||||
'lets_Check_all_domains' => 'Check all domains',
 | 
			
		||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain',
 | 
			
		||||
'lets_Internal_IP' => 'Internal IP',
 | 
			
		||||
'lets_APPLY' => 'Apply',
 | 
			
		||||
'lets_List_of_Domains_and_Hosts' => 'List of Domains and Hosts',
 | 
			
		||||
'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful',
 | 
			
		||||
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
 | 
			
		||||
'lets_Letsencrypt_certificate' => 'Letsencrypt certificate',
 | 
			
		||||
'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_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_All_domains_check_result' => 'All domains check result',
 | 
			
		||||
'lets_Domain_name_/_HOSTNAME' => 'Domain name / HOSTNAME',
 | 
			
		||||
'lets_Save' => 'Save',
 | 
			
		||||
'lets_SERVICE_STATUS' => 'SERVICE STATUS',
 | 
			
		||||
'lets_Current_certificate_details' => 'Current certificate details',
 | 
			
		||||
'lets_Configuration_for_Letsencrypt' => 'Configuration for Letsencrypt',
 | 
			
		||||
'lets_CHECKALLENABLEDDOMAINS_panel_action_was_successful' => 'CHECKALLENABLEDDOMAINS panel action was successful',
 | 
			
		||||
'lets_CHECK_ENABLED_DOMAINS' => 'CHECK ENABLED DOMAINS',
 | 
			
		||||
'lets_Loop_through_checking_the_letsencrypt' => 'Loop through checking the letsencrypt status for each configured domain which is enabled',
 | 
			
		||||
'lets_Not_Before' => 'Not Before',
 | 
			
		||||
'lets_CONFIG' => 'Config',
 | 
			
		||||
'lets_IS_IN_CERT' => 'Is In cart',
 | 
			
		||||
'lets_Check_all_domains' => 'Check all domains',
 | 
			
		||||
'lets_ACCEPT_TERMS_STATUS' => 'Accept Terms Status',
 | 
			
		||||
'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_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>
 | 
			
		||||
 | 
			
		||||
	<ButtonLink><![CDATA[
 | 
			
		||||
		%= button_to l('${title}'), '${structure:href}' , class=>'buttonlink buttonlink${type_serial}'
 | 
			
		||||
	]]>
 | 
			
		||||
	</ButtonLink>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
</root>
 | 
			
		||||
@@ -13,18 +13,18 @@
 | 
			
		||||
        {
 | 
			
		||||
            'Name': 'List',
 | 
			
		||||
            'route': 'LIST',
 | 
			
		||||
			'Link2': {
 | 
			
		||||
				'Type': 'Link',
 | 
			
		||||
			'ButtonLink2': {
 | 
			
		||||
				'Type': 'ButtonLink',
 | 
			
		||||
				'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CONFIG_PAGE',
 | 
			
		||||
				'title': 'CONFIG'
 | 
			
		||||
			},
 | 
			
		||||
			'Link3': {
 | 
			
		||||
				'Type': 'Link',
 | 
			
		||||
			'ButtonLink3': {
 | 
			
		||||
				'Type': 'ButtonLink',
 | 
			
		||||
				'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_DOMAINS_PAGE',
 | 
			
		||||
				'title': 'CHECK_ALL_DOMAINS'
 | 
			
		||||
			},
 | 
			
		||||
			'Link4': {
 | 
			
		||||
				'Type': 'Link',
 | 
			
		||||
			'ButtonLink4': {
 | 
			
		||||
				'Type': 'ButtonLink',
 | 
			
		||||
				'href': 'letsencrypt?page=0&page_stack=&Next=Next&wherenext=CHECK_ENABLED_DOMAINS_PAGE',
 | 
			
		||||
				'title': 'CHECK_ENABLED_DOMAINS'
 | 
			
		||||
			},
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										49
									
								
								sm2gen.py
									
									
									
									
									
								
							
							
						
						
									
										49
									
								
								sm2gen.py
									
									
									
									
									
								
							@@ -12,8 +12,7 @@ from pathlib import Path
 | 
			
		||||
import traceback
 | 
			
		||||
import os
 | 
			
		||||
from datetime import datetime, timedelta
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from spellchecker import SpellChecker
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# To Do
 | 
			
		||||
@@ -30,7 +29,41 @@ OPENAI_API_KEY = ""
 | 
			
		||||
 | 
			
		||||
def example_function(**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):
 | 
			
		||||
	#print(data)
 | 
			
		||||
	if data:
 | 
			
		||||
@@ -301,7 +334,7 @@ def format_text(text):
 | 
			
		||||
            formatted_sentences.append(formatted_sentence)
 | 
			
		||||
        # Join the formatted sentences back together
 | 
			
		||||
        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):
 | 
			
		||||
@@ -399,6 +432,14 @@ def convert_lex_to_dict(pairs_string):
 | 
			
		||||
    formatted_dict = [{"id": key, "text": value} for key, value in data_dict.items()]
 | 
			
		||||
    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):
 | 
			
		||||
    result = {}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user