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 = ' ';
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,

View File

@ -2,7 +2,7 @@
# Routines to be editted by the developer to provide validation for parameters
# 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;
@ -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;

View File

@ -1,6 +1,6 @@
% 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
<div id="module" class="module Nfsshare-panel">

View File

@ -1,6 +1,6 @@
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
@ -67,7 +67,7 @@ sub main {
$c->app->log->info( $c->log_req );
my %nfs_data = ();
my $title = $c->l("nfs_NFS data share");
my $title = $c->l("nfs_NFS_data_share");
my $modul = '';
$nfs_data{'trt'} = 'TABLE';
@ -119,7 +119,7 @@ sub do_update {
$c->app->log->info($c->log_req);
my %nfs_data = ();
my $title = $c->l("nfs_NFS data share");
my $title = $c->l("nfs_NFS_data_share");
# Accessing all POST parameters
my %params = $c->req->params->to_hash;
@ -167,7 +167,7 @@ sub do_update {
$c->stash(error => $c->l($ret));
$c->render("Nfsshare");
} 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->render("Nfsshare");
} 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);
my %nfs_data = ();
my $title = $c->l("nfs_NFS data share");
my $title = $c->l("nfs_NFS_data_share");
# Accessing all POST parameters
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">
<script>
@ -8,9 +8,9 @@
};
</script>
<h2>
%= l("nfs Hello PARAMS");
%= l("nfs_Hello_PARAMS");
</h2>
% my $btn = l('APPLY');
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
% param 'trt' => $nfs_data->{trt} unless param 'trt';
@ -20,17 +20,17 @@
<h2>Manage NFS Ibay settings:</h2>
<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><span class=label>
%=l('nfs_Information Bay name'), class => 'label'
%=l('nfs_Information_Bay_name'), class => 'label'
</span><span class=data>
%= stash("IbayName"), class => 'data'
</span></p>
<p><span class=label>
%=l('nfs_Share owner Group')
%=l('nfs_Share_owner_Group')
</span><span class=data>
% my @ShareOwnerGrp_options = ['Write = admin, Read = group', 'Write = group, Read = everyone', 'Write = group, Read = group'];
% param 'ShareOwnerGrp' => $nfs_data->{ShareOwnerGrp} unless param 'ShareOwnerGrp';
@ -38,7 +38,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Enable the NFS Share')
%=l('nfs_Enable_the_NFS_Share')
</span><span class=data>
% my @EnableNFSshare_options = ['Disabled', 'Enabled'];
% param 'EnableNFSshare' => $nfs_data->{EnableNFSshare} unless param 'EnableNFSshare';
@ -46,7 +46,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_EnableShare on local network')
%=l('nfs_EnableShare_on_local_network')
</span><span class=data>
% my @ShareOnLocalNetwork_options = ['Disabled', 'Enabled'];
% param 'ShareOnLocalNetwork' => $nfs_data->{ShareOnLocalNetwork} unless param 'ShareOnLocalNetwork';
@ -54,18 +54,18 @@
<br></span> </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>
<span class=label>
%=l('nfs_NFS Client(s) allowed')
%=l('nfs_NFS_Client(s)_allowed')
</span><span class=data>
% param 'NFSClientsAllowed' => $nfs_data->{NFSClientsAllowed} unless param 'NFSClientsAllowed';
%= text_area 'NFSClientsAllowed', cols=>40, rows=>5
</span><br>
<p><span class=label>
%=l('nfs_File system permissions')
%=l('nfs_File_system_permissions')
</span><span class=data>
% my @FileSystemPermissions_options = ['Read only', 'Read and Write'];
% param 'FileSystemPermissions' => $nfs_data->{FileSystemPermissions} unless param 'FileSystemPermissions';
@ -73,7 +73,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Write (a)synchronously')
%=l('nfs_Write_(a)synchronously')
</span><span class=data>
% my @WriteAsync_options = ['Synchronous', 'Asynchronous'];
% param 'WriteAsync' => $nfs_data->{WriteAsync} unless param 'WriteAsync';
@ -81,7 +81,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Delays the disk writing')
%=l('nfs_Delays_the_disk_writing')
</span><span class=data>
% my @DelayWrite_options = ['Write delay', 'No write delay'];
% param 'DelayWrite' => $nfs_data->{DelayWrite} unless param 'DelayWrite';
@ -89,7 +89,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Squash the power of users')
%=l('nfs_Squash_the_power_of_users')
</span><span class=data>
% my @Squash_options = ['All users squash', 'No root squash', 'root squash'];
% param 'Squash' => $nfs_data->{Squash} unless param 'Squash';
@ -97,7 +97,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Browse the parent folders')
%=l('nfs_Browse_the_parent_folders')
</span><span class=data>
% my @BrowseParents_options = ['Hide folder', 'Show folder'];
% param 'BrowseParents' => $nfs_data->{BrowseParents} unless param 'BrowseParents';
@ -105,7 +105,7 @@
<br></span> </p>
<p><span class=label>
%=l('nfs_Requests on secure ports')
%=l('nfs_Requests_on_secure_ports')
</span><span class=data>
% my @SecurePorts_options = ['Secure', 'Insecure'];
% param 'SecurePorts' => $nfs_data->{SecurePorts} unless param 'SecurePorts';
@ -113,25 +113,25 @@
<br></span> </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><span class=label>
%=l('nfs_Set the UID.')
%=l('nfs_Set_the_UID.')
</span><span class=data>
% param 'SetUID' => $nfs_data->{SetUID} unless param 'SetUID';
%= text_field 'SetUID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetUID'
<br></span></p>
<p><span class=label>
%=l('nfs_Set the GID.')
%=l('nfs_Set_the_GID.')
</span><span class=data>
% param 'SetGID' => $nfs_data->{SetGID} unless param 'SetGID';
%= text_field 'SetGID', size => '50', class => 'input' , pattern=>'.*' , placeholder=>'SetGID'
<br></span></p>
<span class='data'>
%= submit_button l('Save'), class => 'action'
%= submit_button l('nfs_Save'), class => 'action'
</span>
%# 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">
<script>
@ -8,9 +8,9 @@
};
</script>
<h2>
%= l("nfs Hello TABLE");
%= l("nfs_Hello_TABLE");
</h2>
% my $btn = l('APPLY');
% my $btn = l('nfs_APPLY');
%= form_for "Nfsshared" => (method => 'POST') => begin
% param 'trt' => $nfs_data->{trt} unless param 'trt';

