]> bicyclesonthemoon.info Git - ott/bsta/commitdiff
started work to support comment in viewer
authorb <rowerynaksiezycu@gmail.com>
Sat, 6 Jan 2024 13:07:56 +0000 (13:07 +0000)
committerb <rowerynaksiezycu@gmail.com>
Sat, 6 Jan 2024 13:07:56 +0000 (13:07 +0000)
botm-common
bsta.css
bsta_lib.1.pm
makefile
makefile.1.mak
settings.txt
viewer.1.pl

index 92789f87d558991f3b602fcc553ddc37cfe83b5c..6b4b21b9139670faf83bb894ec378d49ecc6acdc 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 92789f87d558991f3b602fcc553ddc37cfe83b5c
+Subproject commit 6b4b21b9139670faf83bb894ec378d49ecc6acdc
index d5a3ce2ce1278ffdcc57e97c72eed4788fc34670..f03fb825c8f817a15f8c0e3b6c38e6956a195772 100644 (file)
--- a/bsta.css
+++ b/bsta.css
@@ -93,6 +93,17 @@ div#title
        margin: 0px;
 }
 
+div.title
+{
+       text-align: center;
+       padding-top: 21px;
+       padding-bottom: 21px;
+       padding-left: 0px;
+       padding-right: 0px;
+       border: 0px;
+       margin: 0px;
+}
+
 h1#titletext
 {
        margin: 0px;
@@ -100,6 +111,13 @@ h1#titletext
        padding: 0px;
 }
 
+h1.titletext
+{
+       margin: 0px;
+       border: 0px;
+       padding: 0px;
+}
+
 div#storypuzzle
 {
        text-align: left;
@@ -193,6 +211,14 @@ div#undertext
        border: 0px;
 }
 
+div.undertext
+{
+       text-align: left;
+       padding: 8px;
+       margin: 0px;
+       border: 0px;
+}
+
 div#chat
 {
        text-align: left;
@@ -225,6 +251,39 @@ div.tq:hover
        border-color: #bb6622;
 }
 
