From: <Cra...@nt...> - 2005-11-10 18:38:29
|
Author: CrawfordCurrie Date: 2005-11-10 10:36:50 -0800 (Thu, 10 Nov 2005) New Revision: 7424 Modified: twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin.pm twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm Log: Item866: extended URL parsing to handle MAINWEB and TWIKIWEB twiki variables, in the same hacky way as the core. Modified: twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm =================================================================== --- twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm 2005-11-10 18:07:41 UTC (rev 7423) +++ twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm 2005-11-10 18:36:50 UTC (rev 7424) @@ -614,12 +614,12 @@ $topic = &{$this->{context}->{parseWikiUrl}}( $href ); } my $nop = ($options & $WC::NOP_ALL) ? '<nop>' : ''; - if( $topic ) { my $cleantext = $text; $cleantext =~ s/(<nop>)//g; # if the clean text is the known topic we can ignore it - if( $cleantext eq $topic || $topic =~ /\.$cleantext$/ ) { + if( ($cleantext eq $topic || $topic =~ /\.$cleantext$/) && + $topic =~ /^[\w.#]+$/ ) { # wikiword or web.wikiword return (0, $WC::CHECK1.$nop.$topic.$WC::CHECK2); } else { @@ -627,7 +627,8 @@ return (0, $WC::CHECKw.'['.$nop.'['.$topic.']['.$text. ']]'.$WC::CHECKw ); } - } elsif ( $href =~ $WC::PROTOCOL ) { + } elsif( $href =~ $WC::PROTOCOL ) { + # the url starts with a protocol ID or a twiki variable # normal link if( $text eq $href ) { # Wikiword Modified: twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin.pm =================================================================== --- twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin.pm 2005-11-10 18:07:41 UTC (rev 7423) +++ twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/lib/TWiki/Plugins/WysiwygPlugin.pm 2005-11-10 18:36:50 UTC (rev 7424) @@ -56,13 +56,6 @@ $calledThisSession = 0; $modern = defined( &TWiki::Func::normalizeWebTopicName ); - # switch in the post rendering handler depending on whether this - # is Dakar or earlier. - if( $modern ) { - *postRenderingHandler = \&afterRendering; - } else { - *endRenderingHandler = \&afterRendering; - } # Plugin correctly initialized return 1; } @@ -153,12 +146,25 @@ $calledThisSession = 1; } -sub afterRendering { - return unless $html2tml; +# DEPRECATED in Dakar (modifyHeaderHandler does the job better) +sub writeHeaderHandler { + return '' if $modern; - $html2tml->cleanup( @_ ); + my $query = shift; + return "Expires: 0\nCache-control: max-age=0, must-revalidate\n"; + } +# Dakar modify headers. +sub modifyHeaderHandler { + my( $headers, $query ) = @_; + + if( $query->param( 'wysiwyg_edit' )) { + $headers->{Expires} = 0; + $headers->{'Cache-control'} = 'max-age=0, must-revalidate'; + } +} + # callback passed down to TML2HTML generator sub getViewUrl { my( $web, $topic ) = @_; @@ -179,13 +185,14 @@ $url =~ s/([#\?].*)$//; my $anchor = $1 || ''; - if( $url =~ /^(\w+\.)?\w+$/ ) { + if( $url =~ /^((%(MAIN|TWIKI)WEB%|\w+)\.)?\w+$/ ) { + my $webexpr = $1 || ''; if( $modern ) { ( $web, $topic) = TWiki::Func::normalizeWebTopicName(undef, $url); } else { ( $web, $topic) = TWiki::Store::normalizeWebTopicName(undef, $url); } - return $web.'.'.$topic . $anchor; + return $webexpr.$topic.$anchor; } my $aurl = TWiki::Func::getViewUrl('WEB', 'TOPIC'); $aurl =~ s!WEB/TOPIC.*$!!; Modified: twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm =================================================================== --- twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm 2005-11-10 18:07:41 UTC (rev 7423) +++ twiki/branches/DEVELOP/twikiplugins/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm 2005-11-10 18:36:50 UTC (rev 7424) @@ -863,6 +863,26 @@ html => '<span class="TMLvariable">SEARCH{"ReqNo" scope="topic" regex="on" nosearch="on" nototal="on" casesensitive="on" format="$percntCALC{$IF($NOT($FIND(%TOPIC%,$formfield(ReqParents))), <nop>, [[$topic]] - $formfield(ReqShortDescript) %BR% )}$percnt"}</span>', tml => '%SEARCH{"ReqNo" scope="topic" regex="on" nosearch="on" nototal="on" casesensitive="on" format="$percntCALC{$IF($NOT($FIND(%TOPIC%,$formfield(ReqParents))), <nop>, [[$topic]] - $formfield(ReqShortDescript) %BR% )}$percnt"}%', }, + { + exec => 2, + name => 'variableInIMGtag', + html => '<img src="%ATTACHURLPATH%/T-logo-16x16.gif"></img>', + tml => '<img src="%ATTACHURLPATH%/T-logo-16x16.gif" />', + finaltml => '<img src="%ATTACHURLPATH%/T-logo-16x16.gif"></img>' + }, + { + exec => 2, + name => 'twikiWebSnarf', + html => '<a href="%TWIKIWEB%.TopicName">bah</a>', + tml => '[[%TWIKIWEB%.TopicName][bah]]', + }, + { + exec => 2, + name => 'mainWebSnarf', + html => '<a href="%MAINWEB%.TopicName">bah</a>', + tml => '[[%MAINWEB%.TopicName][bah]]', + }, + ]; |