3 # update.pl is generated from update.1.pl.
5 # update already ONGed frames & stuff
7 # Copyright (C) 2016, 2017, 2023, 2024 Balthasar SzczepaĆski
9 # This program is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU Affero General Public License as
11 # published by the Free Software Foundation, either version 3 of the
12 # License, or (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU Affero General Public License for more details.
19 # You should have received a copy of the GNU Affero General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 use Encode::Locale ('decode_argv');
25 use Encode ('encode', 'decode');
27 use lib '/botm/lib/test-bsta';
35 'write_index', 'write_static_viewer_page', 'write_static_goto'
38 ###PERL_PATH_SEPARATOR: PATH_SEPARATOR = /
40 ###PERL_DATA_PATH: DATA_PATH = /botm/data/bsta/
41 ###PERL_DATA_DEFAULT_PATH: DATA_DEFAULT_PATH = /botm/data/bsta/default
42 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
43 ###PERL_DATA_STATE_PATH: DATA_STATE_PATH = /botm/data/bsta/state
44 ###PERL_DATA_WORDS_PATH: DATA_WORDS_PATH = /botm/data/bsta/words/
46 binmode STDIN, ':encoding(UTF-8)';
47 binmode STDOUT, ':encoding(UTF-8)';
48 binmode STDERR, ':encoding(UTF-8)';
54 my %settings = read_data_file(DATA_SETTINGS_PATH());
55 my %default = read_data_file(DATA_DEFAULT_PATH());
56 my %state = read_data_file(DATA_STATE_PATH());
57 my %all_frame_data = ();
58 my %all_words_data = ();
62 my $ong_state = int($state{'state'});
63 my $last_frame = ($ong_state > STATE->{'inactive'}) ?
73 foreach my $id (@ARGV) {
78 for (my $f=0; $f<=$last_frame; $f+=1) {
82 elsif ($id =~ /^[0-9]+$/) {
85 if ($f <= $last_frame) {
89 print "$f > $last_frame\n";
93 elsif ($id =~ /^[ic]$/) {
102 foreach my $id (@list) {
107 '', # timer value; not relevant
119 make_static_pages($id);
123 my $r = write_static_goto(
143 unless ($id =~ /^[0-9]+$/) {
148 unless (($f >= 0) && ($f <= $last_frame)) {
152 my $r = $all_frame_data{$f};
157 my %frame_data = read_data_file(
158 join_path(PATH_SEPARATOR(), DATA_PATH(), $f)
160 $all_frame_data{$f} = \%frame_data;
167 unless ($id =~ /^[0-9]+$/) {
172 unless (($f >= 0) && ($f <= $last_frame)) {
176 my $r = $all_words_data{$f};
181 my %frame_data = read_data_file(
182 join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $f),
186 1, # as list; not relevant
188 $all_words_data{$f} = \%frame_data;
192 sub make_static_page {
194 unless ($id =~ /^[0-9]+$/) {
200 ($f < $last_frame-1) || (
201 ($ong_state >= STATE->{'ready'}) &&
202 ($f <= $last_frame-1)
204 ($ong_state >= STATE->{'end'}) &&
213 if (($f == 0) && ($ong_state > STATE->{'inactive'})) {
219 print (($r) ? " OK\n" : " FAIL\n");
222 print 'static page '.$f;
223 $r = write_static_viewer_page (
229 get_frame_data($f-1),
230 get_frame_data($f+1),
233 print (($r) ? " OK\n" : " FAIL\n");
237 sub make_static_pages {
239 unless ($id =~ /^[0-9]+$/) {
243 unless (($f >= 0) && ($f <= $last_frame)) {
247 make_static_page($f);
248 make_static_page($f-1);
249 make_static_page($f+1);
250 make_static_page($f);