From 0068808ecc7d9e3fb215ae272ab396266c13438a Mon Sep 17 00:00:00 2001 From: martinahansen Date: Tue, 12 May 2009 15:44:25 +0000 Subject: [PATCH] changed wiki renderer git-svn-id: http://biopieces.googlecode.com/svn/trunk@369 74ccb610-7750-0410-82ae-013aeee3265d --- code_perl/Maasha/Biopieces.pm | 33 +++++++++++++++++---------------- code_perl/Maasha/Gwiki.pm | 20 ++++++++++++++++++-- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/code_perl/Maasha/Biopieces.pm b/code_perl/Maasha/Biopieces.pm index 8260d09..cba6c52 100644 --- a/code_perl/Maasha/Biopieces.pm +++ b/code_perl/Maasha/Biopieces.pm @@ -1,7 +1,7 @@ package Maasha::Biopieces; -# Copyright (C) 2007-2008 Martin A. Hansen. +# Copyright (C) 2007-2009 Martin A. Hansen. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -97,8 +97,10 @@ $BP_TMP = Maasha::Common::get_tmpdir(); # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOG <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -my $log_global = Maasha::Common::append_open( "$ENV{ 'BP_LOG' }/biopieces.log" ); -my $log_local = Maasha::Common::append_open( "$ENV{ 'HOME' }/.biopieces.log" ); +my ( $log_global, $log_local ); + +$log_global = Maasha::Common::append_open( "$ENV{ 'BP_LOG' }/biopieces.log" ); +$log_local = Maasha::Common::append_open( "$ENV{ 'HOME' }/.biopieces.log" ); $log_global->autoflush( 1 ); $log_local->autoflush( 1 ); @@ -1161,8 +1163,10 @@ sub script_print_usage $wiki = Maasha::Gwiki::gwiki_read( $file ); + ( $wiki->[ 2 ], $wiki->[ 3 ], $wiki->[ 0 ], $wiki->[ 1 ] ) = ( $wiki->[ 0 ], $wiki->[ 1 ], $wiki->[ 2 ], $wiki->[ 3 ] ); + if ( not $options->{ "help" } ) { - @{ $wiki } = grep { $_->[ 0 ]->{ 'SECTION' } =~ /Biopiece|Synopsis|Usage|Options|Help/ } @{ $wiki }; + @{ $wiki } = grep { $_->[ 0 ]->{ 'SECTION' } =~ /Biopiece|summary|Usage|Options|Help/ } @{ $wiki }; } $lines = Maasha::Gwiki::gwiki2ascii( $wiki ); @@ -1177,7 +1181,7 @@ sub script_list_biopieces { # Martin A. Hansen, January 2008. - # Prints the synopsis from the usage for each of the biopieces. + # Prints the summary from the usage for each of the biopieces. my ( $in, # handle to in stream $out, # handle to out stream @@ -1186,7 +1190,7 @@ sub script_list_biopieces # Returns nothing. - my ( @files, $file, $wiki, $program, $synopsis ); + my ( @files, $file, $wiki, $program, $summary ); @files = Maasha::Common::ls_files( "$ENV{ 'BP_DIR' }/bp_usage" ); @@ -1198,13 +1202,10 @@ sub script_list_biopieces $wiki = Maasha::Gwiki::gwiki_read( $file ); - @{ $wiki } = grep { $_->[ 0 ]->{ 'SECTION' } =~ /Synopsis/ } @{ $wiki }; - @{ $wiki } = grep { $_->[ 0 ]->{ 'FORMAT' } =~ /paragraph/ } @{ $wiki }; - - $synopsis = $wiki->[ 0 ]->[ 0 ]->{ 'TEXT' }; - $synopsis =~ s/!(\w)/$1/g; + $summary = $wiki->[ 0 ]->[ 0 ]->{ 'TEXT' }; + $summary =~ s/^#summary\s+//; - printf( "%-30s%s\n", $program, $synopsis ); + printf( "%-30s%s\n", $program, $summary ); } } @@ -6478,11 +6479,11 @@ sub grab_eval if ( defined $record->{ $key } ) { - return 1 if ( $op eq "<" and $record->{ $key } < $val ); - return 1 if ( $op eq ">" and $record->{ $key } > $val ); + return 1 if ( $op eq "<" and $record->{ $key } < $val ); + return 1 if ( $op eq ">" and $record->{ $key } > $val ); return 1 if ( $op eq ">=" and $record->{ $key } >= $val ); return 1 if ( $op eq "<=" and $record->{ $key } <= $val ); - return 1 if ( $op eq "=" and $record->{ $key } == $val ); + return 1 if ( $op eq "=" and $record->{ $key } == $val ); return 1 if ( $op eq "!=" and $record->{ $key } != $val ); return 1 if ( $op eq "eq" and $record->{ $key } eq $val ); return 1 if ( $op eq "ne" and $record->{ $key } ne $val ); @@ -6700,7 +6701,7 @@ sub clean_tmp $sid = $2; $pid = $3; - next if $user eq "m.hansen"; +# next if $user eq "maasha"; # DEBUG if ( $user eq Maasha::Common::get_user() ) { diff --git a/code_perl/Maasha/Gwiki.pm b/code_perl/Maasha/Gwiki.pm index b0e5c97..cd65868 100644 --- a/code_perl/Maasha/Gwiki.pm +++ b/code_perl/Maasha/Gwiki.pm @@ -1,6 +1,6 @@ package Maasha::Gwiki; -# Copyright (C) 2008 Martin A. Hansen. +# Copyright (C) 2008-2009 Martin A. Hansen. # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -63,6 +63,12 @@ sub gwiki2ascii { push @lines, text_bold( "$block->[ 0 ]->{ 'TEXT' }" ); } + elsif ( $block->[ 0 ]->{ 'FORMAT' } eq "summary" ) + { + $block->[ 0 ]->{ 'TEXT' } =~ s/^#summary\s+//; + + push @lines, text_bold( "Summary" ), "\n$block->[ 0 ]->{ 'TEXT' }"; + } elsif ( $block->[ 0 ]->{ 'FORMAT' } eq "level_3" ) { push @lines, "$block->[ 0 ]->{ 'TEXT' }"; @@ -144,7 +150,17 @@ sub gwiki_read { undef @block; - if ( $lines[ $i ] =~ /^===\s*(.+)\s*===$/ ) + if ( $lines[ $i ] =~ /^(#summary.+)/ ) + { + $section = $1; + + push @block, { + TEXT => $section, + SECTION => $section, + FORMAT => "summary", + }; + } + elsif ( $lines[ $i ] =~ /^===\s*(.+)\s*===$/ ) { $section = $1; -- 2.39.5