+div.comment
+{
+       text-align: left;
+       border: solid #0057af 4px;
+       background-color: #0057af;
+}
+
+div.comment:hover
+{
+       border-color: #bb6622;
+       background-color: #bb6622;
+}
+
+div.commentinfo
+{
+       color: #ffffff!important;
+       /* font-weight: bold; */
+}
+
+div.commenttext
+{
+       background-color: #ffffff;
+       color: #000000;
+}
+
+div.space
+{
+       background-color: #46a3ff;
+       height: 27px;
+       margin-top: 27px;
+       margin-bottom: 27px;
+}
+
 div#command
 {
        text-align: left;
index 575ec16c0fb668e42373285e0ccff974698b9521..2f1581d5383f486d4eebc7221b8378df153b0d51 100644 (file)
@@ -123,6 +123,7 @@ use constant TEXT_MODE => {
        'normal' => 0,
        'bb'     => 1,
        'info'   => 2,
+       'words'  => 3
 };
 use constant CHAT_STATE => {
        'disconnected' => 0,
@@ -846,6 +847,7 @@ sub print_html_data {
        print $fh html_encode_line("\n".$data->{'content'});
 }
 
+# TODO: previous page preload?
 sub print_viewer_page {
        (
                my $file,
@@ -853,7 +855,8 @@ sub print_viewer_page {
                my $state,
                my $settings,
                my $frame_data,
-               my $next_frame_data
+               my $next_frame_data,
+               my $words_data,
        ) = @_;
        my $fh;
        
@@ -866,6 +869,7 @@ sub print_viewer_page {
        my $text_mode      = int($context->{'text_mode'});
        my $timer_unlocked = int($context->{'timer_unlocked'});
        my $timer          = int($context->{'timer'});
+       my $words_page     = int($context->{'words_page'});
        
        # my $prev_frame = $frame - 1;
        my $next_frame = $frame + 1;
@@ -910,6 +914,9 @@ sub print_viewer_page {
                $timer_s = 'EE';
        }
        
+       my $words_posts = int($words_data->{'posts'});
+       my $words_link_text = 'Words'.(($words_posts > 0) ? "[$words_posts]" : '');
+       
        my $prev_available = (($frame > 0) && $access);
        my $next_available = ($launch || $password_ok || ($next_frame <= $last_frame));
        my $prefetch_next  = (
@@ -1000,6 +1007,12 @@ sub print_viewer_page {
                                'b' => TEXT_MODE->{'info'}
                        }}
                );
+       my $words_url = merge_url (
+               $viewer_url,
+               {'query'=>{
+                       'b' => TEXT_MODE->{'words'}
+               }}
+       );
        my $frame_file;
        my $frame_url;
        my $frame_next_url;
@@ -1050,6 +1063,7 @@ sub print_viewer_page {
                $password_query = url_query_encode({'p', $settings->{'password'}});
                $goto_url        = merge_url($goto_url       , {'query' => $password_query, 'append_query' => 1});
                $info_url        = merge_url($info_url       , {'query' => $password_query, 'append_query' => 1});
+               $words_url       = merge_url($words_url      , {'query' => $password_query, 'append_query' => 1});
                $bbcode_url      = merge_url($bbcode_url     , {'query' => $password_query, 'append_query' => 1});
                $viewer_url      = merge_url($viewer_url     , {'query' => $password_query, 'append_query' => 1});
                $viewer_0_url    = merge_url($viewer_0_url   , {'query' => $password_query, 'append_query' => 1});
@@ -1066,6 +1080,7 @@ sub print_viewer_page {
        my $_base_url        = html_entity_encode_dec($base_url       , 1);
        my $_goto_url        = html_entity_encode_dec($goto_url       , 1);
        my $_info_url        = html_entity_encode_dec($info_url       , 1);
+       my $_words_url       = html_entity_encode_dec($words_url      , 1);
        my $_bbcode_url      = html_entity_encode_dec($bbcode_url     , 1);
        my $_timer_url       = html_entity_encode_dec($timer_url      , 1);
        my $_viewer_full_url = html_entity_encode_dec($viewer_full_url, 1);
@@ -1210,7 +1225,10 @@ sub print_viewer_page {
        }
        print $fh '<a href="'.$_goto_url.'">GOTO</a>'."\n";
        print $fh '     <span style="float: right;">'."\n      ";
-       if ($text_mode != TEXT_MODE->{'normal'}) {
+       if ($text_mode == TEXT_MODE->{'normal'}) {
+               print $fh '<a href="'.$_words_url.'">'.$words_link_text.'</a> | ';
+       }
+       else {
                print $fh '<a href="'.$_viewer_url.'">Without</a> | ';
        }
        print $fh '<a href="'.$_info_url.'">Info</a> | ';
@@ -1220,6 +1238,10 @@ sub print_viewer_page {
        print $fh "    </div>\n";
        print $fh "   </div>\n";
        
+       if ($text_mode == TEXT_MODE->{'words'}) {
+               # TODO: HERE PRINT COMMENTS
+       }
+       
        print_html_body_end($fh, $ong_state == STATE->{'inactive'});
        print_html_end($fh);
        
@@ -1255,6 +1277,13 @@ sub write_index {
                my %frame_data     = read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 0));
                my %next_frame_data= read_data_file(join_path(PATH_SEPARATOR(), DATA_PATH(), 1));
                my %default        = read_data_file(DATA_DEFAULT_PATH());
+               my %words_data     = read_data_file(
+                       join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), 0),
+                       '', # encoding
+                       0,  # no header
+                       1,  # header only
+                       1,  # as list
+               );
                
                %frame_data     = merge_settings(\%default,      \%frame_data);
                %next_frame_data= merge_settings(\%default, \%next_frame_data);
@@ -1262,19 +1291,22 @@ sub write_index {
                $r = print_viewer_page(
                        $fh,
                        {
-                               'launch' => 0,
-                               'frame' => 0,
-                               'access' => 1,
-                               'password_ok' => 0,
+                               'launch'         => 0,
+                               'frame'          => 0,
+                               'access'         => 1,
+                               'password_ok'    => 0,
                                'timer_unlocked' => 3, # not relevant
-                               'timer' => 0, # not relevant
-                               'static' => 1,
-                               'show_command' => 1
+                               'timer'          => 0, # not relevant
+                               'static'         => 1,
+                               'show_command'   => 1,
+                               'text_mode'      => TEXT_MODE->{'normal'},
+                               'words_page'     => 0 # not relevant
                        },
                        $state,
                        $settings,
                        \%frame_data,
-                       \%next_frame_data
+                       \%next_frame_data,
+                       \%words_data
                );
        }
        # no conditions met, pretend a normal Apache2 index
@@ -1341,19 +1373,22 @@ sub write_index {
                        $r = print_viewer_page(
                                $fh,
                                {
-                                       'launch' => 1,
-                                       'frame' => 0,
-                                       'access' => 1,
-                                       'password_ok' => 0,
+                                       'launch'         => 1,
+                                       'frame'          => 0,
+                                       'access'         => 1,
+                                       'password_ok'    => 0,
                                        'timer_unlocked' => 3,
-                                       'timer' => 0,
-                                       'static' => 1,
-                                       'show_command' => 1,
+                                       'timer'          => 0,
+                                       'static'         => 1,
+                                       'show_command'   => 1,
+                                       'text_mode'      => TEXT_MODE->{'normal'},
+                                       'words_page'     => 0 # not relevant
                                },
                                $state,
                                $settings,
                                \%frame_data,
-                               \%next_frame_data
+                               \%next_frame_data,
+                               {'posts' => 0} # words_data
                        );
                        return $r;
                }
index 36db1a77dcae416393b842d4a809cf03bc24bc28..3f30f89bb7e7f7268091b149b608907d62ba500b 100644 (file)
--- a/makefile
+++ b/makefile
@@ -33,12 +33,13 @@ PERL =/usr/bin/perl
 RM   =/usr/bin/rm
 SUDO =/usr/bin/sudo
 
-BIN_PATH  = /botm/bin/test-bsta
-DATA_PATH = /botm/data/test-bsta
-LIB_PATH  = /botm/lib/test-bsta
-LOG_PATH  = /botm/log/test-bsta
-TMP_PATH  = /botm/tmp/test-bsta
-WWW_PATH  = /botm/www/1190/bstatest
+BIN_PATH        = /botm/bin/test-bsta
+DATA_PATH       = /botm/data/test-bsta
+DATA_WORDS_PATH = /botm/data/test-bsta/words
+LIB_PATH        = /botm/lib/test-bsta
+LOG_PATH        = /botm/log/test-bsta
+TMP_PATH        = /botm/tmp/test-bsta
+WWW_PATH        = /botm/www/1190/bstatest
 
 CONF = /botm/etc/www/conf/1190/test-bsta.conf
 CRON = /etc/cron.d/test-bsta
@@ -87,6 +88,7 @@ viewer.pl
 DIR=\
 $(BIN_PATH)\
 $(DATA_PATH)\
+$(DATA_WORDS_PATH)\
 $(LIB_PATH)\
 $(LOG_PATH)\
 $(TMP_PATH)\
@@ -94,6 +96,7 @@ $(WWW_PATH)
 
 HIDDEN_DIR=\
 $(DATA_PATH)\
+$(DATA_WORDS_PATH)\
 $(TMP_PATH)
 
 SETUID=\
index e4d82af56bba52b35f7913810c6c6ed4133cc3f5..260980405e423b782d661692e18d6a20c5bef98d 100644 (file)
@@ -33,12 +33,13 @@ PERL = perl
 ###MAKE_RM:    RM    = rm
 ###MAKE_SUDO:  SUDO  = sudo
 
-###MAKE_BIN_PATH:  BIN_PATH  = /botm/bin/bsta
-###MAKE_DATA_PATH: DATA_PATH = /botm/data/bsta
-###MAKE_LIB_PATH:  LIB_PATH  = /botm/lib/bsta
-###MAKE_LOG_PATH:  LOG_PATH  = /botm/log/bsta
-###MAKE_TMP_PATH:  TMP_PATH  = /botm/tmp/bsta
-###MAKE_WWW_PATH:  WWW_PATH  = /botm/www/1190/bsta
+###MAKE_BIN_PATH:        BIN_PATH        = /botm/bin/bsta
+###MAKE_DATA_PATH:       DATA_PATH       = /botm/data/bsta
+###MAKE_DATA_WORDS_PATH: DATA_WORDS_PATH = /botm/data/bsta/words
+###MAKE_LIB_PATH:        LIB_PATH        = /botm/lib/bsta
+###MAKE_LOG_PATH:        LOG_PATH        = /botm/log/bsta
+###MAKE_TMP_PATH:        TMP_PATH        = /botm/tmp/bsta
+###MAKE_WWW_PATH:        WWW_PATH        = /botm/www/1190/bsta
 
 ###MAKE_CONF: CONF = /botm/etc/www/conf/1190/bsta.conf
 ###MAKE_CRON: CRON = /etc/cron.d/bsta
@@ -87,6 +88,7 @@ viewer.pl
 DIR=\
 $(BIN_PATH)\
 $(DATA_PATH)\
+$(DATA_WORDS_PATH)\
 $(LIB_PATH)\
 $(LOG_PATH)\
 $(TMP_PATH)\
@@ -94,6 +96,7 @@ $(WWW_PATH)
 
 HIDDEN_DIR=\
 $(DATA_PATH)\
+$(DATA_WORDS_PATH)\
 $(TMP_PATH)
 
 SETUID=\
index 14643788e372be53dd7a68371387ac46cfe49374..abd46c1df76a00d1a611654749d616b4e50754a0 100644 (file)
@@ -63,6 +63,7 @@ _data_noaccess_path = @_PATH( $data_path, noaccess   )
 _data_settings_path = @_PATH( $data_path, settings   )
 _data_state_path    = @_PATH( $data_path, state      )
 _data_story_path    = @_PATH( $data_path, story      )
+_data_words_path    = @_PATH( $data_path, words      )
 
 _log_path           = @_PATH( $log_path,        )
 _log_ong_path       = @_PATH( $log_path, ong.log)
@@ -128,12 +129,13 @@ MAKE_CF    = CF   =$CF
 MAKE_CONF = CONF = $_conf_path
 MAKE_CRON = CRON = $_cron_path
 
-MAKE_BIN_PATH  = BIN_PATH  = $bin_path
-MAKE_DATA_PATH = DATA_PATH = $data_path
-MAKE_LIB_PATH  = LIB_PATH  = $lib_path
-MAKE_LOG_PATH  = LOG_PATH  = $log_path
-MAKE_TMP_PATH  = TMP_PATH  = $tmp_path
-MAKE_WWW_PATH  = WWW_PATH  = $www_path
+MAKE_BIN_PATH        = BIN_PATH        = $bin_path
+MAKE_DATA_PATH       = DATA_PATH       = $data_path
+MAKE_DATA_WORDS_PATH = DATA_WORDS_PATH = $_data_words_path
+MAKE_LIB_PATH        = LIB_PATH        = $lib_path
+MAKE_LOG_PATH        = LOG_PATH        = $log_path
+MAKE_TMP_PATH        = TMP_PATH        = $tmp_path
+MAKE_WWW_PATH        = WWW_PATH        = $www_path
 
 
 PERL_LIB = @_PERL_USE_2(lib, @_PERL_STR($lib_path))
@@ -167,6 +169,7 @@ PERL_DATA_NOACCESS_PATH = @_PERL_CONSTANT_STR( DATA_NOACCESS_PATH, $_data_noacce
 PERL_DATA_SETTINGS_PATH = @_PERL_CONSTANT_STR( DATA_SETTINGS_PATH, $_data_settings_path)
 PERL_DATA_STATE_PATH    = @_PERL_CONSTANT_STR( DATA_STATE_PATH   , $_data_state_path   )
 PERL_DATA_STORY_PATH    = @_PERL_CONSTANT_STR( DATA_STORY_PATH   , $_data_story_path   )
+PERL_DATA_WORDS_PATH    = @_PERL_CONSTANT_STR( DATA_WORDS_PATH   , $_data_words_path   )
 
 PERL_LOG_PATH           = @_PERL_CONSTANT_STR( LOG_PATH, $_log_path)
 
index 9c5364ad9c7d1f064288a19c702288798b829034..f58229d99d2c9c88ee4d45a4367ece939c9920ac 100644 (file)
@@ -50,6 +50,7 @@ use bsta_lib (
 ###PERL_DATA_SETTINGS_PATH: DATA_SETTINGS_PATH = /botm/data/bsta/settings
 ###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/
 
 binmode STDIN,  ':encoding(UTF-8)';
 binmode STDOUT, ':encoding(UTF-8)';
@@ -68,6 +69,7 @@ my %settings;
 my %state;
 my %new_state;
 my %goto_list;
+my %words_data;
 
 my $method;
 my $frame;
@@ -83,6 +85,8 @@ my $state_file;
 my $show_command;
 my $ongtime;
 my $text_mode;
+my $words_page;
+my $words_data_path;
 
 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
 ###PERL_SET_PATH: $ENV{'PATH'} = /usr/local/bin:/usr/bin:/bin;
@@ -274,9 +278,19 @@ else {
 }
 
 $text_mode = int($cgi{'b'});
-if($text_mode > 2) {
+if($text_mode > TEXT_MODE->{'words'}) {
        $text_mode = TEXT_MODE->{'normal'};
 }
+$words_page = int($cgi{'i'});
+
+$words_data_path = join_path(PATH_SEPARATOR(), DATA_WORDS_PATH(), $frame);
+%words_data = read_data_file(
+       $words_data_path, # file
+       '', # encoding
+       0,  # no header
+       ($text_mode != TEXT_MODE->{'words'}), # header only
+       1,  # as list
+);
 
 print "Content-type: text/html\n";
 if(!$access) {
@@ -299,9 +313,11 @@ print_viewer_page (
                'static'        => 0,
                'show_command'  => $show_command,
                'text_mode'     => $text_mode,
+               'words_page'    => $words_page
        },
        \%state,
        \%settings,
        \%frame_data,
-       \%next_frame_data
+       \%next_frame_data,
+       \%words_data,
 );