From: b Date: Fri, 29 Sep 2023 22:33:01 +0000 (+0000) Subject: html output generator: bbcode, info, content parts mostly X-Git-Tag: v1.1.0~39 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=eb3c57408fcd84e4964b90f85bd8b07d42fb79ac;p=ott%2Fbsta html output generator: bbcode, info, content parts mostly --- diff --git a/botm-common b/botm-common index 6881684..bd6107e 160000 --- a/botm-common +++ b/botm-common @@ -1 +1 @@ -Subproject commit 6881684b6dcb50d6d9e77584aadf3eaa47dd096c +Subproject commit bd6107e790c6666a87a0e9f2bec9370868bf531b diff --git a/bsta_lib.1.pm b/bsta_lib.1.pm index eca8565..a91aa68 100644 --- a/bsta_lib.1.pm +++ b/bsta_lib.1.pm @@ -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\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\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 ''."\n"; + print $fh ''."\n"; } print_html_head_end($fh); print_html_body_start($fh); - print '
'."\n"; + print $fh '
'."\n"; - print '
'."\n"; - print '

'.$_title.'

'."\n"; - print '
'."\n"; + print $fh '
'."\n"; + print $fh '

'.$_title.'

'."\n"; + print $fh '
'."\n"; - print '
'."\n"; + print $fh '
'."\n"; - print ''.$frame.''."\n"; + print $fh ''.$frame.''."\n"; - print '
'."\n"; + print $fh '
'."\n"; if ($textmode == TEXT_MODE->{'info'}) { - print '
'."\n"; + print $fh '
'."\n"; + + print_html_data($fh, $frame_data); - print '
'."\n"; + print $fh '
'."\n"; } elsif ($textmode == TEXT_MODE->{'bb'}) { + print $fh '
'."\n"; + + print $fh '[quote][center][size=200]'.$_title.'[/size]
'."\n"; + print $fh '[url='.$_viewer_full_url.'][img]'.$_frame_full_url.'[/img][/url][/center]
'."\n"; + print $fh html_encode_line(bb_to_bbcode(eval_bb($frame_data->{'content'}))); + print $fh '[/quote]
'."\n"; + print $fh '
'."\n"; } elsif ($frame_data->{'content'} ne '') { - + print $fh '
'."\n"; + print $fh bb_to_html(eval_bb($frame_data->{'content'}))."\n"; + print $fh '
'."\n"; } + print $fh '
'."\n"; + # TODO + print_html_body_end($fh); print_html_end($fh); diff --git a/settings-again.txt b/settings-again.txt index 43b314b..10b67c0 100644 --- a/settings-again.txt +++ b/settings-again.txt @@ -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 diff --git a/settings-bsta.txt b/settings-bsta.txt index ac27eae..e2426f1 100644 --- a/settings-bsta.txt +++ b/settings-bsta.txt @@ -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 diff --git a/settings-debug.txt b/settings-debug.txt index 7a8ed15..ec1a28c 100644 --- a/settings-debug.txt +++ b/settings-debug.txt @@ -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 diff --git a/settings-tbst.txt b/settings-tbst.txt index ca7d30b..2365d73 100644 --- a/settings-tbst.txt +++ b/settings-tbst.txt @@ -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 diff --git a/settings.txt b/settings.txt index d52dee8..f6b4cd0 100644 --- a/settings.txt +++ b/settings.txt @@ -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)