]> bicyclesonthemoon.info Git - ott/bsta/commitdiff
html output generator: bbcode, info, content parts mostly
authorb <rowerynaksiezycu@gmail.com>
Fri, 29 Sep 2023 22:33:01 +0000 (22:33 +0000)
committerb <rowerynaksiezycu@gmail.com>
Fri, 29 Sep 2023 22:33:01 +0000 (22:33 +0000)
botm-common
bsta_lib.1.pm
settings-again.txt
settings-bsta.txt
settings-debug.txt
settings-tbst.txt
settings.txt

index 6881684b6dcb50d6d9e77584aadf3eaa47dd096c..bd6107e790c6666a87a0e9f2bec9370868bf531b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6881684b6dcb50d6d9e77584aadf3eaa47dd096c
+Subproject commit bd6107e790c6666a87a0e9f2bec9370868bf531b
index eca8565b97473006fa22bd6a9bfa6daf6d64c852..a91aa6864281e568b704b0dc011b8d28e73c87c7 100644 (file)
@@ -825,7 +825,7 @@ sub convtree {
 }
 
 #bbcode to html, TBD
-sub bb2ht {
+sub bb_to_html {
        (my $bb, my $printdebug) = @_;
        my $ht;
        my %bbtree;
@@ -835,173 +835,10 @@ sub bb2ht {
        ($debug, $ht) = convtree ($printdebug, $debug, 'html', %bbtree);
        
        return $ht;
-       
-       # $level=0;
-       # $ind='_';
-       # $ht='';
-       # $debug .= debug($printdebug, "\n<!--PROCESSING BBCODE TREE:\n");
-       
-       # while ($level >=0) {
-               # $debug .= debug($printdebug, "[$level:$ind:".int($bbtree{$ind.'.e'})."]");
-               # if($bbtree{$ind.'.t'} eq 'tx') {
-                       # $debug .= debug($printdebug, "text: ".$bbtree{$ind.'.v'});
-                       # $ht = $ht.html_encode_line($bbtree{$ind.'.v'});
-                       
-                       # {do{
-                               # $ind =~ s/\.([0-9]+)$//;
-                               # $indd = int($1)+1;
-                               # if ($indd < $bbtree{$ind.'.e'}){
-                                       # $ind = $ind.'.'.$indd;
-                                       # last;
-                               # }
-                               # else {
-                                       # #should not occur with a correct bbtree
-                                       # $debug .= debug($printdebug, "[<tx]");
-                                       # $level -= 1;
-                               # }
-                       # } while ($level>=0);}
-               # }
-               # elsif($bbtree{$ind.'.t'} eq 'tg') {
-                       # if($bbtree{$ind.'.n'} =~ /^\//) {
-                               # $debug .= debug($printdebug, "tag: [".$bbtree{$ind.'.n'}."]");
-                               # if($bbtree{$ind.'.n'} eq '/ht') {
-                                       # #
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} =~ /^\/(fq|tq)$/) {
-                                       # $ht = $ht.'</div>';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} =~ /^\/(br|ni|po)$/) {
-                                       # $ht = $ht.'</span>';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} eq '/url') {
-                                       # $ht = $ht.'</a>';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} eq '/i') {
-                                       # $ht = $ht.'</i>';
-                               # }
-                               # else { #unimpl.
-                                       # $ht = $ht.'['.html_encode_line($bbtree{$ind.'.n'}).']';
-                                       # $debug .= debug($printdebug, "[unknown!]");
-                               # }
-                               # $ind =~ s/\.([0-9]+)$//;
-                               # $level -= 1;
-                               # $debug .= debug($printdebug, "[<]");
-                               # if($level>=0) {
-                                       # {do{
-                                               # $ind =~ s/\.([0-9]+)$//;
-                                               # $indd = int($1)+1;
-                                               # if ($indd < $bbtree{$ind.'.e'}){
-                                                       # $ind = $ind.'.'.$indd;
-                                                       # last;
-                                               # }
-                                               # else {
-                                                       # #should not occur with a correct bbtree
-                                                       # $debug .= debug($printdebug, "[<nd]");
-                                                       # $level -= 1;
-                                               # }
-                                       # } while ($level>=0);}
-                               # }
-                               # else {
-                                       # # time to end this
-                                       # $level = -1;
-                               # }
-                       # }
-                       # else {
-                               # if($bbtree{$ind.'.c'} ne '') {
-                                       # if($bbtree{$ind.'.n'} eq 'ht') {
-                                               # #
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'fq') {
-                                               # $ht = $ht.'<div class="fq">';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'tq') {
-                                               # $ht = $ht.'<div class="tq">';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'br') {
-                                               # $ht = $ht.'<span class="br">';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'ni') {
-                                               # $ht = $ht.'<span class="ni">';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'po') {
-                                               # $ht = $ht.'<span class="po">';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'i') {
-                                               # $ht = $ht.'<i>';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'url') {
-                                               # $ht = $ht.'<a href="'.entityencode($bbtree{$ind.'.v'}).'">';
-                                       # }
-                                       # else { #unimpl.
-                                               # $ht = $ht.'['.html_encode_line($bbtree{$ind.'.n'}).(($bbtree{$ind.'.v'} ne '' )?entityencode($bbtree{$ind.'.v'}):'').']';
-                                               # $debug .= debug($printdebug, "[unknown!]");
-                                       # }
-                               # }
-                               # else {
-                                       # $debug .= debug($printdebug, "unclosed tag: [".$bbtree{$ind.'.n'}."]");
-                                       # $ht = $ht.'['.html_encode_line($bbtree{$ind.'.n'}).']';
-                               # }
-                               # if($bbtree{$ind.'.e'}>0) {
-                                       # $ind = $ind.'.0';
-                                       # $level += 1;
-                                       # $debug .= debug($printdebug, "[>]");
-                               # }
-                               # else {
-                                       # {do{
-                                               # $ind =~ s/\.([0-9]+)$//;
-                                               # $indd = int($1)+1;
-                                               # if ($indd < $bbtree{$ind.'.e'}){
-                                                       # $ind = $ind.'.'.$indd;
-                                                       # last;
-                                               # }
-                                               # else {
-                                                       # #should not occur with a correct bbtree
-                                                       # $debug .= debug($printdebug, "[<st]");
-                                                       # $level -= 1;
-                                               # }
-                                       # } while ($level>=0);}
-                               # }
-                       # }
-               # }
-               # else {
-                       # $debug .= debug($printdebug, "unknown thing: ".$bbtree{$ind.'.t'});
-                       # #should not occur with a correct bbtree
-                       # #unless unimplemented
-                       # $ind =~ s/\.([0-9]+)$//;
-                       # $level -= 1;
-                       # $debug .= debug($printdebug, "[<ui]");
-                       # if($level>0) {
-                               # {do{
-                                       # $ind =~ s/\.([0-9]+)$//;
-                                       # $indd = int($1)+1;
-                                       # if ($indd < $bbtree{$ind.'.e'}){
-                                               # $ind = $ind.'.'.$indd;
-                                               # last;
-                                       # }
-                                       # else {
-                                               # #should not occur with a correct bbtree
-                                               # $debug .= debug($printdebug, "[<un]");
-                                               # $level -= 1;
-                                       # }
-                               # } while ($level>=0);}
-                       # }
-                       # else {
-                               # # time to end this
-                               # $level = -1;
-                       # }
-               # }
-               # $debug .= debug($printdebug, "[>$level:$ind]\n");
-       # }
-       
-       # $debug .= debug($printdebug, "-->\n");
-       # # print $debug;
-       
-       
-       
 }
 
 #bbcode to bb, TBD
-sub bb2bb {
+sub bb_to_bbcode {
        (my $bb, my $printdebug) = @_;
        my $ht;
        my %bbtree;
@@ -1011,167 +848,56 @@ sub bb2bb {
        ($debug, $ht) = convtree ($printdebug, $debug, 'bb', %bbtree);
        
        return $ht;
+}
+
+# TO REMOVE
+sub bb2ht {
+       return bb_to_html(@_);
+}
+
+# TO REMOVE
+sub bb2bb {
+       return bb_to_bbcode(@_);
+}
+
+sub eval_bb {
+       (my $bb) = @_;
+       my $value;
+       my $before;
+       my $after;
        
-       # $level=0;
-       # $ind='_';
-       # $ht='';
-       # $debug .= debug($printdebug, "\n<!--PROCESSING BBCODE TREE:\n");
-       
-       # while ($level >=0) {
-               # $debug .= debug($printdebug, "[$level:$ind:".int($bbtree{$ind.'.e'})."]");
-               # if($bbtree{$ind.'.t'} eq 'tx') {
-                       # $debug .= debug($printdebug, "text: ".$bbtree{$ind.'.v'});
-                       # $ht = $ht.$bbtree{$ind.'.v'};
-                       
-                       # {do{
-                               # $ind =~ s/\.([0-9]+)$//;
-                               # $indd = int($1)+1;
-                               # if ($indd < $bbtree{$ind.'.e'}){
-                                       # $ind = $ind.'.'.$indd;
-                                       # last;
-                               # }
-                               # else {
-                                       # #should not occur with a correct bbtree
-                                       # $debug .= debug($printdebug, "[<tx]");
-                                       # $level -= 1;
-                               # }
-                       # } while ($level>=0);}
-               # }
-               # elsif($bbtree{$ind.'.t'} eq 'tg') {
-                       # if($bbtree{$ind.'.n'} =~ /^\//) {
-                               # $debug .= debug($printdebug, "tag: [".$bbtree{$ind.'.n'}."]");
-                               # if($bbtree{$ind.'.n'} eq '/ht') {
-                                       # #
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} =~ /^\/(fq|tq)$/) {
-                                       # $ht = $ht.'[/quote]';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} =~ /^\/(br|ni|po)$/) {
-                                       # $ht = $ht.'[/color]';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} eq '/url') {
-                                       # $ht = $ht.'[/url]';
-                               # }
-                               # elsif ($bbtree{$ind.'.n'} eq '/i') {
-                                       # $ht = $ht.'[/i]';
-                               # }
-                               # else { #unimpl.
-                                       # $ht = $ht.'['.$bbtree{$ind.'.n'}.']';
-                                       # $debug .= debug($printdebug, "[unknown!]");
-                               # }
-                               # $ind =~ s/\.([0-9]+)$//;
-                               # $level -= 1;
-                               # $debug .= debug($printdebug, "[<]");
-                               # if($level>0) {
-                                       # {do{
-                                               # $ind =~ s/\.([0-9]+)$//;
-                                               # $indd = int($1)+1;
-                                               # if ($indd < $bbtree{$ind.'.e'}){
-                                                       # $ind = $ind.'.'.$indd;
-                                                       # last;
-                                               # }
-                                               # else {
-                                                       # #should not occur with a correct bbtree
-                                                       # $debug .= debug($printdebug, "[<nd]");
-                                                       # $level -= 1;
-                                               # }
-                                       # } while ($level>=0);}
-                               # }
-                               # else {
-                                       # # time to end this
-                                       # $level = -1;
-                               # }
-                       # }
-                       # else {
-                               # if($bbtree{$ind.'.c'} ne '') {
-                                       # $debug .= debug($printdebug, "tag: [".$bbtree{$ind.'.n'}."]");
-                                       # if($bbtree{$ind.'.n'} eq 'ht') {
-                                               # #
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} =~ /^(fq|tq)$/) {
-                                               # $ht = $ht.'[quote]';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'br') {
-                                               # $ht = $ht.'[color=#BB6622]';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'po') {
-                                               # $ht = $ht.'[color=#FF8800]';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'ni') {
-                                               # $ht = $ht.'[color=#0057AF]';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'url') {
-                                               # $ht = $ht.'[url='.$bbtree{$ind.'.v'}.']';
-                                       # }
-                                       # elsif($bbtree{$ind.'.n'} eq 'i') {
-                                               # $ht = $ht.'[i]';
-                                       # }
-                                       # else { #unimpl.
-                                               # $ht = $ht.'['.$bbtree{$ind.'.n'}.(($bbtree{$ind.'.v'} ne '' )?($bbtree{$ind.'.v'}):'').']';
-                                               # $debug .= debug($printdebug, "[unknown!]");
-                                       # }
-                               # }
-                               # else {
-                                       # $debug .= debug($printdebug, "unclosed tag: [".$bbtree{$ind.'.n'}."]");
-                                       # $ht = $ht.'['.$bbtree{$ind.'.n'}.']';
-                               # }
-                               # if($bbtree{$ind.'.e'}>0) {
-                                       # $ind = $ind.'.0';
-                                       # $level += 1;
-                                       # $debug .= debug($printdebug, "[>]");
-                               # }
-                               # else {
-                                       # {do{
-                                               # $ind =~ s/\.([0-9]+)$//;
-                                               # $indd = int($1)+1;
-                                               # if ($indd < $bbtree{$ind.'.e'}){
-                                                       # $ind = $ind.'.'.$indd;
-                                                       # last;
-                                               # }
-                                               # else {
-                                                       # #should not occur with a correct bbtree
-                                                       # $debug .= debug($printdebug, "[<st]");
-                                                       # $level -= 1;
-                                               # }
-                                       # } while ($level>=0);}
-                               # }
-                       # }
-               # }
-               # else {
-                       # $debug .= debug($printdebug, "unknown thing: ".$bbtree{$ind.'.t'});
-                       # #should not occur with a correct bbtree
-                       # #unless unimplemented
-                       # $ind =~ s/\.([0-9]+)$//;
-                       # $level -= 1;
-                       # $debug .= debug($printdebug, "[<ui]");
-                       # if($level>0) {
-                               # {do{
-                                       # $ind =~ s/\.([0-9]+)$//;
-                                       # $indd = int($1)+1;
-                                       # if ($indd < $bbtree{$ind.'.e'}){
-                                               # $ind = $ind.'.'.$indd;
-                                               # last;
-                                       # }
-                                       # else {
-                                               # #should not occur with a correct bbtree
-                                               # $debug .= debug($printdebug, "[<un]");
-                                               # $level -= 1;
-                                       # }
-                               # } while ($level>=0);}
-                       # }
-                       # else {
-                               # # time to end this
-                               # $level = -1;
-                       # }
-               # }
-               # $debug .= debug($printdebug, "[>$level:$ind]\n");
-       # }
-       
-       # $debug .= debug($printdebug, "-->\n");
-       # # print $debug;
-       
-       
-       
+       while ($bb =~ m/###([^#;]*);/g) {
+               $value = $1;
+               $before = $`;
+               $after = $';
+               
+               if ($value =~ /^att&([0-9]+)$/) {
+                       $value = merge_url(
+                               SCHEME().WEBSITE(),
+                               CGI_ATTACH_PATH(),
+                               int($1)
+                       )
+               }
+               elsif ($value =~ /^vw&([0-9]+)$/) {
+                       $value = merge_url(
+                               SCHEME().WEBSITE(),
+                               CGI_VIEWER_PATH(),
+                               int($1)
+                       )
+               }
+               elsif ($value =~ /^fr&([0-9]+)$/) {
+                       $value = merge_url(
+                               SCHEME().WEBSITE(),
+                               CGI_FRAME_PATH(),
+                               int($1)
+                       )
+               }
+               else {
+                       $value = '';
+               }
+               $bb = $before . $value . $after;
+       }
+       return $bb;
 }
 
 
@@ -1311,23 +1037,34 @@ sub print_viewer_page {
        
        my $goto_url = CGI_GOTO_PATH;
        my $timer_url = CGI_TIMER_PATH;
+       my $viewer_full_url = merge_url(
+               SCHEME().WEBSITE(),
+               CGI_VIEWER_PATH(),
+               $frame
+       );
        my $viewer_0_url    = merge_url(CGI_VIEWER_PATH(), 0);
        my $viewer_prev_url = merge_url(CGI_VIEWER_PATH(), $frame-1);
        my $viewer_next_url = merge_url(CGI_VIEWER_PATH(), $frame+1);
-       my $frame_url;
        my $frame_file = '';
+       my $frame_url;
        my $frame_next_url;
-       if ($frame_indirect) {
-               $frame_url = merge_url(CGI_FRAME_PATH(), $frame);
-       }
-       elsif ($frame_data->{'frame'} ne '') {
+       my $frame_normal_url;
+       my $frame_full_url;
+       if ($frame_data->{'frame'} ne '') {
                $frame_file = $frame_data->{'frame'};
-               $frame_url = merge_url(CGI_PATH(), $frame_file);
+               $frame_normal_url = merge_url(CGI_PATH(), $frame_file);
        }
        else {
                $frame_file = sprintf($settings->{'frame'}, $frame, $frame_data->{'ext'});
-               $frame_url = merge_url(CGI_PATH(), $frame_file);
+               $frame_normal_url = merge_url(CGI_PATH(), $frame_file);
        }
+       $frame_url = $frame_indirect ?
+               merge_url(CGI_FRAME_PATH(), $frame) :
+               $frame_normal_url;
+       $frame_full_url = merge_url(
+               SCHEME().WEBSITE(),
+               $frame_normal_url
+       );
        if ($nextframe_indirect) {
                $frame_next_url = merge_url(CGI_FRAME_PATH(), $frame);
        }
@@ -1355,11 +1092,13 @@ sub print_viewer_page {
        }
        my $_goto_url        = html_entity_encode_dec($goto_url       , 1);
        my $_timer_url       = html_entity_encode_dec($timer_url      , 1);
+       my $_viewer_full_url = html_entity_encode_dec($viewer_full_url, 1);
        my $_viewer_0_url    = html_entity_encode_dec($viewer_0_url   , 1);
        my $_viewer_prev_url = html_entity_encode_dec($viewer_prev_url, 1);
        my $_viewer_next_url = html_entity_encode_dec($viewer_next_url, 1);
        my $_frame_url       = html_entity_encode_dec($frame_url      , 1);
        my $_frame_next_url  = html_entity_encode_dec($frame_next_url , 1);
+       my $_frame_full_url  = html_entity_encode_dec($frame_full_url , 1);
        
        my $_title = html_entity_encode_dec($framedata->{'title'}, 1);
        
@@ -1400,36 +1139,50 @@ sub print_viewer_page {
                }
        }
        if ($show_timer) {
-               print '<!-- <script src="'.$_timer_url.'"></script> -->'."\n";
+               print $fh '<!-- <script src="'.$_timer_url.'"></script> -->'."\n";
        }
        
        print_html_head_end($fh);
        print_html_body_start($fh);
        
-       print '<div id="inst" class="ins">'."\n";
+       print $fh '<div id="inst" class="ins">'."\n";
        
-       print '<div id="title">'."\n";
-       print '<h1 id="titletext">'.$_title.'</h1>'."\n";
-       print '</div>'."\n";
+       print $fh '<div id="title">'."\n";
+       print $fh '<h1 id="titletext">'.$_title.'</h1>'."\n";
+       print $fh '</div>'."\n";
        
-       print '</div><div id="framespace">'."\n";
+       print $fh '</div><div id="framespace">'."\n";
        
-       print '<img src="'.$_frame_url.'" id="frame" alt="'.$frame.'" title="'.$_title.'">'."\n";
+       print $fh '<img src="'.$_frame_url.'" id="frame" alt="'.$frame.'" title="'.$_title.'">'."\n";
        
-       print '</div><div id="insb" class="ins">'."\n";
+       print $fh '</div><div id="insb" class="ins">'."\n";
        
        if ($textmode == TEXT_MODE->{'info'}) {
-               print '<div id="chat">'."\n";
+               print $fh '<div id="chat">'."\n";
+               
+               print_html_data($fh, $frame_data); 
                
-               print '</div>'."\n";
+               print $fh '</div>'."\n";
        }
        elsif ($textmode == TEXT_MODE->{'bb'}) {
+               print $fh '<div id="chat">'."\n";
+               
+               print $fh '[quote][center][size=200]'.$_title.'[/size]<br>'."\n";
+               print $fh '[url='.$_viewer_full_url.'][img]'.$_frame_full_url.'[/img][/url][/center]<br>'."\n";
+               print $fh html_encode_line(bb_to_bbcode(eval_bb($frame_data->{'content'})));
+               print $fh '[/quote]</div>'."\n";
                
+               print $fh '</div>'."\n";
        }
        elsif ($frame_data->{'content'} ne '') {
-               
+               print $fh '<div id="undertext">'."\n";
+               print $fh bb_to_html(eval_bb($frame_data->{'content'}))."\n";
+               print $fh '</div>'."\n";
        }
        
+       print $fh '<div id="command">'."\n";
+       # TODO
+       
        print_html_body_end($fh);
        print_html_end($fh);
        
index 43b314bd9d5b3eaca8780782049025a3be63d05b..10b67c0a049c7fc02498a7a9f50e1bf9131dc019 100644 (file)
@@ -73,6 +73,7 @@ reset_schedule: 33 4 * * *
 cron_user: b
 
 
+scheme      : http
 website     : 1190.bicyclesonthemoon.info
 website_name: Bicycles on the Moon
 favicon_path: /img/favicon.png
index ac27eae4907f6f073bf909cd31af37e8e253def4..e2426f194a6bb5a76df5a22258ab7aef06419f22 100644 (file)
@@ -73,6 +73,7 @@ reset_schedule: #33 4 * * *
 cron_user: b
 
 
+scheme      : http
 website     : 1190.bicyclesonthemoon.info
 website_name: Bicycles on the Moon
 favicon_path: /img/favicon.png
index 7a8ed156eb25d1e29fcf8c937f11fcacbdaaa1ca..ec1a28c699ff1e856fb09b1542a3649f9d8c6cda 100644 (file)
@@ -73,6 +73,7 @@ reset_schedule: #33 4 * * *
 cron_user: b
 
 
+scheme      : http
 website     : 1190.bicyclesonthemoon.info
 website_name: Bicycles on the Moon
 favicon_path: /img/favicon.png
index ca7d30b37b712608a7b2f2f3cc6a04885c8ebc63..2365d73b7c6b29825d4c97173bfaa1fd2ac53815 100644 (file)
@@ -73,6 +73,7 @@ reset_schedule: #33 4 * * *
 cron_user: b
 
 
+scheme      : http
 website     : 1190.bicyclesonthemoon.info
 website_name: Bicycles on the Moon
 favicon_path: /img/favicon.png
index d52dee86a492196c2d2ce6b887e74094c52a44f8..f6b4cd0eb398f7436cbd356bffdb361b5209126c 100644 (file)
@@ -168,6 +168,7 @@ PERL_LOG_PATH           = @_PERL_CONSTANT_STR( LOG_PATH, $_log_path)
 PERL_WWW_PATH           = @_PERL_CONSTANT_STR( WWW_PATH      , $_www_path      )
 PERL_WWW_INDEX_PATH     = @_PERL_CONSTANT_STR( WWW_INDEX_PATH, $_www_index_path)
 
+PERL_SCHEME             = @_PERL_CONSTANT_STR( SCHEME      , $scheme://   )
 PERL_WEBSITE            = @_PERL_CONSTANT_STR( WEBSITE     , $website     )
 PERL_WEBSITE_NAME       = @_PERL_CONSTANT_STR( WEBSITE_NAME, $website_name)
 PERL_FAVICON_PATH       = @_PERL_CONSTANT_STR( FAVICON_PATH, $favicon_path)