Add in entries for other mojo input tags
This commit is contained in:
parent
3b6e1930a0
commit
4d7cc1f076
@ -2,7 +2,7 @@
|
|||||||
# Routines to be edited by the developer to provide validation for parameters
|
# Routines to be edited by the developer to provide validation for parameters
|
||||||
# and provison of the control data for table(s)
|
# and provison of the control data for table(s)
|
||||||
#
|
#
|
||||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 17:41
|
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 12:03
|
||||||
#
|
#
|
||||||
|
|
||||||
use esmith::util;
|
use esmith::util;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package SrvMngr::Controller::CreateStarterWebsite;
|
package SrvMngr::Controller::CreateStarterWebsite;
|
||||||
#
|
#
|
||||||
# Generated by version:SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 17:41
|
# Generated by version:SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 12:03
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# heading : Miscellaneous
|
# heading : Miscellaneous
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-13 19:20
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 12:03
|
||||||
%#
|
%#
|
||||||
<div id="CreateStarterWebsite-PARAMS" class="partial CreateStarterWebsite-PARAMS">
|
<div id="CreateStarterWebsite-PARAMS" class="partial CreateStarterWebsite-PARAMS">
|
||||||
<script>
|
<script>
|
||||||
@ -20,48 +20,39 @@
|
|||||||
<h2><%=l('csw_Manage_CreateStarterWebsite_settings:')%></h2>
|
<h2><%=l('csw_Manage_CreateStarterWebsite_settings:')%></h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('To create a simple web page for your company, fill
|
%=l('csw_To_create_a_simple_web')
|
||||||
in the fields below and click onCreate.')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('csw_You_can_leave_any_field')
|
%=l('csw_You_can_leave_any_field')
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('The text that you enter below will be line wrapped
|
%=l('csw_The_text_that_you_enter')
|
||||||
for a nicer appearance in your web page. Leave a blank line
|
|
||||||
whenever you want to start a new paragraph. If you need
|
|
||||||
to force a line break without starting a new paragraph (for
|
|
||||||
example after each line of a mailing address), then type
|
|
||||||
the four-character sequence')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('Do not use this option if you have already customized your web site, since it will
|
%=l('csw_Do_not_use_this_optionif')
|
||||||
overwrite the 'index.htm' file in your web site directory.')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('csw_')
|
%=l('csw_')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
%=
|
% text_field
|
||||||
</span></p>
|
</span></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('First header, typically used for short phrases such
|
%=l('csw_First_header,_typically_used_for')
|
||||||
as 'Leader in the field of textile manufacturing'')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('csw_')
|
%=l('csw_')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
%=
|
% text_field
|
||||||
</span></p>
|
</span></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('Text following first header, typically used for a
|
%=l('csw_Text_following_first_header,_typically')
|
||||||
paragraph of marketing information.')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<span class=label>
|
<span class=label>
|
||||||
@ -72,19 +63,17 @@
|
|||||||
</span><br>
|
</span><br>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('Second header, typically used for short phrases such
|
%=l('csw_Second_header,_typically_used_for')
|
||||||
as 'For more information' or 'To order our products':')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('csw_')
|
%=l('csw_')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
%=
|
% text_field
|
||||||
</span></p>
|
</span></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('Text following second header, typically used for contact
|
%=l('csw_Text_following_second_header,_typically')
|
||||||
or ordering information:')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<span class=label>
|
<span class=label>
|
||||||
@ -95,15 +84,17 @@
|
|||||||
</span><br>
|
</span><br>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('When you create this web page, the file
|
%=l('csw_When_you_create_this_web')
|
||||||
'index.htm' will be overwritten
|
|
||||||
in your web site directory.')
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('csw_Do_you_wish_to_proceed?')
|
%=l('csw_Do_you_wish_to_proceed?')
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<span class='data'>
|
||||||
|
%= submit_button l('csw_Create'), class => 'action'
|
||||||
|
</span>
|
||||||
|
|
||||||
%# Probably finally by a submit.
|
%# Probably finally by a submit.
|
||||||
%end
|
%end
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
% layout 'default', title => "Sme server 2 - Create Starter Website", share_dir => './';
|
% layout 'default', title => "Sme server 2 - Create Starter Website", share_dir => './';
|
||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 17:41
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 12:03
|
||||||
%#
|
%#
|
||||||
% content_for 'module' => begin
|
% content_for 'module' => begin
|
||||||
<div id="module" class="module CreateStarterWebsite-panel">
|
<div id="module" class="module CreateStarterWebsite-panel">
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
'csw_Do_not_use_this_optionif' => 'Do not use this optionif you have already customized your web site, Since it will overwrite the \'index. Htm\' file in your web site directory. ',
|
'csw_Text_following_second_header,_typically' => 'Text following second header, Typically used for contact or ordering information:',
|
||||||
'csw_Second_header,_typically_used_for' => 'Second header, Typically used for short phrases such as \'For more information\' or \'To order our products\':',
|
|
||||||
'csw_Hello_PARAMS' => 'Hello PARAMS',
|
'csw_Hello_PARAMS' => 'Hello PARAMS',
|
||||||
'csw_To_create_a_simple_web' => 'To create a simple web page for your company, Fill in the fields below and click onCreate. ',
|
'csw_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||||
|
'csw_Do_you_wish_to_proceed?' => 'Do you wish to proceed?',
|
||||||
|
'csw_Create' => 'Create',
|
||||||
|
'csw_When_you_create_this_web' => 'When you create this web page, The file 'index. Htm' will be overwritten in your web site directory. ',
|
||||||
|
'csw_Manage_CreateStarterWebsite_settings:' => 'Manage CreateStarterWebsite settings:',
|
||||||
|
'csw_' => '',
|
||||||
'csw_The_text_that_you_enter' => 'The text that you enter below will be line wrapped for a nicer appearance in your web page. Leave a blank line whenever you want to start a new paragraph. If you need to force a line break without starting a new paragraph (for example after each line of a mailing address), Then type the four-character sequence',
|
'csw_The_text_that_you_enter' => 'The text that you enter below will be line wrapped for a nicer appearance in your web page. Leave a blank line whenever you want to start a new paragraph. If you need to force a line break without starting a new paragraph (for example after each line of a mailing address), Then type the four-character sequence',
|
||||||
'csw_You_can_leave_any_field' => 'You can leave any field blank if you do not need it. ',
|
'csw_You_can_leave_any_field' => 'You can leave any field blank if you do not need it. ',
|
||||||
|
'csw_First_header,_typically_used_for' => 'First header, Typically used for short phrases such as 'Leader in the field of textile manufacturing'',
|
||||||
'csw_Text_following_first_header,_typically' => 'Text following first header, Typically used for a paragraph of marketing information. ',
|
'csw_Text_following_first_header,_typically' => 'Text following first header, Typically used for a paragraph of marketing information. ',
|
||||||
'csw_Do_you_wish_to_proceed?' => 'Do you wish to proceed?',
|
'csw_Do_not_use_this_optionif' => 'Do not use this optionif you have already customized your web site, Since it will overwrite the 'index. Htm' file in your web site directory. ',
|
||||||
'csw_Manage_CreateStarterWebsite_settings:' => 'Manage CreateStarterWebsite settings:',
|
|
||||||
'csw_When_you_create_this_web' => 'When you create this web page, The file \'index. Htm\' will be overwritten in your web site directory. ',
|
|
||||||
'csw_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
|
||||||
'csw_Create_Starter_Website' => 'Create Starter Website',
|
'csw_Create_Starter_Website' => 'Create Starter Website',
|
||||||
'csw_First_header,_typically_used_for' => 'First header, Typically used for short phrases such as \'Leader in the field of textile manufacturing\'',
|
'csw_To_create_a_simple_web' => 'To create a simple web page for your company, Fill in the fields below and click onCreate. ',
|
||||||
'csw_' => '',
|
|
||||||
'csw_APPLY' => 'Apply',
|
'csw_APPLY' => 'Apply',
|
||||||
'csw_Text_following_second_header,_typically' => 'Text following second header, Typically used for contact or ordering information:',
|
'csw_Second_header,_typically_used_for' => 'Second header, Typically used for short phrases such as 'For more information' or 'To order our products':',
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
%#
|
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 17:41
|
|
||||||
%#
|
|
||||||
<div id="CreateStarterWebsite-PARAMS" class="partial CreateStarterWebsite-PARAMS">
|
|
||||||
<script>
|
|
||||||
window.onload = function() {
|
|
||||||
SelectInput();
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<h2>
|
|
||||||
%= l('csw_Hello_PARAMS');
|
|
||||||
</h2>
|
|
||||||
% my $btn = l('csw_APPLY');
|
|
||||||
%= form_for "CreateStarterWebsited" => (method => 'POST') => begin
|
|
||||||
|
|
||||||
% param 'trt' => $csw_data->{trt} unless param 'trt';
|
|
||||||
%= hidden_field 'trt' => $csw_data->{trt}
|
|
||||||
%# Inputs etc in here.
|
|
||||||
|
|
||||||
<h2><%=l('csw_Manage_CreateStarterWebsite_settings:')%></h2>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_To_create_a_simple_web')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_You_can_leave_any_field')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_The_text_that_you_enter')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_Do_not_use_this_optionif')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p><span class=label>
|
|
||||||
%=l('csw_')
|
|
||||||
</span><span class=data>
|
|
||||||
%=
|
|
||||||
</span></p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_First_header,_typically_used_for')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p><span class=label>
|
|
||||||
%=l('csw_')
|
|
||||||
</span><span class=data>
|
|
||||||
%=
|
|
||||||
</span></p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_Text_following_first_header,_typically')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<span class=label>
|
|
||||||
%=l('csw_')
|
|
||||||
</span><span class=data>
|
|
||||||
% param 'text1' => $csw_data->{text1} unless param 'text1';
|
|
||||||
%= text_area 'text1', cols=>40, rows=>10
|
|
||||||
</span><br>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_Second_header,_typically_used_for')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p><span class=label>
|
|
||||||
%=l('csw_')
|
|
||||||
</span><span class=data>
|
|
||||||
%=
|
|
||||||
</span></p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_Text_following_second_header,_typically')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<span class=label>
|
|
||||||
%=l('csw_')
|
|
||||||
</span><span class=data>
|
|
||||||
% param 'text2' => $csw_data->{text2} unless param 'text2';
|
|
||||||
%= text_area 'text2', cols=>40, rows=>10
|
|
||||||
</span><br>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_When_you_create_this_web')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
%=l('csw_Do_you_wish_to_proceed?')
|
|
||||||
</p>
|
|
||||||
|
|
||||||
%# Probably finally by a submit.
|
|
||||||
%end
|
|
||||||
</div>
|
|
@ -2,7 +2,7 @@
|
|||||||
# Routines to be edited by the developer to provide validation for parameters
|
# Routines to be edited by the developer to provide validation for parameters
|
||||||
# and provison of the control data for table(s)
|
# and provison of the control data for table(s)
|
||||||
#
|
#
|
||||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 12:09
|
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 10:49
|
||||||
#
|
#
|
||||||
|
|
||||||
use esmith::util;
|
use esmith::util;
|
||||||
@ -36,7 +36,11 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
|||||||
# Return an array of hashes of the contents for each row and column for Table1
|
# Return an array of hashes of the contents for each row and column for Table1
|
||||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my @ret = {};
|
my $control_data = $self->stash('Table1');
|
||||||
|
my @ret = {}
|
||||||
|
# foreach my $colHead (@$control_data) {
|
||||||
|
# my ret{$colHead} = "$colhead-1"
|
||||||
|
# };
|
||||||
return \@ret
|
return \@ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +48,11 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
|||||||
# Return an array of hashes of the contents for each row and column for Table2
|
# Return an array of hashes of the contents for each row and column for Table2
|
||||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my @ret = {};
|
my $control_data = $self->stash('Table2');
|
||||||
|
my @ret = {}
|
||||||
|
# foreach my $colHead (@$control_data) {
|
||||||
|
# my ret{$colHead} = "$colhead-1"
|
||||||
|
# };
|
||||||
return \@ret
|
return \@ret
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
# Routines to be edited by the developer to provide validation for parameters
|
# Routines to be edited by the developer to provide validation for parameters
|
||||||
# and provison of the control data for table(s)
|
# and provison of the control data for table(s)
|
||||||
#
|
#
|
||||||
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 11:53
|
# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 11:51
|
||||||
#
|
#
|
||||||
|
|
||||||
use esmith::util;
|
use esmith::util;
|
||||||
@ -33,14 +33,26 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
|||||||
# Get control data for tables(s)
|
# Get control data for tables(s)
|
||||||
|
|
||||||
sub get_Table1 {
|
sub get_Table1 {
|
||||||
|
# Return an array of hashes of the contents for each row and column for Table1
|
||||||
|
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my @ret = {};
|
my $control_data = $self->stash('Table1');
|
||||||
|
my @ret = {}
|
||||||
|
# foreach my $colHead (@$control_data) {
|
||||||
|
# my ret{$colHead} = "$colhead-1"
|
||||||
|
# };
|
||||||
return \@ret
|
return \@ret
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_Table2 {
|
sub get_Table2 {
|
||||||
|
# Return an array of hashes of the contents for each row and column for Table2
|
||||||
|
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my @ret = {};
|
my $control_data = $self->stash('Table2');
|
||||||
|
my @ret = {}
|
||||||
|
# foreach my $colHead (@$control_data) {
|
||||||
|
# my ret{$colHead} = "$colhead-1"
|
||||||
|
# };
|
||||||
return \@ret
|
return \@ret
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
package SrvMngr::Controller::Diskusage;
|
package SrvMngr::Controller::DiskUsage;
|
||||||
#
|
#
|
||||||
# Generated by version:SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 12:09
|
# Generated by version:SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 11:51
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
# heading : Miscellaneous
|
# heading : Miscellaneous
|
||||||
# description : Disk Usage
|
# description : Disk Usage
|
||||||
# navigation : 2000 400
|
# navigation : 2000 400
|
||||||
#
|
#
|
||||||
# name : diskusage, method : get, url : /diskusage, ctlact : Diskusage#main
|
# name : diskusage, method : get, url : /diskusage, ctlact : DiskUsage#main
|
||||||
# name : diskusageu, method : post, url : /diskusageu, ctlact : Diskusage#do_update
|
# name : diskusageu, method : post, url : /diskusageu, ctlact : DiskUsage#do_update
|
||||||
# name : diskusaged, method : get, url : /diskusaged, ctlact : Diskusage#do_display
|
# name : diskusaged, method : get, url : /diskusaged, ctlact : DiskUsage#do_display
|
||||||
#
|
#
|
||||||
# routes : end
|
# routes : end
|
||||||
#
|
#
|
||||||
# Documentation: https://wiki.contribs.org/Diskusage
|
# Documentation: https://wiki.contribs.org/DiskUsage
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -49,7 +49,7 @@ our $ndb = esmith::NetworksDB->open() || die("Couldn't open Network db");
|
|||||||
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
our $hdb = esmith::HostsDB->open() || die("Couldn't open Hosts db");
|
||||||
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
||||||
|
|
||||||
require '/usr/share/smanager/lib/SrvMngr/Controller/Diskusage-Custom.pm'; #The code that is to be added by the developer
|
require '/usr/share/smanager/lib/SrvMngr/Controller/DiskUsage-Custom.pm'; #The code that is to be added by the developer
|
||||||
|
|
||||||
sub main {
|
sub main {
|
||||||
#
|
#
|
@ -1,7 +1,7 @@
|
|||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 12:09
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 11:51
|
||||||
%#
|
%#
|
||||||
<div id="Diskusage-PARAMS" class="partial Diskusage-PARAMS">
|
<div id="DiskUsage-PARAMS" class="partial DiskUsage-PARAMS">
|
||||||
<script>
|
<script>
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
SelectInput();
|
SelectInput();
|
||||||
@ -11,7 +11,7 @@
|
|||||||
%= l('du_Hello_PARAMS');
|
%= l('du_Hello_PARAMS');
|
||||||
</h2>
|
</h2>
|
||||||
% my $btn = l('du_APPLY');
|
% my $btn = l('du_APPLY');
|
||||||
%= form_for "Diskusaged" => (method => 'POST') => begin
|
%= form_for "DiskUsaged" => (method => 'POST') => begin
|
||||||
|
|
||||||
% param 'trt' => $du_data->{trt} unless param 'trt';
|
% param 'trt' => $du_data->{trt} unless param 'trt';
|
||||||
%= hidden_field 'trt' => $du_data->{trt}
|
%= hidden_field 'trt' => $du_data->{trt}
|
||||||
@ -20,11 +20,11 @@
|
|||||||
<h2><%=l('du_Manage_DiskUsage_settings:')%></h2>
|
<h2><%=l('du_Manage_DiskUsage_settings:')%></h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('du_&nbsp')
|
%=l('du_')
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('du_Wed_Sep_11_19:01:00_BST')
|
%=l('du_Wed_Sep_11_19:01:00_BST')
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@ -60,7 +60,7 @@ tmpfs 2.0G 648K 2.0G 1% /run
|
|||||||
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
%= l('du_&nbsp')
|
%=l('du_')
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<br /><table class="sme-border TableSort sme-table">
|
<br /><table class="sme-border TableSort sme-table">
|
@ -1,9 +1,9 @@
|
|||||||
% layout 'default', title => "Sme server 2 - Disk Usage", share_dir => './';
|
% layout 'default', title => "Sme server 2 - Disk Usage", share_dir => './';
|
||||||
%#
|
%#
|
||||||
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-14 12:09
|
%# Generated by SM2Gen version:0.8 Chameleon version:4.5.4 On Python:3.12.3 at 2024-09-15 11:51
|
||||||
%#
|
%#
|
||||||
% content_for 'module' => begin
|
% content_for 'module' => begin
|
||||||
<div id="module" class="module Diskusage-panel">
|
<div id="module" class="module DiskUsage-panel">
|
||||||
|
|
||||||
% if ($config->{debug} == 1) {
|
% if ($config->{debug} == 1) {
|
||||||
<p>
|
<p>
|
@ -1,11 +1,11 @@
|
|||||||
'du_&nbsp' => '&nbsp',
|
'du_' => '',
|
||||||
'du_I-bays' => 'I-bays',
|
|
||||||
'du_Usage' => 'Usage',
|
|
||||||
'du_Disk_Usage' => 'Disk Usage',
|
|
||||||
'du_Path' => 'Path',
|
|
||||||
'du_Wed_Sep_11_19:01:00_BST' => 'Wed Sep 11 19:01:00 BST 2024',
|
|
||||||
'du_Users' => 'Users',
|
|
||||||
'du_APPLY' => 'Apply',
|
|
||||||
'du_Hello_PARAMS' => 'Hello PARAMS',
|
|
||||||
'du_Manage_DiskUsage_settings:' => 'Manage DiskUsage settings:',
|
'du_Manage_DiskUsage_settings:' => 'Manage DiskUsage settings:',
|
||||||
'du_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
'du_PARAMS_panel_action_was_successful' => 'PARAMS panel action was successful',
|
||||||
|
'du_Wed_Sep_11_19:01:00_BST' => 'Wed Sep 11 19:01:00 BST 2024',
|
||||||
|
'du_Path' => 'Path',
|
||||||
|
'du_I-bays' => 'I-bays',
|
||||||
|
'du_Hello_PARAMS' => 'Hello PARAMS',
|
||||||
|
'du_Usage' => 'Usage',
|
||||||
|
'du_Users' => 'Users',
|
||||||
|
'du_Disk_Usage' => 'Disk Usage',
|
||||||
|
'du_APPLY' => 'Apply',
|
@ -36,7 +36,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
|
|||||||
# Return an array of hashes of the contents for each row and column for ${tablecontrol}
|
# Return an array of hashes of the contents for each row and column for ${tablecontrol}
|
||||||
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
# default is a single row of strings "col1header-1, col2header-1, col3Header-1 etc"
|
||||||
my $c = shift;
|
my $c = shift;
|
||||||
my $control_data = $self->stash('${TableControl}');
|
my $control_data = $self->stash('${tablecontrol}');
|
||||||
my @ret = {}
|
my @ret = {}
|
||||||
# foreach my $colHead (@$control_data) {
|
# foreach my $colHead (@$control_data) {
|
||||||
# my ret{$colHead} = "$colhead-1"
|
# my ret{$colHead} = "$colhead-1"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${prefix}_${Label}')
|
%=l('${prefix}_${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
%= ${Value}
|
% text_field ${Value}
|
||||||
</span></p>
|
</span></p>
|
||||||
]]></Text>
|
]]></Text>
|
||||||
|
|
||||||
@ -17,6 +17,8 @@
|
|||||||
<br></span> </p>
|
<br></span> </p>
|
||||||
]]></Selection>
|
]]></Selection>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Textarea><![CDATA[
|
<Textarea><![CDATA[
|
||||||
<span class=label>
|
<span class=label>
|
||||||
%=l('${prefix}_${Label}')
|
%=l('${prefix}_${Label}')
|
||||||
@ -34,6 +36,15 @@
|
|||||||
</span><br>
|
</span><br>
|
||||||
]]></Date>
|
]]></Date>
|
||||||
|
|
||||||
|
<Time><![CDATA[
|
||||||
|
<span class=label>
|
||||||
|
%=l('${prefix}_${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=time_field '${Name}' =>$$${Name}, pattern=>${regexp | .*}
|
||||||
|
</span><br>
|
||||||
|
]]></Time>
|
||||||
|
|
||||||
|
|
||||||
<Textinput><![CDATA[
|
<Textinput><![CDATA[
|
||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${prefix}_${Label}')
|
%=l('${prefix}_${Label}')
|
||||||
@ -55,7 +66,7 @@
|
|||||||
|
|
||||||
<Submit><![CDATA[
|
<Submit><![CDATA[
|
||||||
<span class='data'>
|
<span class='data'>
|
||||||
%= submit_button l('${value}'), class => 'action'
|
%= submit_button l('${Value}'), class => 'action'
|
||||||
</span>]]>
|
</span>]]>
|
||||||
</Submit>
|
</Submit>
|
||||||
|
|
||||||
@ -63,6 +74,8 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${prefix}_${Label}')
|
%=l('${prefix}_${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
|
%=Search field
|
||||||
|
%=search field
|
||||||
</span>span></p>
|
</span>span></p>
|
||||||
]]>
|
]]>
|
||||||
</search>
|
</search>
|
||||||
@ -71,6 +84,7 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${Label}')
|
%=l('${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
|
%=URL field
|
||||||
</span>span></p>
|
</span>span></p>
|
||||||
]]>
|
]]>
|
||||||
</url>
|
</url>
|
||||||
@ -79,6 +93,7 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${Label}')
|
%=l('${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
|
%=tel field
|
||||||
</span>span></p>
|
</span>span></p>
|
||||||
]]>
|
]]>
|
||||||
</tel>
|
</tel>
|
||||||
@ -87,6 +102,7 @@
|
|||||||
<p><span class=label>
|
<p><span class=label>
|
||||||
%=l('${Label}')
|
%=l('${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
|
%=email field
|
||||||
</span>span></p>
|
</span>span></p>
|
||||||
]]>
|
]]>
|
||||||
</email>
|
</email>
|
||||||
@ -95,10 +111,92 @@
|
|||||||
<p><span class='label'>
|
<p><span class='label'>
|
||||||
%=l('${Label}')
|
%=l('${Label}')
|
||||||
</span><span class=data>
|
</span><span class=data>
|
||||||
|
%=password field
|
||||||
</span>span></p>
|
</span>span></p>
|
||||||
]]>
|
]]>
|
||||||
</password>
|
</password>
|
||||||
|
|
||||||
|
<timedate><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=timedate field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</timedate>
|
||||||
|
|
||||||
|
<week><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=week field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</week>
|
||||||
|
|
||||||
|
<month><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=month field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</month>
|
||||||
|
|
||||||
|
<range><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=range field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</range>
|
||||||
|
|
||||||
|
<radio><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=radio field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</radio>
|
||||||
|
|
||||||
|
<number><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=number field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</number>
|
||||||
|
|
||||||
|
<file><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=file field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<color><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=color field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</color>
|
||||||
|
|
||||||
|
<checkbox><![CDATA[
|
||||||
|
<p><span class='label'>
|
||||||
|
%=l('${Label}')
|
||||||
|
</span><span class=data>
|
||||||
|
%=checkbox field
|
||||||
|
</span>span></p>
|
||||||
|
]]>
|
||||||
|
</checkbox>
|
||||||
|
|
||||||
<Table><![CDATA[
|
<Table><![CDATA[
|
||||||
<br /><table class="sme-border TableSort sme-table">
|
<br /><table class="sme-border TableSort sme-table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -125,11 +223,5 @@
|
|||||||
]]>
|
]]>
|
||||||
</Preformatted>
|
</Preformatted>
|
||||||
|
|
||||||
<submit><![CDATA[
|
|
||||||
<p> <br>
|
|
||||||
%= submit_button "${Value}", class => 'action'
|
|
||||||
</p>
|
|
||||||
]]>
|
|
||||||
</submit>
|
|
||||||
|
|
||||||
</root>
|
</root>
|
||||||
|
@ -6,7 +6,8 @@
|
|||||||
'MenuNavigation': '2000 400',
|
'MenuNavigation': '2000 400',
|
||||||
'firstPanel': 'PARAMS',
|
'firstPanel': 'PARAMS',
|
||||||
'signalEvent': 'smeserver-createstarterwebsite-update',
|
'signalEvent': 'smeserver-createstarterwebsite-update',
|
||||||
'html':[ {
|
'html': [
|
||||||
|
{
|
||||||
'Name': 'params',
|
'Name': 'params',
|
||||||
'route': 'PARAMS',
|
'route': 'PARAMS',
|
||||||
'Header': 'Create a starter website',
|
'Header': 'Create a starter website',
|
||||||
@ -14,14 +15,14 @@
|
|||||||
'Paragraph1': 'To create a simple web page for your company, fill in the fields below and click onCreate.',
|
'Paragraph1': 'To create a simple web page for your company, fill in the fields below and click onCreate.',
|
||||||
'Paragraph2': 'You can leave any field blank if you do not need it.',
|
'Paragraph2': 'You can leave any field blank if you do not need it.',
|
||||||
'Paragraph3': 'The text that you enter below will be line wrapped for a nicer appearance in your web page. Leave a blank line whenever you want to start a new paragraph. If you need to force a line break without starting a new paragraph (for example after each line of a mailing address), then type the four-character sequence',
|
'Paragraph3': 'The text that you enter below will be line wrapped for a nicer appearance in your web page. Leave a blank line whenever you want to start a new paragraph. If you need to force a line break without starting a new paragraph (for example after each line of a mailing address), then type the four-character sequence',
|
||||||
'Paragraph4': 'Do not use this optionif you have already customized your web site, since it will overwrite the index.htm file in your web site directory.',
|
'Paragraph4': 'Do not use this optionif you have already customized your web site, since it will overwrite the \'index.htm\' file in your web site directory.',
|
||||||
'Input1': {
|
'Input1': {
|
||||||
'Type': 'Text',
|
'Type': 'Text',
|
||||||
'Value': '',
|
'Value': '',
|
||||||
'Name': 'companyName',
|
'Name': 'companyName',
|
||||||
'Label': null
|
'Label': null
|
||||||
},
|
},
|
||||||
'Paragraph5': 'First header, typically used for short phrases such as Leader in the field of textile manufacturing',
|
'Paragraph5': 'First header, typically used for short phrases such as \'Leader in the field of textile manufacturing\'',
|
||||||
'Input2': {
|
'Input2': {
|
||||||
'Type': 'Text',
|
'Type': 'Text',
|
||||||
'Value': '',
|
'Value': '',
|
||||||
@ -35,7 +36,7 @@
|
|||||||
'Name': 'text1',
|
'Name': 'text1',
|
||||||
'Label': null
|
'Label': null
|
||||||
},
|
},
|
||||||
'Paragraph7': 'Second header, typically used for short phrases such as For more information or To order our products:',
|
'Paragraph7': 'Second header, typically used for short phrases such as \'For more information\' or \'To order our products\':',
|
||||||
'Input4': {
|
'Input4': {
|
||||||
'Type': 'Text',
|
'Type': 'Text',
|
||||||
'Value': '',
|
'Value': '',
|
||||||
@ -49,7 +50,7 @@
|
|||||||
'Name': 'text2',
|
'Name': 'text2',
|
||||||
'Label': null
|
'Label': null
|
||||||
},
|
},
|
||||||
'Paragraph9': 'When you create this web page, the file index.htm will be overwritten in your web site directory.',
|
'Paragraph9': 'When you create this web page, the file \'index.htm\' will be overwritten in your web site directory.',
|
||||||
'Paragraph10': 'Do you wish to proceed?',
|
'Paragraph10': 'Do you wish to proceed?',
|
||||||
'Input6': {
|
'Input6': {
|
||||||
'Type': 'Submit',
|
'Type': 'Submit',
|
||||||
|
@ -1,47 +1,49 @@
|
|||||||
{
|
{
|
||||||
PackageName: 'Diskusage',
|
'PackageName': 'DiskUsage',
|
||||||
prefix: 'du',
|
'prefix': 'du',
|
||||||
MenuHeading: 'Miscellaneous',
|
'MenuHeading': 'Miscellaneous',
|
||||||
MenuDescription: 'Disk Usage',
|
'MenuDescription': 'Disk Usage',
|
||||||
MenuNavigation: '2000 400',
|
'MenuNavigation': '2000 400',
|
||||||
firstPanel: 'PARAMS',
|
'firstPanel': 'PARAMS',
|
||||||
signalEvent: 'smeserver-diskusage-update',
|
'signalEvent': 'smeserver-diskusage-update',
|
||||||
html: [{
|
'html': [
|
||||||
Name: 'params',
|
{
|
||||||
route: 'PARAMS',
|
'Name': 'params',
|
||||||
Header: 'Disk usage',
|
'route': 'PARAMS',
|
||||||
SubHeader: 'Manage DiskUsage settings:',
|
'Header': 'Disk usage',
|
||||||
Paragraph1: ' ',
|
'SubHeader': 'Manage DiskUsage settings:',
|
||||||
Paragraph2: 'Wed Sep 11 19:01:00 BST 2024',
|
'Paragraph1': '',
|
||||||
Preformatted1: 'Filesystem Size Used Avail Use% Mounted on\n/dev/mapper/main-root 29G 4.8G 24G 17% /\ndevtmpfs 2.0G 0 2.0G 0% /dev\ntmpfs 2.0G 12K 2.0G 1% /dev/shm\ntmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup\ntmpfs 2.0G 648K 2.0G 1% /run\n/dev/sda1 497M 111M 386M 23% /boot',
|
'Paragraph2': 'Wed Sep 11 19:01:00 BST 2024',
|
||||||
Table1: {
|
'Preformatted1': 'Filesystem Size Used Avail Use% Mounted on\n/dev/mapper/main-root 29G 4.8G 24G 17% /\ndevtmpfs 2.0G 0 2.0G 0% /dev\ntmpfs 2.0G 12K 2.0G 1% /dev/shm\ntmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup\ntmpfs 2.0G 648K 2.0G 1% /run\n/dev/sda1 497M 111M 386M 23% /boot',
|
||||||
Type: 'Table',
|
'Table1': {
|
||||||
TableControl: 'Table1',
|
'Type': 'Table',
|
||||||
TopHeadings: [
|
'TableControl': 'Table1',
|
||||||
|
'TopHeadings': [
|
||||||
'I-bays',
|
'I-bays',
|
||||||
'Usage',
|
'Usage',
|
||||||
'Path'
|
'Path'
|
||||||
],
|
],
|
||||||
Columns: [
|
'Columns': [
|
||||||
'Table1-I-bays',
|
'Table1-I-bays',
|
||||||
'Table1-Usage',
|
'Table1-Usage',
|
||||||
'Table1-Path'
|
'Table1-Path'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
Paragraph3: ' ',
|
'Paragraph3': '',
|
||||||
Table2: {
|
'Table2': {
|
||||||
Type: 'Table',
|
'Type': 'Table',
|
||||||
TableControl: 'Table2',
|
'TableControl': 'Table2',
|
||||||
TopHeadings: [
|
'TopHeadings': [
|
||||||
'Users',
|
'Users',
|
||||||
'Usage',
|
'Usage',
|
||||||
'Path'
|
'Path'
|
||||||
],
|
],
|
||||||
Columns: [
|
'Columns': [
|
||||||
'Table2-Users',
|
'Table2-Users',
|
||||||
'Table2-Usage',
|
'Table2-Usage',
|
||||||
'Table2-Path'
|
'Table2-Path'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
@ -3,12 +3,16 @@ import os
|
|||||||
import re
|
import re
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from lxml import etree # Import lxml for HTML validation
|
from lxml import etree # Import lxml for HTML validation
|
||||||
|
import html
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def read_html_file(filename):
|
def read_html_file(filename):
|
||||||
"""Read HTML content from a file."""
|
"""Read HTML content from a file."""
|
||||||
with open(filename, 'r', encoding='utf-8') as file:
|
with open(filename, "r", encoding="utf-8") as file:
|
||||||
return file.read()
|
return file.read()
|
||||||
|
|
||||||
|
|
||||||
def validate_html(html):
|
def validate_html(html):
|
||||||
"""Validate the HTML content."""
|
"""Validate the HTML content."""
|
||||||
try:
|
try:
|
||||||
@ -17,13 +21,19 @@ def validate_html(html):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ValueError("Invalid HTML document") from e
|
raise ValueError("Invalid HTML document") from e
|
||||||
|
|
||||||
|
|
||||||
def sanitize_text(text):
|
def sanitize_text(text):
|
||||||
# Replace newlines with spaces
|
# Replace newlines with spaces
|
||||||
sanitized_text = text.replace('\n', ' ').replace('\r', ' ') # Handle both Unix and Windows line endings
|
decoded_text = html.unescape(text)
|
||||||
|
sanitized_text = decoded_text.replace("\n", "").replace(
|
||||||
|
"\r", " "
|
||||||
|
) # Handle both Unix and Windows line endings
|
||||||
# Replace tabs with spaces
|
# Replace tabs with spaces
|
||||||
sanitized_text = sanitized_text.replace('\t', ' ')
|
sanitized_text = sanitized_text.replace("\t", "")
|
||||||
# Escape quote characters
|
# map single quotes to double
|
||||||
sanitized_text = sanitized_text.replace('"', '\\"').replace("'", "\\'")
|
sanitized_text = sanitized_text.replace("'", '"')
|
||||||
|
#Take out any multiple spaces - reduce to one.
|
||||||
|
sanitized_text = ' '.join(sanitized_text.split())
|
||||||
# Strip leading and trailing whitespace
|
# Strip leading and trailing whitespace
|
||||||
sanitized_text = sanitized_text.strip()
|
sanitized_text = sanitized_text.strip()
|
||||||
return sanitized_text
|
return sanitized_text
|
||||||
@ -31,15 +41,10 @@ def sanitize_text(text):
|
|||||||
|
|
||||||
def extract_data(html):
|
def extract_data(html):
|
||||||
"""Extract paragraphs, inputs, tables, and pre blocks from HTML and organize them in order."""
|
"""Extract paragraphs, inputs, tables, and pre blocks from HTML and organize them in order."""
|
||||||
soup = BeautifulSoup(html, 'lxml')
|
soup = BeautifulSoup(html, "lxml")
|
||||||
records = []
|
records = []
|
||||||
|
|
||||||
hidden_input_names = [
|
hidden_input_names = ["page", "page_stack", ".id", "csrf_token"]
|
||||||
'page',
|
|
||||||
'page_stack',
|
|
||||||
'.id',
|
|
||||||
'csrf_token'
|
|
||||||
]
|
|
||||||
|
|
||||||
header_text = None
|
header_text = None
|
||||||
sub_header_text = None
|
sub_header_text = None
|
||||||
@ -48,81 +53,81 @@ def extract_data(html):
|
|||||||
table_counter = 0
|
table_counter = 0
|
||||||
|
|
||||||
# Extract elements while preserving order
|
# Extract elements while preserving order
|
||||||
for element in soup.find_all(['h1', 'h2', 'p', 'pre', 'input', 'select', 'textarea', 'button', 'table']):
|
for element in soup.find_all(
|
||||||
if element.name == 'h1':
|
["h1", "h2", "p", "pre", "input", "select", "textarea", "button", "table"]
|
||||||
|
):
|
||||||
|
if element.name == "h1":
|
||||||
header_text = element.get_text(strip=True)
|
header_text = element.get_text(strip=True)
|
||||||
records.append({
|
records.append({"Type": "Header", "Text": header_text})
|
||||||
'Type': 'Header',
|
|
||||||
'Text': header_text
|
|
||||||
})
|
|
||||||
|
|
||||||
elif element.name == 'h2':
|
elif element.name == "h2":
|
||||||
sub_header_text = element.get_text(strip=True)
|
sub_header_text = element.get_text(strip=True)
|
||||||
records.append({
|
records.append({"Type": "SubHeader", "Text": sub_header_text})
|
||||||
'Type': 'SubHeader',
|
|
||||||
'Text': sub_header_text
|
|
||||||
})
|
|
||||||
|
|
||||||
elif element.name == 'p':
|
elif element.name == "p":
|
||||||
text = element.get_text(strip=True)
|
text = element.get_text(strip=True)
|
||||||
if text: # Ignore empty paragraphs
|
if text: # Ignore empty paragraphs
|
||||||
#Sanitise text freom newlines,tabs and escape quotes.
|
# Sanitise text freom newlines,tabs and escape quotes.
|
||||||
records.append({
|
records.append({"Type": "Paragraph", "Text": sanitize_text(text)})
|
||||||
'Type': 'Paragraph',
|
|
||||||
'Text': sanitize_text(text)
|
|
||||||
})
|
|
||||||
|
|
||||||
elif element.name == 'pre':
|
elif element.name == "pre":
|
||||||
text = element.get_text(strip=True)
|
text = element.get_text(strip=True)
|
||||||
if text: # Ensure non-empty before adding
|
if text: # Ensure non-empty before adding
|
||||||
records.append({
|
records.append({"Type": "Preformatted", "Text": text})
|
||||||
'Type': 'Preformatted',
|
|
||||||
'Text': text
|
|
||||||
})
|
|
||||||
|
|
||||||
elif element.name == 'input':
|
elif element.name == "input":
|
||||||
if element.get('type') == 'hidden' or element.get('name') in hidden_input_names:
|
if (
|
||||||
|
element.get("type") == "hidden"
|
||||||
|
or element.get("name") in hidden_input_names
|
||||||
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
input_info = {
|
input_info = {
|
||||||
'Type': element.get('type', 'text').capitalize(),
|
"Type": element.get("type", "text").capitalize(),
|
||||||
'Name': element.get('name'),
|
"Name": element.get("name"),
|
||||||
'Value': element.get('value', ''),
|
"Value": element.get("value", ""),
|
||||||
}
|
}
|
||||||
label = element.find_next('label')
|
label = element.find_next("label")
|
||||||
input_info['Label'] = label.get_text(strip=True) if label else None
|
input_info["Label"] = label.get_text(strip=True) if label else None
|
||||||
records.append(input_info)
|
records.append(input_info)
|
||||||
|
|
||||||
elif element.name == 'select':
|
elif element.name == "select":
|
||||||
options = [{'Value': option.get('value'), 'Text': option.get_text(strip=True)} for option in element.find_all('option')]
|
options = [
|
||||||
|
{"Value": option.get("value"), "Text": option.get_text(strip=True)}
|
||||||
|
for option in element.find_all("option")
|
||||||
|
]
|
||||||
select_info = {
|
select_info = {
|
||||||
'Type': 'Select',
|
"Type": "Select",
|
||||||
'Name': element.get('name'),
|
"Name": element.get("name"),
|
||||||
'Options': options,
|
"Options": options,
|
||||||
'Label': element.find_previous('label').get_text(strip=True) if element.find_previous('label') else None,
|
"Label": element.find_previous("label").get_text(strip=True)
|
||||||
|
if element.find_previous("label")
|
||||||
|
else None,
|
||||||
}
|
}
|
||||||
records.append(select_info)
|
records.append(select_info)
|
||||||
|
|
||||||
elif element.name == 'textarea':
|
elif element.name == "textarea":
|
||||||
textarea_info = {
|
textarea_info = {
|
||||||
'Type': 'Textarea',
|
"Type": "Textarea",
|
||||||
'Name': element.get('name'),
|
"Name": element.get("name"),
|
||||||
'Value': element.get_text(strip=True),
|
"Value": element.get_text(strip=True),
|
||||||
}
|
}
|
||||||
label = element.find_previous('label')
|
label = element.find_previous("label")
|
||||||
textarea_info['Label'] = label.get_text(strip=True) if label else None
|
textarea_info["Label"] = label.get_text(strip=True) if label else None
|
||||||
records.append(textarea_info)
|
records.append(textarea_info)
|
||||||
|
|
||||||
elif element.name == 'button':
|
elif element.name == "button":
|
||||||
button_info = {
|
button_info = {
|
||||||
'Type': 'Button',
|
"Type": "Button",
|
||||||
'Name': element.get('name'),
|
"Name": element.get("name"),
|
||||||
'Value': element.get_text(strip=True),
|
"Value": element.get_text(strip=True),
|
||||||
'Label': element.find_previous('label').get_text(strip=True) if label else None,
|
"Label": element.find_previous("label").get_text(strip=True)
|
||||||
|
if label
|
||||||
|
else None,
|
||||||
}
|
}
|
||||||
records.append(button_info)
|
records.append(button_info)
|
||||||
|
|
||||||
elif element.name == 'table' and 'sme-border' in element.get('class', []):
|
elif element.name == "table" and "sme-border" in element.get("class", []):
|
||||||
# Increment the table counter
|
# Increment the table counter
|
||||||
table_counter += 1
|
table_counter += 1
|
||||||
|
|
||||||
@ -132,37 +137,47 @@ def extract_data(html):
|
|||||||
columns = []
|
columns = []
|
||||||
|
|
||||||
# Extract headings from the first row
|
# Extract headings from the first row
|
||||||
first_row = element.find('tr')
|
first_row = element.find("tr")
|
||||||
if first_row:
|
if first_row:
|
||||||
for th in first_row.find_all('th'):
|
for th in first_row.find_all("th"):
|
||||||
top_headings.append(th.get_text(strip=True))
|
top_headings.append(th.get_text(strip=True))
|
||||||
|
|
||||||
# Extract only the first data row's cell values for Columns
|
# Extract only the first data row's cell values for Columns
|
||||||
data_rows = element.find_all('tr')[1:] # Skip the heading row
|
data_rows = element.find_all("tr")[1:] # Skip the heading row
|
||||||
if data_rows:
|
if data_rows:
|
||||||
first_data_row = data_rows[0] # Take the first row of data
|
first_data_row = data_rows[0] # Take the first row of data
|
||||||
for idx, th in enumerate(first_row.find_all('th')):
|
for idx, th in enumerate(first_row.find_all("th")):
|
||||||
td = first_data_row.find_all('td')[idx] if idx < len(first_data_row.find_all('td')) else None
|
td = (
|
||||||
|
first_data_row.find_all("td")[idx]
|
||||||
|
if idx < len(first_data_row.find_all("td"))
|
||||||
|
else None
|
||||||
|
)
|
||||||
if td:
|
if td:
|
||||||
columns.append(f"{table_control}-{th.get_text(strip=True)}") # Format as desired
|
columns.append(
|
||||||
|
f"{table_control}-{th.get_text(strip=True)}"
|
||||||
|
) # Format as desired
|
||||||
|
|
||||||
records.append({
|
records.append(
|
||||||
'Type': 'Table',
|
{
|
||||||
'TableControl': table_control,
|
"Type": "Table",
|
||||||
'TopHeadings': top_headings,
|
"TableControl": table_control,
|
||||||
'Columns': columns,
|
"TopHeadings": top_headings,
|
||||||
})
|
"Columns": columns,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return records, header_text, sub_header_text
|
return records, header_text, sub_header_text
|
||||||
|
|
||||||
|
|
||||||
def insert_spaces_before_caps(text):
|
def insert_spaces_before_caps(text):
|
||||||
"""Insert spaces before each capital letter in a given string."""
|
"""Insert spaces before each capital letter in a given string."""
|
||||||
return re.sub(r'(?<!^)(?=[A-Z])', ' ', text)
|
return re.sub(r"(?<!^)(?=[A-Z])", " ", text)
|
||||||
|
|
||||||
|
|
||||||
def save_to_json5(data, output_filename, package_name, header, sub_header):
|
def save_to_json5(data, output_filename, package_name, header, sub_header):
|
||||||
"""Save extracted data to a JSON5 file with a specific structure."""
|
"""Save extracted data to a JSON5 file with a specific structure."""
|
||||||
# Generate prefix from uppercase letters in PackageName made into lowercase
|
# Generate prefix from uppercase letters in PackageName made into lowercase
|
||||||
prefix = ''.join(re.findall(r'[A-Z]', package_name)).lower()
|
prefix = "".join(re.findall(r"[A-Z]", package_name)).lower()
|
||||||
|
|
||||||
# Prepare structured html list
|
# Prepare structured html list
|
||||||
structured_html = []
|
structured_html = []
|
||||||
@ -172,81 +187,99 @@ def save_to_json5(data, output_filename, package_name, header, sub_header):
|
|||||||
table_count = 1
|
table_count = 1
|
||||||
|
|
||||||
for record in data:
|
for record in data:
|
||||||
if record['Type'] == 'Paragraph':
|
if record["Type"] == "Paragraph":
|
||||||
structured_html.append({
|
structured_html.append({f"Paragraph{paragraph_count}": record["Text"]})
|
||||||
f'Paragraph{paragraph_count}': record['Text']
|
|
||||||
})
|
|
||||||
paragraph_count += 1
|
paragraph_count += 1
|
||||||
elif record['Type'] == 'Preformatted':
|
elif record["Type"] == "Preformatted":
|
||||||
structured_html.append({
|
structured_html.append(
|
||||||
f'Preformatted{preformatted_count}': record['Text']
|
{f"Preformatted{preformatted_count}": record["Text"]}
|
||||||
})
|
)
|
||||||
preformatted_count += 1
|
preformatted_count += 1
|
||||||
elif record['Type'] == 'Header' or record['Type'] == 'SubHeader':
|
elif record["Type"] == "Header" or record["Type"] == "SubHeader":
|
||||||
continue # Skip headers for input count
|
continue # Skip headers for input count
|
||||||
elif record['Type'] == 'Table':
|
elif record["Type"] == "Table":
|
||||||
# Construct the table entry
|
# Construct the table entry
|
||||||
table_structure = {
|
table_structure = {
|
||||||
'Type': record['Type'],
|
"Type": record["Type"],
|
||||||
'TableControl': record['TableControl'],
|
"TableControl": record["TableControl"],
|
||||||
'TopHeadings': record['TopHeadings'],
|
"TopHeadings": record["TopHeadings"],
|
||||||
'Columns': record['Columns']
|
"Columns": record["Columns"],
|
||||||
}
|
}
|
||||||
structured_html.append({
|
structured_html.append({f"Table{table_count}": table_structure})
|
||||||
f'Table{table_count}': table_structure
|
|
||||||
})
|
|
||||||
table_count += 1
|
table_count += 1
|
||||||
else: # For inputs, selects, textareas, and buttons
|
else: # For inputs, selects, textareas, and buttons
|
||||||
input_structure = {
|
input_structure = {
|
||||||
'Type': record['Type'],
|
"Type": record["Type"],
|
||||||
'Value': record.get('Value', ''), # Safely access Value
|
"Value": record.get("Value", ""), # Safely access Value
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use .get() for the Name key to avoid KeyError
|
# Use .get() for the Name key to avoid KeyError
|
||||||
input_structure['Name'] = record.get('Name', None) # Set to None if not present
|
input_structure["Name"] = record.get(
|
||||||
input_structure['Label'] = record.get('Label', None) # Set to None if not present
|
"Name", None
|
||||||
|
) # Set to None if not present
|
||||||
|
input_structure["Label"] = record.get(
|
||||||
|
"Label", None
|
||||||
|
) # Set to None if not present
|
||||||
|
|
||||||
# Handle specific case for Select options
|
# Handle specific case for Select options
|
||||||
if 'Options' in record:
|
if "Options" in record:
|
||||||
input_structure['Options'] = record['Options']
|
input_structure["Options"] = record["Options"]
|
||||||
|
|
||||||
structured_html.append({
|
structured_html.append({f"Input{input_count}": input_structure})
|
||||||
f'Input{input_count}': input_structure
|
|
||||||
})
|
|
||||||
input_count += 1
|
input_count += 1
|
||||||
|
|
||||||
# Wrap the records with the required fields
|
# Wrap the records with the required fields
|
||||||
json5_data = {
|
json5_data = {
|
||||||
'PackageName': package_name,
|
"PackageName": package_name,
|
||||||
'prefix': prefix,
|
"prefix": prefix,
|
||||||
'MenuHeading': 'Miscellaneous',
|
"MenuHeading": "Miscellaneous",
|
||||||
'MenuDescription': insert_spaces_before_caps(package_name),
|
"MenuDescription": insert_spaces_before_caps(package_name),
|
||||||
'MenuNavigation': '2000 400',
|
"MenuNavigation": "2000 400",
|
||||||
'firstPanel': 'PARAMS',
|
"firstPanel": "PARAMS",
|
||||||
'signalEvent': f'smeserver-{package_name.lower()}-update',
|
"signalEvent": f"smeserver-{package_name.lower()}-update",
|
||||||
'html': {
|
"html": [{
|
||||||
'Name': 'params',
|
"Name": "params",
|
||||||
'route': 'PARAMS',
|
"route": "PARAMS",
|
||||||
'Header': header if header else f'{package_name} Contrib',
|
"Header": header if header else f"{package_name} Contrib",
|
||||||
'SubHeader': sub_header if sub_header else f'Manage {package_name} settings:',
|
"SubHeader": sub_header
|
||||||
**{k: v for item in structured_html for k, v in item.items()} # Flatten the structured_html into the dict
|
if sub_header
|
||||||
}
|
else f"Manage {package_name} settings:",
|
||||||
|
**{
|
||||||
|
k: v for item in structured_html for k, v in item.items()
|
||||||
|
}, # Flatten the structured_html into the dict
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
|
|
||||||
# Save in JSON5 format (JSON with comments and unquoted keys)
|
# Save in JSON5 format (JSON with comments and unquoted keys)
|
||||||
with open(output_filename, 'w', encoding='utf-8') as json_file:
|
with open(output_filename, "w", encoding="utf-8") as json_file:
|
||||||
json.dump(json5_data, json_file, ensure_ascii=False, indent=4)
|
json.dump(json5_data, json_file, ensure_ascii=False, indent=4)
|
||||||
|
|
||||||
# Manually format as JSON5 by adding single quotes (for simplicity)
|
# Manually format as JSON5 by adding single quotes (for simplicity)
|
||||||
with open(output_filename, 'r+', encoding='utf-8') as json_file:
|
with open(output_filename, "r+", encoding="utf-8") as json_file:
|
||||||
content = json_file.read()
|
content = json_file.read()
|
||||||
content = content.replace('"', "'") # Replace double quotes with single quotes for JSON5
|
content = content.replace(
|
||||||
|
'"', "'"
|
||||||
|
) # Replace double quotes with single quotes for JSON5
|
||||||
json_file.seek(0)
|
json_file.seek(0)
|
||||||
json_file.write(content)
|
json_file.write(content)
|
||||||
json_file.truncate() # Remove any old content beyond the new content length
|
json_file.truncate() # Remove any old content beyond the new content length
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
input_file = '/home/brianr/clients/SM2/SM2Gen/venv/html/CreateStarterWebsite.html' # Specify the input HTML file path
|
# command line parameters
|
||||||
|
parser = argparse.ArgumentParser(description="sm1--html-2-jsopn5")
|
||||||
|
parser.add_argument(
|
||||||
|
"-f",
|
||||||
|
"--filename",
|
||||||
|
help="Specify a filename for the html file",
|
||||||
|
default="CreateStarterWebsite.html",
|
||||||
|
)
|
||||||
|
args = parser.parse_args()
|
||||||
|
input_file = "/home/brianr/clients/SM2/SM2Gen/venv/html/" + args.filename
|
||||||
|
if not input_file.lower().endswith(".html"):
|
||||||
|
# Add .html extension
|
||||||
|
input_file += ".html"
|
||||||
|
print(input_file)
|
||||||
|
|
||||||
# Read HTML content
|
# Read HTML content
|
||||||
html_content = read_html_file(input_file)
|
html_content = read_html_file(input_file)
|
||||||
@ -256,19 +289,29 @@ def main():
|
|||||||
|
|
||||||
# Extract data from HTML
|
# Extract data from HTML
|
||||||
data, header, sub_header = extract_data(html_content)
|
data, header, sub_header = extract_data(html_content)
|
||||||
|
#
|
||||||
|
# Generate output JSON5 filename based on input file name
|
||||||
|
#
|
||||||
|
# Split the original path into directory and file name
|
||||||
|
directory, filename = os.path.split(input_file)
|
||||||
|
|
||||||
|
# Replace 'html' with 'json5' in the directory path
|
||||||
|
new_directory = directory.replace('/html', '/json5')
|
||||||
|
#print(new_directory)
|
||||||
|
|
||||||
|
# Construct the new path
|
||||||
|
output_file = os.path.join(new_directory, filename.replace('.html', '.json5'))
|
||||||
|
print(output_file)
|
||||||
|
#quit(1)
|
||||||
|
|
||||||
# Generate output JSON5 filename based on input file name
|
# Generate output JSON5 filename based on input file name
|
||||||
base_name = os.path.basename(input_file) # Get the file name (with extension)
|
base_name = os.path.basename(input_file) # Get the file name (with extension)
|
||||||
package_name = os.path.splitext(base_name)[0] # Use the filename without extension
|
package_name = os.path.splitext(base_name)[0] # Use the filename without extension
|
||||||
json_filename = package_name + '.json5' # Change extension to .json5
|
|
||||||
|
|
||||||
# Create the output file path in the same directory
|
|
||||||
output_directory = os.path.dirname(input_file)
|
|
||||||
output_file = os.path.join(output_directory, json_filename)
|
|
||||||
|
|
||||||
# Save extracted data to JSON5
|
# Save extracted data to JSON5
|
||||||
save_to_json5(data, output_file, package_name, header, sub_header)
|
save_to_json5(data, output_file, package_name, header, sub_header)
|
||||||
print(f"Extracted data saved to '{output_file}'.")
|
print(f"Extracted data saved to '{output_file}'.")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
35
sm2gen.py
35
sm2gen.py
@ -311,9 +311,9 @@ if __name__ == "__main__":
|
|||||||
except pkg_resources.DistributionNotFound:
|
except pkg_resources.DistributionNotFound:
|
||||||
chameleon_version = "Version information not available"
|
chameleon_version = "Version information not available"
|
||||||
python_version = sys.version
|
python_version = sys.version
|
||||||
version_pattern = r'(\d{1,3}\.\d{1,3}\.\d{1,3})'
|
version_pattern = r"(\d{1,3}\.\d{1,3}\.\d{1,3})"
|
||||||
version_match = re.search(version_pattern, python_version)
|
version_match = re.search(version_pattern, python_version)
|
||||||
python_version = version_match.group(0) if version_match else 'Unknown'
|
python_version = version_match.group(0) if version_match else "Unknown"
|
||||||
current_datetime = datetime.now()
|
current_datetime = datetime.now()
|
||||||
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M")
|
formatted_datetime = current_datetime.strftime("%Y-%m-%d %H:%M")
|
||||||
strVersion = (
|
strVersion = (
|
||||||
@ -333,7 +333,7 @@ if __name__ == "__main__":
|
|||||||
print(f"SM2 code from JSON5 - {strVersion}")
|
print(f"SM2 code from JSON5 - {strVersion}")
|
||||||
|
|
||||||
home_dir = "/home/brianr/clients/SM2/SM2Gen/"
|
home_dir = "/home/brianr/clients/SM2/SM2Gen/"
|
||||||
json_filename = f"{home_dir}/json5/nfsshare.json5" #CreateStarterWebsite.json5"
|
json_filename = f"{home_dir}/json5/nfsshare.json5" # CreateStarterWebsite.json5"
|
||||||
|
|
||||||
# read open ai key from ini file
|
# read open ai key from ini file
|
||||||
# Check if the file exists
|
# Check if the file exists
|
||||||
@ -376,7 +376,10 @@ if __name__ == "__main__":
|
|||||||
default="yes",
|
default="yes",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-ncu", "--noCust", help="Stop it creating Custom controller file", default="yes"
|
"-ncu",
|
||||||
|
"--noCust",
|
||||||
|
help="Stop it creating Custom controller file",
|
||||||
|
default="yes",
|
||||||
)
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
json_filename = args.filename
|
json_filename = args.filename
|
||||||
@ -384,7 +387,7 @@ if __name__ == "__main__":
|
|||||||
f"JSON5 from {json_filename} with noController={args.noController}, noHtml={args.noHtml} and noLang={args.noLang}"
|
f"JSON5 from {json_filename} with noController={args.noController}, noHtml={args.noHtml} and noLang={args.noLang}"
|
||||||
) # Not yet activated
|
) # Not yet activated
|
||||||
|
|
||||||
#check if json5 file exists
|
# check if json5 file exists
|
||||||
json_file_path = Path(json_filename)
|
json_file_path = Path(json_filename)
|
||||||
if not json_file_path.exists():
|
if not json_file_path.exists():
|
||||||
print(f"json5 file: {json_filename} not found")
|
print(f"json5 file: {json_filename} not found")
|
||||||
@ -412,7 +415,7 @@ if __name__ == "__main__":
|
|||||||
directory_path = Path("Targets/" + hl("PackageName"))
|
directory_path = Path("Targets/" + hl("PackageName"))
|
||||||
# Create the directory if it doesn't exist
|
# Create the directory if it doesn't exist
|
||||||
directory_path.mkdir(parents=True, exist_ok=True)
|
directory_path.mkdir(parents=True, exist_ok=True)
|
||||||
target_directory_path = "Targets/" + hl("PackageName")+"/"
|
target_directory_path = "Targets/" + hl("PackageName") + "/"
|
||||||
|
|
||||||
controller_file = target_directory_path + hl("PackageName") + ".pm"
|
controller_file = target_directory_path + hl("PackageName") + ".pm"
|
||||||
custom_controller_file = target_directory_path + hl("PackageName") + "-Custom.pm"
|
custom_controller_file = target_directory_path + hl("PackageName") + "-Custom.pm"
|
||||||
@ -422,7 +425,9 @@ if __name__ == "__main__":
|
|||||||
layout_file = target_directory_path + hl("PackageName").lower() + ".html.ep"
|
layout_file = target_directory_path + hl("PackageName").lower() + ".html.ep"
|
||||||
partial_files = list()
|
partial_files = list()
|
||||||
for panel in routes:
|
for panel in routes:
|
||||||
partial_files.append(target_directory_path + hl("prefix") + "_" + panel + ".html.ep")
|
partial_files.append(
|
||||||
|
target_directory_path + '_' + hl("prefix") + "_" + panel + ".html.ep"
|
||||||
|
)
|
||||||
print(f"Partial files to be created:{partial_files}")
|
print(f"Partial files to be created:{partial_files}")
|
||||||
lex_file = target_directory_path + hl("PackageName").lower() + "_en.lex"
|
lex_file = target_directory_path + hl("PackageName").lower() + "_en.lex"
|
||||||
tablecontrols = (
|
tablecontrols = (
|
||||||
@ -433,7 +438,9 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# Generate controller file
|
# Generate controller file
|
||||||
try:
|
try:
|
||||||
controller_template = PageTemplateFile("Templates/controller.pm.tem",CHAMELEON_DEBUG="true")
|
controller_template = PageTemplateFile(
|
||||||
|
"Templates/controller.pm.tem", CHAMELEON_DEBUG="true"
|
||||||
|
)
|
||||||
dbentries = get_db_fields() # Params which correspond to Db fields
|
dbentries = get_db_fields() # Params which correspond to Db fields
|
||||||
try:
|
try:
|
||||||
controller_perl = controller_template.render(
|
controller_perl = controller_template.render(
|
||||||
@ -646,7 +653,9 @@ if __name__ == "__main__":
|
|||||||
for lang_item in lang_dict:
|
for lang_item in lang_dict:
|
||||||
print(f"Translating from english lex file to {lang_item['language']}")
|
print(f"Translating from english lex file to {lang_item['language']}")
|
||||||
code = lang_item["code"]
|
code = lang_item["code"]
|
||||||
translated_lex_file = f"{target_directory_path}{hl('PackageName').lower()}_{code}.lex"
|
translated_lex_file = (
|
||||||
|
f"{target_directory_path}{hl('PackageName').lower()}_{code}.lex"
|
||||||
|
)
|
||||||
# Only do it if the lex file is missing
|
# Only do it if the lex file is missing
|
||||||
if not os.path.exists(translated_lex_file):
|
if not os.path.exists(translated_lex_file):
|
||||||
translated_dict = []
|
translated_dict = []
|
||||||
@ -655,7 +664,9 @@ if __name__ == "__main__":
|
|||||||
translated_text = get_translation(
|
translated_text = get_translation(
|
||||||
lex_item["text"], lang_item["language"]
|
lex_item["text"], lang_item["language"]
|
||||||
)
|
)
|
||||||
translated_dict.append({"id": lex_item["id"], "text": translated_text})
|
translated_dict.append(
|
||||||
|
{"id": lex_item["id"], "text": translated_text}
|
||||||
|
)
|
||||||
print(f"Writing out lex file for {lang_item['code']}")
|
print(f"Writing out lex file for {lang_item['code']}")
|
||||||
with open(translated_lex_file, "w") as file:
|
with open(translated_lex_file, "w") as file:
|
||||||
for item in translated_dict:
|
for item in translated_dict:
|
||||||
@ -666,7 +677,9 @@ if __name__ == "__main__":
|
|||||||
.replace('"', r"\"")
|
.replace('"', r"\"")
|
||||||
.replace("'", r"\'")
|
.replace("'", r"\'")
|
||||||
)
|
)
|
||||||
line = "'" + item["id"] + "' => " + '"' + translated_text + '",\n'
|
line = (
|
||||||
|
"'" + item["id"] + "' => " + '"' + translated_text + '",\n'
|
||||||
|
)
|
||||||
file.write(line)
|
file.write(line)
|
||||||
# print(f"{item['id']} => {item['text']}\n")
|
# print(f"{item['id']} => {item['text']}\n")
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user