}
#bbcode to html, TBD
-sub bb2ht {
+sub bb_to_html {
(my $bb, my $printdebug) = @_;
my $ht;
my %bbtree;
($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;
($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;
}
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);
}
}
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);
}
}
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);