Add in generate Stringnames for lex entities and play back into templates

This commit is contained in:
Brian Read 2024-05-03 18:08:44 +01:00
parent 26e9889061
commit 145c45f483
10 changed files with 102 additions and 60 deletions

View File

@ -59,7 +59,7 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
my $actionModify = ' '; my $actionModify = ' ';
if ($modifiable eq 'yes'){ if ($modifiable eq 'yes'){
$actionModify .= "<a href='nfsshareu?trt=PARAMS&IbayName=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp" $actionModify .= "<a href='nfsshareu?trt=PARAMS&Selected=$ibayname'><button class='sme-modify-button' title=".$c->l("MODIFY").">".$c->l("MODIFY")."</button></a>"."&nbsp"
} }
my %hash = ('Name'=> $ibayname, my %hash = ('Name'=> $ibayname,

View File

@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters # Routines to be editted 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 SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-28 11:53 # Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-03 17:51
# #
use esmith::util; use esmith::util;
@ -74,6 +74,13 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
} }
sub create_link{
# WIP
my ($c,$route, $panel, $index) = shift;
my $link = "$route?trt=$panel&Selected=$index";
return $link;
}
1; 1;

View File

@ -1,6 +1,6 @@
% layout 'default', title => "Sme server 2 - NFS data share", share_dir => './'; % layout 'default', title => "Sme server 2 - NFS data share", share_dir => './';
%# %#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-28 11:53 %# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-03 17:51
%# %#
% content_for 'module' => begin % content_for 'module' => begin
<div id="module" class="module Nfsshare-panel"> <div id="module" class="module Nfsshare-panel">

View File

