From 87908530ec89790e69c0b194ecbc301717932a07 Mon Sep 17 00:00:00 2001 From: b Date: Mon, 29 Jan 2024 21:14:52 +0000 Subject: [PATCH] static GOTO --- bsta_lib.1.pm | 169 +++++++++++++++++++++++++++++- goto.1.pl | 138 +++++-------------------- ong.1.pl | 280 ++++++++++++++++++++++++++------------------------ settings.txt | 6 +- update.1.pl | 38 ++++++- viewer.1.pl | 11 +- 6 files changed, 384 insertions(+), 258 deletions(-) diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index 262d852..7b8c37d 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -45,7 +45,7 @@ our @EXPORT_OK = ( 'print_html_start', 'print_html_end', 'print_html_head_start', 'print_html_head_end', 'print_html_body_start', 'print_html_body_end', - 'print_viewer_page', + 'print_viewer_page', 'print_goto', 'write_index', 'write_static_viewer_page', 'write_static_goto', 'ong', 'eval_bb', 'bb_to_bbcode', 'bb_to_html' @@ -77,6 +77,7 @@ use botm_common ( ###PERL_CGI_FRAME_PATH: CGI_FRAME_PATH = /bsta/f ###PERL_CGI_GOTO_PATH: CGI_GOTO_PATH = /bsta/g ###PERL_CGI_INFO_PATH: CGI_INFO_PATH = /bsta/i +###PERL_CGI_LIST_PATH: CGI_LIST_PATH = /bsta/goto.htm ###PERL_CGI_LOGO_PATH: CGI_LOGO_PATH = /bsta/botmlogo.png ###PERL_CGI_TIMER_PATH: CGI_TIMER_PATH = /bsta/timer.js ###PERL_CGI_VIEWER_PATH: CGI_VIEWER_PATH = /bsta/v @@ -88,10 +89,12 @@ use botm_common ( ###PERL_DATA_DEFAULT_PATH: DATA_DEFAULT_PATH = /botm/data/bsta/default ###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list ###PERL_DATA_NOACCESS_PATH: DATA_NOACCESS_PATH = /botm/data/bsta/noaccess +###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state ###PERL_DATA_WORDS_PATH: DATA_WORDS_PATH = /botm/data/bsta/words/ ###PERL_WWW_PATH: WWW_PATH = /botm/www/ +###PERL_WWW_GOTO_PATH: WWW_GOTO_PATH = /botm/www/1190/bsta/goto.htm ###PERL_WWW_INDEX_PATH: WWW_INDEX_PATH = /botm/www/1190/bsta/index.htm ###PERL_SCHEME: SCHEME = http @@ -873,6 +876,146 @@ sub print_html_data { print $fh html_encode_line("\n".$data->{'content'}); } +sub print_goto { + ( + my $file, + my $state, + my $settings, + my $goto_list, + my $password_ok, + ) = @_; + + my $fh; + my $last_frame; + my $ong_state; + my $password_query; + + $last_frame = int($state->{'last'}); + $ong_state = int($state->{'state'}); + $password_query = url_query_encode({'p', $settings->{'password'}}); + + my $_title = html_entity_encode_dec($settings->{'story'}, 1); + my $_website_name = html_entity_encode_dec(WEBSITE_NAME() , 1); + my $_base_url = html_entity_encode_dec(CGI_PATH() , 1); + + if (ref($file)) { + $fh=$file; + unless (seek($fh, 0, 0)) { + #don't actually fail here + } + } + else { + unless (open_encoded($fh, ">:encoding(UTF-8)", $file)) { + return 0; + } + } + + print_html_start($fh); + print_html_head_start($fh); + + print $fh ' GOTO • '.$_title.' • '.$_website_name.''."\n"; + + print_html_head_end($fh); + print_html_body_start($fh); + + print $fh '
'."\n"; + + print $fh '
'."\n"; + print $fh '

'.$_title.'

'."\n"; + print $fh '
'."\n"; + + print $fh '
'."\n"; + print $fh '
'."\n"; + + print $fh '
'."\n"; + + for (my $frame = 0; ; $frame += 1) { + unless ( + $password_ok || ( + ($frame <= $last_frame) && + ($ong_state >= STATE->{'waiting'}) + ) + ) { + last; + } + my $title; + my $ongtime; + my @time_tab; + my $time_text; + my $timer_color; + my $frame_text; + my $viewer_url; + + $ongtime = $goto_list->{'ongtime-'.$frame}; + $title = $goto_list->{'title-' .$frame}; + if (($ongtime eq '') && ($title eq '')) { + my $frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame); + my %frame_data = read_data_file($frame_data_path); + $ongtime = $frame_data{'ongtime'}; + $title = $frame_data{'title'}; + unless (keys %frame_data) { + last; + } + } + + if ($ongtime ne '') { + @time_tab = gmtime($ongtime); + $time_text = sprintf( + '%02d.%02d.%02d %02d:%02d', + $time_tab[3], + $time_tab[4]+1, + $time_tab[5]%100, + $time_tab[2], + $time_tab[1] + ); + } + else { + $time_text = (($frame <= $last_frame) && ($ong_state >= STATE->{'waiting'})) ? + 'EE.EE.EE EE:EE' : '--.--.-- --:--'; + } + if ($title eq '') { + $title = '_'; + } + $timer_color = (($frame > $last_frame) || ($ong_state < STATE->{'waiting'})) ? + 'cz' : ( + (($frame == $last_frame) && ($ong_state < STATE->{'ready'})) ? + 'ni' : 'br' + ); + $frame_text = sprintf('%03d',$frame); + $viewer_url = merge_url( + {'path' => CGI_VIEWER_PATH()}, + {'path' => $frame} + ); # TODO: consider static here? + if ($password_ok) { + $viewer_url = merge_url($viewer_url, {'query' => $password_query, 'append_query' => 1, 'preserve_fragment' => 1}); + } + + my $_viewer_url = html_entity_encode_dec($viewer_url, 1); + my $_title = html_entity_encode_dec($title , 1); + + print $fh ' '.$frame_text.' '.$time_text.' '.$_title.'
'."\n"; + } + print $fh '
'."\n"; + + print $fh ' '."\n"; + + print $fh '
'."\n"; + + print_html_body_end($fh, $ong_state == STATE->{'inactive'}); + print_html_end($fh); + + unless (ref($file)) { + close ($fh); + } + else { + truncate ($fh , tell($fh)); + } + + return 1; +} + sub print_viewer_page { ( my $file, @@ -1065,6 +1208,9 @@ sub print_viewer_page { ); } } + if (_x_encoded('-f',WWW_GOTO_PATH())) { + $goto_url = CGI_LIST_PATH(); + } } my $bbcode_url = ($text_mode == TEXT_MODE->{'bb'}) ? merge_url( @@ -2000,7 +2146,28 @@ sub write_static_viewer_page { } sub write_static_goto { + (my $state_ref, my $settings_ref, my $goto_ref) = @_; + my %state; + my %settings; + my %goto_list; + %state = (ref ($state_ref)) ? + %$state_ref : + read_data_file(DATA_STATE_PATH()); + %settings = (ref ($settings_ref)) ? + %$settings_ref : + read_data_file(DATA_SETTINGS_PATH()); + %goto_list = (ref ($goto_ref)) ? + %$goto_ref : + read_data_file(DATA_SETTINGS_PATH()); + + return print_goto( + WWW_GOTO_PATH(), + \%state, + \%settings, + \%goto_list, + 0, # password OK + ); } # ONG the frame + attachment & stuff. NOT update state file. diff --git a/goto.1.pl b/goto.1.pl index a126160..80dcf16 100644 --- a/goto.1.pl +++ b/goto.1.pl @@ -29,25 +29,22 @@ use Encode ('encode', 'decode'); use botm_common ( 'read_header_env', 'read_data_file', - 'url_query_encode', 'url_query_decode', - 'merge_url', - 'join_path', - 'html_entity_encode_dec' + 'url_query_decode', + '_x_encoded' ); use bsta_lib ( 'STATE', 'fail_method', 'fail_content_type', + 'redirect', 'get_password', - 'print_html_start', 'print_html_end', - 'print_html_head_start', 'print_html_head_end', - 'print_html_body_start', 'print_html_body_end', - 'write_index', + 'print_goto', 'merge_settings' ); ###PERL_PATH_SEPARATOR: PATH_SEPARATOR = / ###PERL_CGI_PATH: CGI_PATH = /bsta/ +###PERL_CGI_LIST_PATH: CGI_LIST_PATH = /bsta/goto.htm ###PERL_CGI_VIEWER_PATH: CGI_VIEWER_PATH = /bsta/v ###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/ @@ -55,6 +52,8 @@ use bsta_lib ( ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state ###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list +###PERL_WWW_GOTO_PATH: WWW_GOTO_PATH = /botm/www/1190/bsta/goto.htm + ###PERL_WEBSITE_NAME: WEBSITE_NAME = Bicycles on the Moon binmode STDIN, ':encoding(UTF-8)'; @@ -74,11 +73,7 @@ my %goto_list; my $method; my $password; my $password_ok; -my $password_query; -my $frame; -my $last_frame; -my $ong_state; -my $line; +my $no_cgi; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin; @@ -104,17 +99,21 @@ if ($method eq 'POST') { } } +$no_cgi = (scalar (keys %cgi) == 0); + +if ($no_cgi) { + if (_x_encoded('-f', WWW_GOTO_PATH())) { + exit redirect($method, CGI_LIST_PATH()); + } +} + $password = get_password(\%cgi); %settings = read_data_file(DATA_SETTINGS_PATH()); %state = read_data_file(DATA_STATE_PATH()); %goto_list = read_data_file(DATA_LIST_PATH()); -$last_frame = int($state{'last'}); -$ong_state = int($state{'state'}); - $password_ok = ($password eq $settings{'password'}); -$password_query = url_query_encode({'p', $settings{'password'}}); print "Content-type: text/html; charset=UTF-8\n"; print "\n"; @@ -122,101 +121,10 @@ if($method eq 'HEAD') { exit; } -my $_title = html_entity_encode_dec($settings{'story'}, 1); -my $_website_name = html_entity_encode_dec(WEBSITE_NAME() , 1); -my $_base_url = html_entity_encode_dec(CGI_PATH() , 1); - -print_html_start(\*STDOUT); -print_html_head_start(\*STDOUT); - -print ' GOTO • '.$_title.' • '.$_website_name.''."\n"; - -print_html_head_end(\*STDOUT); -print_html_body_start(\*STDOUT); - -print '
'."\n"; - -print '
'."\n"; -print '

'.$_title.'

'."\n"; -print '
'."\n"; - -print '
'."\n"; -print '
'."\n"; - -print '
'."\n"; -for ($frame = 0; ; $frame += 1) { - unless ( - $password_ok || ( - ($frame <= $last_frame) && - ($ong_state >= STATE->{'waiting'}) - ) - ) { - last; - } - my $title; - my $ongtime; - my @time_tab; - my $time_text; - my $timer_color; - my $frame_text; - my $viewer_url; - - $ongtime = $goto_list{'ongtime-'.$frame}; - $title = $goto_list{'title-' .$frame}; - if (($ongtime eq '') && ($title eq '')) { - my $frame_data_path = join_path(PATH_SEPARATOR(), DATA_PATH(), $frame); - my %frame_data = read_data_file($frame_data_path); - $ongtime = $frame_data{'ongtime'}; - $title = $frame_data{'title'}; - unless (keys %frame_data) { - last; - } - } - - if ($ongtime ne '') { - @time_tab = gmtime($ongtime); - $time_text = sprintf( - '%02d.%02d.%02d %02d:%02d', - $time_tab[3], - $time_tab[4]+1, - $time_tab[5]-100, # TODO: %100 ? - $time_tab[2], - $time_tab[1] - ); - } - else { - $time_text = (($frame <= $last_frame) && ($ong_state >= STATE->{'waiting'})) ? - 'EE.EE.EE EE:EE' : '--.--.-- --:--'; - } - if ($title eq '') { - $title = '_'; - } - $timer_color = (($frame > $last_frame) || ($ong_state < STATE->{'waiting'})) ? - 'cz' : ( - (($frame == $last_frame) && ($ong_state < STATE->{'ready'})) ? - 'ni' : 'br' - ); - $frame_text = sprintf('%03d',$frame); - $viewer_url = merge_url( - {'path' => CGI_VIEWER_PATH()}, - {'path' => $frame} - ); - if ($password_ok) { - $viewer_url = merge_url($viewer_url, {'query' => $password_query, 'append_query' => 1, 'preserve_fragment' => 1}); - } - - my $_viewer_url = html_entity_encode_dec($viewer_url, 1); - my $_title = html_entity_encode_dec($title , 1); - - print ' '.$frame_text.' '.$time_text.' '.$_title.'
'."\n"; -} -print '
'."\n"; - -print ' '."\n"; - -print '
'."\n"; - -print_html_body_end(\*STDOUT, $ong_state == STATE->{'inactive'}); -print_html_end(\*STDOUT); +print_goto( + \*STDOUT, + \%state, + \%settings, + \%goto_list, + $password_ok +); diff --git a/ong.1.pl b/ong.1.pl index 8c243c0..c5a24eb 100644 --- a/ong.1.pl +++ b/ong.1.pl @@ -33,13 +33,14 @@ use botm_common ( use bsta_lib ( 'STATE', 'ong', - 'write_static_viewer_page', 'write_index' + 'write_static_viewer_page', 'write_index', 'write_static_goto' ); ###PERL_PATH_SEPARATOR: PATH_SEPARATOR = / ###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/ ###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/settings ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state @@ -53,9 +54,13 @@ srand ($time-$$); my %settings; my %state; -my %goto_list; +my %new_state; +# my %goto_list; my %default; my %frame_data; +my %frame_1_data; +my %frame_2_data; +my %frame_3_data; my $fh; my $ongstate; @@ -75,142 +80,147 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin; unless (open_encoded($fh, "+<:encoding(UTF-8)", DATA_STATE_PATH())) { - print "NO STATEFILE\n"; + print "NO STATEFILE\n\n"; + exit; +} +unless (flock($fh, 2)) { + print "NO STATELOCK\n\n"; + close ($fh); + exit; +} +%state = read_data_file($fh); +$ongstate = int($state{'state'}); +print 'state: '.$ongstate."\n"; +unless ($ongstate > STATE->{'inactive'}) { + print "INACTIVE\n\n"; + close ($fh); + exit; +} +$next_ong = int($state{'nextong'}); +print 'ongtime: '.$next_ong."\n"; + +unless ($ongtime >= $next_ong) { + print "WAIT\n\n"; + close ($fh); + exit; +} + +%settings = read_data_file(DATA_SETTINGS_PATH()); +$static_timer = int($settings{'ongtime'}); +$timer = int($settings{'dynamicongtime'}); +$last = int($settings{'last'}); +$frame = int($state {'last'})+1; + +if (($timer > 0) && ($frame < $last)) { + $timer = int($timer / ($last - $frame)); } else { - unless (flock($fh, 2)) { - print "NO STATELOCK\n"; + $timer=0; +} + +if ($static_timer > $timer) { + $timer = $static_timer; +} +$next_ong = $ongtime + ($timer*3600); +$state{'nextong'} = $next_ong; +print 'next ongtime: '.$next_ong.' (+'.$timer.")\n"; +$state{'ongtime'}=$timer; + +if ($ongstate == STATE->{'ready'}) { + print 'next frame: '.$frame."\n"; + + %default = read_data_file(DATA_DEFAULT_PATH()); + %frame_data = read_data_file( + join_path(PATH_SEPARATOR(), DATA_PATH(), $frame) + ); + # %goto_list = read_data_file(DATA_LIST_PATH()); + + $new_state{'last'} = $frame; + $new_state{'state'} = 1; + $new_state{'ip1'} = ''; + $new_state{'ip2'} = ''; + $new_state{'ip3'} = ''; + $new_state{'ongtime'}= $timer; + + if ($frame >= 1) { + %frame_1_data = read_data_file( + join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-1) + ); + } + if ($frame >= 2) { + %frame_2_data = read_data_file( + join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-2) + ); + } + if ($frame >= 3) { + %frame_3_data = read_data_file( + join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-3) + ); + } + + $r = ong ( + $frame, # frame ID + $time, # ONG time + $timer, # timer to next ONG + 0, # update + 1, # print + \%settings, + \%default, + \%frame_data, + '' # \%goto_list + ); + if ($r && ($frame >= 2)) { + print 'static page '.($frame-1); + $r = write_static_viewer_page( + $frame-1, # frame ID + \%new_state, + \%settings, + \%default, + \%frame_1_data, # frame data + \%frame_2_data, # prev frame data + \%frame_data, # next frame data + '' # words data + ); + print (($r) ? " OK\n" : " FAIL\n"); + } + if ($r && ($frame >= 3)) { + print 'static page '.($frame-2); + $r = write_static_viewer_page( + $frame-2, # frame ID + \%new_state, + \%settings, + \%default, + \%frame_2_data, # frame data + \%frame_3_data, # prev frame data + \%frame_1_data, # next frame data + '' # words data + ); + print (($r) ? " OK\n" : " FAIL\n"); + } + if ($r && ($frame <= 2)) { + print 'index'; + $r = write_index( + \%new_state, + \%settings + ); + print (($r) ? " OK\n" : " FAIL\n"); + } + if ($r) { + print 'static GOTO'; + $r = write_static_goto( + \%new_state, + \%settings, + '' # \%goto_list + ); + print (($r) ? " OK\n" : " FAIL\n"); + } + if ($r) { + %state = %new_state; + print "ONG\n\n"; } else { - %state = read_data_file($fh); - $ongstate = int($state{'state'}); - print 'state: '.$ongstate."\n"; - unless ($ongstate > STATE->{'inactive'}) { - print "INACTIVE\n"; - } - else { - $next_ong = int($state{'nextong'}); - print 'ongtime: '.$next_ong."\n"; - - unless ($ongtime >= $next_ong) { - print "WAIT\n"; - } - else { - %settings = read_data_file(DATA_SETTINGS_PATH()); - $static_timer = int($settings{'ongtime'}); - $timer = int($settings{'dynamicongtime'}); - $last = int($settings{'last'}); - $frame = int($state {'last'})+1; - - if (($timer > 0) && ($frame < $last)) { - $timer = int($timer / ($last - $frame)); - } - else { - $timer=0; - } - - if ($static_timer > $timer) { - $timer = $static_timer; - } - $next_ong = $ongtime + ($timer*3600); - $state{'nextong'} = $next_ong; - print 'next ongtime: '.$next_ong.' (+'.$timer.")\n"; - $state{'ongtime'}=$timer; - - if ($ongstate == STATE->{'ready'}) { - print 'next frame: '.$frame."\n"; - - %default = read_data_file(DATA_DEFAULT_PATH()); - %frame_data = read_data_file( - join_path(PATH_SEPARATOR(), DATA_PATH(), $frame) - ); - - $r = ong ( - $frame, # frame ID - $time, # ONG time - $timer, # timer to next ONG - 0, # update - 1, # print - \%settings, - \%default, - \%frame_data, - '' # %goto_list - ); - if ($r) { - $state{'last'} = $frame; - $state{'state'} = 1; - $state{'ip1'} = ''; - $state{'ip2'} = ''; - $state{'ip3'} = ''; - $state{'ongtime'}= $timer; - print "ONG\n"; - - my %frame_1_data; - my %frame_2_data; - my %frame_3_data; - if ($frame >= 1) { - %frame_1_data = read_data_file( - join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-1) - ); - } - if ($frame >= 2) { - %frame_2_data = read_data_file( - join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-2) - ); - } - if ($frame >= 3) { - %frame_3_data = read_data_file( - join_path(PATH_SEPARATOR(), DATA_PATH(), $frame-3) - ); - } - if ($frame >= 2) - { - print 'static page '.($frame-1); - $r = write_static_viewer_page( - $frame-1, # frame ID - \%state, - \%settings, - \%default, - \%frame_1_data, # frame data - \%frame_2_data, # prev frame data - \%frame_data, # next frame data - '' # words data - ); - print (($r) ? " OK\n" : " FAIL\n"); - } - if ($frame >= 3) - { - print 'static page '.($frame-2); - $r = write_static_viewer_page( - $frame-2, # frame ID - \%state, - \%settings, - \%default, - \%frame_2_data, # frame data - \%frame_3_data, # prev frame data - \%frame_1_data, # next frame data - '' # words data - ); - print (($r) ? " OK\n" : " FAIL\n"); - } - if ($frame <= 2) { - print 'index'; - $r = write_index( - \%state, - \%settings - ); - print (($r) ? " OK\n" : " FAIL\n"); - } - } - else { - print "NO ONG\n"; - } - } - write_data_file($fh, \%state); - } - } + print "NO ONG\n\n"; } - close ($fh); } - -print "\n"; \ No newline at end of file +write_data_file($fh, \%state); +close ($fh); diff --git a/settings.txt b/settings.txt index ea00785..fb52921 100644 --- a/settings.txt +++ b/settings.txt @@ -50,6 +50,7 @@ _cgi_css_path = @_PATH( $cgi_path, bsta.css ) _cgi_frame_path = @_PATH( $cgi_path, f ) _cgi_goto_path = @_PATH( $cgi_path, g ) _cgi_info_path = @_PATH( $cgi_path, i ) +_cgi_list_path = @_PATH( $cgi_path, goto.htm ) _cgi_logo_path = @_PATH( $cgi_path, botmlogo.png) _cgi_timer_path = @_PATH( $cgi_path, timer.js ) _cgi_viewer_path = @_PATH( $cgi_path, v ) @@ -73,6 +74,7 @@ _log_spam_path = @_PATH( $log_path, words_spam.log) _log_words_path = @_PATH( $log_path, words.log ) _www_path = @_PATH( $www_path, ) +_www_goto_path = @_PATH( $www_path, goto.htm ) _www_index_path = @_PATH( $www_path, index.htm) _conf_path = @_PATH($conf_path, $name\.conf) @@ -161,10 +163,11 @@ PERL_CGI_CSS_PATH = @_PERL_CONSTANT_STR( CGI_CSS_PATH , $_cgi_css_path PERL_CGI_FRAME_PATH = @_PERL_CONSTANT_STR( CGI_FRAME_PATH , $_cgi_frame_path ) PERL_CGI_GOTO_PATH = @_PERL_CONSTANT_STR( CGI_GOTO_PATH , $_cgi_goto_path ) PERL_CGI_INFO_PATH = @_PERL_CONSTANT_STR( CGI_INFO_PATH , $_cgi_info_path ) +PERL_CGI_LIST_PATH = @_PERL_CONSTANT_STR( CGI_LIST_PATH , $_cgi_list_path ) PERL_CGI_LOGO_PATH = @_PERL_CONSTANT_STR( CGI_LOGO_PATH , $_cgi_logo_path ) PERL_CGI_TIMER_PATH = @_PERL_CONSTANT_STR( CGI_TIMER_PATH , $_cgi_timer_path ) PERL_CGI_VIEWER_PATH = @_PERL_CONSTANT_STR( CGI_VIEWER_PATH, $_cgi_viewer_path) -PERL_CGI_WORDS_PATH = @_PERL_CONSTANT_STR( CGI_WORDS_PATH, $_cgi_words_path) +PERL_CGI_WORDS_PATH = @_PERL_CONSTANT_STR( CGI_WORDS_PATH , $_cgi_words_path ) PERL_DATA_PATH = @_PERL_CONSTANT_STR( DATA_PATH , $_data_path ) PERL_DATA_ATTACH_PATH = @_PERL_CONSTANT_STR( DATA_ATTACH_PATH , $_data_attach_path ) @@ -183,6 +186,7 @@ PERL_LOG_SPAM_PATH = @_PERL_CONSTANT_STR( LOG_SPAM_PATH , $_log_spam_path ) PERL_LOG_WORDS_PATH = @_PERL_CONSTANT_STR( LOG_WORDS_PATH, $_log_words_path) PERL_WWW_PATH = @_PERL_CONSTANT_STR( WWW_PATH , $_www_path ) +PERL_WWW_GOTO_PATH = @_PERL_CONSTANT_STR( WWW_GOTO_PATH , $_www_goto_path ) PERL_WWW_INDEX_PATH = @_PERL_CONSTANT_STR( WWW_INDEX_PATH, $_www_index_path) PERL_SCHEME = @_PERL_CONSTANT_STR( SCHEME , $scheme ) diff --git a/update.1.pl b/update.1.pl index fb6766c..1cc7803 100644 --- a/update.1.pl +++ b/update.1.pl @@ -1,4 +1,4 @@ -###RUN_PERL: #!/usr/bin/perl +#!/usr/bin/perl # update.pl is generated from update.1.pl. # @@ -24,7 +24,7 @@ use utf8; use Encode::Locale ('decode_argv'); use Encode ('encode', 'decode'); -###PERL_LIB: use lib /botm/lib/bsta +use lib '/botm/lib/test-bsta'; use botm_common ( 'read_data_file', 'join_path' @@ -32,7 +32,7 @@ use botm_common ( use bsta_lib ( 'STATE', 'ong', - 'write_index', 'write_static_viewer_page' + 'write_index', 'write_static_viewer_page', 'write_static_goto' ); ###PERL_PATH_SEPARATOR: PATH_SEPARATOR = / @@ -57,6 +57,8 @@ my %state = read_data_file(DATA_STATE_PATH()); my %all_frame_data = (); my %all_words_data = (); +my $update_goto = 0; + my $ong_state = int($state{'state'}); my $last_frame = ($ong_state > STATE->{'inactive'}) ? int($state{'last'}) : @@ -70,6 +72,7 @@ print $time."\n"; foreach my $id (@ARGV) { if ($id eq 'all') { + $update_goto = 1; push @list, 'i'; push @list, 'c'; for (my $f=0; $f<=$last_frame; $f+=1) { @@ -77,6 +80,7 @@ foreach my $id (@ARGV) { } } elsif ($id =~ /^[0-9]+$/) { + $update_goto = 1; my $f = int($&); if ($f <= $last_frame) { push @list, $f @@ -114,6 +118,22 @@ foreach my $id (@list) { } make_static_pages($id); } +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; + } +} + print "\n"; @@ -175,7 +195,17 @@ sub make_static_page { return; } my $f = int($id); - unless (($f >= 0) && ($f <= $last_frame)) { + unless ( + ($f >= 0) && ( + ($f < $last_frame-1) || ( + ($ong_state >= STATE->{'ready'}) && + ($f <= $last_frame-1) + ) || ( + ($ong_state >= STATE->{'end'}) && + ($f <= $last_frame) + ) + ) + ) { return; } my $r; diff --git a/viewer.1.pl b/viewer.1.pl index 4e8cc0e..280a0f9 100644 --- a/viewer.1.pl +++ b/viewer.1.pl @@ -41,7 +41,7 @@ use bsta_lib ( 'fail_method', 'fail_content_type', 'redirect', 'get_remote_addr', 'get_frame', 'get_password', 'merge_settings', - 'print_viewer_page', 'write_index', + 'print_viewer_page', 'write_index', 'write_static_goto', 'ong' ); @@ -52,6 +52,7 @@ use bsta_lib ( ###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/ ###PERL_DATA_DEFAULT_PATH: DATA_DEFAULT_PATH = /botm/data/bsta/default +###PERL_DATA_LIST_PATH: DATA_LIST_PATH = /botm/data/bsta/list ###PERL_DATA_NOACCESS_PATH: DATA_NOACCESS_PATH = /botm/data/bsta/noaccess ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state @@ -177,9 +178,11 @@ if (open_encoded($fh, "+<:encoding(UTF-8)", DATA_STATE_PATH())) { elsif ($state{'ip3'} eq '') { $new_state{'ip3'} = $IP; $new_state{'state'} = STATE->{'ready'}; + write_static_goto(\%new_state, \%settings, ''); } else { $new_state{'state'} = STATE->{'ready'}; + write_static_goto(\%new_state, \%settings, ''); } write_data_file($fh, \%new_state); } @@ -195,6 +198,7 @@ if (open_encoded($fh, "+<:encoding(UTF-8)", DATA_STATE_PATH())) { my $r; %story = read_data_file(DATA_STORY_PATH()); + %goto_list = read_data_file(DATA_LIST_PATH()); if ( (int($story{'state'}) == INTF_STATE->{'>|'} ) && @@ -222,11 +226,14 @@ if (open_encoded($fh, "+<:encoding(UTF-8)", DATA_STATE_PATH())) { \%settings, \%default, \%frame_data, - '' # %goto_list + \%goto_list ); if ($r) { $r = write_index(\%state, \%settings); } + if ($r) { + $r = write_static_goto(\%state, \%settings, \%goto_list); + } if ($r) { $r = write_data_file($fh, \%state); } -- 2.30.2