View File

@ -1,23 +1,23 @@
'nfs_Requests on secure ports' => 'Requests on secure ports'
'nfs_APPLY' => 'APPLY'
'nfs_EnableShare on local network' => 'EnableShare on local network'
'nfs_Set the GID.' => 'Set the GID.'
'nfs_Save' => 'Save'
'nfs_Share owner Group' => 'Share owner Group'
'nfs_Browse the parent folders' => 'Browse the parent folders'
'nfs Hello TABLE' => 'Hello TABLE'
'nfs_File system permissions' => 'File system permissions'
'nfs_Delays the disk writing' => 'Delays the disk writing'
'nfs_NFS data share' => 'NFS data share'
'nfs_Set the UID.' => 'Set the UID.'
'nfs_NFS Client(s) allowed' => 'NFS Client(s) allowed'
'nfs_TABLE panel action was successfull' => 'TABLE panel action was successfull'
'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_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_Write (a)synchronously' => 'Write (a)synchronously'
'nfs_Squash the power of users' => 'Squash the power of users'
'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_Enable the NFS Share' => 'Enable the NFS Share'
'nfs_PARAMS panel action was successfull' => 'PARAMS panel action was successfull'
'nfs Hello PARAMS' => 'Hello PARAMS'
'nfs_Information Bay name' => 'Information Bay name'
'nfs_Enable_the_NFS_Share' => 'Enable the NFS Share',
'nfs_Hello_TABLE' => 'Hello TABLE',
'nfs_Write_(a)synchronously' => 'Write (a)synchronously',
'nfs_NFS_Client(s)_allowed' => 'NFS Client(s) allowed',
'nfs_Save' => 'Save',
'nfs_Information_Bay_name' => 'Information Bay name',
'nfs_Hello_PARAMS' => 'Hello PARAMS',
'nfs_NFS_data_share' => 'NFS data share',
'nfs_Share_owner_Group' => 'Share owner Group',
'nfs_APPLY' => 'APPLY',
'nfs_Set_the_GID.' => 'Set the GID.',
'nfs_PARAMS_panel_action_was_successfull' => 'PARAMS panel action was successfull',
'nfs_Requests_on_secure_ports' => 'Requests on secure ports',
'nfs_Squash_the_power_of_users' => 'Squash the power of users',
'nfs_Set_the_UID.' => 'Set the UID.',
'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_Delays_the_disk_writing' => 'Delays the disk writing',
'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_TABLE_panel_action_was_successfull' => 'TABLE panel action was successfull',
'nfs_EnableShare_on_local_network' => 'EnableShare on local network',
'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_File_system_permissions' => 'File system permissions',
'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>
sub create_link{
# WIP
my ($c,$route, $panel, $index) = shift;
my $link = "$route?trt=$panel&Selected=$index";
return $link;
}
1;

View File

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

View File

@ -377,23 +377,50 @@ if __name__ == "__main__":
all_strings = all_strings + extracted_strings
#Take out any duplicates
all_strings = deduplicate_array(all_strings)
# Now process them one by one into the lexical file
lex_all = "";
# '<prefix>_english-message' => 'English Message',
string_lib = [] #Array of dicts
for lex_message in all_strings:
# 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')):
left_str = lex_message
right_str = lex_message[len(hl('prefix'))+1:]
else:
left_str = hl('prefix')+"_"+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
# 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:
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)