From ee476f4f091a8e94c328f94d6f5fa1e5e14c66d1 Mon Sep 17 00:00:00 2001 From: b Date: Mon, 29 Jan 2024 22:26:58 +0000 Subject: [PATCH] fix ONG; fix update; total reset --- ong.1.pl | 1 + reset.1.pl | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++- update.1.pl | 21 ++++++++++++++++++- 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/ong.1.pl b/ong.1.pl index c5a24eb..6c3ecf3 100644 --- a/ong.1.pl +++ b/ong.1.pl @@ -135,6 +135,7 @@ if ($ongstate == STATE->{'ready'}) { ); # %goto_list = read_data_file(DATA_LIST_PATH()); + %new_state = %state; $new_state{'last'} = $frame; $new_state{'state'} = 1; $new_state{'ip1'} = ''; diff --git a/reset.1.pl b/reset.1.pl index c43e368..a7ee374 100644 --- a/reset.1.pl +++ b/reset.1.pl @@ -32,7 +32,8 @@ use botm_common ( ); use bsta_lib ( 'STATE', 'INTF_STATE', 'CHAT_STATE', - 'write_index' + 'write_index', + 'merge_settings' ); binmode STDIN, ':encoding(UTF-8)'; @@ -42,13 +43,18 @@ decode_argv(); ###PERL_PATH_SEPARATOR: PATH_SEPARATOR = / +###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/ +###PERL_DATA_ATTACH_PATH: DATA_ATTACH_PATH = /botm/data/bsta/a ###PERL_DATA_CHAT_PATH: DATA_CHAT_PATH = /botm/data/bsta/chat +###PERL_DATA_DEFAULT_PATH: DATA_DEFAULT_PATH = /botm/data/bsta/default ###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/state ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state ###PERL_DATA_STORY_PATH: DATA_STORY_PATH = /botm/data/bsta/story ###PERL_DATA_WORDS_PATH: DATA_WORDS_PATH = /botm/data/bsta/words/ +###PERL_WWW_PATH: WWW_PATH = /botm/www/ + ###PERL_RESET_PASSWORD: RESET_PASSWORD = '' my %story; @@ -56,6 +62,9 @@ my %state; my %chat; my %settings; my %goto_list; +my %default; +my $last_frame; +my @remove_list; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin; @@ -71,6 +80,47 @@ unless ( exit 1; } +$last_frame = int($settings{'last'}); +%default = read_data_file(DATA_DEFAULT_PATH()); + +for (my $frame=0; $frame<=$last_frame; $frame+=1) { + my %frame_data =read_data_file( + join_path(PATH_SEPARATOR(), DATA_PATH(), $frame) + ); + %frame_data = merge_settings(\%default, \%frame_data); + unless ($frame == 0) { + push @remove_list, ( + ($frame_data{'page'} ne '') ? + $frame_data{'page'} : + sprintf( + $settings{'frame'}, + $frame, 'htm' + ) + ); + } + push @remove_list, ( + ($frame_data{'frame'} ne '') ? + $frame_data{'frame'} : + sprintf( + $settings{'frame'}, + $frame, $frame_data{'ext'} + ) + ); +} +push @remove_list, 'goto.htm'; +for (my $i=0; ;$i+=1) { + my %file_data; + + %file_data = read_data_file(DATA_ATTACH_PATH().$i); + if ($file_data{'frame'} eq '') { + last; + } + if ($file_data{'content'} ne '') { + next; + } + push @remove_list, $file_data{'filename'}; +} + %state = ( 'state' => STATE->{'inactive'}, 'last' => 0, @@ -115,6 +165,12 @@ if (opendir_encoded(my $dir, DATA_WORDS_PATH())) { next; } my $full_path = join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $file_name); + # print "RM $full_path\n"; unlink_encoded ($full_path); } } +foreach my $file_name (@remove_list) { + my $full_path = join_path(PATH_SEPARATOR(), WWW_PATH(), $file_name); + # print "RM $full_path\n"; + unlink_encoded ($full_path); +} diff --git a/update.1.pl b/update.1.pl index 1cc7803..a5f0c5e 100644 --- a/update.1.pl +++ b/update.1.pl @@ -24,7 +24,7 @@ use utf8; use Encode::Locale ('decode_argv'); use Encode ('encode', 'decode'); -use lib '/botm/lib/test-bsta'; +###PERL_LIB: use lib /botm/lib/bsta use botm_common ( 'read_data_file', 'join_path' @@ -99,6 +99,23 @@ foreach my $id (@ARGV) { } } +# duplicated - before AND after normal pages! +if ($update_goto) { + print 'static GOTO'; + my $r = write_static_goto( + \%state, + \%settings, + '' # \%goto_list + ); + if ($r) { + print " OK\n"; + } + else { + print " FAIL\n"; + $fail += 1; + } +} + foreach my $id (@list) { print "ONG $id\n"; my $r = ong( @@ -118,6 +135,8 @@ foreach my $id (@list) { } make_static_pages($id); } + +# duplicated - before AND after normal pages! if ($update_goto) { print 'static GOTO'; my $r = write_static_goto( -- 2.30.2