@ -1,6 +1,6 @@
package SrvMngr::Controller::Nfsshare; package SrvMngr::Controller::Nfsshare;
# #
# Generated by version:SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-28 11:53 # Generated by version:SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-03 17:51
# #
#---------------------------------------------------------------------- #----------------------------------------------------------------------
# heading : Network # heading : Network
@ -67,7 +67,7 @@ sub main {
$c->app->log->info( $c->log_req ); $c->app->log->info( $c->log_req );
my %nfs_data = (); my %nfs_data = ();
my $title = $c->l("nfs_NFS data share"); my $title = $c->l("nfs_NFS_data_share");
my $modul = ''; my $modul = '';
$nfs_data{'trt'} = 'TABLE'; $nfs_data{'trt'} = 'TABLE';
@ -119,7 +119,7 @@ sub do_update {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %nfs_data = (); my %nfs_data = ();
my $title = $c->l("nfs_NFS data share"); my $title = $c->l("nfs_NFS_data_share");
# Accessing all POST parameters # Accessing all POST parameters
my %params = $c->req->params->to_hash; my %params = $c->req->params->to_hash;
@ -167,7 +167,7 @@ sub do_update {
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->render("Nfsshare"); $c->render("Nfsshare");
} else { } else {
$c->stash( success => $c->l("PARAMS panel action was successfull")); #A bit bland - edit it in the lex file $c->stash( success => $c->l("nfs_PARAMS_panel_action_was_successfull")); #A bit bland - edit it in the lex file
} }
} }
@ -179,7 +179,7 @@ sub do_update {
$c->stash(error => $c->l($ret)); $c->stash(error => $c->l($ret));
$c->render("Nfsshare"); $c->render("Nfsshare");
} else { } else {
$c->stash( success => $c->l("TABLE panel action was successfull")); #A bit bland - edit it in the lex file $c->stash( success => $c->l("nfs_TABLE_panel_action_was_successfull")); #A bit bland - edit it in the lex file
} }
} }
@ -214,7 +214,7 @@ sub do_display {
$c->app->log->info($c->log_req); $c->app->log->info($c->log_req);
my %nfs_data = (); my %nfs_data = ();
my $title = $c->l("nfs_NFS data share"); my $title = $c->l("nfs_NFS_data_share");
# Accessing all POST parameters # Accessing all POST parameters
my %params = $c->req->params->to_hash; my %params = $c->req->params->to_hash;

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-28 11:53 %# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-03 17:51
%# %#
<div id="Nfsshare-PARAMS"> <div id="Nfsshare-PARAMS">
<script> <script>
@ -8,9 +8,9 @@
}; };
</script> </script>
<h2> <h2>
%= l("nfs Hello PARAMS"); %= l("nfs_Hello_PARAMS");
</h2> </h2>
% my $btn = l('APPLY'); % my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin %= form_for "Nfsshared" => (method => 'POST') => begin
% param 'trt' => $nfs_data->{trt} unless param 'trt'; % param 'trt' => $nfs_data->{trt} unless param 'trt';
@ -20,17 +20,17 @@
<h2>Manage NFS Ibay settings:</h2> <h2>Manage NFS Ibay settings:</h2>
<p> <p>
%= l('nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files') %= l('nfs_These_parameters_will_be_effective')
</p> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Information Bay name'), class => 'label' %=l('nfs_Information_Bay_name'), class => 'label'
</span><span class=data> </span><span class=data>
%= stash("IbayName"), class => 'data' %= stash("IbayName"), class => 'data'
</span></p> </span></p>
<p><span class=label> <p><span class=label>
%=l('nfs_Share owner Group') %=l('nfs_Share_owner_Group')
</span><span class=data> </span><span class=data>
% my @ShareOwnerGrp_options = ['Write = admin, Read = group', 'Write = group, Read = everyone', 'Write = group, Read = group']; % my @ShareOwnerGrp_options = ['Write = admin, Read = group', 'Write = group, Read = everyone', 'Write = group, Read = group'];
% param 'ShareOwnerGrp' => $nfs_data->{ShareOwnerGrp} unless param 'ShareOwnerGrp'; % param 'ShareOwnerGrp' => $nfs_data->{ShareOwnerGrp} unless param 'ShareOwnerGrp';
@ -38,7 +38,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Enable the NFS Share') %=l('nfs_Enable_the_NFS_Share')
</span><span class=data> </span><span class=data>
% my @EnableNFSshare_options = ['Disabled', 'Enabled']; % my @EnableNFSshare_options = ['Disabled', 'Enabled'];
% param 'EnableNFSshare' => $nfs_data->{EnableNFSshare} unless param 'EnableNFSshare'; % param 'EnableNFSshare' => $nfs_data->{EnableNFSshare} unless param 'EnableNFSshare';
@ -46,7 +46,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_EnableShare on local network') %=l('nfs_EnableShare_on_local_network')
</span><span class=data> </span><span class=data>
% my @ShareOnLocalNetwork_options = ['Disabled', 'Enabled']; % my @ShareOnLocalNetwork_options = ['Disabled', 'Enabled'];
% param 'ShareOnLocalNetwork' => $nfs_data->{ShareOnLocalNetwork} unless param 'ShareOnLocalNetwork'; % param 'ShareOnLocalNetwork' => $nfs_data->{ShareOnLocalNetwork} unless param 'ShareOnLocalNetwork';
@ -54,18 +54,18 @@
<br></span> </p> <br></span> </p>
<p> <p>
%= l('nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).') %= l('nfs_For_writing_permissions,allowing_the_root')
</p> </p>
<span class=label> <span class=label>
%=l('nfs_NFS Client(s) allowed') %=l('nfs_NFS_Client(s)_allowed')
</span><span class=data> </span><span class=data>
% param 'NFSClientsAllowed' => $nfs_data->{NFSClientsAllowed} unless param 'NFSClientsAllowed'; % param 'NFSClientsAllowed' => $nfs_data->{NFSClientsAllowed} unless param 'NFSClientsAllowed';
%= text_area 'NFSClientsAllowed', cols=>40, rows=>5 %= text_area 'NFSClientsAllowed', cols=>40, rows=>5
</span><br> </span><br>
<p><span class=label> <p><span class=label>
%=l('nfs_File system permissions') %=l('nfs_File_system_permissions')
</span><span class=data> </span><span class=data>
% my @FileSystemPermissions_options = ['Read only', 'Read and Write']; % my @FileSystemPermissions_options = ['Read only', 'Read and Write'];
% param 'FileSystemPermissions' => $nfs_data->{FileSystemPermissions} unless param 'FileSystemPermissions'; % param 'FileSystemPermissions' => $nfs_data->{FileSystemPermissions} unless param 'FileSystemPermissions';
@ -73,7 +73,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Write (a)synchronously') %=l('nfs_Write_(a)synchronously')
</span><span class=data> </span><span class=data>
% my @WriteAsync_options = ['Synchronous', 'Asynchronous']; % my @WriteAsync_options = ['Synchronous', 'Asynchronous'];
% param 'WriteAsync' => $nfs_data->{WriteAsync} unless param 'WriteAsync'; % param 'WriteAsync' => $nfs_data->{WriteAsync} unless param 'WriteAsync';
@ -81,7 +81,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Delays the disk writing') %=l('nfs_Delays_the_disk_writing')
</span><span class=data> </span><span class=data>
% my @DelayWrite_options = ['Write delay', 'No write delay']; % my @DelayWrite_options = ['Write delay', 'No write delay'];
% param 'DelayWrite' => $nfs_data->{DelayWrite} unless param 'DelayWrite'; % param 'DelayWrite' => $nfs_data->{DelayWrite} unless param 'DelayWrite';
@ -89,7 +89,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Squash the power of users') %=l('nfs_Squash_the_power_of_users')
</span><span class=data> </span><span class=data>
% my @Squash_options = ['All users squash', 'No root squash', 'root squash']; % my @Squash_options = ['All users squash', 'No root squash', 'root squash'];
% param 'Squash' => $nfs_data->{Squash} unless param 'Squash'; % param 'Squash' => $nfs_data->{Squash} unless param 'Squash';
@ -97,7 +97,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Browse the parent folders') %=l('nfs_Browse_the_parent_folders')
</span><span class=data> </span><span class=data>
% my @BrowseParents_options = ['Hide folder', 'Show folder']; % my @BrowseParents_options = ['Hide folder', 'Show folder'];
% param 'BrowseParents' => $nfs_data->{BrowseParents} unless param 'BrowseParents'; % param 'BrowseParents' => $nfs_data->{BrowseParents} unless param 'BrowseParents';
@ -105,7 +105,7 @@
<br></span> </p> <br></span> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Requests on secure ports') %=l('nfs_Requests_on_secure_ports')
</span><span class=data> </span><span class=data>
% my @SecurePorts_options = ['Secure', 'Insecure']; % my @SecurePorts_options = ['Secure', 'Insecure'];
% param 'SecurePorts' => $nfs_data->{SecurePorts} unless param 'SecurePorts'; % param 'SecurePorts' => $nfs_data->{SecurePorts} unless param 'SecurePorts';
@ -113,25 +113,25 @@
<br></span> </p> <br></span> </p>
<p> <p>
%= l('nfs_Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank') %= l('nfs_Set_the_uid_and_gid')
</p> </p>
<p><span class=label> <p><span class=label>
%=l('nfs_Set the UID.') %=l('nfs_Set_the_UID.')
</span><span class=data> </span><span class=data>
% param 'SetUID' => $nfs_data->{SetUID} unless param 'SetUID'; % param 'SetUID' => $nfs_data->{SetUID} unless param 'SetUID';
%= text_field 'SetUID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetUID' %= text_field 'SetUID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetUID'
<br></span></p> <br></span></p>
<p><span class=label> <p><span class=label>
%=l('nfs_Set the GID.') %=l('nfs_Set_the_GID.')
</span><span class=data> </span><span class=data>
% param 'SetGID' => $nfs_data->{SetGID} unless param 'SetGID'; % param 'SetGID' => $nfs_data->{SetGID} unless param 'SetGID';
%= text_field 'SetGID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetGID' %= text_field 'SetGID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetGID'
<br></span></p> <br></span></p>
<span class='data'> <span class='data'>
%= submit_button l('Save'), class => 'action' %= submit_button l('nfs_Save'), class => 'action'
</span> </span>
%# Probably finally by a submit. %# Probably finally by a submit.

