1 ###RUN_PERL: #!/usr/bin/perl
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 ###PERL_LIB: use lib /botm/lib/bsta
35 'write_index', 'write_static_viewer_page'
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 = ();
60 my $ong_state = int($state{'state'});
61 my $last_frame = ($ong_state > STATE->{'inactive'}) ?
71 foreach my $id (@ARGV) {
75 for (my $f=0; $f<=$last_frame; $f+=1) {
79 elsif ($id =~ /^[0-9]+$/) {
81 if ($f <= $last_frame) {
85 print "$f > $last_frame\n";
89 elsif ($id =~ /^[ic]$/) {
98 foreach my $id (@list) {
103 '', # timer value; not relevant
115 make_static_pages($id);
123 unless ($id =~ /^[0-9]+$/) {
128 unless (($f >= 0) && ($f <= $last_frame)) {
132 my $r = $all_frame_data{$f};
137 my %frame_data = read_data_file(
138 join_path(PATH_SEPARATOR(), DATA_PATH(), $f)
140 $all_frame_data{$f} = \%frame_data;
147 unless ($id =~ /^[0-9]+$/) {
152 unless (($f >= 0) && ($f <= $last_frame)) {
156 my $r = $all_words_data{$f};
161 my %frame_data = read_data_file(
162 join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $f),
166 1, # as list; not relevant
168 $all_words_data{$f} = \%frame_data;
172 sub make_static_page {
174 unless ($id =~ /^[0-9]+$/) {
178 unless (($f >= 0) && ($f <= $last_frame)) {
183 if (($f == 0) && ($ong_state > STATE->{'inactive'})) {
189 print (($r) ? " OK\n" : " FAIL\n");
192 print 'static page '.$f;
193 $r = write_static_viewer_page (
199 get_frame_data($f-1),
200 get_frame_data($f+1),
203 print (($r) ? " OK\n" : " FAIL\n");
207 sub make_static_pages {
209 unless ($id =~ /^[0-9]+$/) {
213 unless (($f >= 0) && ($f <= $last_frame)) {
217 make_static_page($f);
218 make_static_page($f-1);
219 make_static_page($f+1);
220 make_static_page($f);