View File

@ -1,5 +1,5 @@
%# %#
%# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-04-28 11:53 %# Generated by SME2Gen version:0.6 Chameleon version:4.5.4 On Python:3.10.12 at 2024-05-03 17:51
%# %#
<div id="Nfsshare-TABLE"> <div id="Nfsshare-TABLE">
<script> <script>
@ -8,9 +8,9 @@
}; };
</script> </script>
<h2> <h2>
%= l("nfs Hello TABLE"); %= l("nfs_Hello_TABLE");
</h2> </h2>
% my $btn = l('APPLY'); % my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin %= form_for "Nfsshared" => (method => 'POST') => begin
% param 'trt' => $nfs_data->{trt} unless param 'trt'; % param 'trt' => $nfs_data->{trt} unless param 'trt';

View File

@ -1,23 +1,23 @@
'nfs_Requests on secure ports' => 'Requests on secure ports' 'nfs_Enable_the_NFS_Share' => 'Enable the NFS Share',
'nfs_APPLY' => 'APPLY' 'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_EnableShare on local network' => 'EnableShare on local network' 'nfs_Write_(a)synchronously' => 'Write (a)synchronously',
'nfs_Set the GID.' => 'Set the GID.' 'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_Save' => 'Save' 'nfs_Save' => 'Save',
'nfs_Share owner Group' => 'Share owner Group' 'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Browse the parent folders' => 'Browse the parent folders' 'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs Hello TABLE' => 'Hello TABLE' 'nfs_NFS_data_share' => 'NFS data share',
'nfs_File system permissions' => 'File system permissions' 'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_Delays the disk writing' => 'Delays the disk writing' 'nfs_APPLY' => 'APPLY',
'nfs_NFS data share' => 'NFS data share' 'nfs_Set_the_GID.' => 'Set the GID.',
'nfs_Set the UID.' => 'Set the UID.' 'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed' 'nfs_Requests_on_secure_ports' => 'Requests on secure ports',
'nfs_TABLE panel action was successfull' => 'TABLE panel action was successfull' 'nfs_Squash_the_power_of_users' => 'Squash the power of users',
'nfs_For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).' 'nfs_Set_the_UID.' => 'Set the UID.',
'nfs_These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files' 'nfs_For_writing_permissions,allowing_the_root' => 'For writing permissions,allowing the root user and using insecure ports, you must configure a list of one IP per line, being part of the local network(s).',
'nfs_Write (a)synchronously' => 'Write (a)synchronously' 'nfs_Delays_the_disk_writing' => 'Delays the disk writing',
'nfs_Squash the power of users' => 'Squash the power of users' 'nfs_These_parameters_will_be_effective' => 'These parameters will be effective only if the share is enabled. The share is in /home/e-smith/files/ibays//files',
'nfs_Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank' => 'Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank' 'nfs_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_Enable the NFS Share' => 'Enable the NFS Share' 'nfs_EnableShare_on_local_network' => 'EnableShare on local network',
'nfs_PARAMS panel action was successfull' => 'PARAMS panel action was successfull' 'nfs_Set_the_uid_and_gid' => 'Set the uid and gid if you want all requests appear to be from one user or one group, otherwise leave blank',
'nfs Hello PARAMS' => 'Hello PARAMS' 'nfs_File_system_permissions' => 'File system permissions',
'nfs_Information Bay name' => 'Information Bay name' 'nfs_Browse_the_parent_folders' => 'Browse the parent folders',

View File

@ -56,6 +56,13 @@ our $ddb = esmith::DomainsDB->open() || die("Couldn't open Domains db");
} }
</tal:block> </tal:block>
sub create_link{
# WIP
my ($c,$route, $panel, $index) = shift;
my $link = "$route?trt=$panel&Selected=$index";
return $link;
}
1; 1;

View File

@ -135,6 +135,7 @@
route:"TABLE", route:"TABLE",
Header: 'NFS Share Contrib', Header: 'NFS Share Contrib',
SubHeader: 'Manage NFS Ibay settings:', SubHeader: 'Manage NFS Ibay settings:',
Nextpanel: 'PARAMS',
Table1: { Table1: {
Type:"Table", Type:"Table",
TableControl:"ibays", TableControl:"ibays",

View File

@ -377,22 +377,49 @@ if __name__ == "__main__":
all_strings = all_strings + extracted_strings all_strings = all_strings + extracted_strings
#Take out any duplicates #Take out any duplicates
all_strings = deduplicate_array(all_strings) all_strings = deduplicate_array(all_strings)
# Now process them one by one into the lexical file
lex_all = "";
# '<prefix>_english-message' => 'English Message', # '<prefix>_english-message' => 'English Message',
string_lib = [] #Array of dicts
for lex_message in all_strings: for lex_message in all_strings:
# If has a prefix - leave it for left hand side but delete it for the right # If has a prefix - leave it for left hand side but delete it for the right
# If has no prefix - add one for left hand side but and lkeave it for the right # If has no prefix - add one for left hand side but and leave it for the right
# Map all spaces to "_" on left hand side
# amd truncate it to max five words
original_str = lex_message
if lex_message.startswith(hl('prefix')): if lex_message.startswith(hl('prefix')):
left_str = lex_message left_str = lex_message
right_str = lex_message[len(hl('prefix'))+1:] right_str = lex_message[len(hl('prefix'))+1:]
else: else:
left_str = hl('prefix')+"_"+lex_message left_str = hl('prefix')+"_"+lex_message
right_str = lex_message right_str = lex_message
lex_all += f"'{left_str}' => '{right_str}'\n" left_str = left_str.replace(" ","_")
words = left_str.split('_')[:6]
left_str = "_".join(words)
next_lex_str = {"orig":original_str,"left":left_str,"right":right_str}
string_lib.append(next_lex_str)
print(string_lib)
#And write it to lex file #And write it to lex file
# Now process them one by one into the lexical file
lex_all = "";
for lex_str in string_lib:
lex_all += f"\'{lex_str['left']}\' => \'{lex_str['right']}\',\n"
print(f"Writing {lex_file}")
with open( lex_file, 'w') as file: with open( lex_file, 'w') as file:
file.write(lex_all) file.write(lex_all)
#and then play the strings back into the partials and the layout file
for filename in all_files:
with open(filename, 'r') as file:
file_content = file.read()
# Scan through
for item in string_lib:
original_str = item["orig"]
left_str = item["left"]
right_str = item["right"]
# Replace all occurrences of original string with left string in 'contents'
file_content = file_content.replace(original_str, left_str)
# and write it back
with open(filename, 'w') as file:
file.write(file_content)